]> git.pond.sub.org Git - empserver/commitdiff
(EMPTH_LWP, EMPTH_POSIX, EMPTH_W32): Define in config.h instead of
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 28 Dec 2005 14:27:15 +0000 (14:27 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 28 Dec 2005 14:27:15 +0000 (14:27 +0000)
compiler command line.  Don't bother to conditionalize code in .c
files that are only compiled when their thread package is used.

(_EMPTH_LWP, EMPTH_LWP, _EMPTH_POSIX, EMPTH_POSIX, _EMPTH_WIN32)
(EMPTH_W32): Identifiers beginning with an underscore and an uppercase
letter are reserved for any use.  Rename.

14 files changed:
GNUmakefile.in
Make.mk
configure.ac
include/empthread.h
include/misc.h
src/lib/empthread/lwp.c
src/lib/empthread/ntthread.c
src/lib/empthread/pthread.c
src/lib/lwp/arch.c
src/lib/lwp/lwp.c
src/lib/lwp/queue.c
src/lib/lwp/sel.c
src/lib/lwp/sem.c
src/lib/lwp/status.c

index e2d4523e8a906307be0e7cc0764dffa885dba699..d5adf4d5278880ba4dd4d1165d8eeb7b01096a33 100644 (file)
@@ -44,7 +44,7 @@ LDLIBS := @LIBS@
 empthread := @empthread@
 ifeq ($(empthread),POSIX)
 CC := @PTHREAD_CC@
-CFLAGS := $(CFLAGS) @PTHREAD_CFLAGS@ -D_EMPTH_POSIX=1
+CFLAGS := $(CFLAGS) @PTHREAD_CFLAGS@
 LDFLAGS := $(LDFLAGS) @PTHREAD_CFLAGS@
 LDLIBS := @PTHREAD_LIBS@ $(LDLIBS)
 endif
diff --git a/Make.mk b/Make.mk
index b4040bc8cacd5f5100e3a39fadec8b40f92a1ddd..24b6b7854cfbee6989aca3835462012a8ffae45d 100644 (file)
--- a/Make.mk
+++ b/Make.mk
@@ -74,12 +74,17 @@ subjects.html := $(addprefix info.html/, $(addsuffix .html, $(subjects)))
 topics.html := $(addprefix info.html/, $(addsuffix .html, $(topics)))
 info.html := $(addprefix info.html/, $(addsuffix .html, $(info)))
 
+ifeq ($(empthread),LWP)
+empth_obj := src/lib/empthread/lwp.o
+empth_lib := lib/liblwp.a
+endif
 ifeq ($(empthread),POSIX)
 empth_obj := src/lib/empthread/pthread.o
 empth_lib :=
-else
-empth_obj := src/lib/empthread/lwp.o
-empth_lib := lib/liblwp.a
+endif
+ifeq ($(empthread),Windows)
+empth_obj := src/lib/empthread/ntthread.o
+empth_lib :=
 endif
 
 # Abbreviations
index 370136313caee78b997099a3053962a5edf23862..d3cd103d62fbe0b13a65e257d827ed5f8ff05dfe 100644 (file)
@@ -99,6 +99,7 @@ AC_ARG_WITH([pthread],
                           [use POSIX threads]))
 
 # Select thread package
+# TODO Windows
 case "$ac_cv_func_makecontext$acx_pthread_ok" in
 yesyes)
     if test -z "$with_pthread" || test "$with_pthread" = no; then
@@ -116,6 +117,11 @@ yes*)
 esac
 AC_SUBST(empthread)
 AC_MSG_NOTICE([Using $empthread threads])
+case $empthread in
+LWP)   AC_DEFINE([EMPTH_LWP], 1, [Define to use LWP threads]) ;;
+POSIX) AC_DEFINE([EMPTH_POSIX], 1, [Define to use POSIX threads]) ;;
+Windows) AC_DEFINE([EMPTH_W32], 1, [Define to use Windows threads]) ;;
+esac
 
 op=
 if test "$with_pthread" = no; then
