xref: /openssh-portable/defines.h (revision 48d0d7a4)
1af63951cSDamien Miller /*
2af63951cSDamien Miller  * Copyright (c) 1999-2003 Damien Miller.  All rights reserved.
3af63951cSDamien Miller  *
4af63951cSDamien Miller  * Redistribution and use in source and binary forms, with or without
5af63951cSDamien Miller  * modification, are permitted provided that the following conditions
6af63951cSDamien Miller  * are met:
7af63951cSDamien Miller  * 1. Redistributions of source code must retain the above copyright
8af63951cSDamien Miller  *    notice, this list of conditions and the following disclaimer.
9af63951cSDamien Miller  * 2. Redistributions in binary form must reproduce the above copyright
10af63951cSDamien Miller  *    notice, this list of conditions and the following disclaimer in the
11af63951cSDamien Miller  *    documentation and/or other materials provided with the distribution.
12af63951cSDamien Miller  *
13af63951cSDamien Miller  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14af63951cSDamien Miller  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15af63951cSDamien Miller  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16af63951cSDamien Miller  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17af63951cSDamien Miller  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18af63951cSDamien Miller  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19af63951cSDamien Miller  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20af63951cSDamien Miller  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21af63951cSDamien Miller  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22af63951cSDamien Miller  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23af63951cSDamien Miller  */
24af63951cSDamien Miller 
256b85a7ffSDamien Miller #ifndef _DEFINES_H
266b85a7ffSDamien Miller #define _DEFINES_H
276b85a7ffSDamien Miller 
2874d0d4a3SDamien Miller /* Constants */
2974d0d4a3SDamien Miller 
30248469bcSDarren Tucker #if defined(HAVE_DECL_SHUT_RD) && HAVE_DECL_SHUT_RD == 0
315a3e6838SDamien Miller enum
325a3e6838SDamien Miller {
335a3e6838SDamien Miller   SHUT_RD = 0,		/* No more receptions.  */
345a3e6838SDamien Miller   SHUT_WR,			/* No more transmissions.  */
355a3e6838SDamien Miller   SHUT_RDWR			/* No more receptions or transmissions.  */
365a3e6838SDamien Miller };
375a3e6838SDamien Miller # define SHUT_RD   SHUT_RD
385a3e6838SDamien Miller # define SHUT_WR   SHUT_WR
395a3e6838SDamien Miller # define SHUT_RDWR SHUT_RDWR
405a3e6838SDamien Miller #endif
415a3e6838SDamien Miller 
4273de86acSDamien Miller /*
43353766e0SDarren Tucker  * Cygwin doesn't really have a notion of reserved ports.  It is still
44353766e0SDarren Tucker  * is useful on the client side so for compatibility it defines as 1024 via
45353766e0SDarren Tucker  * netinet/in.h inside an enum.  We * don't actually want that restriction
46353766e0SDarren Tucker  * so we want to set that to zero, but we can't do it direct in config.h
47353766e0SDarren Tucker  * because it'll cause a conflicting definition the first time we include
48353766e0SDarren Tucker  * netinet/in.h.
49353766e0SDarren Tucker  */
50353766e0SDarren Tucker 
51353766e0SDarren Tucker #ifdef HAVE_CYGWIN
52353766e0SDarren Tucker #define IPPORT_RESERVED 0
53353766e0SDarren Tucker #endif
54353766e0SDarren Tucker 
55353766e0SDarren Tucker /*
5673de86acSDamien Miller  * Definitions for IP type of service (ip_tos)
5773de86acSDamien Miller  */
5868790fedSDamien Miller #include <netinet/in_systm.h>
5968790fedSDamien Miller #include <netinet/ip.h>
60bc7c7cceSDamien Miller #ifndef IPTOS_LOWDELAY
61bc7c7cceSDamien Miller # define IPTOS_LOWDELAY          0x10
62bc7c7cceSDamien Miller # define IPTOS_THROUGHPUT        0x08
63bc7c7cceSDamien Miller # define IPTOS_RELIABILITY       0x04
64bc7c7cceSDamien Miller # define IPTOS_LOWCOST           0x02
65bc7c7cceSDamien Miller # define IPTOS_MINCOST           IPTOS_LOWCOST
66bc7c7cceSDamien Miller #endif /* IPTOS_LOWDELAY */
67bc7c7cceSDamien Miller 
6873de86acSDamien Miller /*
6973de86acSDamien Miller  * Definitions for DiffServ Codepoints as per RFC2474
7073de86acSDamien Miller  */
7173de86acSDamien Miller #ifndef IPTOS_DSCP_AF11
7273de86acSDamien Miller # define	IPTOS_DSCP_AF11		0x28
7373de86acSDamien Miller # define	IPTOS_DSCP_AF12		0x30
7473de86acSDamien Miller # define	IPTOS_DSCP_AF13		0x38
7573de86acSDamien Miller # define	IPTOS_DSCP_AF21		0x48
7673de86acSDamien Miller # define	IPTOS_DSCP_AF22		0x50
7773de86acSDamien Miller # define	IPTOS_DSCP_AF23		0x58
7873de86acSDamien Miller # define	IPTOS_DSCP_AF31		0x68
7973de86acSDamien Miller # define	IPTOS_DSCP_AF32		0x70
8073de86acSDamien Miller # define	IPTOS_DSCP_AF33		0x78
8173de86acSDamien Miller # define	IPTOS_DSCP_AF41		0x88
8273de86acSDamien Miller # define	IPTOS_DSCP_AF42		0x90
8373de86acSDamien Miller # define	IPTOS_DSCP_AF43		0x98
8473de86acSDamien Miller # define	IPTOS_DSCP_EF		0xb8
8573de86acSDamien Miller #endif /* IPTOS_DSCP_AF11 */
8673de86acSDamien Miller #ifndef IPTOS_DSCP_CS0
8773de86acSDamien Miller # define	IPTOS_DSCP_CS0		0x00
8873de86acSDamien Miller # define	IPTOS_DSCP_CS1		0x20
8973de86acSDamien Miller # define	IPTOS_DSCP_CS2		0x40
9073de86acSDamien Miller # define	IPTOS_DSCP_CS3		0x60
9173de86acSDamien Miller # define	IPTOS_DSCP_CS4		0x80
9273de86acSDamien Miller # define	IPTOS_DSCP_CS5		0xa0
9373de86acSDamien Miller # define	IPTOS_DSCP_CS6		0xc0
9473de86acSDamien Miller # define	IPTOS_DSCP_CS7		0xe0
9573de86acSDamien Miller #endif /* IPTOS_DSCP_CS0 */
9673de86acSDamien Miller #ifndef IPTOS_DSCP_EF
9773de86acSDamien Miller # define	IPTOS_DSCP_EF		0xb8
9873de86acSDamien Miller #endif /* IPTOS_DSCP_EF */
99ec8a759bSDamien Miller #ifndef IPTOS_DSCP_LE
100ec8a759bSDamien Miller # define	IPTOS_DSCP_LE		0x01
101ec8a759bSDamien Miller #endif /* IPTOS_DSCP_LE */
102c1e0a32fSDarren Tucker #ifndef IPTOS_PREC_CRITIC_ECP
103c1e0a32fSDarren Tucker # define IPTOS_PREC_CRITIC_ECP		0xa0
104c1e0a32fSDarren Tucker #endif
105c1e0a32fSDarren Tucker #ifndef IPTOS_PREC_INTERNETCONTROL
106c1e0a32fSDarren Tucker # define IPTOS_PREC_INTERNETCONTROL	0xc0
107c1e0a32fSDarren Tucker #endif
108c1e0a32fSDarren Tucker #ifndef IPTOS_PREC_NETCONTROL
109c1e0a32fSDarren Tucker # define IPTOS_PREC_NETCONTROL		0xe0
110c1e0a32fSDarren Tucker #endif
11173de86acSDamien Miller 
112f79b5d38STim Rice #ifndef PATH_MAX
113f79b5d38STim Rice # ifdef _POSIX_PATH_MAX
114f79b5d38STim Rice # define PATH_MAX _POSIX_PATH_MAX
115f79b5d38STim Rice # endif
116f79b5d38STim Rice #endif
117f79b5d38STim Rice 
118a66626b2SDamien Miller #ifndef MAXPATHLEN
119a66626b2SDamien Miller # ifdef PATH_MAX
120a66626b2SDamien Miller #  define MAXPATHLEN PATH_MAX
121a66626b2SDamien Miller # else /* PATH_MAX */
122287b4591SDamien Miller #  define MAXPATHLEN 64
123a66626b2SDamien Miller # endif /* PATH_MAX */
124a66626b2SDamien Miller #endif /* MAXPATHLEN */
125a66626b2SDamien Miller 
126a2c95c1bSDamien Miller #ifndef HOST_NAME_MAX
12738806bdaSDamien Miller # include "netdb.h" /* for MAXHOSTNAMELEN */
128a2c95c1bSDamien Miller # if defined(_POSIX_HOST_NAME_MAX)
129a2c95c1bSDamien Miller #  define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
130a2c95c1bSDamien Miller # elif defined(MAXHOSTNAMELEN)
131a2c95c1bSDamien Miller #  define HOST_NAME_MAX MAXHOSTNAMELEN
132676c38d7STim Rice # else
133676c38d7STim Rice #  define HOST_NAME_MAX	255
134a2c95c1bSDamien Miller # endif
135a2c95c1bSDamien Miller #endif /* HOST_NAME_MAX */
136a2c95c1bSDamien Miller 
1376d862a50SDarren Tucker #if defined(HAVE_DECL_MAXSYMLINKS) && HAVE_DECL_MAXSYMLINKS == 0
13873f671a0SDarren Tucker # define MAXSYMLINKS 5
13973f671a0SDarren Tucker #endif
14073f671a0SDarren Tucker 
1410f91b4e3SDamien Miller #ifndef STDIN_FILENO
1420f91b4e3SDamien Miller # define STDIN_FILENO    0
1430f91b4e3SDamien Miller #endif
1440f91b4e3SDamien Miller #ifndef STDOUT_FILENO
1450f91b4e3SDamien Miller # define STDOUT_FILENO   1
1460f91b4e3SDamien Miller #endif
1470f91b4e3SDamien Miller #ifndef STDERR_FILENO
1480f91b4e3SDamien Miller # define STDERR_FILENO   2
1490f91b4e3SDamien Miller #endif
1500f91b4e3SDamien Miller 
15103f07b45SBen Lindstrom #ifndef NGROUPS_MAX	/* Disable groupaccess if NGROUP_MAX is not set */
1526aebb340SBen Lindstrom #ifdef NGROUPS
1536aebb340SBen Lindstrom #define NGROUPS_MAX NGROUPS
1546aebb340SBen Lindstrom #else
15503f07b45SBen Lindstrom #define NGROUPS_MAX 0
15675713c9dSBen Lindstrom #endif
1576aebb340SBen Lindstrom #endif
15875713c9dSBen Lindstrom 
159248469bcSDarren Tucker #if defined(HAVE_DECL_O_NONBLOCK) && HAVE_DECL_O_NONBLOCK == 0
160248469bcSDarren Tucker # define O_NONBLOCK      00004	/* Non Blocking Open */
1610d5af601SBen Lindstrom #endif
1620d5af601SBen Lindstrom 
1639abb697dSTim Rice #ifndef S_IFSOCK
1649abb697dSTim Rice # define S_IFSOCK 0
1659abb697dSTim Rice #endif /* S_IFSOCK */
1669abb697dSTim Rice 
16703017ba6SBen Lindstrom #ifndef S_ISDIR
1680f91b4e3SDamien Miller # define S_ISDIR(mode)	(((mode) & (_S_IFMT)) == (_S_IFDIR))
16903017ba6SBen Lindstrom #endif /* S_ISDIR */
17003017ba6SBen Lindstrom 
17103017ba6SBen Lindstrom #ifndef S_ISREG
1720f91b4e3SDamien Miller # define S_ISREG(mode)	(((mode) & (_S_IFMT)) == (_S_IFREG))
1730f91b4e3SDamien Miller #endif /* S_ISREG */
1740f91b4e3SDamien Miller 
17503017ba6SBen Lindstrom #ifndef S_ISLNK
176d14d7021STim Rice # define S_ISLNK(mode)	(((mode) & S_IFMT) == S_IFLNK)
17703017ba6SBen Lindstrom #endif /* S_ISLNK */
17803017ba6SBen Lindstrom 
1790f91b4e3SDamien Miller #ifndef S_IXUSR
1800f91b4e3SDamien Miller # define S_IXUSR			0000100	/* execute/search permission, */
1810f91b4e3SDamien Miller # define S_IXGRP			0000010	/* execute/search permission, */
1820f91b4e3SDamien Miller # define S_IXOTH			0000001	/* execute/search permission, */
1830f91b4e3SDamien Miller # define _S_IWUSR			0000200	/* write permission, */
1840f91b4e3SDamien Miller # define S_IWUSR			_S_IWUSR	/* write permission, owner */
1850f91b4e3SDamien Miller # define S_IWGRP			0000020	/* write permission, group */
1860f91b4e3SDamien Miller # define S_IWOTH			0000002	/* write permission, other */
1870f91b4e3SDamien Miller # define S_IRUSR			0000400	/* read permission, owner */
1880f91b4e3SDamien Miller # define S_IRGRP			0000040	/* read permission, group */
1890f91b4e3SDamien Miller # define S_IROTH			0000004	/* read permission, other */
1900f91b4e3SDamien Miller # define S_IRWXU			0000700	/* read, write, execute */
1910f91b4e3SDamien Miller # define S_IRWXG			0000070	/* read, write, execute */
1920f91b4e3SDamien Miller # define S_IRWXO			0000007	/* read, write, execute */
1930f91b4e3SDamien Miller #endif /* S_IXUSR */
1940f91b4e3SDamien Miller 
195813f0452STim Rice #if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
196813f0452STim Rice #define MAP_ANON MAP_ANONYMOUS
197813f0452STim Rice #endif
198813f0452STim Rice 
199813f0452STim Rice #ifndef MAP_FAILED
200813f0452STim Rice # define MAP_FAILED ((void *)-1)
201813f0452STim Rice #endif
202813f0452STim Rice 
2034cec93faSTim Rice /*
2044cec93faSTim Rice SCO Open Server 3 has INADDR_LOOPBACK defined in rpc/rpc.h but
2054cec93faSTim Rice including rpc/rpc.h breaks Solaris 6
2064cec93faSTim Rice */
2074cec93faSTim Rice #ifndef INADDR_LOOPBACK
208b8b23047STim Rice #define INADDR_LOOPBACK ((u_long)0x7f000001)
2094cec93faSTim Rice #endif
2104cec93faSTim Rice 
21174d0d4a3SDamien Miller /* Types */
21274d0d4a3SDamien Miller 
2135a3e6838SDamien Miller /* If sys/types.h does not supply intXX_t, supply them ourselves */
2145a3e6838SDamien Miller /* (or die trying) */
215caf6dd6dSDamien Miller 
216caf6dd6dSDamien Miller #ifndef HAVE_U_INT
217caf6dd6dSDamien Miller typedef unsigned int u_int;
218caf6dd6dSDamien Miller #endif
219caf6dd6dSDamien Miller 
2205a3e6838SDamien Miller #ifndef HAVE_INTXX_T
2215ffe1c4bSDamien Miller typedef signed char int8_t;
2225a3e6838SDamien Miller # if (SIZEOF_SHORT_INT == 2)
22374d0d4a3SDamien Miller typedef short int int16_t;
2245a3e6838SDamien Miller # else
2255a3e6838SDamien Miller #   error "16 bit int type not found."
2265a3e6838SDamien Miller # endif
2275a3e6838SDamien Miller # if (SIZEOF_INT == 4)
22874d0d4a3SDamien Miller typedef int int32_t;
2295a3e6838SDamien Miller # else
2305a3e6838SDamien Miller #   error "32 bit int type not found."
2315a3e6838SDamien Miller # endif
2325a3e6838SDamien Miller #endif
2335a3e6838SDamien Miller 
2345a3e6838SDamien Miller /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
2355a3e6838SDamien Miller #ifndef HAVE_U_INTXX_T
2365a3e6838SDamien Miller # ifdef HAVE_UINTXX_T
237e0f4574cSDamien Miller typedef uint8_t u_int8_t;
23874d0d4a3SDamien Miller typedef uint16_t u_int16_t;
23974d0d4a3SDamien Miller typedef uint32_t u_int32_t;
2406b85a7ffSDamien Miller # define HAVE_U_INTXX_T 1
2415a3e6838SDamien Miller # else
242e0f4574cSDamien Miller typedef unsigned char u_int8_t;
2435a3e6838SDamien Miller #  if (SIZEOF_SHORT_INT == 2)
24474d0d4a3SDamien Miller typedef unsigned short int u_int16_t;
2455a3e6838SDamien Miller #  else
2465a3e6838SDamien Miller #    error "16 bit int type not found."
2475a3e6838SDamien Miller #  endif
2485a3e6838SDamien Miller #  if (SIZEOF_INT == 4)
24974d0d4a3SDamien Miller typedef unsigned int u_int32_t;
2505a3e6838SDamien Miller #  else
2515a3e6838SDamien Miller #    error "32 bit int type not found."
2525a3e6838SDamien Miller #  endif
253578783e6SDamien Miller # endif
254d7d7da12SBen Lindstrom #define __BIT_TYPES_DEFINED__
25538e60935SBen Lindstrom #endif
256578783e6SDamien Miller 
257e9dc9863SDarren Tucker #if !defined(LLONG_MIN) && defined(LONG_LONG_MIN)
258e9dc9863SDarren Tucker #define LLONG_MIN LONG_LONG_MIN
259e9dc9863SDarren Tucker #endif
260e9dc9863SDarren Tucker #if !defined(LLONG_MAX) && defined(LONG_LONG_MAX)
261e9dc9863SDarren Tucker #define LLONG_MAX LONG_LONG_MAX
262e9dc9863SDarren Tucker #endif
263e9dc9863SDarren Tucker 
26414ccfdb7SDarren Tucker #ifndef UINT32_MAX
2650d114476SDarren Tucker # if defined(HAVE_DECL_UINT32_MAX) && (HAVE_DECL_UINT32_MAX == 0)
2660d114476SDarren Tucker #  if (SIZEOF_INT == 4)
2670d114476SDarren Tucker #    define UINT32_MAX	UINT_MAX
2680d114476SDarren Tucker #  endif
2690d114476SDarren Tucker # endif
27014ccfdb7SDarren Tucker #endif
2710d114476SDarren Tucker 
272578783e6SDamien Miller /* 64-bit types */
273578783e6SDamien Miller #ifndef HAVE_INT64_T
274578783e6SDamien Miller # if (SIZEOF_LONG_INT == 8)
275578783e6SDamien Miller typedef long int int64_t;
276578783e6SDamien Miller # else
277578783e6SDamien Miller #  if (SIZEOF_LONG_LONG_INT == 8)
278578783e6SDamien Miller typedef long long int int64_t;
279578783e6SDamien Miller #  endif
280578783e6SDamien Miller # endif
281578783e6SDamien Miller #endif
282578783e6SDamien Miller #ifndef HAVE_U_INT64_T
2835a3e6838SDamien Miller # if (SIZEOF_LONG_INT == 8)
28474d0d4a3SDamien Miller typedef unsigned long int u_int64_t;
2855a3e6838SDamien Miller # else
2865a3e6838SDamien Miller #  if (SIZEOF_LONG_LONG_INT == 8)
28774d0d4a3SDamien Miller typedef unsigned long long int u_int64_t;
2885a3e6838SDamien Miller #  endif
2895a3e6838SDamien Miller # endif
2905a3e6838SDamien Miller #endif
2915a3e6838SDamien Miller 
292355f8610SDarren Tucker #ifndef HAVE_UINTXX_T
293355f8610SDarren Tucker typedef u_int8_t uint8_t;
294355f8610SDarren Tucker typedef u_int16_t uint16_t;
295355f8610SDarren Tucker typedef u_int32_t uint32_t;
296355f8610SDarren Tucker typedef u_int64_t uint64_t;
297355f8610SDarren Tucker #endif
298355f8610SDarren Tucker 
299007e3b35SDarren Tucker #ifndef HAVE_INTMAX_T
300007e3b35SDarren Tucker typedef long long intmax_t;
301007e3b35SDarren Tucker #endif
302007e3b35SDarren Tucker 
303007e3b35SDarren Tucker #ifndef HAVE_UINTMAX_T
304007e3b35SDarren Tucker typedef unsigned long long uintmax_t;
305007e3b35SDarren Tucker #endif
306007e3b35SDarren Tucker 
30758be738aSDamien Miller #ifndef HAVE_U_CHAR
30858be738aSDamien Miller typedef unsigned char u_char;
30958be738aSDamien Miller # define HAVE_U_CHAR
31058be738aSDamien Miller #endif /* HAVE_U_CHAR */
31158be738aSDamien Miller 
31296ce9a1eSTim Rice #ifndef ULLONG_MAX
31396ce9a1eSTim Rice # define ULLONG_MAX ((unsigned long long)-1)
31496ce9a1eSTim Rice #endif
31596ce9a1eSTim Rice 
3163962119cSBen Lindstrom #ifndef SIZE_T_MAX
3173962119cSBen Lindstrom #define SIZE_T_MAX ULONG_MAX
3183962119cSBen Lindstrom #endif /* SIZE_T_MAX */
3193962119cSBen Lindstrom 
3209505851fSDamien Miller #ifndef HAVE_SIZE_T
3219505851fSDamien Miller typedef unsigned int size_t;
322b2532b3bSDamien Miller # define HAVE_SIZE_T
3233715be3cSDarren Tucker # define SIZE_T_MAX UINT_MAX
3249505851fSDamien Miller #endif /* HAVE_SIZE_T */
3259505851fSDamien Miller 
32654b1f312SDarren Tucker #ifndef SIZE_MAX
32754b1f312SDarren Tucker #define SIZE_MAX SIZE_T_MAX
32854b1f312SDarren Tucker #endif
32954b1f312SDarren Tucker 
330d29ba6f4SDarren Tucker #ifndef INT32_MAX
331d29ba6f4SDarren Tucker # if (SIZEOF_INT == 4)
332d29ba6f4SDarren Tucker #  define INT32_MAX INT_MAX
333d29ba6f4SDarren Tucker # elif (SIZEOF_LONG == 4)
334d29ba6f4SDarren Tucker #  define INT32_MAX LONG_MAX
335d29ba6f4SDarren Tucker # else
336d29ba6f4SDarren Tucker #  error "need INT32_MAX"
337d29ba6f4SDarren Tucker # endif
338d29ba6f4SDarren Tucker #endif
339d29ba6f4SDarren Tucker 
340d29ba6f4SDarren Tucker #ifndef INT64_MAX
341d29ba6f4SDarren Tucker # if (SIZEOF_INT == 8)
342d29ba6f4SDarren Tucker #  define INT64_MAX INT_MAX
343d29ba6f4SDarren Tucker # elif (SIZEOF_LONG == 8)
344d29ba6f4SDarren Tucker #  define INT64_MAX LONG_MAX
345d29ba6f4SDarren Tucker # elif (SIZEOF_LONG_LONG_INT == 8)
346d29ba6f4SDarren Tucker #  define INT64_MAX LLONG_MAX
347d29ba6f4SDarren Tucker # else
348d29ba6f4SDarren Tucker #  error "need INT64_MAX"
349d29ba6f4SDarren Tucker # endif
350d29ba6f4SDarren Tucker #endif
351d29ba6f4SDarren Tucker 
352615f939eSDamien Miller #ifndef HAVE_SSIZE_T
353615f939eSDamien Miller typedef int ssize_t;
354134a74f4SDarren Tucker #define SSIZE_MAX INT_MAX
355615f939eSDamien Miller # define HAVE_SSIZE_T
356615f939eSDamien Miller #endif /* HAVE_SSIZE_T */
357615f939eSDamien Miller 
3580d5af601SBen Lindstrom #ifndef HAVE_CLOCK_T
3590d5af601SBen Lindstrom typedef long clock_t;
3600d5af601SBen Lindstrom # define HAVE_CLOCK_T
36169f8fb35SKevin Steves #endif /* HAVE_CLOCK_T */
3620d5af601SBen Lindstrom 
363b54b40efSDamien Miller #ifndef HAVE_SA_FAMILY_T
364b54b40efSDamien Miller typedef int sa_family_t;
365b54b40efSDamien Miller # define HAVE_SA_FAMILY_T
366b54b40efSDamien Miller #endif /* HAVE_SA_FAMILY_T */
367b54b40efSDamien Miller 
3680f91b4e3SDamien Miller #ifndef HAVE_PID_T
3690f91b4e3SDamien Miller typedef int pid_t;
3700f91b4e3SDamien Miller # define HAVE_PID_T
3710f91b4e3SDamien Miller #endif /* HAVE_PID_T */
3720f91b4e3SDamien Miller 
3734cec93faSTim Rice #ifndef HAVE_SIG_ATOMIC_T
3744cec93faSTim Rice typedef int sig_atomic_t;
3754cec93faSTim Rice # define HAVE_SIG_ATOMIC_T
3764cec93faSTim Rice #endif /* HAVE_SIG_ATOMIC_T */
3774cec93faSTim Rice 
3780f91b4e3SDamien Miller #ifndef HAVE_MODE_T
3790f91b4e3SDamien Miller typedef int mode_t;
3800f91b4e3SDamien Miller # define HAVE_MODE_T
3810f91b4e3SDamien Miller #endif /* HAVE_MODE_T */
3820f91b4e3SDamien Miller 
38334132e54SDamien Miller #if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS)
38434132e54SDamien Miller # define ss_family __ss_family
38534132e54SDamien Miller #endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */
38634132e54SDamien Miller 
38778315eb6SDamien Miller #ifndef HAVE_SYS_UN_H
38878315eb6SDamien Miller struct	sockaddr_un {
38978315eb6SDamien Miller 	short	sun_family;		/* AF_UNIX */
39078315eb6SDamien Miller 	char	sun_path[108];		/* path name (gag) */
39178315eb6SDamien Miller };
39278315eb6SDamien Miller #endif /* HAVE_SYS_UN_H */
39378315eb6SDamien Miller 
394d9f88915SDarren Tucker #ifndef HAVE_IN_ADDR_T
395d9f88915SDarren Tucker typedef u_int32_t	in_addr_t;
396d9f88915SDarren Tucker #endif
397ccfee058SDarren Tucker #ifndef HAVE_IN_PORT_T
398ccfee058SDarren Tucker typedef u_int16_t	in_port_t;
399ccfee058SDarren Tucker #endif
400d9f88915SDarren Tucker 
40178315eb6SDamien Miller #if defined(BROKEN_SYS_TERMIO_H) && !defined(_STRUCT_WINSIZE)
40278315eb6SDamien Miller #define _STRUCT_WINSIZE
40378315eb6SDamien Miller struct winsize {
40478315eb6SDamien Miller       unsigned short ws_row;          /* rows, in characters */
40578315eb6SDamien Miller       unsigned short ws_col;          /* columns, in character */
40678315eb6SDamien Miller       unsigned short ws_xpixel;       /* horizontal size, pixels */
40778315eb6SDamien Miller       unsigned short ws_ypixel;       /* vertical size, pixels */
40878315eb6SDamien Miller };
40978315eb6SDamien Miller #endif
41078315eb6SDamien Miller 
411c7aad005SDarren Tucker /* bits needed for select that may not be in the system headers */
412c7aad005SDarren Tucker #ifndef HAVE_FD_MASK
41319d7b8d3SBen Lindstrom  typedef unsigned long int	fd_mask;
41419d7b8d3SBen Lindstrom #endif
41519d7b8d3SBen Lindstrom 
416c7aad005SDarren Tucker #if defined(HAVE_DECL_NFDBITS) && HAVE_DECL_NFDBITS == 0
417c7aad005SDarren Tucker # define	NFDBITS (8 * sizeof(unsigned long))
418c7aad005SDarren Tucker #endif
419c7aad005SDarren Tucker 
420c7aad005SDarren Tucker #if defined(HAVE_DECL_HOWMANY) && HAVE_DECL_HOWMANY == 0
421c7aad005SDarren Tucker # define howmany(x,y)	(((x)+((y)-1))/(y))
422c7aad005SDarren Tucker #endif
423c7aad005SDarren Tucker 
42474d0d4a3SDamien Miller /* Paths */
42574d0d4a3SDamien Miller 
4265a3e6838SDamien Miller #ifndef _PATH_BSHELL
4275a3e6838SDamien Miller # define _PATH_BSHELL "/bin/sh"
4285a3e6838SDamien Miller #endif
4295a3e6838SDamien Miller 
4305a3e6838SDamien Miller #ifdef USER_PATH
4315a3e6838SDamien Miller # ifdef _PATH_STDPATH
4325a3e6838SDamien Miller #  undef _PATH_STDPATH
4335a3e6838SDamien Miller # endif
4345a3e6838SDamien Miller # define _PATH_STDPATH USER_PATH
4355a3e6838SDamien Miller #endif
4365a3e6838SDamien Miller 
4375a3e6838SDamien Miller #ifndef _PATH_STDPATH
4385a3e6838SDamien Miller # define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
4395a3e6838SDamien Miller #endif
4405a3e6838SDamien Miller 
441e1a790d0SDarren Tucker #ifndef SUPERUSER_PATH
442e1a790d0SDarren Tucker # define SUPERUSER_PATH	_PATH_STDPATH
443e1a790d0SDarren Tucker #endif
444e1a790d0SDarren Tucker 
4455a3e6838SDamien Miller #ifndef _PATH_DEVNULL
4465a3e6838SDamien Miller # define _PATH_DEVNULL "/dev/null"
4475a3e6838SDamien Miller #endif
4485a3e6838SDamien Miller 
44990f42b07STim Rice /* user may have set a different path */
45090f42b07STim Rice #if defined(_PATH_MAILDIR) && defined(MAIL_DIRECTORY)
451af665bb7SDarren Tucker # undef _PATH_MAILDIR
45290f42b07STim Rice #endif /* defined(_PATH_MAILDIR) && defined(MAIL_DIRECTORY) */
453615f939eSDamien Miller 
45490f42b07STim Rice #ifdef MAIL_DIRECTORY
45590f42b07STim Rice # define _PATH_MAILDIR MAIL_DIRECTORY
4565a3e6838SDamien Miller #endif
4575a3e6838SDamien Miller 
458ad833b3eSDamien Miller #ifndef _PATH_NOLOGIN
459ad833b3eSDamien Miller # define _PATH_NOLOGIN "/etc/nologin"
460ad833b3eSDamien Miller #endif
461ad833b3eSDamien Miller 
46272c9a7e9SDamien Miller /* Define this to be the path of the xauth program. */
46337a777e9SKevin Steves #ifdef XAUTH_PATH
46437a777e9SKevin Steves #define _PATH_XAUTH XAUTH_PATH
46572c9a7e9SDamien Miller #endif /* XAUTH_PATH */
46672c9a7e9SDamien Miller 
467f49a1191SKevin Steves /* derived from XF4/xc/lib/dps/Xlibnet.h */
468f49a1191SKevin Steves #ifndef X_UNIX_PATH
469f49a1191SKevin Steves #  ifdef __hpux
4702f8f6e3bSKevin Steves #    define X_UNIX_PATH "/var/spool/sockets/X11/%u"
471f49a1191SKevin Steves #  else
472f49a1191SKevin Steves #    define X_UNIX_PATH "/tmp/.X11-unix/X%u"
473f49a1191SKevin Steves #  endif
474f49a1191SKevin Steves #endif /* X_UNIX_PATH */
475f49a1191SKevin Steves #define _PATH_UNIX_X X_UNIX_PATH
476f49a1191SKevin Steves 
4774192c467SDamien Miller #ifndef _PATH_TTY
4784192c467SDamien Miller # define _PATH_TTY "/dev/tty"
4794192c467SDamien Miller #endif
4804192c467SDamien Miller 
48174d0d4a3SDamien Miller /* Macros */
48274d0d4a3SDamien Miller 
483ad833b3eSDamien Miller #if defined(HAVE_LOGIN_GETCAPBOOL) && defined(HAVE_LOGIN_CAP_H)
484ad833b3eSDamien Miller # define HAVE_LOGIN_CAP
485ad833b3eSDamien Miller #endif
486ad833b3eSDamien Miller 
4875a3e6838SDamien Miller #ifndef MAX
4885a3e6838SDamien Miller # define MAX(a,b) (((a)>(b))?(a):(b))
4895a3e6838SDamien Miller # define MIN(a,b) (((a)<(b))?(a):(b))
4905a3e6838SDamien Miller #endif
4915a3e6838SDamien Miller 
49279438cc0SDamien Miller #ifndef roundup
49379438cc0SDamien Miller # define roundup(x, y)   ((((x)+((y)-1))/(y))*(y))
49479438cc0SDamien Miller #endif
49579438cc0SDamien Miller 
4965a3e6838SDamien Miller #ifndef timersub
4975a3e6838SDamien Miller #define timersub(a, b, result)					\
4985a3e6838SDamien Miller    do {								\
4995a3e6838SDamien Miller       (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;		\
5005a3e6838SDamien Miller       (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;		\
5015a3e6838SDamien Miller       if ((result)->tv_usec < 0) {				\
5025a3e6838SDamien Miller 	 --(result)->tv_sec;					\
5035a3e6838SDamien Miller 	 (result)->tv_usec += 1000000;				\
5045a3e6838SDamien Miller       }								\
5055a3e6838SDamien Miller    } while (0)
5065a3e6838SDamien Miller #endif
5075a3e6838SDamien Miller 
5083bc0c062SDamien Miller #ifndef TIMEVAL_TO_TIMESPEC
5093bc0c062SDamien Miller #define	TIMEVAL_TO_TIMESPEC(tv, ts) {					\
5103bc0c062SDamien Miller 	(ts)->tv_sec = (tv)->tv_sec;					\
5113bc0c062SDamien Miller 	(ts)->tv_nsec = (tv)->tv_usec * 1000;				\
5123bc0c062SDamien Miller }
5133bc0c062SDamien Miller #endif
5143bc0c062SDamien Miller 
5153bc0c062SDamien Miller #ifndef TIMESPEC_TO_TIMEVAL
5163bc0c062SDamien Miller #define	TIMESPEC_TO_TIMEVAL(tv, ts) {					\
5173bc0c062SDamien Miller 	(tv)->tv_sec = (ts)->tv_sec;					\
5183bc0c062SDamien Miller 	(tv)->tv_usec = (ts)->tv_nsec / 1000;				\
5193bc0c062SDamien Miller }
5203bc0c062SDamien Miller #endif
5213bc0c062SDamien Miller 
522bcd14850SDamien Miller #ifndef timespeccmp
523bcd14850SDamien Miller #define timespeccmp(tsp, usp, cmp)					\
524bcd14850SDamien Miller 	(((tsp)->tv_sec == (usp)->tv_sec) ?				\
525bcd14850SDamien Miller 	    ((tsp)->tv_nsec cmp (usp)->tv_nsec) :			\
526bcd14850SDamien Miller 	    ((tsp)->tv_sec cmp (usp)->tv_sec))
527bcd14850SDamien Miller #endif
528bcd14850SDamien Miller 
5295a3e6838SDamien Miller #ifndef __P
5305a3e6838SDamien Miller # define __P(x) x
5315a3e6838SDamien Miller #endif
5325a3e6838SDamien Miller 
5331c67c996SDamien Miller #if !defined(IN6_IS_ADDR_V4MAPPED)
5341c67c996SDamien Miller # define IN6_IS_ADDR_V4MAPPED(a) \
535db819595SDamien Miller 	((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \
536db819595SDamien Miller 	 (((u_int32_t *) (a))[2] == htonl (0xffff)))
5371c67c996SDamien Miller #endif /* !defined(IN6_IS_ADDR_V4MAPPED) */
5381c67c996SDamien Miller 
5395a3e6838SDamien Miller #if !defined(__GNUC__) || (__GNUC__ < 2)
5405a3e6838SDamien Miller # define __attribute__(x)
5415a3e6838SDamien Miller #endif /* !defined(__GNUC__) || (__GNUC__ < 2) */
5425a3e6838SDamien Miller 
5434a42257bSDarren Tucker #if !defined(HAVE_ATTRIBUTE__SENTINEL__) && !defined(__sentinel__)
5444a42257bSDarren Tucker # define __sentinel__
5454a42257bSDarren Tucker #endif
5464a42257bSDarren Tucker 
5479ac1a65aSDarren Tucker #if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__bounded__)
5489ac1a65aSDarren Tucker # define __bounded__(x, y, z)
5499ac1a65aSDarren Tucker #endif
5509ac1a65aSDarren Tucker 
551391de5c0SDarren Tucker #if !defined(HAVE_ATTRIBUTE__NONNULL__) && !defined(__nonnull__)
552391de5c0SDarren Tucker # define __nonnull__(x)
553391de5c0SDarren Tucker #endif
554391de5c0SDarren Tucker 
555d77facdaSDamien Miller #ifndef OSSH_ALIGNBYTES
556d77facdaSDamien Miller #define OSSH_ALIGNBYTES	(sizeof(int) - 1)
557219bef12SKevin Steves #endif
558219bef12SKevin Steves #ifndef __CMSG_ALIGN
559d77facdaSDamien Miller #define	__CMSG_ALIGN(p) (((u_int)(p) + OSSH_ALIGNBYTES) &~ OSSH_ALIGNBYTES)
560219bef12SKevin Steves #endif
561219bef12SKevin Steves 
562219bef12SKevin Steves /* Length of the contents of a control message of length len */
563219bef12SKevin Steves #ifndef CMSG_LEN
564219bef12SKevin Steves #define	CMSG_LEN(len)	(__CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
565219bef12SKevin Steves #endif
566219bef12SKevin Steves 
567219bef12SKevin Steves /* Length of the space taken up by a padded control message of length len */
568219bef12SKevin Steves #ifndef CMSG_SPACE
569219bef12SKevin Steves #define	CMSG_SPACE(len)	(__CMSG_ALIGN(sizeof(struct cmsghdr)) + __CMSG_ALIGN(len))
570219bef12SKevin Steves #endif
571219bef12SKevin Steves 
5728e3653d2SDarren Tucker /* given pointer to struct cmsghdr, return pointer to data */
5738e3653d2SDarren Tucker #ifndef CMSG_DATA
5748e3653d2SDarren Tucker #define CMSG_DATA(cmsg) ((u_char *)(cmsg) + __CMSG_ALIGN(sizeof(struct cmsghdr)))
5758e3653d2SDarren Tucker #endif /* CMSG_DATA */
5768e3653d2SDarren Tucker 
5778e3653d2SDarren Tucker /*
5788e3653d2SDarren Tucker  * RFC 2292 requires to check msg_controllen, in case that the kernel returns
5798e3653d2SDarren Tucker  * an empty list for some reasons.
5808e3653d2SDarren Tucker  */
5818e3653d2SDarren Tucker #ifndef CMSG_FIRSTHDR
5828e3653d2SDarren Tucker #define CMSG_FIRSTHDR(mhdr) \
5838e3653d2SDarren Tucker 	((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
5848e3653d2SDarren Tucker 	 (struct cmsghdr *)(mhdr)->msg_control : \
5858e3653d2SDarren Tucker 	 (struct cmsghdr *)NULL)
5868e3653d2SDarren Tucker #endif /* CMSG_FIRSTHDR */
5878e3653d2SDarren Tucker 
588dca0edffSDarren Tucker #if defined(HAVE_DECL_OFFSETOF) && HAVE_DECL_OFFSETOF == 0
5890e220dbfSDamien Miller # define offsetof(type, member) ((size_t) &((type *)0)->member)
5900e220dbfSDamien Miller #endif
5918e3653d2SDarren Tucker 
592af87af16SDamien Miller /* Set up BSD-style BYTE_ORDER definition if it isn't there already */
593af87af16SDamien Miller /* XXX: doesn't try to cope with strange byte orders (PDP_ENDIAN) */
594af87af16SDamien Miller #ifndef BYTE_ORDER
595af87af16SDamien Miller # ifndef LITTLE_ENDIAN
596af87af16SDamien Miller #  define LITTLE_ENDIAN  1234
597af87af16SDamien Miller # endif /* LITTLE_ENDIAN */
598af87af16SDamien Miller # ifndef BIG_ENDIAN
599af87af16SDamien Miller #  define BIG_ENDIAN     4321
600af87af16SDamien Miller # endif /* BIG_ENDIAN */
601af87af16SDamien Miller # ifdef WORDS_BIGENDIAN
602af87af16SDamien Miller #  define BYTE_ORDER BIG_ENDIAN
603af87af16SDamien Miller # else /* WORDS_BIGENDIAN */
604af87af16SDamien Miller #  define BYTE_ORDER LITTLE_ENDIAN
605af87af16SDamien Miller # endif /* WORDS_BIGENDIAN */
606af87af16SDamien Miller #endif /* BYTE_ORDER */
607af87af16SDamien Miller 
60874d0d4a3SDamien Miller /* Function replacement / compatibility hacks */
60974d0d4a3SDamien Miller 
610594a71b9SDamien Miller #if !defined(HAVE_GETADDRINFO) && (defined(HAVE_OGETADDRINFO) || defined(HAVE_NGETADDRINFO))
611594a71b9SDamien Miller # define HAVE_GETADDRINFO
612594a71b9SDamien Miller #endif
613594a71b9SDamien Miller 
614813f0452STim Rice #ifndef HAVE_GETOPT_OPTRESET
615ee9ac35fSBen Lindstrom # undef getopt
616ee9ac35fSBen Lindstrom # undef opterr
617ee9ac35fSBen Lindstrom # undef optind
618ee9ac35fSBen Lindstrom # undef optopt
619ee9ac35fSBen Lindstrom # undef optreset
620ee9ac35fSBen Lindstrom # undef optarg
621813f0452STim Rice # define getopt(ac, av, o)  BSDgetopt(ac, av, o)
622ee9ac35fSBen Lindstrom # define opterr             BSDopterr
623ee9ac35fSBen Lindstrom # define optind             BSDoptind
624ee9ac35fSBen Lindstrom # define optopt             BSDoptopt
625ee9ac35fSBen Lindstrom # define optreset           BSDoptreset
626ee9ac35fSBen Lindstrom # define optarg             BSDoptarg
627813f0452STim Rice #endif
628813f0452STim Rice 
629eca71f84SDamien Miller #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO)
630eca71f84SDamien Miller # undef HAVE_GETADDRINFO
631d54e55cfSDamien Miller #endif
632d54e55cfSDamien Miller #if defined(BROKEN_GETADDRINFO) && defined(HAVE_FREEADDRINFO)
633d54e55cfSDamien Miller # undef HAVE_FREEADDRINFO
634d54e55cfSDamien Miller #endif
635d54e55cfSDamien Miller #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GAI_STRERROR)
636d54e55cfSDamien Miller # undef HAVE_GAI_STRERROR
637d54e55cfSDamien Miller #endif
638eca71f84SDamien Miller 
63928ba006cSDarren Tucker #if defined(HAVE_GETADDRINFO)
64028ba006cSDarren Tucker # if defined(HAVE_DECL_AI_NUMERICSERV) && HAVE_DECL_AI_NUMERICSERV == 0
641e50e8c97SDarren Tucker #   define AI_NUMERICSERV	0
642e50e8c97SDarren Tucker # endif
64328ba006cSDarren Tucker #endif
644e50e8c97SDarren Tucker 
6458db9a0ffSDarren Tucker #if defined(BROKEN_UPDWTMPX) && defined(HAVE_UPDWTMPX)
6468db9a0ffSDarren Tucker # undef HAVE_UPDWTMPX
6478db9a0ffSDarren Tucker #endif
6488db9a0ffSDarren Tucker 
649bc1bd9dbSDarren Tucker #if defined(BROKEN_SHADOW_EXPIRE) && defined(HAS_SHADOW_EXPIRE)
650bc1bd9dbSDarren Tucker # undef HAS_SHADOW_EXPIRE
651bc1bd9dbSDarren Tucker #endif
652bc1bd9dbSDarren Tucker 
653bb59814cSDamien Miller #if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT) && \
654bb59814cSDamien Miller     defined(SYSLOG_R_SAFE_IN_SIGHAND)
655bb59814cSDamien Miller # define DO_LOG_SAFE_IN_SIGHAND
656bb59814cSDamien Miller #endif
657bb59814cSDamien Miller 
658615f939eSDamien Miller #if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY)
659615f939eSDamien Miller # define memmove(s1, s2, n) bcopy((s2), (s1), (n))
660615f939eSDamien Miller #endif /* !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) */
661615f939eSDamien Miller 
662606f880eSDamien Miller #ifndef GETPGRP_VOID
6630dc5484cSDarren Tucker # include <unistd.h>
664606f880eSDamien Miller # define getpgrp() getpgrp(0)
665606f880eSDamien Miller #endif
666606f880eSDamien Miller 
667d9f88915SDarren Tucker #ifdef USE_BSM_AUDIT
668d9f88915SDarren Tucker # define SSH_AUDIT_EVENTS
669d9f88915SDarren Tucker # define CUSTOM_SSH_AUDIT_EVENTS
670d9f88915SDarren Tucker #endif
671d9f88915SDarren Tucker 
672ea52a829SDarren Tucker #ifdef USE_LINUX_AUDIT
673ea52a829SDarren Tucker # define SSH_AUDIT_EVENTS
674ea52a829SDarren Tucker # define CUSTOM_SSH_AUDIT_EVENTS
675ea52a829SDarren Tucker #endif
676ea52a829SDarren Tucker 
67703bab286SBen Lindstrom #if !defined(HAVE___func__) && defined(HAVE___FUNCTION__)
67803bab286SBen Lindstrom #  define __func__ __FUNCTION__
67903bab286SBen Lindstrom #elif !defined(HAVE___func__)
68003bab286SBen Lindstrom #  define __func__ ""
6814846f4abSKevin Steves #endif
6824846f4abSKevin Steves 
68349aaf4adSDarren Tucker #if defined(KRB5) && !defined(HEIMDAL)
68449aaf4adSDarren Tucker #  define krb5_get_err_text(context,code) error_message(code)
68549aaf4adSDarren Tucker #endif
68649aaf4adSDarren Tucker 
687e00074a7SDamien Miller /* Maximum number of file descriptors available */
688e00074a7SDamien Miller #ifdef HAVE_SYSCONF
689e00074a7SDamien Miller # define SSH_SYSFDMAX sysconf(_SC_OPEN_MAX)
690e00074a7SDamien Miller #else
691e00074a7SDamien Miller # define SSH_SYSFDMAX 10000
692e00074a7SDamien Miller #endif
693e00074a7SDamien Miller 
69477001384SDarren Tucker #ifdef FSID_HAS_VAL
69577001384SDarren Tucker /* encode f_fsid into a 64 bit value  */
69677001384SDarren Tucker #define FSID_TO_ULONG(f) \
69777001384SDarren Tucker 	((((u_int64_t)(f).val[0] & 0xffffffffUL) << 32) | \
69877001384SDarren Tucker 	    ((f).val[1] & 0xffffffffUL))
6993278062bSDarren Tucker #elif defined(FSID_HAS___VAL)
7003278062bSDarren Tucker #define FSID_TO_ULONG(f) \
7013278062bSDarren Tucker 	((((u_int64_t)(f).__val[0] & 0xffffffffUL) << 32) | \
7023278062bSDarren Tucker 	    ((f).__val[1] & 0xffffffffUL))
70377001384SDarren Tucker #else
70477001384SDarren Tucker # define FSID_TO_ULONG(f) ((f))
70577001384SDarren Tucker #endif
70677001384SDarren Tucker 
70793e7e8f3SDarren Tucker #if defined(__Lynx__)
70893e7e8f3SDarren Tucker  /*
70993e7e8f3SDarren Tucker   * LynxOS defines these in param.h which we do not want to include since
71093e7e8f3SDarren Tucker   * it will also pull in a bunch of kernel definitions.
71193e7e8f3SDarren Tucker   */
71293e7e8f3SDarren Tucker # define ALIGNBYTES (sizeof(int) - 1)
71393e7e8f3SDarren Tucker # define ALIGN(p) (((unsigned)p + ALIGNBYTES) & ~ALIGNBYTES)
71493e7e8f3SDarren Tucker   /* Missing prototypes on LynxOS */
71593e7e8f3SDarren Tucker   int snprintf (char *, size_t, const char *, ...);
71693e7e8f3SDarren Tucker   int mkstemp (char *);
71793e7e8f3SDarren Tucker   char *crypt (const char *, const char *);
71893e7e8f3SDarren Tucker   int seteuid (uid_t);
71993e7e8f3SDarren Tucker   int setegid (gid_t);
72093e7e8f3SDarren Tucker   char *mkdtemp (char *);
72193e7e8f3SDarren Tucker   int rresvport_af (int *, sa_family_t);
72293e7e8f3SDarren Tucker   int innetgr (const char *, const char *, const char *, const char *);
72393e7e8f3SDarren Tucker #endif
724e00074a7SDamien Miller 
72572c9a7e9SDamien Miller /*
72672c9a7e9SDamien Miller  * Define this to use pipes instead of socketpairs for communicating with the
72772c9a7e9SDamien Miller  * client program.  Socketpairs do not seem to work on all systems.
72872c9a7e9SDamien Miller  *
729b89e694bSTim Rice  * configure.ac sets this for a few OS's which are known to have problems
73072c9a7e9SDamien Miller  * but you may need to set it yourself
73172c9a7e9SDamien Miller  */
73272c9a7e9SDamien Miller /* #define USE_PIPES 1 */
73372c9a7e9SDamien Miller 
7342ff7b5d0Sandre /**
7352ff7b5d0Sandre  ** login recorder definitions
7362ff7b5d0Sandre  **/
7372ff7b5d0Sandre 
7382ff7b5d0Sandre /* FIXME: put default paths back in */
73936ccb5c4SDamien Miller #ifndef UTMP_FILE
74036ccb5c4SDamien Miller #  ifdef _PATH_UTMP
7412ff7b5d0Sandre #    define UTMP_FILE _PATH_UTMP
74236ccb5c4SDamien Miller #  else
74336ccb5c4SDamien Miller #    ifdef CONF_UTMP_FILE
74436ccb5c4SDamien Miller #      define UTMP_FILE CONF_UTMP_FILE
7452ff7b5d0Sandre #    endif
74636ccb5c4SDamien Miller #  endif
74736ccb5c4SDamien Miller #endif
74836ccb5c4SDamien Miller #ifndef WTMP_FILE
74936ccb5c4SDamien Miller #  ifdef _PATH_WTMP
7502ff7b5d0Sandre #    define WTMP_FILE _PATH_WTMP
75136ccb5c4SDamien Miller #  else
75236ccb5c4SDamien Miller #    ifdef CONF_WTMP_FILE
75336ccb5c4SDamien Miller #      define WTMP_FILE CONF_WTMP_FILE
75436ccb5c4SDamien Miller #    endif
75536ccb5c4SDamien Miller #  endif
7562ff7b5d0Sandre #endif
7572ff7b5d0Sandre /* pick up the user's location for lastlog if given */
75836ccb5c4SDamien Miller #ifndef LASTLOG_FILE
75936ccb5c4SDamien Miller #  ifdef _PATH_LASTLOG
7602ff7b5d0Sandre #    define LASTLOG_FILE _PATH_LASTLOG
76136ccb5c4SDamien Miller #  else
76236ccb5c4SDamien Miller #    ifdef CONF_LASTLOG_FILE
7632994e089SDamien Miller #      define LASTLOG_FILE CONF_LASTLOG_FILE
7642994e089SDamien Miller #    endif
76536ccb5c4SDamien Miller #  endif
76636ccb5c4SDamien Miller #endif
7672ff7b5d0Sandre 
7689df3defdSDarren Tucker #if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW)
7699df3defdSDarren Tucker # define USE_SHADOW
7709df3defdSDarren Tucker #endif
7712ff7b5d0Sandre 
7722ff7b5d0Sandre /* The login() library function in libutil is first choice */
7732ff7b5d0Sandre #if defined(HAVE_LOGIN) && !defined(DISABLE_LOGIN)
7742ff7b5d0Sandre #  define USE_LOGIN
7752ff7b5d0Sandre 
7762ff7b5d0Sandre #else
7772ff7b5d0Sandre /* Simply select your favourite login types. */
7782ff7b5d0Sandre /* Can't do if-else because some systems use several... <sigh> */
779261d93a5SDarren Tucker #  if !defined(DISABLE_UTMPX)
7802ff7b5d0Sandre #    define USE_UTMPX
7812ff7b5d0Sandre #  endif
7822ff7b5d0Sandre #  if defined(UTMP_FILE) && !defined(DISABLE_UTMP)
7832ff7b5d0Sandre #    define USE_UTMP
7842ff7b5d0Sandre #  endif
7852ff7b5d0Sandre #  if defined(WTMPX_FILE) && !defined(DISABLE_WTMPX)
7862ff7b5d0Sandre #    define USE_WTMPX
7872ff7b5d0Sandre #  endif
7882ff7b5d0Sandre #  if defined(WTMP_FILE) && !defined(DISABLE_WTMP)
7892ff7b5d0Sandre #    define USE_WTMP
7902ff7b5d0Sandre #  endif
7912ff7b5d0Sandre 
7922ff7b5d0Sandre #endif
7932ff7b5d0Sandre 
79411f18294SDarren Tucker #ifndef UT_LINESIZE
79511f18294SDarren Tucker # define UT_LINESIZE 8
79611f18294SDarren Tucker #endif
79711f18294SDarren Tucker 
7982ff7b5d0Sandre /* I hope that the presence of LASTLOG_FILE is enough to detect this */
7992ff7b5d0Sandre #if defined(LASTLOG_FILE) && !defined(DISABLE_LASTLOG)
8002ff7b5d0Sandre #  define USE_LASTLOG
8012ff7b5d0Sandre #endif
8022ff7b5d0Sandre 
80391bf45c5SDarren Tucker #ifdef HAVE_OSF_SIA
80491bf45c5SDarren Tucker # ifdef USE_SHADOW
80591bf45c5SDarren Tucker #  undef USE_SHADOW
80691bf45c5SDarren Tucker # endif
80791bf45c5SDarren Tucker # define CUSTOM_SYS_AUTH_PASSWD 1
80891bf45c5SDarren Tucker #endif
80991bf45c5SDarren Tucker 
810351529ceSTim Rice #if defined(HAVE_LIBIAF) && defined(HAVE_SET_ID) && !defined(HAVE_SECUREWARE)
8116ebefac2STim Rice # define CUSTOM_SYS_AUTH_PASSWD 1
8126ebefac2STim Rice #endif
81399203ec4STim Rice #if defined(HAVE_LIBIAF) && defined(HAVE_SET_ID) && !defined(BROKEN_LIBIAF)
81499203ec4STim Rice # define USE_LIBIAF
8152291c00aSTim Rice #endif
8162291c00aSTim Rice 
8172fba9930SDarren Tucker /* HP-UX 11.11 */
8182fba9930SDarren Tucker #ifdef BTMP_FILE
8192fba9930SDarren Tucker # define _PATH_BTMP BTMP_FILE
8202fba9930SDarren Tucker #endif
8212fba9930SDarren Tucker 
8222fba9930SDarren Tucker #if defined(USE_BTMP) && defined(_PATH_BTMP)
8232fba9930SDarren Tucker # define CUSTOM_FAILED_LOGIN
8242fba9930SDarren Tucker #endif
8252fba9930SDarren Tucker 
8262ff7b5d0Sandre /** end of login recorder definitions */
8272ff7b5d0Sandre 
8282be1cbb7SDarren Tucker #ifdef BROKEN_GETGROUPS
8292be1cbb7SDarren Tucker # define getgroups(a,b) ((a)==0 && (b)==NULL ? NGROUPS_MAX : getgroups((a),(b)))
8302be1cbb7SDarren Tucker #endif
8312be1cbb7SDarren Tucker 
832cefd8bb3SDarren Tucker #ifndef IOV_MAX
833cefd8bb3SDarren Tucker # if defined(_XOPEN_IOV_MAX)
834cefd8bb3SDarren Tucker #  define	IOV_MAX		_XOPEN_IOV_MAX
835cefd8bb3SDarren Tucker # elif defined(DEF_IOV_MAX)
836cefd8bb3SDarren Tucker #  define	IOV_MAX		DEF_IOV_MAX
837cefd8bb3SDarren Tucker # else
838cefd8bb3SDarren Tucker #  define	IOV_MAX		16
839cefd8bb3SDarren Tucker # endif
840cefd8bb3SDarren Tucker #endif
841cefd8bb3SDarren Tucker 
842d8968adbSDamien Miller #ifndef EWOULDBLOCK
843d8968adbSDamien Miller # define EWOULDBLOCK EAGAIN
844d8968adbSDamien Miller #endif
845d8968adbSDamien Miller 
846642ebe5bSDarren Tucker #ifndef INET6_ADDRSTRLEN	/* for non IPv6 machines */
847642ebe5bSDarren Tucker #define INET6_ADDRSTRLEN 46
848642ebe5bSDarren Tucker #endif
849642ebe5bSDarren Tucker 
85086e30a01SDarren Tucker #ifndef SSH_IOBUFSZ
85186e30a01SDarren Tucker # define SSH_IOBUFSZ 8192
85286e30a01SDarren Tucker #endif
85386e30a01SDarren Tucker 
854df8b030bSDamien Miller /*
855032147b6SDarren Tucker  * We want functions in openbsd-compat, if enabled, to override system ones.
856032147b6SDarren Tucker  * We no-op out the weak symbol definition rather than remove it to reduce
8570c7f8d23SDarren Tucker  * future sync problems.  Some compilers (eg Unixware) do not allow an
8580c7f8d23SDarren Tucker  * empty statement, so we use a bogus function declaration.
859032147b6SDarren Tucker  */
8600c7f8d23SDarren Tucker #define DEF_WEAK(x)	void __ssh_compat_weak_##x(void)
861032147b6SDarren Tucker 
862032147b6SDarren Tucker /*
863df8b030bSDamien Miller  * Platforms that have arc4random_uniform() and not arc4random_stir()
864df8b030bSDamien Miller  * shouldn't need the latter.
865df8b030bSDamien Miller  */
866df8b030bSDamien Miller #if defined(HAVE_ARC4RANDOM) && defined(HAVE_ARC4RANDOM_UNIFORM) && \
867df8b030bSDamien Miller     !defined(HAVE_ARC4RANDOM_STIR)
868df8b030bSDamien Miller # define arc4random_stir()
869df8b030bSDamien Miller #endif
870df8b030bSDamien Miller 
871cf5392c2SDarren Tucker #ifndef HAVE_VA_COPY
872cf5392c2SDarren Tucker # ifdef HAVE___VA_COPY
873cf5392c2SDarren Tucker #  define va_copy(dest, src) __va_copy(dest, src)
874cf5392c2SDarren Tucker # else
875cf5392c2SDarren Tucker #  define va_copy(dest, src) (dest) = (src)
876cf5392c2SDarren Tucker # endif
877cf5392c2SDarren Tucker #endif
878cf5392c2SDarren Tucker 
87923f26956SDamien Miller #ifndef __predict_true
88023f26956SDamien Miller # if defined(__GNUC__) && \
88123f26956SDamien Miller      ((__GNUC__ > (2)) || (__GNUC__ == (2) && __GNUC_MINOR__ >= (96)))
88223f26956SDamien Miller #  define __predict_true(exp)     __builtin_expect(((exp) != 0), 1)
88323f26956SDamien Miller #  define __predict_false(exp)    __builtin_expect(((exp) != 0), 0)
88423f26956SDamien Miller # else
88523f26956SDamien Miller #  define __predict_true(exp)     ((exp) != 0)
88623f26956SDamien Miller #  define __predict_false(exp)    ((exp) != 0)
88723f26956SDamien Miller # endif /* gcc version */
88823f26956SDamien Miller #endif /* __predict_true */
88923f26956SDamien Miller 
8908db134e7SDarren Tucker #if defined(HAVE_GLOB_H) && defined(GLOB_HAS_ALTDIRFUNC) && \
8918db134e7SDarren Tucker     defined(GLOB_HAS_GL_MATCHC) && defined(GLOB_HAS_GL_STATV) && \
8928db134e7SDarren Tucker     defined(HAVE_DECL_GLOB_NOMATCH) &&  HAVE_DECL_GLOB_NOMATCH != 0 && \
8938db134e7SDarren Tucker     !defined(BROKEN_GLOB)
8948db134e7SDarren Tucker # define USE_SYSTEM_GLOB
8958db134e7SDarren Tucker #endif
8968db134e7SDarren Tucker 
897*48d0d7a4SDarren Tucker /*
898*48d0d7a4SDarren Tucker  * sntrup761 uses variable length arrays, only enable if the compiler
899*48d0d7a4SDarren Tucker  * supports them.
900*48d0d7a4SDarren Tucker  */
901*48d0d7a4SDarren Tucker #ifdef VARIABLE_LENGTH_ARRAYS
902*48d0d7a4SDarren Tucker # define USE_SNTRUP761X25519 1
903