popt
1.16
system.h
Go to the documentation of this file.
1
5
#ifdef HAVE_CONFIG_H
6
#include "config.h"
7
#endif
8
9
#if defined (__GLIBC__) && defined(__LCLINT__)
10
/*@-declundef@*/
11
/*@unchecked@*/
12
extern
__const __int32_t *__ctype_tolower;
13
/*@unchecked@*/
14
extern
__const __int32_t *__ctype_toupper;
15
/*@=declundef@*/
16
#endif
17
18
#include <ctype.h>
19
20
/* XXX isspace(3) has i18n encoding signednesss issues on Solaris. */
21
#define _isspaceptr(_chp) isspace((int)(*(unsigned char *)(_chp)))
22
23
#include <errno.h>
24
#include <fcntl.h>
25
#include <limits.h>
26
27
#ifdef HAVE_MCHECK_H
28
#include <mcheck.h>
29
#endif
30
31
#include <stdio.h>
32
#include <stdlib.h>
33
#include <string.h>
34
35
#if defined(HAVE_UNISTD_H) && !defined(__LCLINT__)
36
#include <unistd.h>
37
#endif
38
39
#ifdef __NeXT
40
/* access macros are not declared in non posix mode in unistd.h -
41
don't try to use posix on NeXTstep 3.3 ! */
42
#include <libc.h>
43
#endif
44
45
/*@-incondefs@*/
46
/*@mayexit@*/
/*@only@*/
/*@out@*/
/*@unused@*/
47
void
*
xmalloc
(
size_t
size)
48
/*@globals errno @*/
49
/*@ensures maxSet(result) == (size - 1) @*/
50
/*@modifies errno @*/
;
51
52
/*@mayexit@*/
/*@only@*/
/*@unused@*/
53
void
*
xcalloc
(
size_t
nmemb,
size_t
size)
54
/*@ensures maxSet(result) == (nmemb - 1) @*/
55
/*@*/
;
56
57
/*@mayexit@*/
/*@only@*/
/*@unused@*/
58
void
*
xrealloc
(
/*@null@*/
/*@only@*/
void
* ptr,
size_t
size)
59
/*@ensures maxSet(result) == (size - 1) @*/
60
/*@modifies *ptr @*/
;
61
62
/*@mayexit@*/
/*@only@*/
/*@unused@*/
63
char
*
xstrdup
(
const
char
*str)
64
/*@*/
;
65
/*@=incondefs@*/
66
67
#if !defined(HAVE_STPCPY)
68
/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
69
static
inline
char
*
stpcpy
(
char
*dest,
const
char
* src) {
70
register
char
*d = dest;
71
register
const
char
*s = src;
72
73
do
74
*d++ = *s;
75
while
(*s++ !=
'\0'
);
76
return
d - 1;
77
}
78
#endif
79
80
/* Memory allocation via macro defs to get meaningful locations from mtrace() */
81
#if defined(HAVE_MCHECK_H) && defined(__GNUC__)
82
#define vmefail() (fprintf(stderr, "virtual memory exhausted.\n"), exit(EXIT_FAILURE), NULL)
83
#define xmalloc(_size) (malloc(_size) ? : vmefail())
84
#define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail())
85
#define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail())
86
#define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str)))
87
#else
88
#define xmalloc(_size) malloc(_size)
89
#define xcalloc(_nmemb, _size) calloc((_nmemb), (_size))
90
#define xrealloc(_ptr, _size) realloc((_ptr), (_size))
91
#define xstrdup(_str) strdup(_str)
92
#endif
/* defined(HAVE_MCHECK_H) && defined(__GNUC__) */
93
94
#ifndef __LCLINT__
95
# if defined HAVE_SECURE_GETENV
96
# define getenv(_s) secure_getenv(_s)
97
# elif defined HAVE___SECURE_GETENV
98
# define getenv(_s) __secure_getenv(_s)
99
#endif
100
#endif
/* !__LCLINT__ */
101
102
#if !defined(__GNUC__) && !defined(__attribute__)
103
#define __attribute__(x)
104
#endif
105
#define UNUSED(x) x __attribute__((__unused__))
106
107
#include "
popt.h
"
stpcpy
static char * stpcpy(char *dest, const char *src)
Definition:
system.h:69
xcalloc
#define xcalloc(_nmemb, _size)
Definition:
system.h:89
xstrdup
#define xstrdup(_str)
Definition:
system.h:91
xrealloc
#define xrealloc(_ptr, _size)
Definition:
system.h:90
popt.h
xmalloc
#define xmalloc(_size)
Definition:
system.h:88
Generated for popt by
1.8.17