(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:
parent
b921d3c262
commit
69150d10fc
14 changed files with 23 additions and 58 deletions
|
@ -44,7 +44,7 @@ LDLIBS := @LIBS@
|
||||||
empthread := @empthread@
|
empthread := @empthread@
|
||||||
ifeq ($(empthread),POSIX)
|
ifeq ($(empthread),POSIX)
|
||||||
CC := @PTHREAD_CC@
|
CC := @PTHREAD_CC@
|
||||||
CFLAGS := $(CFLAGS) @PTHREAD_CFLAGS@ -D_EMPTH_POSIX=1
|
CFLAGS := $(CFLAGS) @PTHREAD_CFLAGS@
|
||||||
LDFLAGS := $(LDFLAGS) @PTHREAD_CFLAGS@
|
LDFLAGS := $(LDFLAGS) @PTHREAD_CFLAGS@
|
||||||
LDLIBS := @PTHREAD_LIBS@ $(LDLIBS)
|
LDLIBS := @PTHREAD_LIBS@ $(LDLIBS)
|
||||||
endif
|
endif
|
||||||
|
|
11
Make.mk
11
Make.mk
|
@ -74,12 +74,17 @@ subjects.html := $(addprefix info.html/, $(addsuffix .html, $(subjects)))
|
||||||
topics.html := $(addprefix info.html/, $(addsuffix .html, $(topics)))
|
topics.html := $(addprefix info.html/, $(addsuffix .html, $(topics)))
|
||||||
info.html := $(addprefix info.html/, $(addsuffix .html, $(info)))
|
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)
|
ifeq ($(empthread),POSIX)
|
||||||
empth_obj := src/lib/empthread/pthread.o
|
empth_obj := src/lib/empthread/pthread.o
|
||||||
empth_lib :=
|
empth_lib :=
|
||||||
else
|
endif
|
||||||
empth_obj := src/lib/empthread/lwp.o
|
ifeq ($(empthread),Windows)
|
||||||
empth_lib := lib/liblwp.a
|
empth_obj := src/lib/empthread/ntthread.o
|
||||||
|
empth_lib :=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Abbreviations
|
# Abbreviations
|
||||||
|
|
|
@ -99,6 +99,7 @@ AC_ARG_WITH([pthread],
|
||||||
[use POSIX threads]))
|
[use POSIX threads]))
|
||||||
|
|
||||||
# Select thread package
|
# Select thread package
|
||||||
|
# TODO Windows
|
||||||
case "$ac_cv_func_makecontext$acx_pthread_ok" in
|
case "$ac_cv_func_makecontext$acx_pthread_ok" in
|
||||||
yesyes)
|
yesyes)
|
||||||
if test -z "$with_pthread" || test "$with_pthread" = no; then
|
if test -z "$with_pthread" || test "$with_pthread" = no; then
|
||||||
|
@ -116,6 +117,11 @@ yes*)
|
||||||
esac
|
esac
|
||||||
AC_SUBST(empthread)
|
AC_SUBST(empthread)
|
||||||
AC_MSG_NOTICE([Using $empthread threads])
|
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=
|
op=
|
||||||
if test "$with_pthread" = no; then
|
if test "$with_pthread" = no; then
|
||||||
|
|
|
@ -48,15 +48,7 @@
|
||||||
#ifndef _EMTHREAD_H_
|
#ifndef _EMTHREAD_H_
|
||||||
#define _EMTHREAD_H_
|
#define _EMTHREAD_H_
|
||||||
|
|
||||||
#include "misc.h"
|
#ifdef EMPTH_LWP
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#undef _EMPTH_LWP
|
|
||||||
#undef _EMPTH_POSIX
|
|
||||||
#define _EMPTH_WIN32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _EMPTH_LWP
|
|
||||||
#include "lwp.h"
|
#include "lwp.h"
|
||||||
|
|
||||||
/* Abstract data types */
|
/* Abstract data types */
|
||||||
|
@ -77,9 +69,9 @@ typedef struct lwpSem empth_sem_t;
|
||||||
/* Request stack checking */
|
/* Request stack checking */
|
||||||
#define EMPTH_STACKCHECK LWP_STACKCHECK
|
#define EMPTH_STACKCHECK LWP_STACKCHECK
|
||||||
|
|
||||||
#endif /* _EMPTH_LWP */
|
#endif /* EMPTH_LWP */
|
||||||
|
|
||||||
#ifdef _EMPTH_POSIX
|
#ifdef EMPTH_POSIX
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#define EMPTH_FD_READ 0x1
|
#define EMPTH_FD_READ 0x1
|
||||||
#define EMPTH_FD_WRITE 0x2
|
#define EMPTH_FD_WRITE 0x2
|
||||||
|
@ -90,9 +82,9 @@ typedef struct lwpSem empth_sem_t;
|
||||||
typedef struct empth_t empth_t;
|
typedef struct empth_t empth_t;
|
||||||
typedef struct empth_sem_t empth_sem_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 */
|
/* The Windows NT Threads */
|
||||||
#define EMPTH_FD_READ 0x1
|
#define EMPTH_FD_READ 0x1
|
||||||
#define EMPTH_FD_WRITE 0x2
|
#define EMPTH_FD_WRITE 0x2
|
||||||
|
@ -104,7 +96,7 @@ typedef struct loc_Thread_t empth_t;
|
||||||
typedef struct loc_Sem_t empth_sem_t;
|
typedef struct loc_Sem_t empth_sem_t;
|
||||||
|
|
||||||
void empth_request_shutdown(void);
|
void empth_request_shutdown(void);
|
||||||
#endif /* _EMPTH_WIN32 */
|
#endif /* EMPTH_W32 */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize thread package.
|
* Initialize thread package.
|
||||||
|
|
|
@ -99,11 +99,6 @@ struct mob_acc_globals {
|
||||||
|
|
||||||
typedef u_char natid; /* NSC_NATID must match this */
|
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)
|
#if !defined(aix) && !defined(sgi)
|
||||||
typedef char s_char; /* change to signed char for aix */
|
typedef char s_char; /* change to signed char for aix */
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -37,8 +37,6 @@
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
#include "empthread.h"
|
#include "empthread.h"
|
||||||
|
|
||||||
#ifdef _EMPTH_LWP
|
|
||||||
|
|
||||||
/* The thread `created' by lwpInitSystem() */
|
/* The thread `created' by lwpInitSystem() */
|
||||||
static empth_t *empth_main;
|
static empth_t *empth_main;
|
||||||
|
|
||||||
|
@ -134,5 +132,3 @@ empth_sem_wait(empth_sem_t *sm)
|
||||||
{
|
{
|
||||||
lwpWait(sm);
|
lwpWait(sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -54,7 +54,6 @@
|
||||||
#include "empthread.h"
|
#include "empthread.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(_EMPTH_WIN32)
|
|
||||||
#define WIN32
|
#define WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#undef NS_ALL
|
#undef NS_ALL
|
||||||
|
@ -683,5 +682,3 @@ empth_sem_wait(empth_sem_t *pSem)
|
||||||
|
|
||||||
loc_RunThisThread();
|
loc_RunThisThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _WIN32 */
|
|
||||||
|
|
|
@ -51,8 +51,6 @@
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#ifdef _EMPTH_POSIX
|
|
||||||
|
|
||||||
#define EMPTH_KILLED 1
|
#define EMPTH_KILLED 1
|
||||||
|
|
||||||
struct empth_t {
|
struct empth_t {
|
||||||
|
@ -454,5 +452,3 @@ empth_sem_wait(empth_sem_t *sm)
|
||||||
} else
|
} else
|
||||||
pthread_mutex_unlock(&sm->mtx_update);
|
pthread_mutex_unlock(&sm->mtx_update);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -38,8 +38,6 @@
|
||||||
#include "lwp.h"
|
#include "lwp.h"
|
||||||
#include "lwpint.h"
|
#include "lwpint.h"
|
||||||
|
|
||||||
#if defined(_EMPTH_LWP)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implement machine-dependent functions lwpNewContext(),
|
* Implement machine-dependent functions lwpNewContext(),
|
||||||
* lwpSwitchContext().
|
* lwpSwitchContext().
|
||||||
|
@ -468,5 +466,3 @@ lwpSwitchContext(struct lwpProc *oldp, struct lwpProc *nextp)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !UCONTEXT */
|
#endif /* !UCONTEXT */
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
#include "lwpint.h"
|
#include "lwpint.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
|
|
||||||
#if defined(_EMPTH_LWP)
|
|
||||||
|
|
||||||
struct lwpQueue LwpSchedQ[LWP_MAX_PRIO], LwpDeadQ;
|
struct lwpQueue LwpSchedQ[LWP_MAX_PRIO], LwpDeadQ;
|
||||||
|
|
||||||
struct lwpProc *LwpCurrent = NULL;
|
struct lwpProc *LwpCurrent = NULL;
|
||||||
|
@ -310,9 +308,9 @@ lwpInitSystem(int pri, char **ctxptr, int flags)
|
||||||
/* *LwpContextPtr = 0; */
|
/* *LwpContextPtr = 0; */
|
||||||
LwpStackGrowsDown = growsdown(&marker);
|
LwpStackGrowsDown = growsdown(&marker);
|
||||||
if (!(LwpCurrent = calloc(1, sizeof(struct lwpProc))))
|
if (!(LwpCurrent = calloc(1, sizeof(struct lwpProc))))
|
||||||
return 0;
|
return NULL;
|
||||||
if (!(stack = malloc(64)))
|
if (!(stack = malloc(64)))
|
||||||
return 0;
|
return NULL;
|
||||||
if (LWP_MAX_PRIO <= pri)
|
if (LWP_MAX_PRIO <= pri)
|
||||||
pri = LWP_MAX_PRIO - 1;
|
pri = LWP_MAX_PRIO - 1;
|
||||||
if (LwpMaxpri < pri)
|
if (LwpMaxpri < pri)
|
||||||
|
@ -407,5 +405,3 @@ lwpStackCheckUsed(struct lwpProc *newp)
|
||||||
lwpStatus(newp, "Thread stack %d used, %d left, %d total",
|
lwpStatus(newp, "Thread stack %d used, %d left, %d total",
|
||||||
used, total - used, total);
|
used, total - used, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -26,8 +26,6 @@
|
||||||
#include "lwp.h"
|
#include "lwp.h"
|
||||||
#include "lwpint.h"
|
#include "lwpint.h"
|
||||||
|
|
||||||
#if defined(_EMPTH_LWP)
|
|
||||||
|
|
||||||
struct lwpProc *
|
struct lwpProc *
|
||||||
lwpGetFirst(struct lwpQueue *q)
|
lwpGetFirst(struct lwpQueue *q)
|
||||||
{
|
{
|
||||||
|
@ -48,5 +46,3 @@ lwpAddTail(register struct lwpQueue *q, register struct lwpProc *p)
|
||||||
q->tail = p;
|
q->tail = p;
|
||||||
p->next = 0;
|
p->next = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -44,8 +44,6 @@
|
||||||
#include "lwp.h"
|
#include "lwp.h"
|
||||||
#include "lwpint.h"
|
#include "lwpint.h"
|
||||||
|
|
||||||
#if defined(_EMPTH_LWP)
|
|
||||||
|
|
||||||
struct lwpSelect {
|
struct lwpSelect {
|
||||||
int maxfd;
|
int maxfd;
|
||||||
int nfds;
|
int nfds;
|
||||||
|
@ -228,4 +226,3 @@ lwpSelect(void *arg)
|
||||||
}
|
}
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -29,8 +29,6 @@
|
||||||
#include "lwp.h"
|
#include "lwp.h"
|
||||||
#include "lwpint.h"
|
#include "lwpint.h"
|
||||||
|
|
||||||
#if defined(_EMPTH_LWP)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create a lwpSemaphore.
|
* create a lwpSemaphore.
|
||||||
*/
|
*/
|
||||||
|
@ -79,4 +77,3 @@ lwpWait(struct lwpSem *s)
|
||||||
lwpReschedule();
|
lwpReschedule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -39,8 +39,6 @@
|
||||||
#include "lwp.h"
|
#include "lwp.h"
|
||||||
#include "lwpint.h"
|
#include "lwpint.h"
|
||||||
|
|
||||||
#if defined(_EMPTH_LWP)
|
|
||||||
|
|
||||||
void
|
void
|
||||||
lwpStatus(struct lwpProc *proc, char *format, ...)
|
lwpStatus(struct lwpProc *proc, char *format, ...)
|
||||||
{
|
{
|
||||||
|
@ -67,5 +65,3 @@ lwpStatus(struct lwpProc *proc, char *format, ...)
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue