Grid Community Toolkit  6.2.1629922860 (tag: v6.2.20210826)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
defines.h
1 /*
2  * Copyright (c) 1999-2003 Damien Miller. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  */
24 
25 #ifndef _DEFINES_H
26 #define _DEFINES_H
27 
28 /* Constants */
29 
30 #if defined(HAVE_DECL_SHUT_RD) && HAVE_DECL_SHUT_RD == 0
31 enum
32 {
33  SHUT_RD = 0, /* No more receptions. */
34  SHUT_WR, /* No more transmissions. */
35  SHUT_RDWR /* No more receptions or transmissions. */
36 };
37 # define SHUT_RD SHUT_RD
38 # define SHUT_WR SHUT_WR
39 # define SHUT_RDWR SHUT_RDWR
40 #endif
41 
42 /*
43  * Cygwin doesn't really have a notion of reserved ports. It is still
44  * is useful on the client side so for compatibility it defines as 1024 via
45  * netinet/in.h inside an enum. We * don't actually want that restriction
46  * so we want to set that to zero, but we can't do it direct in config.h
47  * because it'll cause a conflicting definition the first time we include
48  * netinet/in.h.
49  */
50 
51 #ifdef HAVE_CYGWIN
52 #define IPPORT_RESERVED 0
53 #endif
54 
55 /*
56  * Definitions for IP type of service (ip_tos)
57  */
58 #include <netinet/in_systm.h>
59 #include <netinet/ip.h>
60 #ifndef IPTOS_LOWDELAY
61 # define IPTOS_LOWDELAY 0x10
62 # define IPTOS_THROUGHPUT 0x08
63 # define IPTOS_RELIABILITY 0x04
64 # define IPTOS_LOWCOST 0x02
65 # define IPTOS_MINCOST IPTOS_LOWCOST
66 #endif /* IPTOS_LOWDELAY */
67 
68 /*
69  * Definitions for DiffServ Codepoints as per RFC2474
70  */
71 #ifndef IPTOS_DSCP_AF11
72 # define IPTOS_DSCP_AF11 0x28
73 # define IPTOS_DSCP_AF12 0x30
74 # define IPTOS_DSCP_AF13 0x38
75 # define IPTOS_DSCP_AF21 0x48
76 # define IPTOS_DSCP_AF22 0x50
77 # define IPTOS_DSCP_AF23 0x58
78 # define IPTOS_DSCP_AF31 0x68
79 # define IPTOS_DSCP_AF32 0x70
80 # define IPTOS_DSCP_AF33 0x78
81 # define IPTOS_DSCP_AF41 0x88
82 # define IPTOS_DSCP_AF42 0x90
83 # define IPTOS_DSCP_AF43 0x98
84 # define IPTOS_DSCP_EF 0xb8
85 #endif /* IPTOS_DSCP_AF11 */
86 #ifndef IPTOS_DSCP_CS0
87 # define IPTOS_DSCP_CS0 0x00
88 # define IPTOS_DSCP_CS1 0x20
89 # define IPTOS_DSCP_CS2 0x40
90 # define IPTOS_DSCP_CS3 0x60
91 # define IPTOS_DSCP_CS4 0x80
92 # define IPTOS_DSCP_CS5 0xa0
93 # define IPTOS_DSCP_CS6 0xc0
94 # define IPTOS_DSCP_CS7 0xe0
95 #endif /* IPTOS_DSCP_CS0 */
96 #ifndef IPTOS_DSCP_EF
97 # define IPTOS_DSCP_EF 0xb8
98 #endif /* IPTOS_DSCP_EF */
99 #ifndef IPTOS_DSCP_LE
100 # define IPTOS_DSCP_LE 0x01
101 #endif /* IPTOS_DSCP_LE */
102 #ifndef IPTOS_PREC_CRITIC_ECP
103 # define IPTOS_PREC_CRITIC_ECP 0xa0
104 #endif
105 #ifndef IPTOS_PREC_INTERNETCONTROL
106 # define IPTOS_PREC_INTERNETCONTROL 0xc0
107 #endif
108 #ifndef IPTOS_PREC_NETCONTROL
109 # define IPTOS_PREC_NETCONTROL 0xe0
110 #endif
111 
112 #ifndef PATH_MAX
113 # ifdef _POSIX_PATH_MAX
114 # define PATH_MAX _POSIX_PATH_MAX
115 # endif
116 #endif
117 
118 #ifndef MAXPATHLEN
119 # ifdef PATH_MAX
120 # define MAXPATHLEN PATH_MAX
121 # else /* PATH_MAX */
122 # define MAXPATHLEN 64
123 # endif /* PATH_MAX */
124 #endif /* MAXPATHLEN */
125 
126 #ifndef HOST_NAME_MAX
127 # include "netdb.h" /* for MAXHOSTNAMELEN */
128 # if defined(_POSIX_HOST_NAME_MAX)
129 # define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
130 # elif defined(MAXHOSTNAMELEN)
131 # define HOST_NAME_MAX MAXHOSTNAMELEN
132 # else
133 # define HOST_NAME_MAX 255
134 # endif
135 #endif /* HOST_NAME_MAX */
136 
137 #if defined(HAVE_DECL_MAXSYMLINKS) && HAVE_DECL_MAXSYMLINKS == 0
138 # define MAXSYMLINKS 5
139 #endif
140 
141 #ifndef STDIN_FILENO
142 # define STDIN_FILENO 0
143 #endif
144 #ifndef STDOUT_FILENO
145 # define STDOUT_FILENO 1
146 #endif
147 #ifndef STDERR_FILENO
148 # define STDERR_FILENO 2
149 #endif
150 
151 #ifndef NGROUPS_MAX /* Disable groupaccess if NGROUP_MAX is not set */
152 #ifdef NGROUPS
153 #define NGROUPS_MAX NGROUPS
154 #else
155 #define NGROUPS_MAX 0
156 #endif
157 #endif
158 
159 #if defined(HAVE_DECL_O_NONBLOCK) && HAVE_DECL_O_NONBLOCK == 0
160 # define O_NONBLOCK 00004 /* Non Blocking Open */
161 #endif
162 
163 #ifndef S_IFSOCK
164 # define S_IFSOCK 0
165 #endif /* S_IFSOCK */
166 
167 #ifndef S_ISDIR
168 # define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR))
169 #endif /* S_ISDIR */
170 
171 #ifndef S_ISREG
172 # define S_ISREG(mode) (((mode) & (_S_IFMT)) == (_S_IFREG))
173 #endif /* S_ISREG */
174 
175 #ifndef S_ISLNK
176 # define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
177 #endif /* S_ISLNK */
178 
179 #ifndef S_IXUSR
180 # define S_IXUSR 0000100 /* execute/search permission, */
181 # define S_IXGRP 0000010 /* execute/search permission, */
182 # define S_IXOTH 0000001 /* execute/search permission, */
183 # define _S_IWUSR 0000200 /* write permission, */
184 # define S_IWUSR _S_IWUSR /* write permission, owner */
185 # define S_IWGRP 0000020 /* write permission, group */
186 # define S_IWOTH 0000002 /* write permission, other */
187 # define S_IRUSR 0000400 /* read permission, owner */
188 # define S_IRGRP 0000040 /* read permission, group */
189 # define S_IROTH 0000004 /* read permission, other */
190 # define S_IRWXU 0000700 /* read, write, execute */
191 # define S_IRWXG 0000070 /* read, write, execute */
192 # define S_IRWXO 0000007 /* read, write, execute */
193 #endif /* S_IXUSR */
194 
195 #if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
196 #define MAP_ANON MAP_ANONYMOUS
197 #endif
198 
199 #ifndef MAP_FAILED
200 # define MAP_FAILED ((void *)-1)
201 #endif
202 
203 /*
204 SCO Open Server 3 has INADDR_LOOPBACK defined in rpc/rpc.h but
205 including rpc/rpc.h breaks Solaris 6
206 */
207 #ifndef INADDR_LOOPBACK
208 #define INADDR_LOOPBACK ((u_long)0x7f000001)
209 #endif
210 
211 /* Types */
212 
213 /* If sys/types.h does not supply intXX_t, supply them ourselves */
214 /* (or die trying) */
215 
216 #ifndef HAVE_U_INT
217 typedef unsigned int u_int;
218 #endif
219 
220 #ifndef HAVE_INTXX_T
221 typedef signed char int8_t;
222 # if (SIZEOF_SHORT_INT == 2)
223 typedef short int int16_t;
224 # else
225 # error "16 bit int type not found."
226 # endif
227 # if (SIZEOF_INT == 4)
228 typedef int int32_t;
229 # else
230 # error "32 bit int type not found."
231 # endif
232 #endif
233 
234 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
235 #ifndef HAVE_U_INTXX_T
236 # ifdef HAVE_UINTXX_T
237 typedef uint8_t u_int8_t;
238 typedef uint16_t u_int16_t;
239 typedef uint32_t u_int32_t;
240 # define HAVE_U_INTXX_T 1
241 # else
242 typedef unsigned char u_int8_t;
243 # if (SIZEOF_SHORT_INT == 2)
244 typedef unsigned short int u_int16_t;
245 # else
246 # error "16 bit int type not found."
247 # endif
248 # if (SIZEOF_INT == 4)
249 typedef unsigned int u_int32_t;
250 # else
251 # error "32 bit int type not found."
252 # endif
253 # endif
254 #define __BIT_TYPES_DEFINED__
255 #endif
256 
257 #if !defined(LLONG_MIN) && defined(LONG_LONG_MIN)
258 #define LLONG_MIN LONG_LONG_MIN
259 #endif
260 #if !defined(LLONG_MAX) && defined(LONG_LONG_MAX)
261 #define LLONG_MAX LONG_LONG_MAX
262 #endif
263 
264 #ifndef UINT32_MAX
265 # if defined(HAVE_DECL_UINT32_MAX) && (HAVE_DECL_UINT32_MAX == 0)
266 # if (SIZEOF_INT == 4)
267 # define UINT32_MAX UINT_MAX
268 # endif
269 # endif
270 #endif
271 
272 /* 64-bit types */
273 #ifndef HAVE_INT64_T
274 # if (SIZEOF_LONG_INT == 8)
275 typedef long int int64_t;
276 # else
277 # if (SIZEOF_LONG_LONG_INT == 8)
278 typedef long long int int64_t;
279 # endif
280 # endif
281 #endif
282 #ifndef HAVE_U_INT64_T
283 # if (SIZEOF_LONG_INT == 8)
284 typedef unsigned long int u_int64_t;
285 # else
286 # if (SIZEOF_LONG_LONG_INT == 8)
287 typedef unsigned long long int u_int64_t;
288 # endif
289 # endif
290 #endif
291 
292 #ifndef HAVE_UINTXX_T
293 typedef u_int8_t uint8_t;
294 typedef u_int16_t uint16_t;
295 typedef u_int32_t uint32_t;
296 typedef u_int64_t uint64_t;
297 #endif
298 
299 #ifndef HAVE_INTMAX_T
300 typedef long long intmax_t;
301 #endif
302 
303 #ifndef HAVE_UINTMAX_T
304 typedef unsigned long long uintmax_t;
305 #endif
306 
307 #ifndef HAVE_U_CHAR
308 typedef unsigned char u_char;
309 # define HAVE_U_CHAR
310 #endif /* HAVE_U_CHAR */
311 
312 #ifndef ULLONG_MAX
313 # define ULLONG_MAX ((unsigned long long)-1)
314 #endif
315 
316 #ifndef SIZE_T_MAX
317 #define SIZE_T_MAX ULONG_MAX
318 #endif /* SIZE_T_MAX */
319 
320 #ifndef HAVE_SIZE_T
321 typedef unsigned int size_t;
322 # define HAVE_SIZE_T
323 # define SIZE_T_MAX UINT_MAX
324 #endif /* HAVE_SIZE_T */
325 
326 #ifndef SIZE_MAX
327 #define SIZE_MAX SIZE_T_MAX
328 #endif
329 
330 #ifndef INT32_MAX
331 # if (SIZEOF_INT == 4)
332 # define INT32_MAX INT_MAX
333 # elif (SIZEOF_LONG == 4)
334 # define INT32_MAX LONG_MAX
335 # else
336 # error "need INT32_MAX"
337 # endif
338 #endif
339 
340 #ifndef INT64_MAX
341 # if (SIZEOF_INT == 8)
342 # define INT64_MAX INT_MAX
343 # elif (SIZEOF_LONG == 8)
344 # define INT64_MAX LONG_MAX
345 # elif (SIZEOF_LONG_LONG_INT == 8)
346 # define INT64_MAX LLONG_MAX
347 # else
348 # error "need INT64_MAX"
349 # endif
350 #endif
351 
352 #ifndef HAVE_SSIZE_T
353 typedef int ssize_t;
354 #define SSIZE_MAX INT_MAX
355 # define HAVE_SSIZE_T
356 #endif /* HAVE_SSIZE_T */
357 
358 #ifndef HAVE_CLOCK_T
359 typedef long clock_t;
360 # define HAVE_CLOCK_T
361 #endif /* HAVE_CLOCK_T */
362 
363 #ifndef HAVE_SA_FAMILY_T
364 typedef int sa_family_t;
365 # define HAVE_SA_FAMILY_T
366 #endif /* HAVE_SA_FAMILY_T */
367 
368 #ifndef HAVE_PID_T
369 typedef int pid_t;
370 # define HAVE_PID_T
371 #endif /* HAVE_PID_T */
372 
373 #ifndef HAVE_SIG_ATOMIC_T
374 typedef int sig_atomic_t;
375 # define HAVE_SIG_ATOMIC_T
376 #endif /* HAVE_SIG_ATOMIC_T */
377 
378 #ifndef HAVE_MODE_T
379 typedef int mode_t;
380 # define HAVE_MODE_T
381 #endif /* HAVE_MODE_T */
382 
383 #if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS)
384 # define ss_family __ss_family
385 #endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */
386 
387 #ifndef HAVE_SYS_UN_H
388 struct sockaddr_un {
389  short sun_family; /* AF_UNIX */
390  char sun_path[108]; /* path name (gag) */
391 };
392 #endif /* HAVE_SYS_UN_H */
393 
394 #ifndef HAVE_IN_ADDR_T
395 typedef u_int32_t in_addr_t;
396 #endif
397 #ifndef HAVE_IN_PORT_T
398 typedef u_int16_t in_port_t;
399 #endif
400 
401 #if defined(BROKEN_SYS_TERMIO_H) && !defined(_STRUCT_WINSIZE)
402 #define _STRUCT_WINSIZE
403 struct winsize {
404  unsigned short ws_row; /* rows, in characters */
405  unsigned short ws_col; /* columns, in character */
406  unsigned short ws_xpixel; /* horizontal size, pixels */
407  unsigned short ws_ypixel; /* vertical size, pixels */
408 };
409 #endif
410 
411 /* bits needed for select that may not be in the system headers */
412 #ifndef HAVE_FD_MASK
413  typedef unsigned long int fd_mask;
414 #endif
415 
416 #if defined(HAVE_DECL_NFDBITS) && HAVE_DECL_NFDBITS == 0
417 # define NFDBITS (8 * sizeof(unsigned long))
418 #endif
419 
420 #if defined(HAVE_DECL_HOWMANY) && HAVE_DECL_HOWMANY == 0
421 # define howmany(x,y) (((x)+((y)-1))/(y))
422 #endif
423 
424 /* Paths */
425 
426 #ifndef _PATH_BSHELL
427 # define _PATH_BSHELL "/bin/sh"
428 #endif
429 
430 #ifdef USER_PATH
431 # ifdef _PATH_STDPATH
432 # undef _PATH_STDPATH
433 # endif
434 # define _PATH_STDPATH USER_PATH
435 #endif
436 
437 #ifndef _PATH_STDPATH
438 # define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
439 #endif
440 
441 #ifndef SUPERUSER_PATH
442 # define SUPERUSER_PATH _PATH_STDPATH
443 #endif
444 
445 #ifndef _PATH_DEVNULL
446 # define _PATH_DEVNULL "/dev/null"
447 #endif
448 
449 /* user may have set a different path */
450 #if defined(_PATH_MAILDIR) && defined(MAIL_DIRECTORY)
451 # undef _PATH_MAILDIR
452 #endif /* defined(_PATH_MAILDIR) && defined(MAIL_DIRECTORY) */
453 
454 #ifdef MAIL_DIRECTORY
455 # define _PATH_MAILDIR MAIL_DIRECTORY
456 #endif
457 
458 #ifndef _PATH_NOLOGIN
459 # define _PATH_NOLOGIN "/etc/nologin"
460 #endif
461 
462 /* Define this to be the path of the xauth program. */
463 #ifdef XAUTH_PATH
464 #define _PATH_XAUTH XAUTH_PATH
465 #endif /* XAUTH_PATH */
466 
467 /* derived from XF4/xc/lib/dps/Xlibnet.h */
468 #ifndef X_UNIX_PATH
469 # ifdef __hpux
470 # define X_UNIX_PATH "/var/spool/sockets/X11/%u"
471 # else
472 # define X_UNIX_PATH "/tmp/.X11-unix/X%u"
473 # endif
474 #endif /* X_UNIX_PATH */
475 #define _PATH_UNIX_X X_UNIX_PATH
476 
477 #ifndef _PATH_TTY
478 # define _PATH_TTY "/dev/tty"
479 #endif
480 
481 /* Macros */
482 
483 #if defined(HAVE_LOGIN_GETCAPBOOL) && defined(HAVE_LOGIN_CAP_H)
484 # define HAVE_LOGIN_CAP
485 #endif
486 
487 #ifndef MAX
488 # define MAX(a,b) (((a)>(b))?(a):(b))
489 # define MIN(a,b) (((a)<(b))?(a):(b))
490 #endif
491 
492 #ifndef roundup
493 # define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
494 #endif
495 
496 #ifndef timersub
497 #define timersub(a, b, result) \
498  do { \
499  (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
500  (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
501  if ((result)->tv_usec < 0) { \
502  --(result)->tv_sec; \
503  (result)->tv_usec += 1000000; \
504  } \
505  } while (0)
506 #endif
507 
508 #ifndef TIMEVAL_TO_TIMESPEC
509 #define TIMEVAL_TO_TIMESPEC(tv, ts) { \
510  (ts)->tv_sec = (tv)->tv_sec; \
511  (ts)->tv_nsec = (tv)->tv_usec * 1000; \
512 }
513 #endif
514 
515 #ifndef TIMESPEC_TO_TIMEVAL
516 #define TIMESPEC_TO_TIMEVAL(tv, ts) { \
517  (tv)->tv_sec = (ts)->tv_sec; \
518  (tv)->tv_usec = (ts)->tv_nsec / 1000; \
519 }
520 #endif
521 
522 #ifndef timespeccmp
523 #define timespeccmp(tsp, usp, cmp) \
524  (((tsp)->tv_sec == (usp)->tv_sec) ? \
525  ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
526  ((tsp)->tv_sec cmp (usp)->tv_sec))
527 #endif
528 
529 #ifndef __P
530 # define __P(x) x
531 #endif
532 
533 #if !defined(IN6_IS_ADDR_V4MAPPED)
534 # define IN6_IS_ADDR_V4MAPPED(a) \
535  ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \
536  (((u_int32_t *) (a))[2] == htonl (0xffff)))
537 #endif /* !defined(IN6_IS_ADDR_V4MAPPED) */
538 
539 #if !defined(__GNUC__) || (__GNUC__ < 2)
540 # define __attribute__(x)
541 #endif /* !defined(__GNUC__) || (__GNUC__ < 2) */
542 
543 #if !defined(HAVE_ATTRIBUTE__SENTINEL__) && !defined(__sentinel__)
544 # define __sentinel__
545 #endif
546 
547 #if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__bounded__)
548 # define __bounded__(x, y, z)
549 #endif
550 
551 #if !defined(HAVE_ATTRIBUTE__NONNULL__) && !defined(__nonnull__)
552 # define __nonnull__(x)
553 #endif
554 
555 #ifndef OSSH_ALIGNBYTES
556 #define OSSH_ALIGNBYTES (sizeof(int) - 1)
557 #endif
558 #ifndef __CMSG_ALIGN
559 #define __CMSG_ALIGN(p) (((u_int)(p) + OSSH_ALIGNBYTES) &~ OSSH_ALIGNBYTES)
560 #endif
561 
562 /* Length of the contents of a control message of length len */
563 #ifndef CMSG_LEN
564 #define CMSG_LEN(len) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
565 #endif
566 
567 /* Length of the space taken up by a padded control message of length len */
568 #ifndef CMSG_SPACE
569 #define CMSG_SPACE(len) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + __CMSG_ALIGN(len))
570 #endif
571 
572 /* given pointer to struct cmsghdr, return pointer to data */
573 #ifndef CMSG_DATA
574 #define CMSG_DATA(cmsg) ((u_char *)(cmsg) + __CMSG_ALIGN(sizeof(struct cmsghdr)))
575 #endif /* CMSG_DATA */
576 
577 /*
578  * RFC 2292 requires to check msg_controllen, in case that the kernel returns
579  * an empty list for some reasons.
580  */
581 #ifndef CMSG_FIRSTHDR
582 #define CMSG_FIRSTHDR(mhdr) \
583  ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
584  (struct cmsghdr *)(mhdr)->msg_control : \
585  (struct cmsghdr *)NULL)
586 #endif /* CMSG_FIRSTHDR */
587 
588 #if defined(HAVE_DECL_OFFSETOF) && HAVE_DECL_OFFSETOF == 0
589 # define offsetof(type, member) ((size_t) &((type *)0)->member)
590 #endif
591 
592 /* Set up BSD-style BYTE_ORDER definition if it isn't there already */
593 /* XXX: doesn't try to cope with strange byte orders (PDP_ENDIAN) */
594 #ifndef BYTE_ORDER
595 # ifndef LITTLE_ENDIAN
596 # define LITTLE_ENDIAN 1234
597 # endif /* LITTLE_ENDIAN */
598 # ifndef BIG_ENDIAN
599 # define BIG_ENDIAN 4321
600 # endif /* BIG_ENDIAN */
601 # ifdef WORDS_BIGENDIAN
602 # define BYTE_ORDER BIG_ENDIAN
603 # else /* WORDS_BIGENDIAN */
604 # define BYTE_ORDER LITTLE_ENDIAN
605 # endif /* WORDS_BIGENDIAN */
606 #endif /* BYTE_ORDER */
607 
608 /* Function replacement / compatibility hacks */
609 
610 #if !defined(HAVE_GETADDRINFO) && (defined(HAVE_OGETADDRINFO) || defined(HAVE_NGETADDRINFO))
611 # define HAVE_GETADDRINFO
612 #endif
613 
614 #ifndef HAVE_GETOPT_OPTRESET
615 # undef getopt
616 # undef opterr
617 # undef optind
618 # undef optopt
619 # undef optreset
620 # undef optarg
621 # define getopt(ac, av, o) BSDgetopt(ac, av, o)
622 # define opterr BSDopterr
623 # define optind BSDoptind
624 # define optopt BSDoptopt
625 # define optreset BSDoptreset
626 # define optarg BSDoptarg
627 #endif
628 
629 #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO)
630 # undef HAVE_GETADDRINFO
631 #endif
632 #if defined(BROKEN_GETADDRINFO) && defined(HAVE_FREEADDRINFO)
633 # undef HAVE_FREEADDRINFO
634 #endif
635 #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GAI_STRERROR)
636 # undef HAVE_GAI_STRERROR
637 #endif
638 
639 #if defined(HAVE_GETADDRINFO)
640 # if defined(HAVE_DECL_AI_NUMERICSERV) && HAVE_DECL_AI_NUMERICSERV == 0
641 # define AI_NUMERICSERV 0
642 # endif
643 #endif
644 
645 #if defined(BROKEN_UPDWTMPX) && defined(HAVE_UPDWTMPX)
646 # undef HAVE_UPDWTMPX
647 #endif
648 
649 #if defined(BROKEN_SHADOW_EXPIRE) && defined(HAS_SHADOW_EXPIRE)
650 # undef HAS_SHADOW_EXPIRE
651 #endif
652 
653 #if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT) && \
654  defined(SYSLOG_R_SAFE_IN_SIGHAND)
655 # define DO_LOG_SAFE_IN_SIGHAND
656 #endif
657 
658 #if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY)
659 # define memmove(s1, s2, n) bcopy((s2), (s1), (n))
660 #endif /* !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) */
661 
662 #ifndef GETPGRP_VOID
663 # include <unistd.h>
664 # define getpgrp() getpgrp(0)
665 #endif
666 
667 #ifdef USE_BSM_AUDIT
668 # define SSH_AUDIT_EVENTS
669 # define CUSTOM_SSH_AUDIT_EVENTS
670 #endif
671 
672 #ifdef USE_LINUX_AUDIT
673 # define SSH_AUDIT_EVENTS
674 # define CUSTOM_SSH_AUDIT_EVENTS
675 #endif
676 
677 #if !defined(HAVE___func__) && defined(HAVE___FUNCTION__)
678 # define __func__ __FUNCTION__
679 #elif !defined(HAVE___func__)
680 # define __func__ ""
681 #endif
682 
683 #if defined(KRB5) && !defined(HEIMDAL)
684 # define krb5_get_err_text(context,code) error_message(code)
685 #endif
686 
687 /* Maximum number of file descriptors available */
688 #ifdef HAVE_SYSCONF
689 # define SSH_SYSFDMAX sysconf(_SC_OPEN_MAX)
690 #else
691 # define SSH_SYSFDMAX 10000
692 #endif
693 
694 #ifdef FSID_HAS_VAL
695 /* encode f_fsid into a 64 bit value */
696 #define FSID_TO_ULONG(f) \
697  ((((u_int64_t)(f).val[0] & 0xffffffffUL) << 32) | \
698  ((f).val[1] & 0xffffffffUL))
699 #elif defined(FSID_HAS___VAL)
700 #define FSID_TO_ULONG(f) \
701  ((((u_int64_t)(f).__val[0] & 0xffffffffUL) << 32) | \
702  ((f).__val[1] & 0xffffffffUL))
703 #else
704 # define FSID_TO_ULONG(f) ((f))
705 #endif
706 
707 #if defined(__Lynx__)
708  /*
709  * LynxOS defines these in param.h which we do not want to include since
710  * it will also pull in a bunch of kernel definitions.
711  */
712 # define ALIGNBYTES (sizeof(int) - 1)
713 # define ALIGN(p) (((unsigned)p + ALIGNBYTES) & ~ALIGNBYTES)
714  /* Missing prototypes on LynxOS */
715  int snprintf (char *, size_t, const char *, ...);
716  int mkstemp (char *);
717  char *crypt (const char *, const char *);
718  int seteuid (uid_t);
719  int setegid (gid_t);
720  char *mkdtemp (char *);
721  int rresvport_af (int *, sa_family_t);
722  int innetgr (const char *, const char *, const char *, const char *);
723 #endif
724 
725 /*
726  * Define this to use pipes instead of socketpairs for communicating with the
727  * client program. Socketpairs do not seem to work on all systems.
728  *
729  * configure.ac sets this for a few OS's which are known to have problems
730  * but you may need to set it yourself
731  */
732 /* #define USE_PIPES 1 */
733 
738 /* FIXME: put default paths back in */
739 #ifndef UTMP_FILE
740 # ifdef _PATH_UTMP
741 # define UTMP_FILE _PATH_UTMP
742 # else
743 # ifdef CONF_UTMP_FILE
744 # define UTMP_FILE CONF_UTMP_FILE
745 # endif
746 # endif
747 #endif
748 #ifndef WTMP_FILE
749 # ifdef _PATH_WTMP
750 # define WTMP_FILE _PATH_WTMP
751 # else
752 # ifdef CONF_WTMP_FILE
753 # define WTMP_FILE CONF_WTMP_FILE
754 # endif
755 # endif
756 #endif
757 /* pick up the user's location for lastlog if given */
758 #ifndef LASTLOG_FILE
759 # ifdef _PATH_LASTLOG
760 # define LASTLOG_FILE _PATH_LASTLOG
761 # else
762 # ifdef CONF_LASTLOG_FILE
763 # define LASTLOG_FILE CONF_LASTLOG_FILE
764 # endif
765 # endif
766 #endif
767 
768 #if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW)
769 # define USE_SHADOW
770 #endif
771 
772 /* The login() library function in libutil is first choice */
773 #if defined(HAVE_LOGIN) && !defined(DISABLE_LOGIN)
774 # define USE_LOGIN
775 
776 #else
777 /* Simply select your favourite login types. */
778 /* Can't do if-else because some systems use several... <sigh> */
779 # if !defined(DISABLE_UTMPX)
780 # define USE_UTMPX
781 # endif
782 # if defined(UTMP_FILE) && !defined(DISABLE_UTMP)
783 # define USE_UTMP
784 # endif
785 # if defined(WTMPX_FILE) && !defined(DISABLE_WTMPX)
786 # define USE_WTMPX
787 # endif
788 # if defined(WTMP_FILE) && !defined(DISABLE_WTMP)
789 # define USE_WTMP
790 # endif
791 
792 #endif
793 
794 #ifndef UT_LINESIZE
795 # define UT_LINESIZE 8
796 #endif
797 
798 /* I hope that the presence of LASTLOG_FILE is enough to detect this */
799 #if defined(LASTLOG_FILE) && !defined(DISABLE_LASTLOG)
800 # define USE_LASTLOG
801 #endif
802 
803 #ifdef HAVE_OSF_SIA
804 # ifdef USE_SHADOW
805 # undef USE_SHADOW
806 # endif
807 # define CUSTOM_SYS_AUTH_PASSWD 1
808 #endif
809 
810 #if defined(HAVE_LIBIAF) && defined(HAVE_SET_ID) && !defined(HAVE_SECUREWARE)
811 # define CUSTOM_SYS_AUTH_PASSWD 1
812 #endif
813 #if defined(HAVE_LIBIAF) && defined(HAVE_SET_ID) && !defined(BROKEN_LIBIAF)
814 # define USE_LIBIAF
815 #endif
816 
817 /* HP-UX 11.11 */
818 #ifdef BTMP_FILE
819 # define _PATH_BTMP BTMP_FILE
820 #endif
821 
822 #if defined(USE_BTMP) && defined(_PATH_BTMP)
823 # define CUSTOM_FAILED_LOGIN
824 #endif
825 
828 #ifdef BROKEN_GETGROUPS
829 # define getgroups(a,b) ((a)==0 && (b)==NULL ? NGROUPS_MAX : getgroups((a),(b)))
830 #endif
831 
832 #ifndef IOV_MAX
833 # if defined(_XOPEN_IOV_MAX)
834 # define IOV_MAX _XOPEN_IOV_MAX
835 # elif defined(DEF_IOV_MAX)
836 # define IOV_MAX DEF_IOV_MAX
837 # else
838 # define IOV_MAX 16
839 # endif
840 #endif
841 
842 #ifndef EWOULDBLOCK
843 # define EWOULDBLOCK EAGAIN
844 #endif
845 
846 #ifndef INET6_ADDRSTRLEN /* for non IPv6 machines */
847 #define INET6_ADDRSTRLEN 46
848 #endif
849 
850 #ifndef SSH_IOBUFSZ
851 # define SSH_IOBUFSZ 32*1024
852 #endif
853 
854 /*
855  * We want functions in openbsd-compat, if enabled, to override system ones.
856  * We no-op out the weak symbol definition rather than remove it to reduce
857  * future sync problems. Some compilers (eg Unixware) do not allow an
858  * empty statement, so we use a bogus function declaration.
859  */
860 #define DEF_WEAK(x) void __ssh_compat_weak_##x(void)
861 
862 /*
863  * Platforms that have arc4random_uniform() and not arc4random_stir()
864  * shouldn't need the latter.
865  */
866 #if defined(HAVE_ARC4RANDOM) && defined(HAVE_ARC4RANDOM_UNIFORM) && \
867  !defined(HAVE_ARC4RANDOM_STIR)
868 # define arc4random_stir()
869 #endif
870 
871 #ifndef HAVE_VA_COPY
872 # ifdef HAVE___VA_COPY
873 # define va_copy(dest, src) __va_copy(dest, src)
874 # else
875 # define va_copy(dest, src) (dest) = (src)
876 # endif
877 #endif
878 
879 #ifndef __predict_true
880 # if defined(__GNUC__) && \
881  ((__GNUC__ > (2)) || (__GNUC__ == (2) && __GNUC_MINOR__ >= (96)))
882 # define __predict_true(exp) __builtin_expect(((exp) != 0), 1)
883 # define __predict_false(exp) __builtin_expect(((exp) != 0), 0)
884 # else
885 # define __predict_true(exp) ((exp) != 0)
886 # define __predict_false(exp) ((exp) != 0)
887 # endif /* gcc version */
888 #endif /* __predict_true */
889 
890 #if defined(HAVE_GLOB_H) && defined(GLOB_HAS_ALTDIRFUNC) && \
891  defined(GLOB_HAS_GL_MATCHC) && defined(GLOB_HAS_GL_STATV) && \
892  defined(HAVE_DECL_GLOB_NOMATCH) && HAVE_DECL_GLOB_NOMATCH != 0 && \
893  !defined(BROKEN_GLOB)
894 # define USE_SYSTEM_GLOB
895 #endif
896 
897 /*
898  * sntrup761 uses variable length arrays, only enable if the compiler
899  * supports them.
900  */
901 #ifdef VARIABLE_LENGTH_ARRAYS
902 # define USE_SNTRUP761X25519 1
903 #endif
904 #endif /* _DEFINES_H */