Commit | Line | Data |
---|---|---|
b348deae MP |
1 | #ifdef HAVE_CONFIG_H |
2 | #include "config.h" | |
3 | #endif | |
4 | ||
5 | #include <ctype.h> | |
6 | #include <errno.h> | |
7 | #include <fcntl.h> | |
8 | #include <limits.h> | |
9 | ||
10 | #if HAVE_MCHECK_H | |
11 | #include <mcheck.h> | |
12 | #endif | |
13 | ||
14 | #include <stdio.h> | |
15 | #include <stdlib.h> | |
16 | #include <string.h> | |
17 | ||
18 | #if HAVE_UNISTD_H | |
19 | #include <unistd.h> | |
20 | #endif | |
21 | ||
73042aae WD |
22 | #if !defined(__GNUC__) || defined(APPLE) |
23 | /* Apparently the OS X port of gcc gags on __attribute__. | |
24 | * | |
25 | * <http://www.opensource.apple.com/bugs/X/gcc/2512150.html> */ | |
26 | #define __attribute__(x) | |
27 | ||
28 | #endif | |
29 | ||
b348deae MP |
30 | #ifdef __NeXT |
31 | /* access macros are not declared in non posix mode in unistd.h - | |
32 | don't try to use posix on NeXTstep 3.3 ! */ | |
33 | #include <libc.h> | |
34 | #endif | |
35 | ||
cc248aae WD |
36 | #if defined(__LCLINT__) |
37 | /*@-declundef -incondefs -redecl@*/ /* LCL: missing annotation */ | |
38 | /*@only@*/ void * alloca (size_t __size) | |
39 | /*@ensures MaxSet(result) == (__size - 1) @*/ | |
40 | /*@*/; | |
41 | /*@=declundef =incondefs =redecl@*/ | |
42 | #endif | |
43 | ||
b348deae MP |
44 | /* AIX requires this to be the first thing in the file. */ |
45 | #ifndef __GNUC__ | |
46 | # if HAVE_ALLOCA_H | |
47 | # include <alloca.h> | |
48 | # else | |
49 | # ifdef _AIX | |
50 | #pragma alloca | |
51 | # else | |
74474192 WD |
52 | # if HAVE_ALLOCA |
53 | # ifndef alloca /* predefined by HP cc +Olibcalls */ | |
b348deae | 54 | char *alloca (); |
74474192 WD |
55 | # endif |
56 | # else | |
57 | # ifdef alloca | |
58 | # undef alloca | |
59 | # endif | |
60 | # define alloca(sz) malloc(sz) /* Kludge this for now */ | |
b348deae MP |
61 | # endif |
62 | # endif | |
63 | # endif | |
64 | #elif defined(__GNUC__) && defined(__STRICT_ANSI__) | |
65 | #define alloca __builtin_alloca | |
66 | #endif | |
67 | ||
cc248aae WD |
68 | /*@-redecl -redef@*/ |
69 | /*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str) | |
70 | /*@*/; | |
71 | /*@=redecl =redef@*/ | |
b348deae MP |
72 | |
73 | #if HAVE_MCHECK_H && defined(__GNUC__) | |
74 | #define vmefail() (fprintf(stderr, "virtual memory exhausted.\n"), exit(EXIT_FAILURE), NULL) | |
75 | #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str))) | |
76 | #else | |
77 | #define xstrdup(_str) strdup(_str) | |
78 | #endif /* HAVE_MCHECK_H && defined(__GNUC__) */ | |
79 | ||
73042aae WD |
80 | #define UNUSED(x) x __attribute__((__unused__)) |
81 | ||
b348deae | 82 | #include "popt.h" |