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 | ||
22 | #ifdef __NeXT | |
23 | /* access macros are not declared in non posix mode in unistd.h - | |
24 | don't try to use posix on NeXTstep 3.3 ! */ | |
25 | #include <libc.h> | |
26 | #endif | |
27 | ||
cc248aae WD |
28 | #if defined(__LCLINT__) |
29 | /*@-declundef -incondefs -redecl@*/ /* LCL: missing annotation */ | |
30 | /*@only@*/ void * alloca (size_t __size) | |
31 | /*@ensures MaxSet(result) == (__size - 1) @*/ | |
32 | /*@*/; | |
33 | /*@=declundef =incondefs =redecl@*/ | |
34 | #endif | |
35 | ||
b348deae MP |
36 | /* AIX requires this to be the first thing in the file. */ |
37 | #ifndef __GNUC__ | |
38 | # if HAVE_ALLOCA_H | |
39 | # include <alloca.h> | |
40 | # else | |
41 | # ifdef _AIX | |
42 | #pragma alloca | |
43 | # else | |
74474192 WD |
44 | # if HAVE_ALLOCA |
45 | # ifndef alloca /* predefined by HP cc +Olibcalls */ | |
b348deae | 46 | char *alloca (); |
74474192 WD |
47 | # endif |
48 | # else | |
49 | # ifdef alloca | |
50 | # undef alloca | |
51 | # endif | |
52 | # define alloca(sz) malloc(sz) /* Kludge this for now */ | |
b348deae MP |
53 | # endif |
54 | # endif | |
55 | # endif | |
56 | #elif defined(__GNUC__) && defined(__STRICT_ANSI__) | |
57 | #define alloca __builtin_alloca | |
58 | #endif | |
59 | ||
cc248aae WD |
60 | /*@-redecl -redef@*/ |
61 | /*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str) | |
62 | /*@*/; | |
63 | /*@=redecl =redef@*/ | |
b348deae MP |
64 | |
65 | #if HAVE_MCHECK_H && defined(__GNUC__) | |
66 | #define vmefail() (fprintf(stderr, "virtual memory exhausted.\n"), exit(EXIT_FAILURE), NULL) | |
67 | #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str))) | |
68 | #else | |
69 | #define xstrdup(_str) strdup(_str) | |
70 | #endif /* HAVE_MCHECK_H && defined(__GNUC__) */ | |
71 | ||
37101856 | 72 | #define UNUSED(x) x __attribute__((__unused__)) |
b348deae MP |
73 | |
74 | #include "popt.h" |