index 8fee0f555f5a0f42228bb3205837f64158aa8117..916ff23f498c2cc08224a852bc2d84f49788c8db 100644 (file)
 #ifndef _EMTHREAD_H_
 #define _EMTHREAD_H_
 
-#include "misc.h"
-
-#if defined(_WIN32)
-#undef _EMPTH_LWP
-#undef _EMPTH_POSIX
-#define _EMPTH_WIN32
-#endif
-
-#ifdef _EMPTH_LWP
+#ifdef EMPTH_LWP
 #include "lwp.h"
 
 /* Abstract data types */
@@ -77,9 +69,9 @@ typedef struct lwpSem empth_sem_t;
 /* Request stack checking */
 #define EMPTH_STACKCHECK  LWP_STACKCHECK
 
-#endif /* _EMPTH_LWP */
+#endif /* EMPTH_LWP */
 
-#ifdef _EMPTH_POSIX
+#ifdef EMPTH_POSIX
 #include <pthread.h>
 #define EMPTH_FD_READ   0x1
 #define EMPTH_FD_WRITE  0x2
@@ -90,9 +82,9 @@ typedef struct lwpSem empth_sem_t;
 typedef struct empth_t empth_t;
 typedef struct empth_sem_t empth_sem_t;
 
-#endif /* _EMPTH_POSIX */
+#endif /* EMPTH_POSIX */
 
-#if defined(_EMPTH_WIN32)
+#ifdef EMPTH_W32
 /* The Windows NT Threads */
 #define EMPTH_FD_READ   0x1
 #define EMPTH_FD_WRITE  0x2
@@ -104,7 +96,7 @@ typedef struct loc_Thread_t empth_t;
 typedef struct loc_Sem_t empth_sem_t;
 
 void empth_request_shutdown(void);
-#endif /* _EMPTH_WIN32 */
+#endif /* EMPTH_W32 */
 
 /*
  * Initialize thread package.
index 9cf0da1e70860350fdb932f90775543d24d4a720..241ca33110e8dde14bb03dbbd77e44b2201d55ab 100644 (file)
@@ -99,11 +99,6 @@ struct mob_acc_globals {
 
 typedef u_char natid;          /* NSC_NATID must match this */
 
-#if !defined (_EMPTH_LWP) && !defined (_EMPTH_POSIX)
-#define _EMPTH_LWP     1
-#endif
-
-
 #if !defined(aix) && !defined(sgi)
 typedef char s_char;           /* change to signed char for aix */
 #else
index 3b0fe65ca441deac1f5b8a6ee22f18273463fa5f..f6746520e96e05f06c9f8def7288872febbcc0c9 100644 (file)
@@ -37,8 +37,6 @@
 #include "prototypes.h"
 #include "empthread.h"
 
-#ifdef _EMPTH_LWP
-
 /* The thread `created' by lwpInitSystem() */
 static empth_t *empth_main;
 
@@ -134,5 +132,3 @@ empth_sem_wait(empth_sem_t *sm)
 {
     lwpWait(sm);
 }
-
-#endif
index 155ea520f0f067ced23a738e630a66dea1c85747..a53ab6c95f2b7735c575a9591e41a49a5c1b3128 100644 (file)
@@ -54,7 +54,6 @@
 #include "empthread.h"
 #include "prototypes.h"
 
-#if defined(_WIN32) && defined(_EMPTH_WIN32)
 #define WIN32
 #include <winsock2.h>
 #undef NS_ALL
@@ -683,5 +682,3 @@ empth_sem_wait(empth_sem_t *pSem)
 
     loc_RunThisThread();
 }
-
-#endif /* _WIN32 */
index 0f7614c60d9e066c15df91331d2bcb9cabd89452..8ccea93e647567b10776dcaaed0f34a9a733c2b3 100644 (file)
@@ -51,8 +51,6 @@
 
 #include <stdarg.h>
 
-#ifdef _EMPTH_POSIX
-
 #define EMPTH_KILLED  1
 
 struct empth_t {
@@ -454,5 +452,3 @@ empth_sem_wait(empth_sem_t *sm)
     } else
        pthread_mutex_unlock(&sm->mtx_update);
 }
