m3core/src/unix/Common/Uconstants.c
/* Copyright (C) 1990, Digital Equipment Corporation. */
/* All rights reserved. */
/* See the file COPYRIGHT for a full description. */
#include "m3unix.h"
#if defined(__OpenBSD__)
#include "context/setjmp/context.h"
#define HAS_UCONTEXT_T
#elif defined(__linux) && defined(__i386)
#include <ucontext.h>
#define HAS_UCONTEXT_T
#else
/*#include <ucontext.h>*/
#endif
#include <signal.h>
#ifndef _WIN32
#include <netinet/tcp.h>
#include <netinet/in.h>
#endif
#ifdef __sun
#include <sys/filio.h>
#endif
#ifdef __CYGWIN__
#include <process.h>
#include <sys/termios.h>
#endif
#include <net/if.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef union {
#define X(x) char a##x[x];
#include "UerrorX.h"
} CheckMax_t;
/* check that Uerror.Max=248 is enough; if you get an error here, raise it in Uerror.i3 and here */
typedef int CheckMax[248 - sizeof(CheckMax_t)];
#undef X
#define X(x) const int Uerror__##x = x;
#include "UerrorX.h"
#ifndef _WIN32
#undef X
#define X(x) const int Uexec__##x = x; \
const int Uexec_##x = x;
X(WNOHANG)
#endif
#undef X
#define X(x) const int Usignal__##x = x;
X(SIGINT)
X(SIGTERM)
#ifndef _WIN32
X(SIGKILL)
X(SIGCHLD)
X(SIGALRM)
X(SIGHUP)
X(SIGSTOP)
#endif
#ifdef SIGQUIT
X(SIGQUIT)
#endif
#ifdef SIGILL
X(SIGILL)
#endif
#ifdef SIGTRAP
X(SIGTRAP)
#endif
#ifdef SIGABRT
X(SIGABRT)
#endif
#ifdef SIGEXCEPT
X(SIGEXCEPT)
#endif
#ifdef SIGFPE
X(SIGFPE)
#endif
#ifdef SIGBUS
X(SIGBUS)
#endif
#ifdef SIGSEGV
X(SIGSEGV)
#endif
#ifdef SIGSYS
X(SIGSYS)
#endif
#ifdef SIGPIPE
X(SIGPIPE)
#endif
#ifdef SIGUSR1
X(SIGUSR1)
#endif
#ifdef SIGUSR2
X(SIGUSR2)
#endif
#ifdef SIGIO
X(SIGIO)
#endif
#ifdef SIGWINCH
X(SIGWINCH)
#endif
#ifdef SIGURG
X(SIGURG)
#endif
#ifdef SIGPOLL
X(SIGPOLL)
#endif
#ifdef SIGTSTP
X(SIGTSTP)
#endif
#ifdef SIGCONT
X(SIGCONT)
#endif
#ifdef SIGTTIN
X(SIGTTIN)
#endif
#ifdef SIGTTOU
X(SIGTTOU)
#endif
#ifdef SIGVTALRM
X(SIGVTALRM)
#endif
#ifdef SIGPROF
X(SIGPROF)
#endif
#ifdef SIGXCPU
X(SIGXCPU)
#endif
#ifdef SIGXFSZ
X(SIGXFSZ)
#endif
#ifdef SIGCANCEL
X(SIGCANCEL)
#endif
#ifdef NSIG
X(NSIG)
#endif
#ifdef SIGIOT
X(SIGIOT)
#endif
#ifdef SIGCLD
X(SIGCLD)
#endif
#ifdef SA_NOCLDSTOP
X(SA_NOCLDSTOP)
#endif
#ifdef SA_RESTART
X(SA_RESTART)
#endif
#ifdef SA_RESETHAND
X(SA_RESETHAND)
#endif
#ifdef SIG_BLOCK
X(SIG_BLOCK)
#endif
#ifdef SIG_UNBLOCK
X(SIG_UNBLOCK)
#endif
#ifdef SIG_SETMASK
X(SIG_SETMASK)
#endif
#undef X
#define X(x) const int Unix__##x = x;
#undef Y
#define Y(x, y) const int Unix__##x = y;
X(FIONREAD)
X(O_RDONLY)
X(O_RDWR)
X(O_CREAT)
X(O_EXCL)
X(O_TRUNC)
X(O_APPEND)
#ifndef _WIN32
X(O_NONBLOCK)
Y(O_NDELAY, O_NONBLOCK) /* compat */
Y(M3_NONBLOCK, O_NONBLOCK) /* compat */
#endif
#ifndef _WIN32
X(F_OK)
X(X_OK)
X(W_OK)
X(R_OK)
#else
Y(F_OK, 0)
Y(W_OK, 2)
Y(R_OK, 4)
#endif
#ifndef _WIN32
X(F_SETFD) /* Set close-on-exec flag */
X(F_GETFL) /* Get fd status flags */
X(F_SETFL) /* Set fd status flags */
Y(MSETUID, S_ISUID) /* set user id on execution */
Y(MSETGID, S_ISGID) /* set group id on execution */
Y(MSTICKY, S_ISVTX) /* save swapped text even after use */
Y(MROWNER, S_IRUSR) /* readable by owner */
Y(MWOWNER, S_IWUSR) /* writable by owner */
Y(MXOWNER, S_IXUSR) /* executable by owner */
Y(MRGROUP, S_IRGRP) /* readable by group */
Y(MWGROUP, S_IWGRP) /* writable by group */
Y(MXGROUP, S_IXGRP) /* executable by group */
Y(MROTHER, S_IROTH) /* readable by other */
Y(MWOTHER, S_IWOTH) /* writable by other */
Y(MXOTHER, S_IXOTH) /* executable by other */
/* readable/writable by all, executable by none */
Y(Mrwrwrw, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
#endif
#undef X
#define X(x) const int Usocket__##x = x;
/* core Usocket that m3core/libm3 use */
X(SOCK_STREAM)
X(SOCK_DGRAM)
X(SO_REUSEADDR)
X(SO_KEEPALIVE)
X(SO_LINGER)
X(SOL_SOCKET)
X(AF_INET)
X(MSG_PEEK)
/* other Usocket that others might use, maybe less portable? */
#ifdef AF_UNSPEC
X(AF_UNSPEC)
#endif
#ifdef AF_INET6
X(AF_INET6)
#endif
#ifdef AF_NETBIOS
X(AF_NETBIOS)
#endif
#ifdef AF_IRDA
X(AF_IRDA) /* infrared */
#endif
#ifdef AF_BTH
X(AF_BTH) /* bluetooth */
#endif
#ifdef AF_UNIX
X(AF_UNIX)
#endif
#ifdef AF_LOCAL
X(AF_LOCAL)
#endif
#ifdef AF_IPX
X(AF_IPX)
#endif
#ifdef AF_AX25
X(AF_AX25)
#endif
#ifdef AF_NETROM
X(AF_NETROM)
#endif
#ifdef AF_BRIDGE
X(AF_BRIDGE)
#endif
#ifdef AF_AAL5
X(AF_AAL5)
#endif
#ifdef AF_X25
X(AF_X25)
#endif
#ifdef AF_IMPLINK
X(AF_IMPLINK)
#endif
#ifdef AF_PUP
X(AF_PUP)
#endif
#ifdef AF_CHAOS
X(AF_CHAOS)
#endif
#ifdef AF_NS
X(AF_NS)
#endif
#ifdef AF_NBS
X(AF_NBS)
#endif
#ifdef AF_ECMA
X(AF_ECMA)
#endif
#ifdef AF_DATAKIT
X(AF_DATAKIT)
#endif
#ifdef AF_CCITT
X(AF_CCITT)
#endif
#ifdef AF_SNA
X(AF_SNA)
#endif
#ifdef AF_DECnet
X(AF_DECnet)
#endif
#ifdef AF_DLI
X(AF_DLI)
#endif
#ifdef AF_LAT
X(AF_LAT)
#endif
#ifdef AF_HYLINK
X(AF_HYLINK)
#endif
#ifdef AF_APPLETALK
X(AF_APPLETALK)
#endif
#ifdef AF_BSC
X(AF_BSC)
#endif
#ifdef AF_DSS
X(AF_DSS)
#endif
#ifdef AI_PASSIVE
X(AI_PASSIVE)
#endif
#ifdef AI_CANONNAME
X(AI_CANONNAME)
#endif
#ifdef AI_NUMERIC_HOST
X(AI_NUMERIC_HOST)
#endif
#ifdef AI_ADDRCONFIG
X(AI_ADDRCONFIG)
#endif
#ifdef AI_NON_AUTHORITATIVE
X(AI_NON_AUTHORITATIVE)
#endif
#ifdef AI_SECURE
X(AI_SECURE)
#endif
#ifdef AI_RETURN_PREFERRED_NAMES
X(AI_RETURN_PREFERRED_NAMES)
#endif
X(IPPROTO_TCP)
#ifdef IPPROTO_UDP
X(IPPROTO_UDP)
#endif
#ifdef IPPROTO_RM
X(IPPROTO_RM)
#endif
#ifdef IPPROTO_PGM
X(IPPROTO_PGM)
#endif
#ifdef IPPROTO_IGMP
X(IPPROTO_IGMP)
#endif
#ifdef SOCK_RAW
X(SOCK_RAW)
#endif
#ifdef SOCK_RDM
X(SOCK_RDM)
#endif
#ifdef SOCK_SEQPACKET
X(SOCK_SEQPACKET)
#endif
#ifdef SO_TYPE
X(SO_TYPE)
#endif
#ifdef SO_ERROR
X(SO_ERROR)
#endif
#ifdef SO_DONTROUTE
X(SO_DONTROUTE)
#endif
#ifdef SO_BROADCAST
X(SO_BROADCAST)
#endif
#ifdef SO_SNDBUF
X(SO_SNDBUF)
#endif
#ifdef SO_RCVBUF
X(SO_RCVBUF)
#endif
#ifdef SO_OOBINLINE
X(SO_OOBINLINE)
#endif
#ifdef SO_NO_CHECK
X(SO_NO_CHECK)
#endif
#ifdef SO_PRIORITY
X(SO_PRIORITY)
#endif
#ifdef SO_BSDCOMPAT
X(SO_BSDCOMPAT)
#endif
#ifdef SO_ACCEPTCON
X(SO_ACCEPTCON)
#endif
#ifdef SO_CONDITIONAL_ACCEPT
X(SO_CONDITIONAL_ACCEPT)
#endif
#ifdef SO_EXCLUSIVEADDRUSE
X(SO_EXCLUSIVEADDRUSE)
#endif
#ifdef SO_PORT_SCALABILITY
X(SO_PORT_SCALABILITY)
#endif
#ifdef SO_PASSCRED
X(SO_PASSCRED)
#endif
#ifdef SO_PEERCRED
X(SO_PEERCRED)
#endif
#ifdef SO_RCVLOWAT
X(SO_RCVLOWAT)
#endif
#ifdef SO_SNDLOWAT
X(SO_SNDLOWAT)
#endif
#ifdef SO_REUSEPORT
X(SO_REUSEPORT)
#endif
#ifdef SO_RCVTIMEO
X(SO_RCVTIMEO)
#endif
#ifdef SO_SNDTIMEO
X(SO_SNDTIMEO)
#endif
#ifdef SO_SECURITY_AUTHENTICATION
X(SO_SECURITY_AUTHENTICATION)
#endif
#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
X(SO_SECURITY_ENCRYPTION_TRANSPORT)
#endif
#ifdef SO_SECURITY_ENCRYPTION_NETWORK
X(SO_SECURITY_ENCRYPTION_NETWORK)
#endif
#ifdef MSG_OOB
X(MSG_OOB)
#endif
#ifdef MSG_DONTROUTE
X(MSG_DONTROUTE)
#endif
#ifdef MSG_CTRUNC
X(MSG_CTRUNC)
#endif
#ifdef MSG_PROXY
X(MSG_PROXY)
#endif
#ifdef SOMAXCONN
X(SOMAXCONN)
#endif
#undef X
#define X(x) const int Ustat__##x = x;
#undef Y
#define Y(x, y) const int Ustat__##x = y;
X(S_IFMT)
X(S_IFREG)
X(S_IFDIR)
X(S_IFCHR)
#ifndef _WIN32
X(S_IFIFO)
X(S_IFSOCK)
X(S_IFLNK)
X(S_IFBLK)
X(S_ISUID)
X(S_ISGID)
X(S_ISVTX)
#endif
X(S_IREAD)
X(S_IWRITE)
X(S_IEXEC)
#ifndef _WIN32
Y(S_GREAD, S_IRGRP)
Y(S_GWRITE, S_IWGRP)
Y(S_GEXEC, S_IXGRP)
Y(S_OREAD, S_IROTH)
Y(S_OWRITE, S_IWOTH)
Y(S_OEXEC, S_IXOTH)
#endif
#ifdef HAS_STAT_FLAGS
/* Super-user and owner changeable flags. */
#ifdef UF_SETTABLE
X(UF_SETTABLE) /* mask of owner changeable flags */
#else
Y(UF_SETTABLE, 0)
#endif
#ifdef UF_NODUMP
X(UF_NODUMP)
#else
Y(UF_NODUMP, 0)
#endif
#ifdef UF_IMMUTABLE
X(UF_IMMUTABLE)
#else
Y(UF_IMMUTABLE, 0)
#endif
#ifdef UF_APPEND
X(UF_APPEND)
#else
Y(UF_APPEND, 0)
#endif
#ifdef UF_NOUNLINK
X(UF_NOUNLINK)
#else
Y(UF_NOUNLINK, 0)
#endif
#ifdef UF_OPAQUE
X(UF_OPAQUE)
#else
Y(UF_OPAQUE, 0)
#endif
/* Super-user changeable flags. */
#ifdef SF_SETTABLE
X(SF_SETTABLE) /* mask of superuser changeable flags */
#else
Y(SF_SETTABLE, 0)
#endif
#ifdef SF_ARCHIVED
X(SF_ARCHIVED)
#else
Y(SF_ARCHIVED, 0)
#endif
#ifdef SF_IMMUTABLE
X(SF_IMMUTABLE)
#else
Y(SF_IMMUTABLE, 0)
#endif
#ifdef SF_APPEND
X(SF_APPEND)
#else
Y(SF_APPEND, 0)
#endif
#ifdef SF_NOUNLINK
X(SF_NOUNLINK)
#else
Y(SF_NOUNLINK, 0)
#endif
#ifdef SF_SNAPSHOT
X(SF_SNAPSHOT)
#else
Y(SF_SNAPSHOT, 0)
#endif
#else
Y(UF_NODUMP, 0)
Y(UF_IMMUTABLE, 0)
Y(UF_APPEND, 0)
Y(UF_NOUNLINK, 0)
Y(UF_OPAQUE, 0)
Y(SF_ARCHIVED, 0)
Y(SF_IMMUTABLE, 0)
Y(SF_APPEND, 0)
Y(SF_NOUNLINK, 0)
Y(SF_SNAPSHOT, 0)
#endif
#undef X
#define X(x) const int Unetdb__##x = x;
X(TRY_AGAIN)
X(NO_RECOVERY)
X(NO_ADDRESS)
#undef X
#define X(x) const int Uin__##x = x;
X(IPPROTO_TCP)
#undef X
#undef Y
#define X(x) const int Utime__##x = x;
#define Y(x, y) const int Utime__##x = y;
/* Cygwin only supports real time whereas Modula-3 only uses virtual time. Lie. */
#ifndef _WIN32
#ifdef __CYGWIN__
Y(ITIMER_VIRTUAL, ITIMER_REAL)
#else
X(ITIMER_VIRTUAL) /* virtual time intervals */
#endif
#endif
#undef X
#define X(x) const int Umman__##x = x;
#ifndef _WIN32
X(PROT_NONE)
X(PROT_READ)
X(PROT_WRITE)
#endif
#ifdef PROT_EXEC
X(PROT_EXEC)
#endif
#ifdef MAP_SHARED
X(MAP_SHARED)
#endif
#ifdef MAP_PRIVATE
X(MAP_PRIVATE)
#endif
#ifdef MAP_FIXED
X(MAP_FIXED)
#endif
#ifdef MAP_RENAME
X(MAP_RENAME)
#endif
#ifdef MAP_NORESERVE
X(MAP_NORESERVE)
#endif
#ifdef MAP_HASSEMAPHORE
X(MAP_HASSEMAPHORE)
#endif
#ifdef MAP_STACK
X(MAP_STACK)
#endif
#ifdef MAP_NOSYNC
X(MAP_NOSYNC)
#endif
#ifdef MAP_FILE
X(MAP_FILE)
#endif
#ifdef MAP_ANON
X(MAP_ANON)
#endif
#ifdef MAP_NOCORE
X(MAP_NOCORE)
#endif
#ifdef HAS_UCONTEXT_T
#undef X
#undef Y
#define X(x) const int Uucontext__##x = x;
#define Y(x, y) const int Uucontext__##x = y;
Y(context_t_size, sizeof(ucontext_t))
#endif
#ifdef __CYGWIN__
#undef X
#define X(x) const int Usysdep__##x = x;
#undef Y
#define Y(x, y) const int Usysdep__##x = y;
Y(P_NOWAIT, _P_NOWAIT)
#undef X
#undef Y
#define X(x) const int Utermio__##x = x;
#define Y(x, y) const int Utermio__##x = y;
Y(BAUDBITS, CBAUD)
X(B75)
X(B110)
X(B300)
X(B600)
X(B1200)
X(B2400)
X(B4800)
X(B9600)
#ifdef B14400
X(B14400)
#else
Y(B14400, -1)
#endif
X(B19200)
X(B38400)
X(B57600)
X(B115200)
X(B230400)
X(CSIZE)
X(CS8)
X(CS7)
X(CS6)
X(CS5 )
X(CSTOPB)
Y(PARITYBITS, PARODD | PARENB)
Y(PARNONE, 0)
Y(PARODD, PARODD | PARENB)
Y(PAREVEN, PARENB)
X(IGNBRK)
X(IGNPAR)
X(CREAD)
X(VMIN)
X(VTIME)
X(TCSANOW)
#endif /* cygwin */
#undef X
#define X(x) const int Unix__##x = x;
#ifdef TIOCCAR
X(TIOCCAR)
#endif
#ifdef TIOCCBRK
X(TIOCCBRK)
#endif
#ifdef TIOCCDTR
X(TIOCCDTR)
#endif
#ifdef TIOCCINUSE
X(TIOCCINUSE)
#endif
#ifdef TIOCCMLB
X(TIOCCMLB)
#endif
#ifdef TIOCEXCL
X(TIOCEXCL)
#endif
#ifdef TIOCFLUSH
X(TIOCFLUSH)
#endif
#ifdef TIOCGETC
X(TIOCGETC)
#endif
#ifdef TIOCGETD
X(TIOCGETD)
#endif
#ifdef TIOCGETP
X(TIOCGETP)
#endif
#ifdef TIOCGLTC
X(TIOCGLTC)
#endif
#ifdef TIOCGPGRP
X(TIOCGPGRP)
#endif
#ifdef TIOCGWINSZ
X(TIOCGWINSZ)
#endif
#ifdef TIOCHPCL
X(TIOCHPCL)
#endif
#ifdef TIOCLBIC
X(TIOCLBIC)
#endif
#ifdef TIOCLBIS
X(TIOCLBIS)
#endif
#ifdef TIOCLGET
X(TIOCLGET)
#endif
#ifdef TIOCLSET
X(TIOCLSET)
#endif
#ifdef TIOCMASTER
X(TIOCMASTER)
#endif
#ifdef TIOCMBIC
X(TIOCMBIC)
#endif
#ifdef TIOCMBIS
X(TIOCMBIS)
#endif
#ifdef TIOCMGET
X(TIOCMGET)
#endif
#ifdef TIOCMODEM
X(TIOCMODEM)
#endif
#ifdef TIOCMODG
X(TIOCMODG)
#endif
#ifdef TIOCMODS
X(TIOCMODS)
#endif
#ifdef TIOCMSET
X(TIOCMSET)
#endif
#ifdef TIOCM_CAR
X(TIOCM_CAR)
#endif
#ifdef TIOCM_CD
X(TIOCM_CD)
#endif
#ifdef TIOCM_CTS
X(TIOCM_CTS)
#endif
#ifdef TIOCM_DSR
X(TIOCM_DSR)
#endif
#ifdef TIOCM_DTR
X(TIOCM_DTR)
#endif
#ifdef TIOCM_LE
X(TIOCM_LE)
#endif
#ifdef TIOCM_RI
X(TIOCM_RI)
#endif
#ifdef TIOCM_RNG
X(TIOCM_RNG)
#endif
#ifdef TIOCM_RTS
X(TIOCM_RTS)
#endif
#ifdef TIOCM_SR
X(TIOCM_SR)
#endif
#ifdef TIOCM_ST
X(TIOCM_ST)
#endif
#ifdef TIOCNCAR
X(TIOCNCAR)
#endif
#ifdef TIOCNMODEM
X(TIOCNMODEM)
#endif
#ifdef TIOCNOTTY
X(TIOCNOTTY)
#endif
#ifdef TIOCNXCL
X(TIOCNXCL)
#endif
#ifdef TIOCOUTQ
X(TIOCOUTQ)
#endif
#ifdef TIOCPKT
X(TIOCPKT)
#endif
#ifdef TIOCPKT_DATA
X(TIOCPKT_DATA)
#endif
#ifdef TIOCPKT_DOSTOP
X(TIOCPKT_DOSTOP)
#endif
#ifdef TIOCPKT_FLUSHREAD
X(TIOCPKT_FLUSHREAD)
#endif
#ifdef TIOCPKT_FLUSHWRITE
X(TIOCPKT_FLUSHWRITE)
#endif
#ifdef TIOCPKT_IOCTL
X(TIOCPKT_IOCTL)
#endif
#ifdef TIOCPKT_NOSTOP
X(TIOCPKT_NOSTOP)
#endif
#ifdef TIOCPKT_START
X(TIOCPKT_START)
#endif
#ifdef TIOCPKT_STOP
X(TIOCPKT_STOP)
#endif
#ifdef TIOCREMOTE
X(TIOCREMOTE)
#endif
#ifdef TIOCSBRK
X(TIOCSBRK)
#endif
#ifdef TIOCSDTR
X(TIOCSDTR)
#endif
#ifdef TIOCSETC
X(TIOCSETC)
#endif
#ifdef TIOCSETD
X(TIOCSETD)
#endif
#ifdef TIOCSETN
X(TIOCSETN)
#endif
#ifdef TIOCSETP
X(TIOCSETP)
#endif
#ifdef TIOCSINUSE
X(TIOCSINUSE)
#endif
#ifdef TIOCSLTC
X(TIOCSLTC)
#endif
#ifdef TIOCSMLB
X(TIOCSMLB)
#endif
#ifdef TIOCSPGRP
X(TIOCSPGRP)
#endif
#ifdef TIOCSTART
X(TIOCSTART)
#endif
#ifdef TIOCSTI
X(TIOCSTI)
#endif
#ifdef TIOCSTOP
X(TIOCSTOP)
#endif
#ifdef TIOCSWINSZ
X(TIOCSWINSZ)
#endif
#ifdef TIOCUCNTL
X(TIOCUCNTL)
#endif
#ifdef TIOCWONLINE
X(TIOCWONLINE)
#endif
#ifdef __cplusplus
}
#endif