Skip to content

Commit

Permalink
m3core: Fold UerrorX.h into Uconstants.c. (#629)
Browse files Browse the repository at this point in the history
The enables building cm3 with just one file instead of two.
  • Loading branch information
jaykrell committed Jun 8, 2021
1 parent e67988a commit 1f347f3
Show file tree
Hide file tree
Showing 4 changed files with 260 additions and 262 deletions.
269 changes: 258 additions & 11 deletions m3-libs/m3core/src/unix/Common/Uconstants.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ extern "C" {
#endif
#endif

#undef X
#define X(x) EXTERN_CONST int Uerror__##x = x;
#include "UerrorX.h"

// Check that Uerror.Max=248 is enough; if you get an error here, raise it in Uerror.i3 and here.
//
// FreeBSD (12.2/amd64) compiling with clang++ has some numbers between 9000 and 10000.
Expand All @@ -65,14 +61,264 @@ extern "C" {
#endif
#endif // FreeBSD/clang++

typedef union {
#undef X
#define X(x) char a##x[x];
#include "UerrorX.h"
} M3UerrorCheckMax_t;
// Preserve this technique until it is blogged?
//typedef union {
//#undef X
//#define X(x) char a##x[x];
//#include "UerrorX.h"
//} M3UerrorCheckMax_t;
// sizeof(M3UerrorCheckMax_t) is the largest errno.
// If it is less or equal to M3_UERROR_MAX, this typedef is illegal, due to zero- or negative-sized array.
typedef int M3UerrorCheckMax[M3_UERROR_MAX - sizeof(M3UerrorCheckMax_t)];
//typedef int M3UerrorCheckMax[M3_UERROR_MAX - sizeof(M3UerrorCheckMax_t)];

#undef X
#define X(x) M3_STATIC_ASSERT (x < M3_UERROR_MAX); EXTERN_CONST int Uerror__##x = x;

#ifndef _WIN32
/* These do exist but
- They have "WSA" in front of them.
- They are large (10000+).
*/
X(EADDRINUSE)
X(EADDRNOTAVAIL)
X(EALREADY)
X(ECONNABORTED)
X(ECONNREFUSED)
X(ECONNRESET)
X(EHOSTDOWN)
X(EHOSTUNREACH)
X(EINPROGRESS)
X(EISCONN)
X(ENETDOWN)
X(ENETRESET)
X(ENETUNREACH)
X(ENOBUFS)
X(ENOTSOCK)
X(ETIMEDOUT)
X(EWOULDBLOCK)
#endif

X(EACCES)
X(EAGAIN)
X(EBADF)
X(ECHILD)
X(EDOM)
X(EEXIST)
X(EINTR)
X(EINVAL)
X(EIO)
X(EISDIR)
X(EMFILE)
X(ENAMETOOLONG)
X(ENFILE)
X(ENOENT)
X(ENOEXEC)
X(ENOMEM)
X(ENOTDIR)
X(ENOTEMPTY)
X(EPERM)
X(EPIPE)
X(ERANGE)

#ifdef E2BIG
X(E2BIG)
#endif
#ifdef EAFNOSUPPORT
X(EAFNOSUPPORT)
#endif
#ifdef EAUTH
X(EAUTH)
#endif
#ifdef EBADARCH
X(EBADARCH)
#endif
#ifdef EBADEXEC
X(EBADEXEC)
#endif
#ifdef EBADMACHO
X(EBADMACHO)
#endif
#ifdef EBADMSG
X(EBADMSG)
#endif
#ifdef EBADRPC
X(EBADRPC)
#endif
#ifdef EBUSY
X(EBUSY)
#endif
#ifdef ECANCELED
X(ECANCELED)
#endif
#ifdef EDEADLK
X(EDEADLK)
#endif
#ifdef EDESTADDRREQ
X(EDESTADDRREQ)
#endif
#ifdef EDEVERR
X(EDEVERR)
#endif
#ifdef EDQUOT
X(EDQUOT)
#endif
#ifdef EFAULT
X(EFAULT)
#endif
#ifdef EFBIG
X(EFBIG)
#endif
#ifdef EFTYPE
X(EFTYPE)
#endif
#ifdef EIDRM
X(EIDRM)
#endif
#ifdef EILSEQ
X(EILSEQ)
#endif
#ifdef ELOOP
X(ELOOP)
#endif
#ifdef EMLINK
X(EMLINK)
#endif
#ifdef EMSGSIZE
X(EMSGSIZE)
#endif
#ifdef EMULTIHOP
X(EMULTIHOP)
#endif
#ifdef ENEEDAUTH
X(ENEEDAUTH)
#endif
#ifdef ENOATTR
X(ENOATTR)
#endif
#ifdef ENODATA
X(ENODATA)
#endif
#ifdef ENODEV
X(ENODEV)
#endif
#ifdef ENOLCK
X(ENOLCK)
#endif
#ifdef ENOLINK
X(ENOLINK)
#endif
#ifdef ENOMSG
X(ENOMSG)
#endif
#ifdef ENOPOLICY
X(ENOPOLICY)
#endif
#ifdef ENOPROTOOPT
X(ENOPROTOOPT)
#endif
#ifdef ENOSPC
X(ENOSPC)
#endif
#ifdef ENOSR
X(ENOSR)
#endif
#ifdef ENOSTR
X(ENOSTR)
#endif
#ifdef ENOSYS
X(ENOSYS)
#endif
#ifdef ENOTBLK
X(ENOTBLK)
#endif
#ifdef ENOTCONN
X(ENOTCONN)
#endif
#ifdef ENOTSUP
X(ENOTSUP)
#endif
#ifdef ENOTTY
X(ENOTTY)
#endif
#ifdef ENXIO
X(ENXIO)
#endif
#ifdef EOPNOTSUPP
X(EOPNOTSUPP)
#endif
#ifdef EOVERFLOW
X(EOVERFLOW)
#endif
#ifdef EPFNOSUPPORT
X(EPFNOSUPPORT)
#endif
#ifdef EPROCLIM
X(EPROCLIM)
#endif
#ifdef EPROCUNAVAIL
X(EPROCUNAVAIL)
#endif
#ifdef EPROGMISMATCH
X(EPROGMISMATCH)
#endif
#ifdef EPROGUNAVAIL
X(EPROGUNAVAIL)
#endif
#ifdef EPROTO
X(EPROTO)
#endif
#ifdef EPROTONOSUPPORT
X(EPROTONOSUPPORT)
#endif
#ifdef EPROTOTYPE
X(EPROTOTYPE)
#endif
#ifdef EPWROFF
X(EPWROFF)
#endif
#ifdef EREMOTE
X(EREMOTE)
#endif
#ifdef EROFS
X(EROFS)
#endif
#ifdef ERPCMISMATCH
X(ERPCMISMATCH)
#endif
#ifdef ESHLIBVERS
X(ESHLIBVERS)
#endif
#ifdef ESHUTDOWN
X(ESHUTDOWN)
#endif
#ifdef ESOCKTNOSUPPORT
X(ESOCKTNOSUPPORT)
#endif
#ifdef ESPIPE
X(ESPIPE)
#endif
#ifdef ESRCH
X(ESRCH)
#endif
#ifdef ESTALE
X(ESTALE)
#endif
#ifdef ETIME
X(ETIME)
#endif
#ifdef ETOOMANYREFS
X(ETOOMANYREFS)
#endif
#ifdef ETXTBSY
X(ETXTBSY)
#endif
#ifdef EUSERS
X(EUSERS)
#endif
#ifdef EXDEV
X(EXDEV)
#endif


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

#ifndef _WIN32

// TODO Why two symbols here?
#undef X
#define X(x) EXTERN_CONST int Uexec__##x = x; \
EXTERN_CONST int Uexec_##x = x;
Expand Down Expand Up @@ -582,7 +829,7 @@ X(SO_SECURITY_ENCRYPTION_NETWORK)
#ifdef MSG_OOB
X(MSG_OOB)
#endif
#ifdef MSG_DONTROUTE
#ifdef MSG_DONTROUTE
X(MSG_DONTROUTE)
#endif
#ifdef MSG_CTRUNC
Expand Down
Loading

0 comments on commit 1f347f3

Please sign in to comment.