File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / tmux / compat.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Jun 14 12:22:44 2017 UTC (6 years, 11 months ago) by misho
Branches: tmux, MAIN
CVS tags: v2_4p0, v2_4, HEAD
tmux 2.4

    1: /*
    2:  * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
    3:  *
    4:  * Permission to use, copy, modify, and distribute this software for any
    5:  * purpose with or without fee is hereby granted, provided that the above
    6:  * copyright notice and this permission notice appear in all copies.
    7:  *
    8:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
    9:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
   10:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
   11:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   12:  * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
   13:  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
   14:  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   15:  */
   16: 
   17: #ifndef COMPAT_H
   18: #define COMPAT_H
   19: 
   20: #include <sys/types.h>
   21: #include <sys/uio.h>
   22: 
   23: #include <limits.h>
   24: #include <stdio.h>
   25: #include <termios.h>
   26: #include <wchar.h>
   27: 
   28: #ifndef __GNUC__
   29: #define __attribute__(a)
   30: #endif
   31: 
   32: #ifndef __unused
   33: #define __unused __attribute__ ((__unused__))
   34: #endif
   35: #ifndef __dead
   36: #define __dead __attribute__ ((__noreturn__))
   37: #endif
   38: #ifndef __packed
   39: #define __packed __attribute__ ((__packed__))
   40: #endif
   41: 
   42: #ifndef ECHOPRT
   43: #define ECHOPRT 0
   44: #endif
   45: 
   46: #ifndef ACCESSPERMS
   47: #define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
   48: #endif
   49: 
   50: #if !defined(FIONREAD) && defined(__sun)
   51: #include <sys/filio.h>
   52: #endif
   53: 
   54: #ifdef HAVE_ERR_H
   55: #include <err.h>
   56: #else
   57: void	err(int, const char *, ...);
   58: void	errx(int, const char *, ...);
   59: void	warn(const char *, ...);
   60: void	warnx(const char *, ...);
   61: #endif
   62: 
   63: #ifndef HAVE_PATHS_H
   64: #define	_PATH_BSHELL	"/bin/sh"
   65: #define	_PATH_TMP	"/tmp/"
   66: #define _PATH_DEVNULL	"/dev/null"
   67: #define _PATH_TTY	"/dev/tty"
   68: #define _PATH_DEV	"/dev/"
   69: #endif
   70: 
   71: #ifndef __OpenBSD__
   72: #define pledge(s, p) (0)
   73: #endif
   74: 
   75: #ifdef HAVE_STDINT_H
   76: #include <stdint.h>
   77: #else
   78: #include <inttypes.h>
   79: #endif
   80: 
   81: #ifdef HAVE_QUEUE_H
   82: #include <sys/queue.h>
   83: #else
   84: #include "compat/queue.h"
   85: #endif
   86: 
   87: #ifdef HAVE_TREE_H
   88: #include <sys/tree.h>
   89: #else
   90: #include "compat/tree.h"
   91: #endif
   92: 
   93: #ifdef HAVE_BITSTRING_H
   94: #include <bitstring.h>
   95: #else
   96: #include "compat/bitstring.h"
   97: #endif
   98: 
   99: #ifdef HAVE_PATHS_H
  100: #include <paths.h>
  101: #endif
  102: 
  103: #ifdef HAVE_FORKPTY
  104: #ifdef HAVE_LIBUTIL_H
  105: #include <libutil.h>
  106: #endif
  107: #ifdef HAVE_PTY_H
  108: #include <pty.h>
  109: #endif
  110: #ifdef HAVE_UTIL_H
  111: #include <util.h>
  112: #endif
  113: #endif
  114: 
  115: #ifdef HAVE_VIS
  116: #include <vis.h>
  117: #else
  118: #include "compat/vis.h"
  119: #endif
  120: 
  121: #ifdef HAVE_IMSG
  122: #include <imsg.h>
  123: #else
  124: #include "compat/imsg.h"
  125: #endif
  126: 
  127: #ifdef BROKEN_CMSG_FIRSTHDR
  128: #undef CMSG_FIRSTHDR
  129: #define CMSG_FIRSTHDR(mhdr) \
  130: 	((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
  131: 	    (struct cmsghdr *)(mhdr)->msg_control :	    \
  132: 	    (struct cmsghdr *)NULL)
  133: #endif
  134: 
  135: #ifndef CMSG_ALIGN
  136: #ifdef _CMSG_DATA_ALIGN
  137: #define CMSG_ALIGN _CMSG_DATA_ALIGN
  138: #else
  139: #define CMSG_ALIGN(len) (((len) + sizeof(long) - 1) & ~(sizeof(long) - 1))
  140: #endif
  141: #endif
  142: 
  143: #ifndef CMSG_SPACE
  144: #define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len))
  145: #endif
  146: 
  147: #ifndef CMSG_LEN
  148: #define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
  149: #endif
  150: 
  151: #ifndef O_DIRECTORY
  152: #define O_DIRECTORY 0
  153: #endif
  154: 
  155: #ifndef INFTIM
  156: #define INFTIM -1
  157: #endif
  158: 
  159: #ifndef WAIT_ANY
  160: #define WAIT_ANY -1
  161: #endif
  162: 
  163: #ifndef SUN_LEN
  164: #define SUN_LEN(sun) (sizeof (sun)->sun_path)
  165: #endif
  166: 
  167: #ifndef timercmp
  168: #define	timercmp(tvp, uvp, cmp)						\
  169: 	(((tvp)->tv_sec == (uvp)->tv_sec) ?				\
  170: 	    ((tvp)->tv_usec cmp (uvp)->tv_usec) :			\
  171: 	    ((tvp)->tv_sec cmp (uvp)->tv_sec))
  172: #endif
  173: 
  174: #ifndef timeradd
  175: #define	timeradd(tvp, uvp, vvp)						\
  176: 	do {								\
  177: 		(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;		\
  178: 		(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;	\
  179: 		if ((vvp)->tv_usec >= 1000000) {			\
  180: 			(vvp)->tv_sec++;				\
  181: 			(vvp)->tv_usec -= 1000000;			\
  182: 		}							\
  183: 	} while (0)
  184: #endif
  185: 
  186: #ifndef timersub
  187: #define timersub(tvp, uvp, vvp)                                         \
  188: 	do {                                                            \
  189: 		(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;          \
  190: 		(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;       \
  191: 		if ((vvp)->tv_usec < 0) {                               \
  192: 			(vvp)->tv_sec--;                                \
  193: 			(vvp)->tv_usec += 1000000;                      \
  194: 		}                                                       \
  195: 	} while (0)
  196: #endif
  197: 
  198: #ifndef TTY_NAME_MAX
  199: #define TTY_NAME_MAX 32
  200: #endif
  201: 
  202: #ifndef HOST_NAME_MAX
  203: #define HOST_NAME_MAX 255
  204: #endif
  205: 
  206: #ifndef HAVE_FLOCK
  207: #define LOCK_SH 0
  208: #define LOCK_EX 0
  209: #define LOCK_NB 0
  210: #define flock(fd, op) (0)
  211: #endif
  212: 
  213: #ifndef HAVE_EXPLICIT_BZERO
  214: /* explicit_bzero.c */
  215: void		 explicit_bzero(void *, size_t);
  216: #endif
  217: 
  218: #ifndef HAVE_GETDTABLECOUNT
  219: /* getdtablecount.c */
  220: int		 getdtablecount(void);
  221: #endif
  222: 
  223: #ifndef HAVE_CLOSEFROM
  224: /* closefrom.c */
  225: void		 closefrom(int);
  226: #endif
  227: 
  228: #ifndef HAVE_STRCASESTR
  229: /* strcasestr.c */
  230: char		*strcasestr(const char *, const char *);
  231: #endif
  232: 
  233: #ifndef HAVE_STRSEP
  234: /* strsep.c */
  235: char		*strsep(char **, const char *);
  236: #endif
  237: 
  238: #ifndef HAVE_STRTONUM
  239: /* strtonum.c */
  240: long long	 strtonum(const char *, long long, long long, const char **);
  241: #endif
  242: 
  243: #ifndef HAVE_STRLCPY
  244: /* strlcpy.c */
  245: size_t	 	 strlcpy(char *, const char *, size_t);
  246: #endif
  247: 
  248: #ifndef HAVE_STRLCAT
  249: /* strlcat.c */
  250: size_t	 	 strlcat(char *, const char *, size_t);
  251: #endif
  252: 
  253: #ifndef HAVE_STRNLEN
  254: /* strnlen.c */
  255: size_t		 strnlen(const char *, size_t);
  256: #endif
  257: 
  258: #ifndef HAVE_STRNDUP
  259: /* strndup.c */
  260: char		*strndup(const char *, size_t);
  261: #endif
  262: 
  263: #ifndef HAVE_DAEMON
  264: /* daemon.c */
  265: int	 	 daemon(int, int);
  266: #endif
  267: 
  268: #ifndef HAVE_GETPROGNAME
  269: /* getprogname.c */
  270: const char	*getprogname(void);
  271: #endif
  272: 
  273: #ifndef HAVE_SETPROCTITLE
  274: /* setproctitle.c */
  275: void		 setproctitle(const char *, ...);
  276: #endif
  277: 
  278: #ifndef HAVE_B64_NTOP
  279: /* base64.c */
  280: #undef b64_ntop
  281: #undef b64_pton
  282: int		 b64_ntop(const char *, size_t, char *, size_t);
  283: int		 b64_pton(const char *, u_char *, size_t);
  284: #endif
  285: 
  286: #ifndef HAVE_FORKPTY
  287: /* forkpty.c */
  288: #include <sys/ioctl.h>
  289: pid_t		 forkpty(int *, char *, struct termios *, struct winsize *);
  290: #endif
  291: 
  292: #ifndef HAVE_ASPRINTF
  293: /* asprintf.c */
  294: int		 asprintf(char **, const char *, ...);
  295: int		 vasprintf(char **, const char *, va_list);
  296: #endif
  297: 
  298: #ifndef HAVE_FGETLN
  299: /* fgetln.c */
  300: char		*fgetln(FILE *, size_t *);
  301: #endif
  302: 
  303: #ifndef HAVE_FPARSELN
  304: char		*fparseln(FILE *, size_t *, size_t *, const char *, int);
  305: #endif
  306: 
  307: #ifndef HAVE_SETENV
  308: /* setenv.c */
  309: int		 setenv(const char *, const char *, int);
  310: int		 unsetenv(const char *);
  311: #endif
  312: 
  313: #ifndef HAVE_CFMAKERAW
  314: /* cfmakeraw.c */
  315: void		 cfmakeraw(struct termios *);
  316: #endif
  317: 
  318: #ifndef HAVE_FREEZERO
  319: /* freezero.c */
  320: void		 freezero(void *, size_t);
  321: #endif
  322: 
  323: #ifndef HAVE_REALLOCARRAY
  324: /* reallocarray.c */
  325: void		*reallocarray(void *, size_t, size_t);
  326: #endif
  327: 
  328: #ifndef HAVE_RECALLOCARRAY
  329: /* recallocarray.c */
  330: void		*recallocarray(void *, size_t, size_t, size_t);
  331: #endif
  332: 
  333: #ifdef HAVE_UTF8PROC
  334: /* utf8proc.c */
  335: int		 utf8proc_wcwidth(wchar_t);
  336: int		 utf8proc_mbtowc(wchar_t *, const char *, size_t);
  337: int		 utf8proc_wctomb(char *, wchar_t);
  338: #endif
  339: 
  340: #ifdef HAVE_GETOPT
  341: #include <getopt.h>
  342: #else
  343: /* getopt.c */
  344: extern int	BSDopterr;
  345: extern int	BSDoptind;
  346: extern int	BSDoptopt;
  347: extern int	BSDoptreset;
  348: extern char    *BSDoptarg;
  349: int	BSDgetopt(int, char *const *, const char *);
  350: #define getopt(ac, av, o)  BSDgetopt(ac, av, o)
  351: #define opterr             BSDopterr
  352: #define optind             BSDoptind
  353: #define optopt             BSDoptopt
  354: #define optreset           BSDoptreset
  355: #define optarg             BSDoptarg
  356: #endif
  357: 
  358: #endif /* COMPAT_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>