Try a full prototype for alloca() for those systems that need it.
[rsync/rsync.git] / popt / system.h
1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4
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
13
14 #include <ctype.h>
15
16 #include <errno.h>
17 #include <fcntl.h>
18 #include <limits.h>
19
20 #if HAVE_MCHECK_H 
21 #include <mcheck.h>
22 #endif
23
24 #include <stdio.h>
25 #ifdef HAVE_SYS_TYPES_H
26 # include <sys/types.h>
27 #endif
28 #ifdef STDC_HEADERS
29 # include <stdlib.h>
30 # include <stddef.h>
31 #else
32 # ifdef HAVE_STDLIB_H
33 #  include <stdlib.h>
34 # endif
35 #endif
36 #ifdef HAVE_STRING_H
37 # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
38 #  include <memory.h>
39 # endif
40 # include <string.h>
41 #endif
42 #ifdef HAVE_STRINGS_H
43 # include <strings.h>
44 #endif
45 #ifdef HAVE_UNISTD_H
46 # include <unistd.h>
47 #endif
48
49 #ifndef __GNUC__
50 #define __attribute__(x) 
51 #endif
52
53 #ifdef __NeXT
54 /* access macros are not declared in non posix mode in unistd.h -
55  don't try to use posix on NeXTstep 3.3 ! */
56 #include <libc.h>
57 #endif
58
59 #if defined(__LCLINT__)
60 /*@-declundef -incondefs @*/ /* LCL: missing annotation */
61 /*@only@*/ /*@out@*/
62 void * alloca (size_t __size)
63         /*@ensures MaxSet(result) == (__size - 1) @*/
64         /*@*/;
65 /*@=declundef =incondefs @*/
66 #endif
67
68 /* AIX requires this to be the first thing in the file.  */ 
69 #ifndef __GNUC__
70 # if HAVE_ALLOCA_H
71 #  include <alloca.h>
72 # else
73 #  ifdef _AIX
74 #pragma alloca
75 #  else
76 #   ifdef HAVE_ALLOCA
77 #    ifndef alloca /* predefined by HP cc +Olibcalls */
78 char *alloca(size_t size);
79 #    endif
80 #   else
81 #    ifdef alloca
82 #     undef alloca
83 #    endif
84 #    define alloca(sz) malloc(sz) /* Kludge this for now */
85 #   endif
86 #  endif
87 # endif
88 #elif defined(__GNUC__) && defined(__STRICT_ANSI__)
89 #define alloca __builtin_alloca
90 #endif
91
92 /*@-redecl -redef@*/
93 /*@mayexit@*/ /*@only@*/ /*@unused@*/
94 char * xstrdup (const char *str)
95         /*@*/;
96 /*@=redecl =redef@*/
97
98 #if HAVE_MCHECK_H && defined(__GNUC__)
99 #define vmefail()       (fprintf(stderr, "virtual memory exhausted.\n"), exit(EXIT_FAILURE), NULL)
100 #define xstrdup(_str)   (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str)))
101 #else
102 #define xstrdup(_str)   strdup(_str)
103 #endif  /* HAVE_MCHECK_H && defined(__GNUC__) */
104
105 #if HAVE___SECURE_GETENV && !defined(__LCLINT__)
106 #define getenv(_s)      __secure_getenv(_s)
107 #endif
108
109 #ifndef HAVE_STRLCPY
110 size_t strlcpy(char *d, const char *s, size_t bufsize);
111 #endif
112
113 #ifndef HAVE_STRLCAT
114 size_t strlcat(char *d, const char *s, size_t bufsize);
115 #endif
116
117 #if !defined HAVE_SNPRINTF || !defined HAVE_C99_VSNPRINTF
118 #define snprintf rsync_snprintf
119 int snprintf(char *str,size_t count,const char *fmt,...);
120 #endif
121
122 #define UNUSED(x) x __attribute__((__unused__))
123
124 #define PACKAGE "rsync"
125
126 #ifndef DBL_EPSILON
127 #define DBL_EPSILON 2.2204460492503131e-16
128 #endif
129
130 #ifdef _ABS
131 #undef _ABS
132 #endif
133
134 #include "popt.h"