The Mac version of GCC can now handle __attribute__ .
[rsync/rsync.git] / popt / system.h
CommitLineData
b348deae
MP
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
4
bc93ee84
WD
5#if defined (__GLIBC__) && defined(__LCLINT__)
6/*@-declundef@*/
7/*@unchecked@*/
8extern __const __int32_t *__ctype_tolower;
9/*@unchecked@*/
10extern __const __int32_t *__ctype_toupper;
11/*@=declundef@*/
12#endif
13
b348deae 14#include <ctype.h>
bc93ee84 15
b348deae
MP
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#include <stdlib.h>
26#include <string.h>
27
28#if HAVE_UNISTD_H
29#include <unistd.h>
30#endif
31
bc93ee84 32#ifndef __GNUC__
73042aae 33#define __attribute__(x)
73042aae
WD
34#endif
35
b348deae
MP
36#ifdef __NeXT
37/* access macros are not declared in non posix mode in unistd.h -
38 don't try to use posix on NeXTstep 3.3 ! */
39#include <libc.h>
40#endif
41
cc248aae 42#if defined(__LCLINT__)
bc93ee84
WD
43/*@-declundef -incondefs @*/ /* LCL: missing annotation */
44/*@only@*/ /*@out@*/
45void * alloca (size_t __size)
cc248aae
WD
46 /*@ensures MaxSet(result) == (__size - 1) @*/
47 /*@*/;
bc93ee84 48/*@=declundef =incondefs @*/
cc248aae
WD
49#endif
50
b348deae
MP
51/* AIX requires this to be the first thing in the file. */
52#ifndef __GNUC__
53# if HAVE_ALLOCA_H
54# include <alloca.h>
55# else
56# ifdef _AIX
57#pragma alloca
58# else
bc93ee84 59# ifdef HAVE_ALLOCA
74474192 60# ifndef alloca /* predefined by HP cc +Olibcalls */
b348deae 61char *alloca ();
74474192
WD
62# endif
63# else
64# ifdef alloca
65# undef alloca
66# endif
67# define alloca(sz) malloc(sz) /* Kludge this for now */
b348deae
MP
68# endif
69# endif
70# endif
71#elif defined(__GNUC__) && defined(__STRICT_ANSI__)
72#define alloca __builtin_alloca
73#endif
74
cc248aae 75/*@-redecl -redef@*/
bc93ee84
WD
76/*@mayexit@*/ /*@only@*/ /*@unused@*/
77char * xstrdup (const char *str)
cc248aae
WD
78 /*@*/;
79/*@=redecl =redef@*/
b348deae
MP
80
81#if HAVE_MCHECK_H && defined(__GNUC__)
82#define vmefail() (fprintf(stderr, "virtual memory exhausted.\n"), exit(EXIT_FAILURE), NULL)
83#define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str)))
84#else
85#define xstrdup(_str) strdup(_str)
86#endif /* HAVE_MCHECK_H && defined(__GNUC__) */
87
bc93ee84
WD
88#if HAVE___SECURE_GETENV && !defined(__LCLINT__)
89#define getenv(_s) __secure_getenv(_s)
90#endif
91
92#ifndef HAVE_STRLCPY
93size_t strlcpy(char *d, const char *s, size_t bufsize);
94#endif
95
96#ifndef HAVE_STRLCAT
97size_t strlcat(char *d, const char *s, size_t bufsize);
98#endif
99
73042aae
WD
100#define UNUSED(x) x __attribute__((__unused__))
101
bc93ee84
WD
102#define PACKAGE "rsync"
103
104#ifndef DBL_EPSILON
105#define DBL_EPSILON 2.2204460492503131e-16
106#endif
107
108#ifdef _ABS
109#undef _ABS
110#endif
111
b348deae 112#include "popt.h"