(EMPTH_LWP, EMPTH_POSIX, EMPTH_W32): Define in config.h instead of

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.
This commit is contained in:
Markus Armbruster 2005-12-28 14:27:15 +00:00
parent b921d3c262
commit 69150d10fc
14 changed files with 23 additions and 58 deletions

View 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

11
Make.mk
View file

@ -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

View 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

View file

@ -48,15 +48,7 @@
#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.

View 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

View 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

View 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 */

View 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

View 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

View 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

View 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

View 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

View 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

View 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