0.9.0.6:
[sbcl.git] / tools-for-build / grovel-headers.c
index 2254aa3..cf02e27 100644 (file)
 #include <fcntl.h>
 #include <unistd.h>
 #include <signal.h>
+#include <errno.h>
+#ifdef __APPLE_CC__
+  #include "../src/runtime/ppc-darwin-dlshim.h"
+  #include "../src/runtime/ppc-darwin-langinfo.h"
+#else
+  #include <dlfcn.h>
+  #include <langinfo.h>
+#endif
 
 #include "genesis/config.h"
 
@@ -41,7 +49,15 @@ defconstant(char* lisp_name, long unix_number)
           lisp_name, unix_number, unix_number);
 }
 
-#define DEFSIGNAL(name) defconstant(#name, name)
+void deferrno(char* lisp_name, long unix_number)
+{
+    defconstant(lisp_name, unix_number);
+}
+
+void defsignal(char* lisp_name, long unix_number)
+{
+    defconstant(lisp_name, unix_number);
+}
 
 int
 main(int argc, char *argv[])
@@ -55,12 +71,23 @@ main(int argc, char *argv[])
     /* don't need no steenking hand-editing */
     printf(
 ";;;; This is an automatically generated file, please do not hand-edit it.\n\
-;;;; See the program \"grovel_headers.c\".\n\
+;;;; See the program \"grovel-headers.c\".\n\
 \n\
 ");
 
+    printf("(in-package \"SB!ALIEN\")\n\n");
+
+    printf (";;;flags for dlopen()\n");
+    
+    defconstant ("rtld-lazy", RTLD_LAZY);
+    defconstant ("rtld-now", RTLD_NOW);
+    defconstant ("rtld-global", RTLD_GLOBAL);
+    
     printf("(in-package \"SB!UNIX\")\n\n");
 
+    printf(";;; langinfo\n");
+    defconstant("codeset", CODESET);
+
     printf(";;; types, types, types\n");
     DEFTYPE("clock-t", clock_t);
     DEFTYPE("dev-t",   dev_t);
@@ -74,7 +101,7 @@ main(int argc, char *argv[])
     DEFTYPE("uid-t",   uid_t);
     printf("\n");
 
-    printf(";;; fcntl.h (or unistd.h on OpenBSD)\n");
+    printf(";;; fcntl.h (or unistd.h on OpenBSD and NetBSD)\n");
     defconstant("r_ok", R_OK);
     defconstant("w_ok", W_OK);
     defconstant("x_ok", X_OK);
@@ -104,6 +131,15 @@ main(int argc, char *argv[])
     defconstant("s-ifsock", S_IFSOCK);
     printf("\n");
 
+    printf(";;; error numbers\n");
+    deferrno("enoent", ENOENT);
+    deferrno("eintr", EINTR);
+    deferrno("eio", EIO);
+    deferrno("eexist", EEXIST);
+    deferrno("espipe", ESPIPE);
+    deferrno("ewouldblock", EWOULDBLOCK);
+    printf("\n");
+
     printf(";;; for wait3(2) in run-program.lisp\n");
     defconstant("wnohang", WNOHANG);
     defconstant("wuntraced", WUNTRACED);
@@ -145,52 +181,47 @@ main(int argc, char *argv[])
     printf("\n");
 
     printf(";;; signals\n");
-    DEFSIGNAL(SIGALRM);
-    DEFSIGNAL(SIGBUS);
-    DEFSIGNAL(SIGCHLD);
-    DEFSIGNAL(SIGCONT);
-/* FIXME: Maybe #ifdef SIGEMT would be a smarter conditional? */
-#if (!(defined LISP_FEATURE_LINUX) || !((defined LISP_FEATURE_PPC) || (defined LISP_FEATURE_X86)))
-    DEFSIGNAL(SIGEMT);
+    defsignal("sigalrm", SIGALRM);
+    defsignal("sigbus", SIGBUS);
+    defsignal("sigchld", SIGCHLD);
+    defsignal("sigcont", SIGCONT);
+#ifdef SIGEMT
+    defsignal("sigemt", SIGEMT);
 #endif
-    DEFSIGNAL(SIGFPE);
-    DEFSIGNAL(SIGHUP);
-    DEFSIGNAL(SIGILL);
-    DEFSIGNAL(SIGINT);
-    DEFSIGNAL(SIGIO);
-    DEFSIGNAL(SIGIOT);
-    DEFSIGNAL(SIGKILL);
-    DEFSIGNAL(SIGPIPE);
-    DEFSIGNAL(SIGPROF);
-    DEFSIGNAL(SIGQUIT);
-    DEFSIGNAL(SIGSEGV);
+    defsignal("sigfpe", SIGFPE);
+    defsignal("sighup", SIGHUP);
+    defsignal("sigill", SIGILL);
+    defsignal("sigint", SIGINT);
+    defsignal("sigio", SIGIO);
+    defsignal("sigiot", SIGIOT);
+    defsignal("sigkill", SIGKILL);
+    defsignal("sigpipe", SIGPIPE);
+    defsignal("sigprof", SIGPROF);
+    defsignal("sigquit", SIGQUIT);
+    defsignal("sigsegv", SIGSEGV);
 #if ((defined LISP_FEATURE_LINUX) && (defined LISP_FEATURE_X86))
-    DEFSIGNAL(SIGSTKFLT);
+    defsignal("sigstkflt", SIGSTKFLT);
 #endif
-    DEFSIGNAL(SIGSTOP);
+    defsignal("sigstop", SIGSTOP);
 #if (!((defined LISP_FEATURE_LINUX) && (defined LISP_FEATURE_X86))) 
-    DEFSIGNAL(SIGSYS);
+    defsignal("sigsys", SIGSYS);
 #endif
-    DEFSIGNAL(SIGTERM);
-    DEFSIGNAL(SIGTRAP);
-    DEFSIGNAL(SIGTSTP);
-    DEFSIGNAL(SIGTTIN);
-    DEFSIGNAL(SIGTTOU);
-    DEFSIGNAL(SIGURG);
-    DEFSIGNAL(SIGUSR1);
-    DEFSIGNAL(SIGUSR2);
-    DEFSIGNAL(SIGVTALRM);
+    defsignal("sigterm", SIGTERM);
+    defsignal("sigtrap", SIGTRAP);
+    defsignal("sigtstp", SIGTSTP);
+    defsignal("sigttin", SIGTTIN);
+    defsignal("sigttou", SIGTTOU);
+    defsignal("sigurg", SIGURG);
+    defsignal("sigusr1", SIGUSR1);
+    defsignal("sigusr2", SIGUSR2);
+    defsignal("sigvtalrm", SIGVTALRM);
 #ifdef LISP_FEATURE_SUNOS
-    DEFSIGNAL(SIGWAITING);
+    defsignal("sigwaiting", SIGWAITING);
 #endif
-    DEFSIGNAL(SIGWINCH);
+    defsignal("sigwinch", SIGWINCH);
 #ifndef LISP_FEATURE_HPUX
-    DEFSIGNAL(SIGXCPU);
-    DEFSIGNAL(SIGXFSZ);
-#endif
-#ifdef LISP_FEATURE_SB_THREAD
-    /* FIXME OAOOM alert: this information is duplicated in linux-os.h */
-    defconstant("sig-dequeue",SIGRTMIN+2);
+    defsignal("sigxcpu", SIGXCPU);
+    defsignal("sigxfsz", SIGXFSZ);
 #endif
     return 0;
 }