summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Makefile68
-rw-r--r--tests/ChangeLog9
-rw-r--r--tests/barrier4.c3
-rw-r--r--tests/cleanup0.c19
-rw-r--r--tests/cleanup1.c19
-rw-r--r--tests/cleanup2.c19
-rw-r--r--tests/cleanup3.c23
-rw-r--r--tests/condvar6.c2
-rw-r--r--tests/errno1.c2
-rw-r--r--tests/once2.c27
-rw-r--r--tests/once3.c27
12 files changed, 175 insertions, 47 deletions
diff --git a/ChangeLog b/ChangeLog
index 0226f76..ff466ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-04-06 Kevin Lussier <Kevin at codegreennetworks.com>
+
+ * Makefile: Added debug targets for all versions of the library.
+
2005-04-01 Ross Johnson <ross at callisto.canberra.edu.au>
* GNUmakefile: Add target to build libpthreadGC1.a as a static link
diff --git a/Makefile b/Makefile
index 22ed80d..bd37472 100644
--- a/Makefile
+++ b/Makefile
@@ -5,36 +5,44 @@
# The variables $DLLDEST and $LIBDEST hold the destination directories for the
# dll and the lib, respectively. Probably all that needs to change is $DEVROOT.
-
+
# DLL_VER:
# See pthread.h and README - This number is computed as 'current - age'
DLL_VER = 1
-
-DEVROOT = c:\pthreads
+DLL_VERD= $(DLL_VER)d
+
+DEVROOT = C:\pthreads
DLLDEST = $(DEVROOT)\DLL
-LIBDEST = $(DEVROOT)\DLL
+LIBDEST = $(DEVROOT)\LIB
+HDRDEST = $(DEVROOT)\INCLUDE
-DLLS = pthreadVCE$(DLL_VER).dll pthreadVSE$(DLL_VER).dll pthreadVC$(DLL_VER).dll
-INLINED_STAMPS = pthreadVCE$(DLL_VER).stamp pthreadVSE$(DLL_VER).stamp pthreadVC$(DLL_VER).stamp
-STATIC_STAMPS = pthreadVCE$(DLL_VER).static pthreadVSE$(DLL_VER).static pthreadVC$(DLL_VER).static
+DLLS = pthreadVCE$(DLL_VER).dll pthreadVSE$(DLL_VER).dll pthreadVC$(DLL_VER).dll \
+ pthreadVCE$(DLL_VERD).dll pthreadVSE$(DLL_VERD).dll pthreadVC$(DLL_VERD).dll
+INLINED_STAMPS = pthreadVCE$(DLL_VER).stamp pthreadVSE$(DLL_VER).stamp pthreadVC$(DLL_VER).stamp \
+ pthreadVCE$(DLL_VERD).stamp pthreadVSE$(DLL_VERD).stamp pthreadVC$(DLL_VERD).stamp
+STATIC_STAMPS = pthreadVCE$(DLL_VER).static pthreadVSE$(DLL_VER).static pthreadVC$(DLL_VER).static \
+ pthreadVCE$(DLL_VERD).static pthreadVSE$(DLL_VERD).static pthreadVC$(DLL_VERD).static
OPTIM = /O2 /Ob2
-#OPTIM =
+OPTIMD =
CFLAGS = /W3 /MD /nologo /Yd /I. /D_WIN32_WINNT=0x400 /DHAVE_CONFIG_H
-#CFLAGS = /W3 /MD /nologo /Yd /Zi /I. /D_WIN32_WINNT=0x400 /DHAVE_CONFIG_H
+CFLAGSD = /Zi $(CFLAGS)
+
-
# Default cleanup style
CLEANUP = __CLEANUP_C
-
+
# C++ Exceptions
VCEFLAGS = /GX /TP $(CFLAGS)
+VCEFLAGSD = /GX /TP $(CFLAGSD)
#Structured Exceptions
VSEFLAGS = $(CFLAGS)
+VSEFLAGSD = $(CFLAGSD)
#C cleanup code
VCFLAGS = $(CFLAGS)
+VCFLAGSD= $(CFLAGSD)
DLL_INLINED_OBJS = \
pthread.obj \
@@ -370,21 +378,40 @@ help:
@ echo nmake clean VSE-inlined (to build the MSVC inlined dll with structured exception handling)
@ echo nmake clean VC-inlined (to build the MSVC inlined dll with C cleanup code)
@ echo nmake clean VC-static (to build the MSVC static lib with C cleanup code)
+ @ echo nmake clean VCE-debug (to build the debug MSVC dll with C++ exception handling)
+ @ echo nmake clean VSE-debug (to build the debug MSVC dll with structured exception handling)
+ @ echo nmake clean VC-debug (to build the debug MSVC dll with C cleanup code)
+ @ echo nmake clean VCE-inlined-debug (to build the debug MSVC inlined dll with C++ exception handling)
+ @ echo nmake clean VSE-inlined-debug (to build the debug MSVC inlined dll with structured exception handling)
+ @ echo nmake clean VC-inlined-debug (to build the debug MSVC inlined dll with C cleanup code)
+ @ echo nmake clean VC-static-debug (to build the debug MSVC static lib with C cleanup code)
all:
@ nmake clean VCE-inlined
@ nmake clean VSE-inlined
@ nmake clean VC-inlined
+ @ nmake clean VCE-inlined-debug
+ @ nmake clean VSE-inlined-debug
+ @ nmake clean VC-inlined-debug
VCE:
@ nmake /nologo EHFLAGS="$(OPTIM) $(VCEFLAGS)" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).dll
+VCE-debug:
+ @ nmake /nologo EHFLAGS="$(OPTIMD) $(VCEFLAGSD)" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).dll
+
VSE:
@ nmake /nologo EHFLAGS="$(OPTIM) $(VSEFLAGS)" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).dll
+VSE-debug:
+ @ nmake /nologo EHFLAGS="$(OPTIMD) $(VSEFLAGSD)" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).dll
+
VC:
@ nmake /nologo EHFLAGS="$(OPTIM) $(VCFLAGS)" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).dll
+VC-debug:
+ @ nmake /nologo EHFLAGS="$(OPTIMD) $(VCFLAGSD)" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).dll
+
#
# The so-called inlined DLL is just a single translation unit with
# inlining optimisation turned on.
@@ -392,15 +419,27 @@ VC:
VCE-inlined:
@ nmake /nologo EHFLAGS="$(OPTIM) $(VCEFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).stamp
+VCE-inlined-debug:
+ @ nmake /nologo EHFLAGS="$(OPTIMD) $(VCEFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).stamp
+
VSE-inlined:
@ nmake /nologo EHFLAGS="$(OPTIM) $(VSEFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).stamp
+VSE-inlined-debug:
+ @ nmake /nologo EHFLAGS="$(OPTIMD) $(VSEFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).stamp
+
VC-inlined:
@ nmake /nologo EHFLAGS="$(OPTIM) $(VCFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).stamp
+VC-inlined-debug:
+ nmake /nologo EHFLAGS="$(OPTIMD) $(VCFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).stamp
+
VC-static:
@ nmake /nologo EHFLAGS="$(OPTIM) $(VCFLAGS) /DPTW32_BUILD_INLINED /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).static
+VC-static-debug:
+ @ nmake /nologo EHFLAGS="$(OPTIMD) $(VCFLAGSD) /DPTW32_BUILD_INLINED /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).static
+
realclean: clean
if exist *.dll del *.dll
if exist *.lib del *.lib
@@ -420,6 +459,9 @@ clean:
install: $(DLLS)
copy pthread*.dll $(DLLDEST)
copy pthread*.lib $(LIBDEST)
+ copy pthread.h $(HDRDEST)
+ copy sched.h $(HDRDEST)
+ copy semaphore.h $(HDRDEST)
$(DLLS): $(DLL_OBJS)
cl /LDd /Zi /nologo $(DLL_OBJS) \
@@ -432,12 +474,12 @@ $(INLINED_STAMPS): $(DLL_INLINED_OBJS)
msvcrt.lib wsock32.lib /out:$*.dll
$(STATIC_STAMPS): $(DLL_INLINED_OBJS)
- if exist $*.lib del $*.lib
+ if exist $*.lib del $*.lib
lib $(DLL_INLINED_OBJS) /out:$*.lib
.c.obj:
cl $(EHFLAGS) /D$(CLEANUP) -c $<
-
+
.rc.res:
rc /dPTW32_RC_MSC /d$(CLEANUP) $<
diff --git a/tests/ChangeLog b/tests/ChangeLog
index ca77d7d..58b4438 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,12 @@
+2005-04-06 Ross Johnson <rpj@callisto.canberra.edu.au>
+
+ * cleanup0.c: Fix unguarded global variable accesses.
+ * cleanup1.c: Likewise.
+ * cleanup2.c: Likewise.
+ * cleanup3.c: Likewise.
+ * once2.c: Likewise.
+ * once3.c: Likewise.
+
2005-04-01 Ross Johnson <rpj@callisto.canberra.edu.au>
* GNUmakefile: Add target to test linking static link library.
diff --git a/tests/barrier4.c b/tests/barrier4.c
index ea9017d..042992d 100644
--- a/tests/barrier4.c
+++ b/tests/barrier4.c
@@ -56,9 +56,6 @@ func(void * arg)
assert(pthread_mutex_lock(&mx) == 0);
-// printf("Barrier wait returned %d [%d]\n", result, WAIT_FAILED);
-// fflush(stdout);
-
if (result == PTHREAD_BARRIER_SERIAL_THREAD)
{
serialThreadCount++;
diff --git a/tests/cleanup0.c b/tests/cleanup0.c
index 8de8c4b..77626eb 100644
--- a/tests/cleanup0.c
+++ b/tests/cleanup0.c
@@ -92,14 +92,21 @@ struct bag_t_ {
static bag_t threadbag[NUMTHREADS + 1];
-static int pop_count = 0;
+typedef struct {
+ int i;
+ CRITICAL_SECTION cs;
+} sharedInt_t;
+
+static sharedInt_t pop_count = {0, {0}};
static void
increment_pop_count(void * arg)
{
- int * c = (int *) arg;
+ sharedInt_t * sI = (sharedInt_t *) arg;
- (*c)++;
+ EnterCriticalSection(&sI->cs);
+ sI->i++;
+ LeaveCriticalSection(&sI->cs);
}
void *
@@ -140,6 +147,8 @@ main()
int i;
pthread_t t[NUMTHREADS + 1];
+ InitializeCriticalSection(&pop_count.cs);
+
assert((t[0] = pthread_self()).p != NULL);
for (i = 1; i <= NUMTHREADS; i++)
@@ -199,7 +208,9 @@ main()
assert(!failed);
- assert(pop_count == NUMTHREADS);
+ assert(pop_count.i == NUMTHREADS);
+
+ DeleteCriticalSection(&pop_count.cs);
/*
* Success.
diff --git a/tests/cleanup1.c b/tests/cleanup1.c
index 65645df..385aed9 100644
--- a/tests/cleanup1.c
+++ b/tests/cleanup1.c
@@ -92,7 +92,12 @@ struct bag_t_ {
static bag_t threadbag[NUMTHREADS + 1];
-static int pop_count = 0;
+typedef struct {
+ int i;
+ CRITICAL_SECTION cs;
+} sharedInt_t;
+
+static sharedInt_t pop_count = {0, {0}};
static void
#ifdef __CLEANUP_C
@@ -100,9 +105,11 @@ __cdecl
#endif
increment_pop_count(void * arg)
{
- int * c = (int *) arg;
+ sharedInt_t * sI = (sharedInt_t *) arg;
- (*c)++;
+ EnterCriticalSection(&sI->cs);
+ sI->i++;
+ LeaveCriticalSection(&sI->cs);
}
void *
@@ -149,6 +156,8 @@ main()
int i;
pthread_t t[NUMTHREADS + 1];
+ InitializeCriticalSection(&pop_count.cs);
+
assert((t[0] = pthread_self()).p != NULL);
for (i = 1; i <= NUMTHREADS; i++)
@@ -212,7 +221,9 @@ main()
assert(!failed);
- assert(pop_count == NUMTHREADS);
+ assert(pop_count.i == NUMTHREADS);
+
+ DeleteCriticalSection(&pop_count.cs);
/*
* Success.
diff --git a/tests/cleanup2.c b/tests/cleanup2.c
index 50672fd..4c63918 100644
--- a/tests/cleanup2.c
+++ b/tests/cleanup2.c
@@ -92,14 +92,21 @@ struct bag_t_ {
static bag_t threadbag[NUMTHREADS + 1];
-static int pop_count = 0;
+typedef struct {
+ int i;
+ CRITICAL_SECTION cs;
+} sharedInt_t;
+
+static sharedInt_t pop_count = {0, {0}};
static void
increment_pop_count(void * arg)
{
- int * c = (int *) arg;
+ sharedInt_t * sI = (sharedInt_t *) arg;
- (*c)++;
+ EnterCriticalSection(&sI->cs);
+ sI->i++;
+ LeaveCriticalSection(&sI->cs);
}
void *
@@ -134,6 +141,8 @@ main()
int i;
pthread_t t[NUMTHREADS + 1];
+ InitializeCriticalSection(&pop_count.cs);
+
assert((t[0] = pthread_self()).p != NULL);
for (i = 1; i <= NUMTHREADS; i++)
@@ -187,7 +196,9 @@ main()
assert(!failed);
- assert(pop_count == NUMTHREADS);
+ assert(pop_count.i == NUMTHREADS);
+
+ DeleteCriticalSection(&pop_count.cs);
/*
* Success.
diff --git a/tests/cleanup3.c b/tests/cleanup3.c
index a12337d..b595ab4 100644
--- a/tests/cleanup3.c
+++ b/tests/cleanup3.c
@@ -93,14 +93,21 @@ struct bag_t_ {
static bag_t threadbag[NUMTHREADS + 1];
-static int pop_count = 0;
+typedef struct {
+ int i;
+ CRITICAL_SECTION cs;
+} sharedInt_t;
+
+static sharedInt_t pop_count = {0, {0}};
static void
increment_pop_count(void * arg)
{
- int * c = (int *) arg;
+ sharedInt_t * sI = (sharedInt_t *) arg;
- (*c)++;
+ EnterCriticalSection(&sI->cs);
+ sI->i++;
+ LeaveCriticalSection(&sI->cs);
}
void *
@@ -120,7 +127,9 @@ mythread(void * arg)
sched_yield();
- pop_count--;
+ EnterCriticalSection(&pop_count.cs);
+ pop_count.i--;
+ LeaveCriticalSection(&pop_count.cs);
pthread_cleanup_pop(0);
#ifdef _MSC_VER
@@ -137,6 +146,8 @@ main()
int i;
pthread_t t[NUMTHREADS + 1];
+ InitializeCriticalSection(&pop_count.cs);
+
assert((t[0] = pthread_self()).p != NULL);
for (i = 1; i <= NUMTHREADS; i++)
@@ -190,7 +201,9 @@ main()
assert(!failed);
- assert(pop_count == -(NUMTHREADS));
+ assert(pop_count.i == -(NUMTHREADS));
+
+ DeleteCriticalSection(&pop_count.cs);
/*
* Success.
diff --git a/tests/condvar6.c b/tests/condvar6.c
index cebcbd4..fc7a53b 100644
--- a/tests/condvar6.c
+++ b/tests/condvar6.c
@@ -1,5 +1,5 @@
/*
- * File:
+ * File: condvar6.c
*
*
* --------------------------------------------------------------------------
diff --git a/tests/errno1.c b/tests/errno1.c
index 78e3d16..70ce928 100644
--- a/tests/errno1.c
+++ b/tests/errno1.c
@@ -1,5 +1,5 @@
/*
- * File: errn1.c
+ * File: errno1.c
*
*
* --------------------------------------------------------------------------
diff --git a/tests/once2.c b/tests/once2.c
index 22881d8..248ccb1 100644
--- a/tests/once2.c
+++ b/tests/once2.c
@@ -49,13 +49,20 @@
pthread_once_t o = PTHREAD_ONCE_INIT;
pthread_once_t once[NUM_ONCE];
-static int numOnce = 0;
-static int numThreads = 0;
+typedef struct {
+ int i;
+ CRITICAL_SECTION cs;
+} sharedInt_t;
+
+static sharedInt_t numOnce = {0, {0}};
+static sharedInt_t numThreads = {0, {0}};
void
myfunc(void)
{
- numOnce++;
+ EnterCriticalSection(&numOnce.cs);
+ numOnce.i++;
+ LeaveCriticalSection(&numOnce.cs);
/* Simulate slow once routine so that following threads pile up behind it */
Sleep(100);
}
@@ -64,7 +71,9 @@ void *
mythread(void * arg)
{
assert(pthread_once(&once[(int) arg], myfunc) == 0);
- numThreads++;
+ EnterCriticalSection(&numThreads.cs);
+ numThreads.i++;
+ LeaveCriticalSection(&numThreads.cs);
return 0;
}
@@ -74,6 +83,9 @@ main()
pthread_t t[NUM_THREADS][NUM_ONCE];
int i, j;
+ InitializeCriticalSection(&numThreads.cs);
+ InitializeCriticalSection(&numOnce.cs);
+
for (j = 0; j < NUM_ONCE; j++)
{
once[j] = o;
@@ -87,8 +99,11 @@ main()
if (pthread_join(t[i][j], NULL) != 0)
printf("Join failed for [thread,once] = [%d,%d]\n", i, j);
- assert(numOnce == NUM_ONCE);
- assert(numThreads == NUM_THREADS * NUM_ONCE);
+ assert(numOnce.i == NUM_ONCE);
+ assert(numThreads.i == NUM_THREADS * NUM_ONCE);
+
+ DeleteCriticalSection(&numOnce.cs);
+ DeleteCriticalSection(&numThreads.cs);
return 0;
}
diff --git a/tests/once3.c b/tests/once3.c
index fabed51..51d2daa 100644
--- a/tests/once3.c
+++ b/tests/once3.c
@@ -53,13 +53,20 @@
pthread_once_t o = PTHREAD_ONCE_INIT;
pthread_once_t once[NUM_ONCE];
-static int numOnce = 0;
-static int numThreads = 0;
+typedef struct {
+ int i;
+ CRITICAL_SECTION cs;
+} sharedInt_t;
+
+static sharedInt_t numOnce = {0, {0}};
+static sharedInt_t numThreads = {0, {0}};
void
myfunc(void)
{
- numOnce++;
+ EnterCriticalSection(&numOnce.cs);
+ numOnce.i++;
+ LeaveCriticalSection(&numOnce.cs);
/* Simulate slow once routine so that following threads pile up behind it */
Sleep(10);
/* test for cancelation late so we're sure to have waiters. */
@@ -77,7 +84,9 @@ mythread(void * arg)
*/
pthread_cancel(pthread_self());
assert(pthread_once(&once[(int) arg], myfunc) == 0);
- numThreads++;
+ EnterCriticalSection(&numThreads.cs);
+ numThreads.i++;
+ LeaveCriticalSection(&numThreads.cs);
return 0;
}
@@ -87,6 +96,9 @@ main()
pthread_t t[NUM_THREADS][NUM_ONCE];
int i, j;
+ InitializeCriticalSection(&numThreads.cs);
+ InitializeCriticalSection(&numOnce.cs);
+
for (j = 0; j < NUM_ONCE; j++)
{
once[j] = o;
@@ -107,8 +119,11 @@ main()
* pthread_once and so numThreads should never be incremented. However,
* numOnce should be incremented by every thread (NUM_THREADS*NUM_ONCE).
*/
- assert(numOnce == NUM_ONCE * NUM_THREADS);
- assert(numThreads == 0);
+ assert(numOnce.i == NUM_ONCE * NUM_THREADS);
+ assert(numThreads.i == 0);
+
+ DeleteCriticalSection(&numOnce.cs);
+ DeleteCriticalSection(&numThreads.cs);
return 0;
}