Skip to content

Commit 7485272

Browse files
committed
m3core: Fold UerrorX.h into Uconstants.c. (#629)
The enables building cm3 with just one file instead of two.
1 parent e67988a commit 7485272

File tree

4 files changed

+260
-262
lines changed

4 files changed

+260
-262
lines changed

m3-libs/m3core/src/unix/Common/Uconstants.c

Lines changed: 258 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ extern "C" {
3636
#endif
3737
#endif
3838

39-
#undef X
40-
#define X(x) EXTERN_CONST int Uerror__##x = x;
41-
#include "UerrorX.h"
42-
4339
// Check that Uerror.Max=248 is enough; if you get an error here, raise it in Uerror.i3 and here.
4440
//
4541
// FreeBSD (12.2/amd64) compiling with clang++ has some numbers between 9000 and 10000.
@@ -65,14 +61,264 @@ extern "C" {
6561
#endif
6662
#endif // FreeBSD/clang++
6763

68-
typedef union {
69-
#undef X
70-
#define X(x) char a##x[x];
71-
#include "UerrorX.h"
72-
} M3UerrorCheckMax_t;
64+
// Preserve this technique until it is blogged?
65+
//typedef union {
66+
//#undef X
67+
//#define X(x) char a##x[x];
68+
//#include "UerrorX.h"
69+
//} M3UerrorCheckMax_t;
7370
// sizeof(M3UerrorCheckMax_t) is the largest errno.
7471
// If it is less or equal to M3_UERROR_MAX, this typedef is illegal, due to zero- or negative-sized array.
75-
typedef int M3UerrorCheckMax[M3_UERROR_MAX - sizeof(M3UerrorCheckMax_t)];
72+
//typedef int M3UerrorCheckMax[M3_UERROR_MAX - sizeof(M3UerrorCheckMax_t)];
73+
74+
#undef X
75+
#define X(x) EXTERN_CONST M3_STATIC_ASSERT (x < M3_UERROR_MAX); int Uerror__##x = x;
76+
77+
#ifndef _WIN32
78+
/* These do exist but
79+
- They have "WSA" in front of them.
80+
- They are large (10000+).
81+
*/
82+
X(EADDRINUSE)
83+
X(EADDRNOTAVAIL)
84+
X(EALREADY)
85+
X(ECONNABORTED)
86+
X(ECONNREFUSED)
87+
X(ECONNRESET)
88+
X(EHOSTDOWN)
89+
X(EHOSTUNREACH)
90+
X(EINPROGRESS)
91+
X(EISCONN)
92+
X(ENETDOWN)
93+
X(ENETRESET)
94+
X(ENETUNREACH)
95+
X(ENOBUFS)
96+
X(ENOTSOCK)
97+
X(ETIMEDOUT)
98+
X(EWOULDBLOCK)
99+
#endif
100+
101+
X(EACCES)
102+
X(EAGAIN)
103+
X(EBADF)
104+
X(ECHILD)
105+
X(EDOM)
106+
X(EEXIST)
107+
X(EINTR)
108+
X(EINVAL)
109+
X(EIO)
110+
X(EISDIR)
111+
X(EMFILE)
112+
X(ENAMETOOLONG)
113+
X(ENFILE)
114+
X(ENOENT)
115+
X(ENOEXEC)
116+
X(ENOMEM)
117+
X(ENOTDIR)
118+
X(ENOTEMPTY)
119+
X(EPERM)
120+
X(EPIPE)
121+
X(ERANGE)
122+
123+
#ifdef E2BIG
124+
X(E2BIG)
125+
#endif
126+
#ifdef EAFNOSUPPORT
127+
X(EAFNOSUPPORT)
128+
#endif
129+
#ifdef EAUTH
130+
X(EAUTH)
131+
#endif
132+
#ifdef EBADARCH
133+
X(EBADARCH)
134+
#endif
135+
#ifdef EBADEXEC
136+
X(EBADEXEC)
137+
#endif
138+
#ifdef EBADMACHO
139+
X(EBADMACHO)
140+
#endif
141+
#ifdef EBADMSG
142+
X(EBADMSG)
143+
#endif
144+
#ifdef EBADRPC
145+
X(EBADRPC)
146+
#endif
147+
#ifdef EBUSY
148+
X(EBUSY)
149+
#endif
150+
#ifdef ECANCELED
151+
X(ECANCELED)
152+
#endif
153+
#ifdef EDEADLK
154+
X(EDEADLK)
155+
#endif
156+
#ifdef EDESTADDRREQ
157+
X(EDESTADDRREQ)
158+
#endif
159+
#ifdef EDEVERR
160+
X(EDEVERR)
161+
#endif
162+
#ifdef EDQUOT
163+
X(EDQUOT)
164+
#endif
165+
#ifdef EFAULT
166+
X(EFAULT)
167+
#endif
168+
#ifdef EFBIG
169+
X(EFBIG)
170+
#endif
171+
#ifdef EFTYPE
172+
X(EFTYPE)
173+
#endif
174+
#ifdef EIDRM
175+
X(EIDRM)
176+
#endif
177+
#ifdef EILSEQ
178+
X(EILSEQ)
179+
#endif
180+
#ifdef ELOOP
181+
X(ELOOP)
182+
#endif
183+
#ifdef EMLINK
184+
X(EMLINK)
185+
#endif
186+
#ifdef EMSGSIZE
187+
X(EMSGSIZE)
188+
#endif
189+
#ifdef EMULTIHOP
190+
X(EMULTIHOP)
191+
#endif
192+
#ifdef ENEEDAUTH
193+
X(ENEEDAUTH)
194+
#endif
195+
#ifdef ENOATTR
196+
X(ENOATTR)
197+
#endif
198+
#ifdef ENODATA
199+
X(ENODATA)
200+
#endif
201+
#ifdef ENODEV
202+
X(ENODEV)
203+
#endif
204+
#ifdef ENOLCK
205+
X(ENOLCK)
206+
#endif
207+
#ifdef ENOLINK
208+
X(ENOLINK)
209+
#endif
210+
#ifdef ENOMSG
211+
X(ENOMSG)
212+
#endif
213+
#ifdef ENOPOLICY
214+
X(ENOPOLICY)
215+
#endif
216+
#ifdef ENOPROTOOPT
217+
X(ENOPROTOOPT)
218+
#endif
219+
#ifdef ENOSPC
220+
X(ENOSPC)
221+
#endif
222+
#ifdef ENOSR
223+
X(ENOSR)
224+
#endif
225+
#ifdef ENOSTR
226+
X(ENOSTR)
227+
#endif
228+
#ifdef ENOSYS
229+
X(ENOSYS)
230+
#endif
231+
#ifdef ENOTBLK
232+
X(ENOTBLK)
233+
#endif
234+
#ifdef ENOTCONN
235+
X(ENOTCONN)
236+
#endif
237+
#ifdef ENOTSUP
238+
X(ENOTSUP)
239+
#endif
240+
#ifdef ENOTTY
241+
X(ENOTTY)
242+
#endif
243+
#ifdef ENXIO
244+
X(ENXIO)
245+
#endif
246+
#ifdef EOPNOTSUPP
247+
X(EOPNOTSUPP)
248+
#endif
249+
#ifdef EOVERFLOW
250+
X(EOVERFLOW)
251+
#endif
252+
#ifdef EPFNOSUPPORT
253+
X(EPFNOSUPPORT)
254+
#endif
255+
#ifdef EPROCLIM
256+
X(EPROCLIM)
257+
#endif
258+
#ifdef EPROCUNAVAIL
259+
X(EPROCUNAVAIL)
260+
#endif
261+
#ifdef EPROGMISMATCH
262+
X(EPROGMISMATCH)
263+
#endif
264+
#ifdef EPROGUNAVAIL
265+
X(EPROGUNAVAIL)
266+
#endif
267+
#ifdef EPROTO
268+
X(EPROTO)
269+
#endif
270+
#ifdef EPROTONOSUPPORT
271+
X(EPROTONOSUPPORT)
272+
#endif
273+
#ifdef EPROTOTYPE
274+
X(EPROTOTYPE)
275+
#endif
276+
#ifdef EPWROFF
277+
X(EPWROFF)
278+
#endif
279+
#ifdef EREMOTE
280+
X(EREMOTE)
281+
#endif
282+
#ifdef EROFS
283+
X(EROFS)
284+
#endif
285+
#ifdef ERPCMISMATCH
286+
X(ERPCMISMATCH)
287+
#endif
288+
#ifdef ESHLIBVERS
289+
X(ESHLIBVERS)
290+
#endif
291+
#ifdef ESHUTDOWN
292+
X(ESHUTDOWN)
293+
#endif
294+
#ifdef ESOCKTNOSUPPORT
295+
X(ESOCKTNOSUPPORT)
296+
#endif
297+
#ifdef ESPIPE
298+
X(ESPIPE)
299+
#endif
300+
#ifdef ESRCH
301+
X(ESRCH)
302+
#endif
303+
#ifdef ESTALE
304+
X(ESTALE)
305+
#endif
306+
#ifdef ETIME
307+
X(ETIME)
308+
#endif
309+
#ifdef ETOOMANYREFS
310+
X(ETOOMANYREFS)
311+
#endif
312+
#ifdef ETXTBSY
313+
X(ETXTBSY)
314+
#endif
315+
#ifdef EUSERS
316+
X(EUSERS)
317+
#endif
318+
#ifdef EXDEV
319+
X(EXDEV)
320+
#endif
321+
76322

77323
#define const_INTEGER const_INTEGER /* inhibit m3c type that lacks const */
78324
typedef const INTEGER const_INTEGER;
@@ -87,6 +333,7 @@ const_INTEGER m3_jmpbuf_size = sizeof(jmp_buf);
87333

88334
#ifndef _WIN32
89335

336+
// TODO Why two symbols here?
90337
#undef X
91338
#define X(x) EXTERN_CONST int Uexec__##x = x; \
92339
EXTERN_CONST int Uexec_##x = x;
@@ -582,7 +829,7 @@ X(SO_SECURITY_ENCRYPTION_NETWORK)
582829
#ifdef MSG_OOB
583830
X(MSG_OOB)
584831
#endif
585-
#ifdef MSG_DONTROUTE
832+
#ifdef MSG_DONTROUTE
586833
X(MSG_DONTROUTE)
587834
#endif
588835
#ifdef MSG_CTRUNC

0 commit comments

Comments
 (0)