summaryrefslogtreecommitdiffstats
path: root/common.h
blob: 0ee870c397d07f036bbdd77010156f1353d7526c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* See LICENSE file for copyright and license details. */
#if !defined(_XOPEN_SOURCE)
# define _XOPEN_SOURCE 700
#elif (_XOPEN_SOURCE + 0 < 700)
# undef _XOPEN_SOURCE
# define _XOPEN_SOURCE 700
#endif
#ifndef _BSD_SOURCE
# define _BSD_SOURCE
#endif
#ifndef _DEFAULT_SOURCE
# define _DEFAULT_SOURCE
#endif

#include <libcore.h>
#include <libcore-arg.h>
#include <libcore-aux.h>

#define malloc2 libcore_malloc2
#define malloc3 libcore_malloc3
#define calloc3 libcore_calloc3
#define realloc2 libcore_realloc2
#define realloc3 libcore_realloc3
#define enmalloc libcore_enmalloc
#define enmalloc2 libcore_enmalloc2
#define enmalloc3 libcore_enmalloc3
#define encalloc libcore_encalloc
#define encalloc3 libcore_encalloc3
#define enrealloc libcore_enrealloc
#define enrealloc2 libcore_enrealloc2
#define enrealloc3 libcore_enrealloc3
#define emalloc(N1) enmalloc(1, (N1))
#define emalloc2(N1, N2) enmalloc2(1, (N1), (N2));
#define emalloc3(N1, N2, N3) enmalloc3(1, (N1), (N2), (N3));
#define ecalloc(N1, N2) encalloc(1, (N1), (N2));
#define ecalloc3(N1, N2, N3) encalloc3(1, (N1), (N2), (N3));
#define erealloc(PTR, N1) enrealloc(1, (PTR), (N1));
#define erealloc2(PTR, N1, N2) enrealloc2(1, (PTR), (N1), (N2));
#define erealloc3(PTR, N1, N2, N3) enrealloc3(1, (PTR), (N1), (N2), (N3));

#define eprintf libcore_eprintf
#define enprintf libcore_enprintf
#define weprintf libcore_weprintf

#define fshut libcore_fshut
#define efshut libcore_efshut
#define enfshut libcore_enfshut

#define toji libcore_toji
#define toju libcore_toju
#define tozi libcore_tozi
#define tozu libcore_tozu
#define tolli libcore_tolli
#define tollu libcore_tollu
#define toli libcore_toli
#define tolu libcore_tolu
#define toi libcore_toi
#define tou libcore_tou
#define entoji_flag libcore_entoji_flag
#define entoju_flag libcore_entoju_flag
#define entozi_flag libcore_entozi_flag
#define entozu_flag libcore_entozu_flag
#define entolli_flag libcore_entolli_flag
#define entollu_flag libcore_entollu_flag
#define entoli_flag libcore_entoli_flag
#define entolu_flag libcore_entolu_flag
#define entoi_flag libcore_entoi_flag
#define entou_flag libcore_entou_flag
#define entoji_arg libcore_entoji_arg
#define entoju_arg libcore_entoju_arg
#define entozi_arg libcore_entozi_arg
#define entozu_arg libcore_entozu_arg
#define entolli_arg libcore_entolli_arg
#define entollu_arg libcore_entollu_arg
#define entoli_arg libcore_entoli_arg
#define entolu_arg libcore_entolu_arg
#define entoi_arg libcore_entoi_arg
#define entou_arg libcore_entou_arg
#define etoji_flag(...) libcore_etoji_flag(__VA_ARGS__)
#define etoju_flag(...) libcore_etoju_flag(__VA_ARGS__)
#define etozi_flag(...) libcore_etozi_flag(__VA_ARGS__)
#define etozu_flag(...) libcore_etozu_flag(__VA_ARGS__)
#define etolli_flag(...) libcore_etolli_flag(__VA_ARGS__)
#define etollu_flag(...) libcore_etollu_flag(__VA_ARGS__)
#define etoli_flag(...) libcore_etoli_flag(__VA_ARGS__)
#define etolu_flag(...) libcore_etolu_flag(__VA_ARGS__)
#define etoi_flag(...) libcore_etoi_flag(__VA_ARGS__)
#define etou_flag(...) libcore_etou_flag(__VA_ARGS__)
#define etoji_arg(...) libcore_etoji_arg(__VA_ARGS__)
#define etoju_arg(...) libcore_etoju_arg(__VA_ARGS__)
#define etozi_arg(...) libcore_etozi_arg(__VA_ARGS__)
#define etozu_arg(...) libcore_etozu_arg(__VA_ARGS__)
#define etolli_arg(...) libcore_etolli_arg(__VA_ARGS__)
#define etollu_arg(...) libcore_etollu_arg(__VA_ARGS__)
#define etoli_arg(...) libcore_etoli_arg(__VA_ARGS__)
#define etolu_arg(...) libcore_etolu_arg(__VA_ARGS__)
#define etoi_arg(...) libcore_etoi_arg(__VA_ARGS__)
#define etou_arg(...) libcore_etou_arg(__VA_ARGS__)
#define tof libcore_tof
#define tolf libcore_tolf
#define tollf libcore_tollf
#define entof_flag libcore_entof_flag
#define entof_arg libcore_entof_arg
#define entolf_flag libcore_entolf_flag
#define entolf_arg libcore_entolf_arg
#define entollf_flag libcore_entollf_flag
#define entollf_arg libcore_entollf_arg
#define etof_flag(...) libcore_etof_flag(__VA_ARGS__)
#define etof_arg(...) libcore_etof_arg(__VA_ARGS__)
#define etolf_flag(...) libcore_etolf_flag(__VA_ARGS__)
#define etolf_arg(...) libcore_etolf_arg(__VA_ARGS__)
#define etollf_flag(...) libcore_etollf_flag(__VA_ARGS__)
#define etollf_arg(...) libcore_etollf_arg(__VA_ARGS__)


static inline long int
estrtol(const char *s, int base)
{
	int saved_errno = errno;
	long long int ret;
	char *end;
	errno = 0;
	ret = strtol(s, &end, base);
	if (errno || *end) {
		if (!errno)
			errno = EINVAL;
		eprintf("strtol %s:", s);
	}
	errno = saved_errno;
	return ret;
}