-
-#endif
index fce4d81e3464c22ea6247ccb686951e64f1d34d5..9c0ee6c495d32977e1a14c1e3e5d7ad48618e26d 100644 (file)
@@ -38,8 +38,6 @@
 #include "lwp.h"
 #include "lwpint.h"
 
-#if defined(_EMPTH_LWP)
-
 /*
  * Implement machine-dependent functions lwpNewContext(),
  * lwpSwitchContext().
@@ -468,5 +466,3 @@ lwpSwitchContext(struct lwpProc *oldp, struct lwpProc *nextp)
 }
 
 #endif /* !UCONTEXT */
-
-#endif
index 845cf6a86770e8263522f1de6297d4dac27c0025..a3a3e47b81b75112ba86532c61b54e5d012de95a 100644 (file)
@@ -31,8 +31,6 @@
 #include "lwpint.h"
 #include "prototypes.h"
 
-#if defined(_EMPTH_LWP)
-
 struct lwpQueue LwpSchedQ[LWP_MAX_PRIO], LwpDeadQ;
 
 struct lwpProc *LwpCurrent = NULL;
@@ -310,9 +308,9 @@ lwpInitSystem(int pri, char **ctxptr, int flags)
     /* *LwpContextPtr = 0; */
     LwpStackGrowsDown = growsdown(&marker);
     if (!(LwpCurrent = calloc(1, sizeof(struct lwpProc))))
-       return 0;
+       return NULL;
     if (!(stack = malloc(64)))
-       return 0;
+       return NULL;
     if (LWP_MAX_PRIO <= pri)
        pri = LWP_MAX_PRIO - 1;
     if (LwpMaxpri < pri)
@@ -407,5 +405,3 @@ lwpStackCheckUsed(struct lwpProc *newp)
     lwpStatus(newp, "Thread stack %d used, %d left, %d total",
              used, total - used, total);
 }
-
-#endif
index e7ea4442f2859cff14eba11ac572d306f0c79e7a..98b84ed56c1e2a1b2ed41915aed49e7d53b3d666 100644 (file)
@@ -26,8 +26,6 @@
 #include "lwp.h"
 #include "lwpint.h"
 
-#if defined(_EMPTH_LWP)
-
 struct lwpProc *
 lwpGetFirst(struct lwpQueue *q)
 {
@@ -48,5 +46,3 @@ lwpAddTail(register struct lwpQueue *q, register struct lwpProc *p)
     q->tail = p;
     p->next = 0;
 }
-
-#endif
index 2668ec9a1dfd151faf350187c83c3a66737e6e05..eca2a4bef58a47115630eaddddb55de67c274c50 100644 (file)
@@ -44,8 +44,6 @@
 #include "lwp.h"
 #include "lwpint.h"
 
-#if defined(_EMPTH_LWP)
-
 struct lwpSelect {
     int maxfd;
     int nfds;
@@ -228,4 +226,3 @@ lwpSelect(void *arg)
     }
     /*NOTREACHED*/
 }
-#endif
index b4fdae1f1ff94c39457b9077955b3a90bf2c13a6..5ae076d32ab4aceb73eb9a22faa4e807e9015b84 100644 (file)
@@ -29,8 +29,6 @@
 #include "lwp.h"
 #include "lwpint.h"
 
-#if defined(_EMPTH_LWP)
-
 /*
  * create a lwpSemaphore.
  */
@@ -79,4 +77,3 @@ lwpWait(struct lwpSem *s)
        lwpReschedule();
     }
 }
-#endif
index 863d4bc1f854e50e3c018bc00b587a18db49fb2b..5b5e22923b410eb8eb5bac4541214fcc47a1d681 100644 (file)
@@ -39,8 +39,6 @@
 #include "lwp.h"
 #include "lwpint.h"
 
-#if defined(_EMPTH_LWP)
-
 void
 lwpStatus(struct lwpProc *proc, char *format, ...)
 {
@@ -67,5 +65,3 @@ lwpStatus(struct lwpProc *proc, char *format, ...)
     }
     va_end(ap);
 }
-
-#endif