# Posix detect program # (c) 2010 Andreas Rumpf # This program produces a C program that produces a Nim include file. # The Nim include file lists the values of each POSIX constant. # This is needed because POSIX is brain-dead: It only cares for C, any other # language is ignored. It would have been easier had they specified the # concrete values of the constants. Sigh. import os, strutils const cc = "gcc -o $# $#.c" cfile = """ /* Generated by detect.nim */ #include #include $1 int main() { FILE* f; f = fopen("$3_$4_consts.nim", "w+"); fputs("# Generated by detect.nim\nconst\n", f); $2 fclose(f); } """ type TTypeKind = enum cint, cshort, clong, cstring, pointer var hd = "" tl = "" proc myExec(cmd: string): bool = echo "CMD ", cmd return execShellCmd(cmd) == 0 proc header(s: string): bool = const testh = "testh" var f: TFile if open(f, addFileExt(testh, "c"), fmWrite): f.write("#include $1\n" % s) f.write("int main() { return 0; }\n") close(f) result = myExec(cc % [testh.addFileExt(ExeExt), testh]) removeFile(addFileExt(testh, "c")) if result: addf(hd, "#include $1\n", s) echo("Found: ", s) else: echo("Not found: ", s) proc main = const gen = "genconsts" var f: TFile if open(f, addFileExt(gen, "c"), fmWrite): f.write(cfile % [hd, tl, system.hostOS, system.hostCPU]) close(f) if not myExec(cc % [gen.addFileExt(ExeExt), gen]): quit(1) when defined(windows): if not myExec(gen.addFileExt(ExeExt)): quit(1) else: if not myExec("./" & gen): quit(1) #removeFile(addFileExt(gen, "c")) echo("Success") proc v(name: string, typ: TTypeKind=cint) = var n = if name[0] == '_': substr(name, 1) else: name var t = $typ case typ of pointer: addf(tl, "#ifdef $3\n fprintf(f, \" $1* = cast[$2](%p)\\n\", $3);\n#endif\n", n, t, name) of cstring: addf(tl, "#ifdef $3\n fprintf(f, \" $1* = $2(\\\"%s\\\")\\n\", $3);\n#endif\n", n, t, name) of clong: addf(tl, "#ifdef $3\n fprintf(f, \" $1* = $2(%ld)\\n\", $3);\n#endif\n", n, t, name) else: addf(tl, "#ifdef $3\n fprintf(f, \" $1* = $2(%d)\\n\", $3);\n#endif\n", n, t, name) if header(""): v("AIO_ALLDONE") v("AIO_CANCELED") v("AIO_NOTCANCELED") v("LIO_NOP") v("LIO_NOWAIT") v("LIO_READ") v("LIO_WAIT") v("LIO_WRITE") if header(""): v("RTLD_LAZY") v("RTLD_NOW") v("RTLD_GLOBAL") v("RTLD_LOCAL") if header(""): v("E2BIG") v("EACCES") v("EADDRINUSE") v("EADDRNOTAVAIL") v("EAFNOSUPPORT") v("EAGAIN") v("EALREADY") v("EBADF") v("EBADMSG") v("EBUSY") v("ECANCELED") v("ECHILD") v("ECONNABORTED") v("ECONNREFUSED") v("ECONNRESET") v("EDEADLK") v("EDESTADDRREQ") v("EDOM") v("EDQUOT") v("EEXIST") v("EFAULT") v("EFBIG") v("EHOSTUNREACH") v("EIDRM") v("EILSEQ") v("EINPROGRESS") v("EINTR") v("EINVAL") v("EIO") v("EISCONN") v("EISDIR") v("ELOOP") v("EMFILE") v("EMLINK") v("EMSGSIZE") v("EMULTIHOP") v("ENAMETOOLONG") v("ENETDOWN") v("ENETRESET") v("ENETUNREACH") v("ENFILE") v("ENOBUFS") v("ENODATA") v("ENODEV") v("ENOENT") v("ENOEXEC") v("ENOLCK") v("ENOLINK") v("ENOMEM") v("ENOMSG") v("ENOPROTOOPT") v("ENOSPC") v("ENOSR") v("ENOSTR") v("ENOSYS") v("ENOTCONN") v("ENOTDIR") v("ENOTEMPTY") v("ENOTSOCK") v("ENOTSUP") v("ENOTTY") v("ENXIO") v("EOPNOTSUPP") v("EOVERFLOW") v("EPERM") v("EPIPE") v("EPROTO") v("EPROTONOSUPPORT") v("EPROTOTYPE") v("ERANGE") v("EROFS") v("ESPIPE") v("ESRCH") v("ESTALE") v("ETIME") v("ETIMEDOUT") v("ETXTBSY") v("EWOULDBLOCK") v("EXDEV") if header(""): v("F_DUPFD") v("F_GETFD") v("F_SETFD") v("F_GETFL") v("F_SETFL") v("F_GETLK") v("F_SETLK") v("F_SETLKW") v("F_GETOWN") v("F_SETOWN") v("FD_CLOEXEC") v("F_RDLCK") v("F_UNLCK") v("F_WRLCK") v("O_CREAT") v("O_EXCL") v("O_NOCTTY") v("O_TRUNC") v("O_APPEND") v("O_DSYNC") v("O_NONBLOCK") v("O_RSYNC") v("O_SYNC") v("O_ACCMODE") v("O_RDONLY") v("O_RDWR") v("O_WRONLY") v("POSIX_FADV_NORMAL") v("POSIX_FADV_SEQUENTIAL") v("POSIX_FADV_RANDOM") v("POSIX_FADV_WILLNEED") v("POSIX_FADV_DONTNEED") v("POSIX_FADV_NOREUSE") if header(""): v("FE_DIVBYZERO") v("FE_INEXACT") v("FE_INVALID") v("FE_OVERFLOW") v("FE_UNDERFLOW") v("FE_ALL_EXCEPT") v("FE_DOWNWARD") v("FE_TONEAREST") v("FE_TOWARDZERO") v("FE_UPWARD") v("FE_DFL_ENV", pointer) if header(""): v("MM_HARD") v("MM_SOFT") v("MM_FIRM") v("MM_APPL") v("MM_UTIL") v("MM_OPSYS") v("MM_RECOVER") v("MM_NRECOV") v("MM_HALT") v("MM_ERROR") v("MM_WARNING") v("MM_INFO") v("MM_NOSEV") v("MM_PRINT") v("MM_CONSOLE") v("MM_OK") v("MM_NOTOK") v("MM_NOMSG") v("MM_NOCON") if header(""): v("FNM_NOMATCH") v("FNM_PATHNAME") v("FNM_PERIOD") v("FNM_NOESCAPE") v("FNM_NOSYS") if header(""): v("FTW_F") v("FTW_D") v("FTW_DNR") v("FTW_DP") v("FTW_NS") v("FTW_SL") v("FTW_SLN") v("FTW_PHYS") v("FTW_MOUNT") v("FTW_DEPTH") v("FTW_CHDIR") if header(""): v("GLOB_APPEND") v("GLOB_DOOFFS") v("GLOB_ERR") v("GLOB_MARK") v("GLOB_NOCHECK") v("GLOB_NOESCAPE") v("GLOB_NOSORT") v("GLOB_ABORTED") v("GLOB_NOMATCH") v("GLOB_NOSPACE") v("GLOB_NOSYS") if header(""): v("CODESET") v("D_T_FMT") v("D_FMT") v("T_FMT") v("T_FMT_AMPM") v("AM_STR") v("PM_STR") v("DAY_1") v("DAY_2") v("DAY_3") v("DAY_4") v("DAY_5") v("DAY_6") v("DAY_7") v("ABDAY_1") v("ABDAY_2") v("ABDAY_3") v("ABDAY_4") v("ABDAY_5") v("ABDAY_6") v("ABDAY_7") v("MON_1") v("MON_2") v("MON_3") v("MON_4") v("MON_5") v("MON_6") v("MON_7") v("MON_8") v("MON_9") v("MON_10") v("MON_11") v("MON_12") v("ABMON_1") v("ABMON_2") v("ABMON_3") v("ABMON_4") v("ABMON_5") v("ABMON_6") v("ABMON_7") v("ABMON_8") v("ABMON_9") v("ABMON_10") v("ABMON_11") v("ABMON_12") v("ERA") v("ERA_D_FMT") v("ERA_D_T_FMT") v("ERA_T_FMT") v("ALT_DIGITS") v("RADIXCHAR") v("THOUSEP") v("YESEXPR") v("NOEXPR") v("CRNCYSTR") if header(""): v("LC_ALL") #{.importc, header: .}: cint v("LC_COLLATE") #{.importc, header: "".}: cint v("LC_CTYPE") #{.importc, header: "".}: cint v("LC_MESSAGES") #{.importc, header: "".}: cint v("LC_MONETARY") #{.importc, header: "".}: cint v("LC_NUMERIC") #{.importc, header: "".}: cint v("LC_TIME") #{.importc, header: "".}: cint if header(""): v("PTHREAD_BARRIER_SERIAL_THREAD") v("PTHREAD_CANCEL_ASYNCHRONOUS") v("PTHREAD_CANCEL_ENABLE") v("PTHREAD_CANCEL_DEFERRED") v("PTHREAD_CANCEL_DISABLE") #v("PTHREAD_CANCELED") #v("PTHREAD_COND_INITIALIZER") v("PTHREAD_CREATE_DETACHED") v("PTHREAD_CREATE_JOINABLE") v("PTHREAD_EXPLICIT_SCHED") v("PTHREAD_INHERIT_SCHED") v("PTHREAD_MUTEX_DEFAULT") v("PTHREAD_MUTEX_ERRORCHECK") #v("PTHREAD_MUTEX_INITIALIZER") v("PTHREAD_MUTEX_NORMAL") v("PTHREAD_MUTEX_RECURSIVE") #{.importc, header: "".}: cint #v("PTHREAD_ONCE_INIT") #{.importc, header: "".}: cint v("PTHREAD_PRIO_INHERIT") #{.importc, header: "".}: cint v("PTHREAD_PRIO_NONE") #{.importc, header: "".}: cint v("PTHREAD_PRIO_PROTECT") #{.importc, header: "".}: cint v("PTHREAD_PROCESS_SHARED") #{.importc, header: "".}: cint v("PTHREAD_PROCESS_PRIVATE") #{.importc, header: "".}: cint v("PTHREAD_SCOPE_PROCESS") #{.importc, header: "".}: cint v("PTHREAD_SCOPE_SYSTEM") #{.importc, header: "".}: cint if header(""): v("_POSIX_ASYNC_IO") v("_POSIX_PRIO_IO") v("_POSIX_SYNC_IO") v("F_OK") v("R_OK") v("W_OK") v("X_OK") v("_CS_PATH") v("_CS_POSIX_V6_ILP32_OFF32_CFLAGS") v("_CS_POSIX_V6_ILP32_OFF32_LDFLAGS") v("_CS_POSIX_V6_ILP32_OFF32_LIBS") v("_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS") v("_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS") v("_CS_POSIX_V6_ILP32_OFFBIG_LIBS") v("_CS_POSIX_V6_LP64_OFF64_CFLAGS") v("_CS_POSIX_V6_LP64_OFF64_LDFLAGS") v("_CS_POSIX_V6_LP64_OFF64_LIBS") v("_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS") v("_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS") v("_CS_POSIX_V6_LPBIG_OFFBIG_LIBS") v("_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS") v("F_LOCK") v("F_TEST") #{.importc: "F_TEST", header: "".}: cint v("F_TLOCK") #{.importc: "F_TLOCK", header: "".}: cint v("F_ULOCK") #{.importc: "F_ULOCK", header: "".}: cint v("_PC_2_SYMLINKS") #{.importc: "_PC_2_SYMLINKS", header: "".}: cint v("_PC_ALLOC_SIZE_MIN") v("_PC_ASYNC_IO") #{.importc: "_PC_ASYNC_IO", header: "".}: cint v("_PC_CHOWN_RESTRICTED") v("_PC_FILESIZEBITS") #{.importc: "_PC_FILESIZEBITS", header: "".}: cint v("_PC_LINK_MAX") #{.importc: "_PC_LINK_MAX", header: "".}: cint v("_PC_MAX_CANON") #{.importc: "_PC_MAX_CANON", header: "".}: cint v("_PC_MAX_INPUT") #{.importc: "_PC_MAX_INPUT", header: "".}: cint v("_PC_NAME_MAX") #{.importc: "_PC_NAME_MAX", header: "".}: cint v("_PC_NO_TRUNC") #{.importc: "_PC_NO_TRUNC", header: "".}: cint v("_PC_PATH_MAX") #{.importc: "_PC_PATH_MAX", header: "".}: cint v("_PC_PIPE_BUF") #{.importc: "_PC_PIPE_BUF", header: "".}: cint v("_PC_PRIO_IO") #{.importc: "_PC_PRIO_IO", header: "".}: cint v("_PC_REC_INCR_XFER_SIZE") v("_PC_REC_MIN_XFER_SIZE") v("_PC_REC_XFER_ALIGN") v("_PC_SYMLINK_MAX") #{.importc: "_PC_SYMLINK_MAX", header: "".}: cint v("_PC_SYNC_IO") #{.importc: "_PC_SYNC_IO", header: "".}: cint v("_PC_VDISABLE") #{.importc: "_PC_VDISABLE", header: "".}: cint v("_SC_2_C_BIND") #{.importc: "_SC_2_C_BIND", header: "".}: cint v("_SC_2_C_DEV") #{.importc: "_SC_2_C_DEV", header: "".}: cint v("_SC_2_CHAR_TERM") #{.importc: "_SC_2_CHAR_TERM", header: "".}: cint v("_SC_2_FORT_DEV") #{.importc: "_SC_2_FORT_DEV", header: "".}: cint v("_SC_2_FORT_RUN") #{.importc: "_SC_2_FORT_RUN", header: "".}: cint v("_SC_2_LOCALEDEF") #{.importc: "_SC_2_LOCALEDEF", header: "".}: cint v("_SC_2_PBS") #{.importc: "_SC_2_PBS", header: "".}: cint v("_SC_2_PBS_ACCOUNTING") v("_SC_2_PBS_CHECKPOINT") v("_SC_2_PBS_LOCATE") #{.importc: "_SC_2_PBS_LOCATE", header: "".}: cint v("_SC_2_PBS_MESSAGE") #{.importc: "_SC_2_PBS_MESSAGE", header: "".}: cint v("_SC_2_PBS_TRACK") #{.importc: "_SC_2_PBS_TRACK", header: "".}: cint v("_SC_2_SW_DEV") #{.importc: "_SC_2_SW_DEV", header: "".}: cint v("_SC_2_UPE") #{.importc: "_SC_2_UPE", header: "".}: cint v("_SC_2_VERSION") #{.importc: "_SC_2_VERSION", header: "".}: cint v("_SC_ADVISORY_INFO") #{.importc: "_SC_ADVISORY_INFO", header: "".}: cint v("_SC_AIO_LISTIO_MAX") v("_SC_AIO_MAX") #{.importc: "_SC_AIO_MAX", header: "".}: cint v("_SC_AIO_PRIO_DELTA_MAX") v("_SC_ARG_MAX") #{.importc: "_SC_ARG_MAX", header: "".}: cint v("_SC_ASYNCHRONOUS_IO") v("_SC_ATEXIT_MAX") #{.importc: "_SC_ATEXIT_MAX", header: "".}: cint v("_SC_BARRIERS") #{.importc: "_SC_BARRIERS", header: "".}: cint v("_SC_BC_BASE_MAX") #{.importc: "_SC_BC_BASE_MAX", header: "".}: cint v("_SC_BC_DIM_MAX") #{.importc: "_SC_BC_DIM_MAX", header: "".}: cint v("_SC_BC_SCALE_MAX") #{.importc: "_SC_BC_SCALE_MAX", header: "".}: cint v("_SC_BC_STRING_MAX") #{.importc: "_SC_BC_STRING_MAX", header: "".}: cint v("_SC_CHILD_MAX") #{.importc: "_SC_CHILD_MAX", header: "".}: cint v("_SC_CLK_TCK") #{.importc: "_SC_CLK_TCK", header: "".}: cint v("_SC_CLOCK_SELECTION") v("_SC_COLL_WEIGHTS_MAX") v("_SC_CPUTIME") #{.importc: "_SC_CPUTIME", header: "".}: cint v("_SC_DELAYTIMER_MAX") v("_SC_EXPR_NEST_MAX") #{.importc: "_SC_EXPR_NEST_MAX", header: "".}: cint v("_SC_FSYNC") #{.importc: "_SC_FSYNC", header: "".}: cint v("_SC_GETGR_R_SIZE_MAX") v("_SC_GETPW_R_SIZE_MAX") v("_SC_HOST_NAME_MAX") #{.importc: "_SC_HOST_NAME_MAX", header: "".}: cint v("_SC_IOV_MAX") #{.importc: "_SC_IOV_MAX", header: "".}: cint v("_SC_IPV6") #{.importc: "_SC_IPV6", header: "".}: cint v("_SC_JOB_CONTROL") #{.importc: "_SC_JOB_CONTROL", header: "".}: cint v("_SC_LINE_MAX") #{.importc: "_SC_LINE_MAX", header: "".}: cint v("_SC_LOGIN_NAME_MAX") v("_SC_MAPPED_FILES") #{.importc: "_SC_MAPPED_FILES", header: "".}: cint v("_SC_MEMLOCK") #{.importc: "_SC_MEMLOCK", header: "".}: cint v("_SC_MEMLOCK_RANGE") #{.importc: "_SC_MEMLOCK_RANGE", header: "".}: cint v("_SC_MEMORY_PROTECTION") v("_SC_MESSAGE_PASSING") v("_SC_MONOTONIC_CLOCK") v("_SC_MQ_OPEN_MAX") #{.importc: "_SC_MQ_OPEN_MAX", header: "".}: cint v("_SC_MQ_PRIO_MAX") #{.importc: "_SC_MQ_PRIO_MAX", header: "".}: cint v("_SC_NGROUPS_MAX") #{.importc: "_SC_NGROUPS_MAX", header: "".}: cint v("_SC_OPEN_MAX") #{.importc: "_SC_OPEN_MAX", header: "".}: cint v("_SC_PAGE_SIZE") #{.importc: "_SC_PAGE_SIZE", header: "".}: cint v("_SC_PRIORITIZED_IO") v("_SC_PRIORITY_SCHEDULING") v("_SC_RAW_SOCKETS") #{.importc: "_SC_RAW_SOCKETS", header: "".}: cint v("_SC_RE_DUP_MAX") #{.importc: "_SC_RE_DUP_MAX", header: "".}: cint v("_SC_READER_WRITER_LOCKS") v("_SC_REALTIME_SIGNALS") v("_SC_REGEXP") #{.importc: "_SC_REGEXP", header: "".}: cint v("_SC_RTSIG_MAX") #{.importc: "_SC_RTSIG_MAX", header: "".}: cint v("_SC_SAVED_IDS") #{.importc: "_SC_SAVED_IDS", header: "".}: cint v("_SC_SEM_NSEMS_MAX") #{.importc: "_SC_SEM_NSEMS_MAX", header: "".}: cint v("_SC_SEM_VALUE_MAX") #{.importc: "_SC_SEM_VALUE_MAX", header: "".}: cint v("_SC_SEMAPHORES") #{.importc: "_SC_SEMAPHORES", header: "".}: cint v("_SC_SHARED_MEMORY_OBJECTS") v("_SC_SHELL") #{.importc: "_SC_SHELL", header: "".}: cint v("_SC_SIGQUEUE_MAX") #{.importc: "_SC_SIGQUEUE_MAX", header: "".}: cint v("_SC_SPAWN") #{.importc: "_SC_SPAWN", header: "".}: cint v("_SC_SPIN_LOCKS") #{.importc: "_SC_SPIN_LOCKS", header: "".}: cint v("_SC_SPORADIC_SERVER") v("_SC_SS_REPL_MAX") #{.importc: "_SC_SS_REPL_MAX", header: "".}: cint v("_SC_STREAM_MAX") #{.importc: "_SC_STREAM_MAX", header: "".}: cint v("_SC_SYMLOOP_MAX") #{.importc: "_SC_SYMLOOP_MAX", header: "".}: cint v("_SC_SYNCHRONIZED_IO") v("_SC_THREAD_ATTR_STACKADDR") v("_SC_THREAD_ATTR_STACKSIZE") v("_SC_THREAD_CPUTIME") v("_SC_THREAD_DESTRUCTOR_ITERATIONS") v("_SC_THREAD_KEYS_MAX") v("_SC_THREAD_PRIO_INHERIT") v("_SC_THREAD_PRIO_PROTECT") v("_SC_THREAD_PRIORITY_SCHEDULING") v("_SC_THREAD_PROCESS_SHARED") v("_SC_THREAD_SAFE_FUNCTIONS") v("_SC_THREAD_SPORADIC_SERVER") v("_SC_THREAD_STACK_MIN") v("_SC_THREAD_THREADS_MAX") v("_SC_THREADS") #{.importc: "_SC_THREADS", header: "".}: cint v("_SC_TIMEOUTS") #{.importc: "_SC_TIMEOUTS", header: "".}: cint v("_SC_TIMER_MAX") #{.importc: "_SC_TIMER_MAX", header: "".}: cint v("_SC_TIMERS") #{.importc: "_SC_TIMERS", header: "".}: cint v("_SC_TRACE") #{.importc: "_SC_TRACE", header: "".}: cint v("_SC_TRACE_EVENT_FILTER") v("_SC_TRACE_EVENT_NAME_MAX") v("_SC_TRACE_INHERIT") #{.importc: "_SC_TRACE_INHERIT", header: "".}: cint v("_SC_TRACE_LOG") #{.importc: "_SC_TRACE_LOG", header: "".}: cint v("_SC_TRACE_NAME_MAX") v("_SC_TRACE_SYS_MAX") #{.importc: "_SC_TRACE_SYS_MAX", header: "".}: cint v("_SC_TRACE_USER_EVENT_MAX") v("_SC_TTY_NAME_MAX") #{.importc: "_SC_TTY_NAME_MAX", header: "".}: cint v("_SC_TYPED_MEMORY_OBJECTS") v("_SC_TZNAME_MAX") #{.importc: "_SC_TZNAME_MAX", header: "".}: cint v("_SC_V6_ILP32_OFF32") v("_SC_V6_ILP32_OFFBIG") v("_SC_V6_LP64_OFF64") #{.importc: "_SC_V6_LP64_OFF64", header: "".}: cint v("_SC_V6_LPBIG_OFFBIG") v("_SC_VERSION") #{.importc: "_SC_VERSION", header: "".}: cint v("_SC_XBS5_ILP32_OFF32") v("_SC_XBS5_ILP32_OFFBIG") v("_SC_XBS5_LP64_OFF64") v("_SC_XBS5_LPBIG_OFFBIG") v("_SC_XOPEN_CRYPT") #{.importc: "_SC_XOPEN_CRYPT", header: "".}: cint v("_SC_XOPEN_ENH_I18N") v("_SC_XOPEN_LEGACY") #{.importc: "_SC_XOPEN_LEGACY", header: "".}: cint v("_SC_XOPEN_REALTIME") v("_SC_XOPEN_REALTIME_THREADS") v("_SC_XOPEN_SHM") #{.importc: "_SC_XOPEN_SHM", header: "".}: cint v("_SC_XOPEN_STREAMS") #{.importc: "_SC_XOPEN_STREAMS", header: "".}: cint v("_SC_XOPEN_UNIX") #{.importc: "_SC_XOPEN_UNIX", header: "".}: cint v("_SC_XOPEN_VERSION") #{.importc: "_SC_XOPEN_VERSION", header: "".}: cint v("SEEK_SET") #{.importc, header: "".}: cint v("SEEK_CUR") #{.importc, header: "".}: cint v("SEEK_END") #{.importc, header: "".}: cint if header(""): v("SEM_FAILED", pointer) if header(""): v("IPC_CREAT") #{.importc, header: .}: cint v("IPC_EXCL") #{.importc, header: "".}: cint v("IPC_NOWAIT") #{.importc, header: "".}: cint v("IPC_PRIVATE") #{.importc, header: "".}: cint v("IPC_RMID") #{.importc, header: "".}: cint v("IPC_SET") #{.importc, header: "".}: cint v("IPC_STAT") #{.importc, header: "".}: cint if header(""): v("S_IFMT") #{.importc, header: .}: cint v("S_IFBLK") #{.importc, header: "".}: cint v("S_IFCHR") #{.importc, header: "".}: cint v("S_IFIFO") #{.importc, header: "".}: cint v("S_IFREG") #{.importc, header: "".}: cint v("S_IFDIR") #{.importc, header: "".}: cint v("S_IFLNK") #{.importc, header: "".}: cint v("S_IFSOCK") #{.importc, header: "".}: cint v("S_IRWXU") #{.importc, header: "".}: cint v("S_IRUSR") #{.importc, header: "".}: cint v("S_IWUSR") #{.importc, header: "".}: cint v("S_IXUSR") #{.importc, header: "".}: cint v("S_IRWXG") #{.importc, header: "".}: cint v("S_IRGRP") #{.importc, header: "".}: cint v("S_IWGRP") #{.importc, header: "".}: cint v("S_IXGRP") #{.importc, header: "".}: cint v("S_IRWXO") #{.importc, header: "".}: cint v("S_IROTH") #{.importc, header: "".}: cint v("S_IWOTH") #{.importc, header: "".}: cint v("S_IXOTH") #{.importc, header: "".}: cint v("S_ISUID") #{.importc, header: "".}: cint v("S_ISGID") #{.importc, header: "".}: cint v("S_ISVTX") #{.importc, header: "".}: cint if header(""): v("ST_RDONLY") #{.importc, header: .}: cint v("ST_NOSUID") #{.importc, header: "".}: cint if header(""): v("PROT_READ") #{.importc, header: .}: cint v("PROT_WRITE") #{.importc, header: "".}: cint v("PROT_EXEC") #{.importc, header: "".}: cint v("PROT_NONE") #{.importc, header: "".}: cint v("MAP_SHARED") #{.importc, header: "".}: cint v("MAP_PRIVATE") #{.importc, header: "".}: cint v("MAP_FIXED") #{.importc, header: "".}: cint v("MS_ASYNC") #{.importc, header: "".}: cint v("MS_SYNC") #{.importc, header: "".}: cint v("MS_INVALIDATE") #{.importc, header: "".}: cint v("MCL_CURRENT") #{.importc, header: "".}: cint v("MCL_FUTURE") #{.importc, header: "".}: cint v("MAP_FAILED", pointer) v("POSIX_MADV_NORMAL") #{.importc, header: "".}: cint v("POSIX_MADV_SEQUENTIAL") #{.importc, header: "".}: cint v("POSIX_MADV_RANDOM") #{.importc, header: "".}: cint v("POSIX_MADV_WILLNEED") #{.importc, header: "".}: cint v("POSIX_MADV_DONTNEED") #{.importc, header: "".}: cint v("POSIX_TYPED_MEM_ALLOCATE") #{.importc, header: "".}: cint v("POSIX_TYPED_MEM_ALLOCATE_CONTIG") #{.importc, header: "".}: cint v("POSIX_TYPED_MEM_MAP_ALLOCATABLE") #{.importc, header: "".}: cint if header(""): v("CLOCKS_PER_SEC", clong) v("CLOCK_PROCESS_CPUTIME_ID") v("CLOCK_THREAD_CPUTIME_ID") v("CLOCK_REALTIME") v("TIMER_ABSTIME") v("CLOCK_MONOTONIC") if header(""): v("WNOHANG") #{.importc, header: .}: cint v("WUNTRACED") #{.importc, header: "".}: cint #v("WEXITSTATUS") #v("WIFCONTINUED") #v("WIFEXITED") #v("WIFSIGNALED") #v("WIFSTOPPED") #v("WSTOPSIG") #v("WTERMSIG") v("WEXITED") #{.importc, header: "".}: cint v("WSTOPPED") #{.importc, header: "".}: cint v("WCONTINUED") #{.importc, header: "".}: cint v("WNOWAIT") #{.importc, header: "".}: cint v("P_ALL") #{.importc, header: "".}: cint v("P_PID") #{.importc, header: "".}: cint v("P_PGID") #{.importc, header: "".}: cint if header(""): v("SIGEV_NONE") #{.importc, header: "".}: cint v("SIGEV_SIGNAL") #{.importc, header: "".}: cint v("SIGEV_THREAD") #{.importc, header: "".}: cint v("SIGABRT") #{.importc, header: "".}: cint v("SIGALRM") #{.importc, header: "".}: cint v("SIGBUS") #{.importc, header: "".}: cint v("SIGCHLD") #{.importc, header: "".}: cint v("SIGCONT") #{.importc, header: "".}: cint v("SIGFPE") #{.importc, header: "".}: cint v("SIGHUP") #{.importc, header: "".}: cint v("SIGILL") #{.importc, header: "".}: cint v("SIGINT") #{.importc, header: "".}: cint v("SIGKILL") #{.importc, header: "".}: cint v("SIGPIPE") #{.importc, header: "".}: cint v("SIGQUIT") #{.importc, header: "".}: cint v("SIGSEGV") #{.importc, header: "".}: cint v("SIGSTOP") #{.importc, header: "".}: cint v("SIGTERM") #{.importc, header: "".}: cint v("SIGTSTP") #{.importc, header: "".}: cint v("SIGTTIN") #{.importc, header: "".}: cint v("SIGTTOU") #{.importc, header: "".}: cint v("SIGUSR1") #{.importc, header: "".}: cint v("SIGUSR2") #{.importc, header: "".}: cint v("SIGPOLL") #{.importc, header: "".}: cint v("SIGPROF") #{.importc, header: "".}: cint v("SIGSYS") #{.importc, header: "".}: cint v("SIGTRAP") #{.importc, header: "".}: cint v("SIGURG") #{.importc, header: "".}: cint v("SIGVTALRM") #{.importc, header: "".}: cint v("SIGXCPU") #{.importc, header: "".}: cint v("SIGXFSZ") #{.importc, header: "".}: cint v("SA_NOCLDSTOP") #{.importc, header: "".}: cint v("SIG_BLOCK") #{.importc, header: "".}: cint v("SIG_UNBLOCK") #{.importc, header: "".}: cint v("SIG_SETMASK") #{.importc, header: "".}: cint v("SA_ONSTACK") #{.importc, header: "".}: cint v("SA_RESETHAND") #{.importc, header: "".}: cint v("SA_RESTART") #{.importc, header: "".}: cint v("SA_SIGINFO") #{.importc, header: "".}: cint v("SA_NOCLDWAIT") #{.importc, header: "".}: cint v("SA_NODEFER") #{.importc, header: "".}: cint v("SS_ONSTACK") #{.importc, header: "".}: cint v("SS_DISABLE") #{.importc, header: "".}: cint v("MINSIGSTKSZ") #{.importc, header: "".}: cint v("SIGSTKSZ") #{.importc, header: "".}: cint if header(""): v("NL_SETD") #{.importc, header: .}: cint v("NL_CAT_LOCALE") #{.importc, header: "".}: cint if header(""): v("SCHED_FIFO") v("SCHED_RR") v("SCHED_SPORADIC") v("SCHED_OTHER") if header(""): v("FD_SETSIZE") if header(""): v("IF_NAMESIZE") if header(""): v("SCM_RIGHTS") #{.importc, header: .}: cint v("SOCK_DGRAM") #{.importc, header: "".}: cint v("SOCK_RAW") #{.importc, header: "".}: cint v("SOCK_SEQPACKET") #{.importc, header: "".}: cint v("SOCK_STREAM") #{.importc, header: "".}: cint v("SOL_SOCKET") #{.importc, header: "".}: cint v("SO_ACCEPTCONN") #{.importc, header: "".}: cint v("SO_BROADCAST") #{.importc, header: "".}: cint v("SO_DEBUG") #{.importc, header: "".}: cint v("SO_DONTROUTE") #{.importc, header: "".}: cint v("SO_ERROR") #{.importc, header: "".}: cint v("SO_KEEPALIVE") #{.importc, header: "".}: cint v("SO_LINGER") #{.importc, header: "".}: cint v("SO_OOBINLINE") #{.importc, header: "".}: cint v("SO_RCVBUF") #{.importc, header: "".}: cint v("SO_RCVLOWAT") #{.importc, header: "".}: cint v("SO_RCVTIMEO") #{.importc, header: "".}: cint v("SO_REUSEADDR") #{.importc, header: "".}: cint v("SO_SNDBUF") #{.importc, header: "".}: cint v("SO_SNDLOWAT") #{.importc, header: "".}: cint v("SO_SNDTIMEO") #{.importc, header: "".}: cint v("SO_TYPE") #{.importc, header: "".}: cint v("SOMAXCONN") #{.importc, header: "".}: cint v("MSG_CTRUNC") #{.importc, header: "".}: cint v("MSG_DONTROUTE") #{.importc, header: "".}: cint v("MSG_EOR") #{.importc, header: "".}: cint v("MSG_OOB") #{.importc, header: "".}: cint v("MSG_PEEK") #{.importc, header: "".}: cint v("MSG_TRUNC") #{.importc, header: "".}: cint v("MSG_WAITALL") #{.importc, header: "".}: cint v("AF_INET") #{.importc, header: "".}: cint v("AF_INET6") #{.importc, header: "".}: cint v("AF_UNIX") #{.importc, header: "".}: cint v("AF_UNSPEC") #{.importc, header: "".}: cint v("SHUT_RD") #{.importc, header: "".}: cint v("SHUT_RDWR") #{.importc, header: "".}: cint v("SHUT_WR") #{.importc, header: "".}: cint if header(""): v("IPPROTO_IP") #{.importc, header: .}: cint v("IPPROTO_IPV6") #{.importc, header: "".}: cint v("IPPROTO_ICMP") #{.importc, header: "".}: cint v("IPPROTO_RAW") #{.importc, header: "".}: cint v("IPPROTO_TCP") #{.importc, header: "".}: cint v("IPPROTO_UDP") #{.importc, header: "".}: cint v("INADDR_ANY") #{.importc, header: "".}: TinAddrScalar v("INADDR_BROADCAST") #{.importc, header: "".}: TinAddrScalar v("INET_ADDRSTRLEN") #{.importc, header: "".}: cint v("IPV6_JOIN_GROUP") #{.importc, header: "".}: cint v("IPV6_LEAVE_GROUP") #{.importc, header: "".}: cint v("IPV6_MULTICAST_HOPS") #{.importc, header: "".}: cint v("IPV6_MULTICAST_IF") #{.importc, header: "".}: cint v("IPV6_MULTICAST_LOOP") #{.importc, header: "".}: cint v("IPV6_UNICAST_HOPS") #{.importc, header: "".}: cint v("IPV6_V6ONLY") #{.importc, header: "".}: cint v("TCP_NODELAY") #{.importc, header: "".}: cint if header(""): v("IPPORT_RESERVED") v("HOST_NOT_FOUND") v("NO_DATA") v("NO_RECOVERY") v("TRY_AGAIN") v("AI_PASSIVE") v("AI_CANONNAME") v("AI_NUMERICHOST") v("AI_NUMERICSERV") v("AI_V4MAPPED") v("AI_ALL") v("AI_ADDRCONFIG") v("NI_NOFQDN") v("NI_NUMERICHOST") v("NI_NAMEREQD") v("NI_NUMERICSERV") v("NI_NUMERICSCOPE") v("NI_DGRAM") v("EAI_AGAIN") v("EAI_BADFLAGS") v("EAI_FAIL") v("EAI_FAMILY") v("EAI_MEMORY") v("EAI_NONAME") v("EAI_SERVICE") v("EAI_SOCKTYPE") v("EAI_SYSTEM") v("EAI_OVERFLOW") if header(""): v("POLLIN", cshort) v("POLLRDNORM", cshort) v("POLLRDBAND", cshort) v("POLLPRI", cshort) v("POLLOUT", cshort) v("POLLWRNORM", cshort) v("POLLWRBAND", cshort) v("POLLERR", cshort) v("POLLHUP", cshort) v("POLLNVAL", cshort) if header(""): v("POSIX_SPAWN_RESETIDS") v("POSIX_SPAWN_SETPGROUP") v("POSIX_SPAWN_SETSCHEDPARAM") v("POSIX_SPAWN_SETSCHEDULER") v("POSIX_SPAWN_SETSIGDEF") v("POSIX_SPAWN_SETSIGMASK") if header(""): v "_IOFBF" v "_IONBF" main()