Mention smart-make in a comment.
[rsync.git] / popt / system.h
blob25c22daeef3b1d889de3cb711ee4698755207234
1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
5 #if defined (__GLIBC__) && defined(__LCLINT__)
6 /*@-declundef@*/
7 /*@unchecked@*/
8 extern __const __int32_t *__ctype_tolower;
9 /*@unchecked@*/
10 extern __const __int32_t *__ctype_toupper;
11 /*@=declundef@*/
12 #endif
14 #ifdef __TANDEM
15 # include <floss.h(floss_execvp,floss_read)>
16 #endif
18 #include <ctype.h>
20 #include <errno.h>
21 #include <fcntl.h>
22 #include <limits.h>
24 #if HAVE_MCHECK_H
25 #include <mcheck.h>
26 #endif
28 #include <stdio.h>
29 #ifdef HAVE_SYS_TYPES_H
30 # include <sys/types.h>
31 #endif
32 #ifdef STDC_HEADERS
33 # include <stdlib.h>
34 # include <stddef.h>
35 #else
36 # ifdef HAVE_STDLIB_H
37 # include <stdlib.h>
38 # endif
39 #endif
40 #ifdef HAVE_STRING_H
41 # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
42 # include <memory.h>
43 # endif
44 # include <string.h>
45 #endif
46 #ifdef HAVE_STRINGS_H
47 # include <strings.h>
48 #endif
49 #ifdef HAVE_UNISTD_H
50 # include <unistd.h>
51 #endif
53 #ifndef __GNUC__
54 #define __attribute__(x)
55 #endif
57 #ifdef __NeXT
58 /* access macros are not declared in non posix mode in unistd.h -
59 don't try to use posix on NeXTstep 3.3 ! */
60 #include <libc.h>
61 #endif
63 #if defined(__LCLINT__)
64 /*@-declundef -incondefs @*/ /* LCL: missing annotation */
65 /*@only@*/ /*@out@*/
66 void * alloca (size_t __size)
67 /*@ensures MaxSet(result) == (__size - 1) @*/
68 /*@*/;
69 /*@=declundef =incondefs @*/
70 #endif
72 /* AIX requires this to be the first thing in the file. */
73 #ifndef __GNUC__
74 # if HAVE_ALLOCA_H
75 # include <alloca.h>
76 # else
77 # ifdef _AIX
78 #pragma alloca
79 # else
80 # ifdef HAVE_ALLOCA
81 # ifndef alloca /* predefined by HP cc +Olibcalls */
82 char *alloca(size_t size);
83 # endif
84 # else
85 # ifdef alloca
86 # undef alloca
87 # endif
88 # define alloca(sz) malloc(sz) /* Kludge this for now */
89 # endif
90 # endif
91 # endif
92 #elif !defined(alloca)
93 #define alloca __builtin_alloca
94 #endif
96 #ifndef HAVE_STRLCPY
97 size_t strlcpy(char *d, const char *s, size_t bufsize);
98 #endif
100 #ifndef HAVE_STRLCAT
101 size_t strlcat(char *d, const char *s, size_t bufsize);
102 #endif
104 #if HAVE_MCHECK_H && defined(__GNUC__)
105 static inline char *
106 xstrdup(const char *s)
108 size_t memsize = strlen(s) + 1;
109 char *ptr = malloc(memsize);
110 if (!ptr) {
111 fprintf(stderr, "virtual memory exhausted.\n");
112 exit(EXIT_FAILURE);
114 strlcpy(ptr, s, memsize);
115 return ptr;
117 #else
118 #define xstrdup(_str) strdup(_str)
119 #endif /* HAVE_MCHECK_H && defined(__GNUC__) */
121 #if HAVE___SECURE_GETENV && !defined(__LCLINT__)
122 #define getenv(_s) __secure_getenv(_s)
123 #endif
125 #if !defined HAVE_SNPRINTF || !defined HAVE_C99_VSNPRINTF
126 #define snprintf rsync_snprintf
127 int snprintf(char *str,size_t count,const char *fmt,...);
128 #endif
130 #define UNUSED(x) x __attribute__((__unused__))
132 #define PACKAGE "rsync"
134 #include "popt.h"