summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrpj <rpj>2011-05-30 00:30:56 +0000
committerrpj <rpj>2011-05-30 00:30:56 +0000
commit26ed1ebeb95caec8d733a6a91e71e31312a8eb06 (patch)
treea957bdd3826088a9e447fc830ac4ccf835b77c44
parent2fe8aba6a8a4ce09f353f34881c77f93a9c01ca3 (diff)
Compiler directive cleanups
-rw-r--r--ChangeLog26
-rw-r--r--GNUmakefile11
-rw-r--r--Makefile10
-rwxr-xr-xautostatic.c2
-rw-r--r--config.h12
-rw-r--r--create.c2
-rw-r--r--dll.c6
-rw-r--r--global.c2
-rw-r--r--implement.h46
-rw-r--r--mutex.c2
-rw-r--r--need_errno.h22
-rw-r--r--pthread.h82
-rw-r--r--pthread_attr_getscope.c4
-rw-r--r--pthread_attr_getstackaddr.c2
-rw-r--r--pthread_attr_getstacksize.c4
-rw-r--r--pthread_attr_init.c6
-rw-r--r--pthread_attr_setscope.c4
-rw-r--r--pthread_attr_setstacksize.c2
-rw-r--r--pthread_detach.c2
-rw-r--r--pthread_exit.c4
-rw-r--r--pthread_join.c2
-rw-r--r--pthread_key_create.c2
-rw-r--r--pthread_kill.c2
-rwxr-xr-xpthread_mutex_consistent.c2
-rw-r--r--pthread_mutex_lock.c2
-rw-r--r--pthread_self.c4
-rw-r--r--pthread_win32_attach_detach_np.c2
-rw-r--r--ptw32_InterlockedCompareExchange.c2
-rw-r--r--ptw32_MCS_lock.c8
-rw-r--r--ptw32_callUserDestroyRoutines.c20
-rw-r--r--ptw32_calloc.c2
-rw-r--r--ptw32_relmillisecs.c10
-rw-r--r--ptw32_reuse.c2
-rw-r--r--ptw32_semwait.c4
-rw-r--r--ptw32_threadStart.c17
-rw-r--r--ptw32_throw.c14
-rw-r--r--ptw32_timespec.c2
-rw-r--r--sched.h40
-rw-r--r--sem_close.c2
-rw-r--r--sem_init.c2
-rw-r--r--sem_open.c2
-rw-r--r--sem_post.c2
-rw-r--r--sem_post_multiple.c2
-rw-r--r--sem_timedwait.c8
-rw-r--r--sem_unlink.c2
-rw-r--r--sem_wait.c4
-rw-r--r--semaphore.c2
-rw-r--r--semaphore.h40
-rw-r--r--signal.c2
-rw-r--r--tests/ChangeLog4
-rw-r--r--tests/GNUmakefile3
-rwxr-xr-xtests/SIZES.GCE6
-rw-r--r--tests/SIZES.VCE6
-rw-r--r--tests/cancel2.c2
-rw-r--r--tests/reuse2.c3
-rw-r--r--version.rc4
56 files changed, 265 insertions, 219 deletions
diff --git a/ChangeLog b/ChangeLog
index 5905825..a8b493a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2011-05-29 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * *.[ch] (#ifdef): Extended cleanup to whole project.
+
+2011-05-29 Daniel Richard G. <skunk at iskunk dot org>
+
+ * Makefile (CC): Define CC to allow use of other compatible
+ compilers such as the Intel compilter icl.
+ * implement.h (#if): Fix forms like #if HAVE_SOMETHING.
+ * pthread.h: Likewise.
+ * sched.h: Likewise; PTW32_LEVEL_* becomes PTW32_SCHED_LEVEL_*.
+ * semaphore.h: Likewise.
+
+2011-05-11 Ross Johnson <ross.johnson at homemail.com.au>
+
+ * ptw32_callUserDestroyRoutines.c (terminate): Altered includes
+ to match ptw32_threadStart.c.
+ * GNUmakefile (GCE-inlined-debug, DOPT): Fixed.
+
+2011-04-31 Ross Johnson <ross.johnson at homemail.com.au>
+
+ * (robust mutexes): Added this API. The API is not
+ mandatory for implementations that don't support PROCESS_SHARED
+ mutexes, nevertheless it was considered useful both functionally
+ and for source-level compatibility.
+
2011-03-26 Ross Johnson <ross.johnson at homemail.com.au>
* pthread_getunique_np.c: New non-POSIX interface for compatibility
diff --git a/GNUmakefile b/GNUmakefile
index 7b15451..3ee8763 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -59,7 +59,6 @@ RANLIB = $(CROSS)ranlib
RC = $(CROSS)windres
OPT = $(CLEANUP) -O3 # -finline-functions -findirect-inlining
-DOPT = $(CLEANUP) -g -O0
XOPT =
RCFLAGS = --include-dir=.
@@ -481,31 +480,31 @@ GC:
$(MAKE) CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_OBJS)" $(GC_DLL)
GC-debug:
- $(MAKE) CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_OBJS)" DLL_VER=$(DLL_VERD) OPT="$(DOPT)" $(GCD_DLL)
+ $(MAKE) CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_DLL)
GCE:
$(MAKE) CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_OBJS)" $(GCE_DLL)
GCE-debug:
- $(MAKE) CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_OBJS)" DLL_VER=$(DLL_VERD) OPT="$(DOPT)" $(GCED_DLL)
+ $(MAKE) CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_CXX -g -O0" $(GCED_DLL)
GC-inlined:
$(MAKE) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GC_INLINED_STAMP)
GC-inlined-debug:
- $(MAKE) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" DLL_VER=$(DLL_VERD) OPT="$(DOPT)" $(GCD_INLINED_STAMP)
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_INLINED_STAMP)
GCE-inlined:
$(MAKE) CC=$(CXX) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GCE_INLINED_STAMP)
GCE-inlined-debug:
- $(MAKE) CC=$(CXX) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" DLL_VER=$(DLL_VERD) OPT="$(DOPT)" $(GCED_INLINED_STAMP)
+ $(MAKE) CC=$(CXX) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_CXX -g -O0" $(GCED_INLINED_STAMP)
GC-static:
$(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GC_STATIC_STAMP)
GC-static-debug:
- $(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" DLL_VER=$(DLL_VERD) OPT="$(DOPT)" $(GCD_STATIC_STAMP)
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_STATIC_STAMP)
tests:
@ cd tests
diff --git a/Makefile b/Makefile
index a7fb483..f3ecdf2 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,7 @@ STATIC_STAMPS = pthreadVCE$(DLL_VER).static pthreadVSE$(DLL_VER).static pthreadV
OPTIM = /O2 /Ob2
OPTIMD =
+CC = cl
CFLAGS = /W3 /MD /nologo /I. /D_WIN32_WINNT=0x400 /DHAVE_PTW32_CONFIG_H
CFLAGSD = /Z7 $(CFLAGS)
@@ -459,6 +460,7 @@ realclean: clean
clean:
if exist *.obj del *.obj
+ if exist *.def del *.def
if exist *.ilk del *.ilk
if exist *.pdb del *.pdb
if exist *.exp del *.exp
@@ -476,12 +478,12 @@ install: $(DLLS)
copy semaphore.h $(HDRDEST)
$(DLLS): $(DLL_OBJS)
- cl /LDd /Zi /nologo $(DLL_OBJS) \
+ $(CC) /LDd /Zi /nologo $(DLL_OBJS) \
/link /nodefaultlib:libcmt /implib:$*.lib \
msvcrt.lib $(XLIBS) /out:$@
$(INLINED_STAMPS): $(DLL_INLINED_OBJS)
- cl /LDd /Zi /nologo $(DLL_INLINED_OBJS) \
+ $(CC) /LDd /Zi /nologo $(DLL_INLINED_OBJS) \
/link /nodefaultlib:libcmt /implib:$*.lib \
msvcrt.lib $(XLIBS) /out:$*.dll
@@ -490,13 +492,13 @@ $(STATIC_STAMPS): $(DLL_INLINED_OBJS)
lib $(DLL_INLINED_OBJS) /out:$*.lib
.c.obj:
- cl $(EHFLAGS) /D$(CLEANUP) -c $<
+ $(CC) $(EHFLAGS) /D$(CLEANUP) -c $<
.rc.res:
rc /dPTW32_RC_MSC /d$(CLEANUP) $<
.c.i:
- cl /P /O2 /Ob1 $(VCFLAGS) $<
+ $(CC) /P /O2 /Ob1 $(VCFLAGS) $<
attr.obj: attr.c $(ATTR_SRCS) $(INCL)
barrier.obj: barrier.c $(BARRIER_SRCS) $(INCL)
diff --git a/autostatic.c b/autostatic.c
index e60bd12..092aff2 100755
--- a/autostatic.c
+++ b/autostatic.c
@@ -34,7 +34,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-#ifdef PTW32_STATIC_LIB
+#if defined(PTW32_STATIC_LIB)
#if defined(__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER)
diff --git a/config.h b/config.h
index 0d1e1be..e231724 100644
--- a/config.h
+++ b/config.h
@@ -108,7 +108,7 @@
* If you find that these are incorrect or incomplete please report it
* to the pthreads-win32 maintainer. Thanks.
*********************************************************************/
-#ifdef WINCE
+#if defined(WINCE)
#define NEED_DUPLICATEHANDLE
#define NEED_CREATETHREAD
#define NEED_ERRNO
@@ -121,12 +121,12 @@
#define RETAIN_WSALASTERROR
#endif
-#ifdef _UWIN
+#if defined(_UWIN)
#define HAVE_MODE_T
#define HAVE_STRUCT_TIMESPEC
#endif
-#ifdef __GNUC__
+#if defined(__GNUC__)
#define HAVE_C_INLINE
#endif
@@ -137,13 +137,13 @@
#define HAVE_MODE_T
#endif
-#ifdef __BORLANDC__
+#if defined(__BORLANDC__)
#endif
-#ifdef __WATCOMC__
+#if defined(__WATCOMC__)
#endif
-#ifdef __DMC__
+#if defined(__DMC__)
#define HAVE_SIGNAL_H
#define HAVE_C_INLINE
#endif
diff --git a/create.c b/create.c
index a67d227..881d537 100644
--- a/create.c
+++ b/create.c
@@ -299,7 +299,7 @@ FAIL0:
*tid = thread;
}
-#ifdef _UWIN
+#if defined(_UWIN)
if (result == 0)
pthread_count++;
#endif
diff --git a/dll.c b/dll.c
index c1cd4e9..05e01be 100644
--- a/dll.c
+++ b/dll.c
@@ -34,12 +34,12 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-#ifndef PTW32_STATIC_LIB
+#if !defined(PTW32_STATIC_LIB)
#include "pthread.h"
#include "implement.h"
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
/*
* lpvReserved yields an unreferenced formal parameter;
* ignore it
@@ -47,7 +47,7 @@
#pragma warning( disable : 4100 )
#endif
-#ifdef __cplusplus
+#if defined(__cplusplus)
/*
* Dear c++: Please don't mangle this name. -thanks
*/
diff --git a/global.c b/global.c
index 874b71b..b73a399 100644
--- a/global.c
+++ b/global.c
@@ -99,7 +99,7 @@ ptw32_mcs_lock_t ptw32_spinlock_test_init_lock = 0;
*/
ptw32_mcs_lock_t ptw32_cond_list_lock = 0;
-#ifdef _UWIN
+#if defined(_UWIN)
/*
* Keep a count of the number of threads.
*/
diff --git a/implement.h b/implement.h
index 8a27fae..bd2836b 100644
--- a/implement.h
+++ b/implement.h
@@ -35,10 +35,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-#ifndef _IMPLEMENT_H
+#if !defined(_IMPLEMENT_H)
#define _IMPLEMENT_H
-#ifdef _WIN32_WINNT
+#if defined(_WIN32_WINNT)
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x400
@@ -48,7 +48,7 @@
/*
* In case windows.h doesn't define it (e.g. WinCE perhaps)
*/
-#ifdef WINCE
+#if defined(WINCE)
typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam);
#endif
@@ -60,7 +60,7 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam);
/*
* In case ETIMEDOUT hasn't been defined above somehow.
*/
-#ifndef ETIMEDOUT
+#if !defined(ETIMEDOUT)
# define ETIMEDOUT 10060 /* This is the value in winsock.h. */
#endif
@@ -82,7 +82,7 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam);
#define INLINE
#endif
-#if defined (__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER)
#define PTW32_INTERLOCKED_LONG unsigned long
#define PTW32_INTERLOCKED_LPLONG volatile unsigned long*
#define PTW32_INTERLOCKED_PVOID PVOID
@@ -133,7 +133,7 @@ typedef struct ptw32_thread_t_ ptw32_thread_t;
struct ptw32_thread_t_
{
-#ifdef _UWIN
+#if defined(_UWIN)
DWORD dummy[5];
#endif
UINT64 seqNumber; /* Process-unique thread sequence number */
@@ -152,10 +152,10 @@ struct ptw32_thread_t_
int cancelState;
int cancelType;
HANDLE cancelEvent;
-#ifdef __CLEANUP_C
+#if defined(__CLEANUP_C)
jmp_buf start_mark;
#endif /* __CLEANUP_C */
-#if HAVE_SIGSET_T
+#if defined(HAVE_SIGSET_T)
sigset_t sigmask;
#endif /* HAVE_SIGSET_T */
int implicit:1;
@@ -182,7 +182,7 @@ struct pthread_attr_t_
struct sched_param param;
int inheritsched;
int contentionscope;
-#if HAVE_SIGSET_T
+#if defined(HAVE_SIGSET_T)
sigset_t sigmask;
#endif /* HAVE_SIGSET_T */
};
@@ -201,7 +201,7 @@ struct sem_t_
int value;
pthread_mutex_t lock;
HANDLE sem;
-#ifdef NEED_SEM
+#if defined(NEED_SEM)
int leftToUnblock;
#endif
};
@@ -485,7 +485,7 @@ struct ThreadKeyAssoc
};
-#ifdef __CLEANUP_SEH
+#if defined(__CLEANUP_SEH)
/*
* --------------------------------------------------------------
* MAKE_SOFTWARE_EXCEPTION
@@ -574,11 +574,11 @@ extern ptw32_mcs_lock_t ptw32_cond_test_init_lock;
extern ptw32_mcs_lock_t ptw32_rwlock_test_init_lock;
extern ptw32_mcs_lock_t ptw32_spinlock_test_init_lock;
-#ifdef _UWIN
+#if defined(_UWIN)
extern int pthread_count;
#endif
-#ifdef __cplusplus
+#if defined(__cplusplus)
extern "C"
{
#endif /* __cplusplus */
@@ -625,7 +625,7 @@ extern "C"
void ptw32_rwlock_cancelwrwait (void *arg);
-#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || (defined (__MSVCRT__) && ! defined(__DMC__))
+#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || (defined(__MSVCRT__) && ! defined(__DMC__))
unsigned __stdcall
#else
void
@@ -650,19 +650,19 @@ extern "C"
void ptw32_mcs_node_transfer (ptw32_mcs_local_node_t * new_node, ptw32_mcs_local_node_t * old_node);
-#ifdef NEED_FTIME
+#if defined(NEED_FTIME)
void ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft);
void ptw32_filetime_to_timespec (const FILETIME * ft, struct timespec *ts);
#endif
/* Declared in misc.c */
-#ifdef NEED_CALLOC
+#if defined(NEED_CALLOC)
#define calloc(n, s) ptw32_calloc(n, s)
void *ptw32_calloc (size_t n, size_t s);
#endif
/* Declared in private.c */
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
/*
* Ignore the warning:
* "C++ exception specification ignored except to indicate that
@@ -671,19 +671,19 @@ extern "C"
#pragma warning(disable:4290)
#endif
void ptw32_throw (DWORD exception)
-#ifdef __CLEANUP_CXX
+#if defined(__CLEANUP_CXX)
throw(ptw32_exception_cancel,ptw32_exception_exit)
#endif
;
-#ifdef __cplusplus
+#if defined(__cplusplus)
}
#endif /* __cplusplus */
-#ifdef _UWIN_
-# ifdef _MT
-# ifdef __cplusplus
+#if defined(_UWIN_)
+# if defined(_MT)
+# if defined(__cplusplus)
extern "C"
{
# endif
@@ -694,7 +694,7 @@ extern "C"
unsigned (__stdcall *) (void *),
void *, unsigned, unsigned *);
_CRTIMP void __cdecl _endthreadex (unsigned);
-# ifdef __cplusplus
+# if defined(__cplusplus)
}
# endif
# endif
diff --git a/mutex.c b/mutex.c
index 8668324..c2b3607 100644
--- a/mutex.c
+++ b/mutex.c
@@ -37,7 +37,7 @@
#if ! defined(_UWIN) && ! defined(WINCE)
# include <process.h>
#endif
-#ifndef NEED_FTIME
+#if !defined(NEED_FTIME)
#include <sys/timeb.h>
#endif
#include "pthread.h"
diff --git a/need_errno.h b/need_errno.h
index 30c674d..abf1c95 100644
--- a/need_errno.h
+++ b/need_errno.h
@@ -17,16 +17,16 @@
#pragma once
#endif
-#ifndef _INC_ERRNO
+#if !defined(_INC_ERRNO)
#define _INC_ERRNO
-#if !defined(_WIN32)
+#if !defined(_WIN32)
#error ERROR: Only Win32 targets supported!
#endif
#include <winsock.h>
-#ifdef __cplusplus
+#if defined(__cplusplus)
extern "C" {
#endif
@@ -35,7 +35,7 @@ extern "C" {
/* Define _CRTIMP */
#ifndef _CRTIMP
-#ifdef _DLL
+#if defined(_DLL)
#define _CRTIMP __declspec(dllimport)
#else /* ndef _DLL */
#define _CRTIMP
@@ -45,13 +45,13 @@ extern "C" {
/* Define __cdecl for non-Microsoft compilers */
-#if ( !defined(_MSC_VER) && !defined(__cdecl) )
+#if ( !defined(_MSC_VER) && !defined(__cdecl) )
#define __cdecl
#endif
/* Define _CRTAPI1 (for compatibility with the NT SDK) */
-#ifndef _CRTAPI1
+#if !defined(_CRTAPI1)
#if _MSC_VER >= 800 && _M_IX86 >= 300
#define _CRTAPI1 __cdecl
#else
@@ -60,7 +60,7 @@ extern "C" {
#endif
#if !defined(PTW32_STATIC_LIB)
-# ifdef PTW32_BUILD
+# if defined(PTW32_BUILD)
# define PTW32_DLLPORT __declspec (dllexport)
# else
# define PTW32_DLLPORT __declspec (dllimport)
@@ -71,7 +71,7 @@ extern "C" {
/* declare reference to errno */
-#if (defined(_MT) || defined(_MD) || defined(_DLL)) && !defined(_MAC)
+#if (defined(_MT) || defined(_MD) || defined(_DLL)) && !defined(_MAC)
PTW32_DLLPORT int * __cdecl _errno(void);
#define errno (*_errno())
#else /* ndef _MT && ndef _MD && ndef _DLL */
@@ -115,7 +115,7 @@ _CRTIMP extern int errno;
#define EDEADLK 36
/* defined differently in winsock.h on WinCE */
-#ifndef ENAMETOOLONG
+#if !defined(ENAMETOOLONG)
#define ENAMETOOLONG 38
#endif
@@ -123,7 +123,7 @@ _CRTIMP extern int errno;
#define ENOSYS 40
/* defined differently in winsock.h on WinCE */
-#ifndef ENOTEMPTY
+#if !defined(ENOTEMPTY)
#define ENOTEMPTY 41
#endif
@@ -138,7 +138,7 @@ _CRTIMP extern int errno;
*/
#define EDEADLOCK EDEADLK
-#ifdef __cplusplus
+#if defined(__cplusplus)
}
#endif
diff --git a/pthread.h b/pthread.h
index d4b5899..1d2d7d3 100644
--- a/pthread.h
+++ b/pthread.h
@@ -81,7 +81,7 @@
/*
* Stop here if we are being included by the resource compiler.
*/
-#ifndef RC_INVOKED
+#if !defined(RC_INVOKED)
#undef PTW32_LEVEL
@@ -109,7 +109,7 @@
/* Include everything */
#endif
-#ifdef _UWIN
+#if defined(_UWIN)
# define HAVE_STRUCT_TIMESPEC 1
# define HAVE_SIGNAL_H 1
# undef HAVE_PTW32_CONFIG_H
@@ -194,7 +194,7 @@
#define PTW32_INCLUDE_WINDOWS_H
#endif
-#ifdef PTW32_INCLUDE_WINDOWS_H
+#if defined(PTW32_INCLUDE_WINDOWS_H)
#include <windows.h>
#endif
@@ -210,17 +210,17 @@ typedef unsigned long DWORD_PTR;
* -----------------
*/
-#if HAVE_PTW32_CONFIG_H
+#if defined(HAVE_PTW32_CONFIG_H)
#include "config.h"
#endif /* HAVE_PTW32_CONFIG_H */
-#ifndef NEED_FTIME
+#if !defined(NEED_FTIME)
#include <time.h>
#else /* NEED_FTIME */
/* use native WIN32 time API */
#endif /* NEED_FTIME */
-#if HAVE_SIGNAL_H
+#if defined(HAVE_SIGNAL_H)
#include <signal.h>
#endif /* HAVE_SIGNAL_H */
@@ -240,7 +240,7 @@ enum {
* which is only used when building the pthread-win32 libraries.
*/
-#ifndef PTW32_CONFIG_H
+#if !defined(PTW32_CONFIG_H)
# if defined(WINCE)
# define NEED_ERRNO
# define NEED_SEM
@@ -258,7 +258,7 @@ enum {
*/
#if PTW32_LEVEL >= PTW32_LEVEL_MAX
-#ifdef NEED_ERRNO
+#if defined(NEED_ERRNO)
#include "need_errno.h"
#else
#include <errno.h>
@@ -268,20 +268,20 @@ enum {
/*
* Several systems don't define some error numbers.
*/
-#ifndef ENOTSUP
+#if !defined(ENOTSUP)
# define ENOTSUP 48 /* This is the value in Solaris. */
#endif
-#ifndef ETIMEDOUT
+#if !defined(ETIMEDOUT)
# define ETIMEDOUT 10060 /* Same as WSAETIMEDOUT */
#endif
-#ifndef ENOSYS
+#if !defined(ENOSYS)
# define ENOSYS 140 /* Semi-arbitrary value */
#endif
-#ifndef EDEADLK
-# ifdef EDEADLOCK
+#if !defined(EDEADLK)
+# if defined(EDEADLOCK)
# define EDEADLK EDEADLOCK
# else
# define EDEADLK 36 /* This is the value in MSVC. */
@@ -289,10 +289,10 @@ enum {
#endif
/* POSIX 2008 - related to robust mutexes */
-#ifndef EOWNERDEAD
+#if !defined(EOWNERDEAD)
# define EOWNERDEAD 43
#endif
-#ifndef ENOTRECOVERABLE
+#if !defined(ENOTRECOVERABLE)
# define ENOTRECOVERABLE 44
#endif
@@ -302,20 +302,20 @@ enum {
* To avoid including windows.h we define only those things that we
* actually need from it.
*/
-#ifndef PTW32_INCLUDE_WINDOWS_H
-#ifndef HANDLE
+#if !defined(PTW32_INCLUDE_WINDOWS_H)
+#if !defined(HANDLE)
# define PTW32__HANDLE_DEF
# define HANDLE void *
#endif
-#ifndef DWORD
+#if !defined(DWORD)
# define PTW32__DWORD_DEF
# define DWORD unsigned long
#endif
#endif
-#ifndef HAVE_STRUCT_TIMESPEC
+#if !defined(HAVE_STRUCT_TIMESPEC)
#define HAVE_STRUCT_TIMESPEC
-#ifndef _TIMESPEC_DEFINED
+#if !defined(_TIMESPEC_DEFINED)
#define _TIMESPEC_DEFINED
struct timespec {
time_t tv_sec;
@@ -324,19 +324,19 @@ struct timespec {
#endif /* _TIMESPEC_DEFINED */
#endif /* HAVE_STRUCT_TIMESPEC */
-#ifndef SIG_BLOCK
+#if !defined(SIG_BLOCK)
#define SIG_BLOCK 0
#endif /* SIG_BLOCK */
-#ifndef SIG_UNBLOCK
+#if !defined(SIG_UNBLOCK)
#define SIG_UNBLOCK 1
#endif /* SIG_UNBLOCK */
-#ifndef SIG_SETMASK
+#if !defined(SIG_SETMASK)
#define SIG_SETMASK 2
#endif /* SIG_SETMASK */
-#ifdef __cplusplus
+#if defined(__cplusplus)
extern "C"
{
#endif /* __cplusplus */
@@ -537,7 +537,7 @@ extern "C"
#define SEM_VALUE_MAX INT_MAX
-#if __GNUC__ && ! defined (__declspec)
+#if defined(__GNUC__) && !defined(__declspec)
# error Please upgrade your GNU compiler to one that supports __declspec.
#endif
@@ -548,7 +548,7 @@ extern "C"
* be imported correctly.
*/
#if !defined(PTW32_STATIC_LIB)
-# ifdef PTW32_BUILD
+# if defined(PTW32_BUILD)
# define PTW32_DLLPORT __declspec (dllexport)
# else
# define PTW32_DLLPORT __declspec (dllimport)
@@ -746,7 +746,7 @@ struct ptw32_cleanup_t
struct ptw32_cleanup_t *prev;
};
-#ifdef __CLEANUP_SEH
+#if defined(__CLEANUP_SEH)
/*
* WIN32 SEH version of cancel cleanup.
*/
@@ -773,7 +773,7 @@ struct ptw32_cleanup_t
#else /* __CLEANUP_SEH */
-#ifdef __CLEANUP_C
+#if defined(__CLEANUP_C)
/*
* C implementation of PThreads cancel cleanup
@@ -791,7 +791,7 @@ struct ptw32_cleanup_t
#else /* __CLEANUP_C */
-#ifdef __CLEANUP_CXX
+#if defined(__CLEANUP_CXX)
/*
* C++ version of cancel cleanup.
@@ -1244,11 +1244,11 @@ PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle,
/*
* Thread-Safe C Runtime Library Mappings.
*/
-#ifndef _UWIN
+#if !defined(_UWIN)
# if defined(NEED_ERRNO)
PTW32_DLLPORT int * PTW32_CDECL _errno( void );
# else
-# ifndef errno
+# if !defined(errno)
# if (defined(_MT) || defined(_DLL))
__declspec(dllimport) extern int * __cdecl _errno(void);
# define errno (*_errno())
@@ -1265,7 +1265,7 @@ PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle,
# define _timeb timeb
#endif
-#ifdef __cplusplus
+#if defined(__cplusplus)
/*
* Internal exceptions
@@ -1286,9 +1286,9 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void);
#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
-#ifndef PTW32_BUILD
+#if !defined(PTW32_BUILD)
-#ifdef __CLEANUP_SEH
+#if defined(__CLEANUP_SEH)
/*
* Redefine the SEH __except keyword to ensure that applications
@@ -1300,19 +1300,19 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void);
#endif /* __CLEANUP_SEH */
-#ifdef __CLEANUP_CXX
+#if defined(__CLEANUP_CXX)
/*
* Redefine the C++ catch keyword to ensure that applications
* propagate our internal exceptions up to the library's internal handlers.
*/
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
/*
* WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll'
* if you want Pthread-Win32 cancelation and pthread_exit to work.
*/
-#ifndef PtW32NoCatchWarn
+#if !defined(PtW32NoCatchWarn)
#pragma message("Specify \"/DPtW32NoCatchWarn\" compiler flag to skip this message.")
#pragma message("------------------------------------------------------------------")
@@ -1321,7 +1321,7 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void);
#pragma message(" with 'PtW32CatchAll' or 'CATCHALL' if you want POSIX thread")
#pragma message(" cancelation and pthread_exit to work. For example:")
#pragma message("")
-#pragma message(" #ifdef PtW32CatchAll")
+#pragma message(" #if defined(PtW32CatchAll)")
#pragma message(" PtW32CatchAll")
#pragma message(" #else")
#pragma message(" catch(...)")
@@ -1349,14 +1349,14 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void);
#endif /* ! PTW32_BUILD */
-#ifdef __cplusplus
+#if defined(__cplusplus)
} /* End of extern "C" */
#endif /* __cplusplus */
-#ifdef PTW32__HANDLE_DEF
+#if defined(PTW32__HANDLE_DEF)
# undef HANDLE
#endif
-#ifdef PTW32__DWORD_DEF
+#if defined(PTW32__DWORD_DEF)
# undef DWORD
#endif
diff --git a/pthread_attr_getscope.c b/pthread_attr_getscope.c
index 3c86382..2efdb2f 100644
--- a/pthread_attr_getscope.c
+++ b/pthread_attr_getscope.c
@@ -38,14 +38,14 @@
#include "implement.h"
/* ignore warning "unreferenced formal parameter" */
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
#pragma warning( disable : 4100 )
#endif
int
pthread_attr_getscope (const pthread_attr_t * attr, int *contentionscope)
{
-#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
+#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
*contentionscope = (*attr)->contentionscope;
return 0;
#else
diff --git a/pthread_attr_getstackaddr.c b/pthread_attr_getstackaddr.c
index 9b55959..1a2da01 100644
--- a/pthread_attr_getstackaddr.c
+++ b/pthread_attr_getstackaddr.c
@@ -38,7 +38,7 @@
#include "implement.h"
/* ignore warning "unreferenced formal parameter" */
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
#pragma warning( disable : 4100 )
#endif
diff --git a/pthread_attr_getstacksize.c b/pthread_attr_getstacksize.c
index da8db63..dff9230 100644
--- a/pthread_attr_getstacksize.c
+++ b/pthread_attr_getstacksize.c
@@ -38,7 +38,7 @@
#include "implement.h"
/* ignore warning "unreferenced formal parameter" */
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
#pragma warning( disable : 4100 )
#endif
@@ -80,7 +80,7 @@ pthread_attr_getstacksize (const pthread_attr_t * attr, size_t * stacksize)
* ------------------------------------------------------
*/
{
-#ifdef _POSIX_THREAD_ATTR_STACKSIZE
+#if defined(_POSIX_THREAD_ATTR_STACKSIZE)
if (ptw32_is_attr (attr) != 0)
{
diff --git a/pthread_attr_init.c b/pthread_attr_init.c
index 6c10bd3..ae9d3eb 100644
--- a/pthread_attr_init.c
+++ b/pthread_attr_init.c
@@ -80,7 +80,7 @@ pthread_attr_init (pthread_attr_t * attr)
return ENOMEM;
}
-#ifdef _POSIX_THREAD_ATTR_STACKSIZE
+#if defined(_POSIX_THREAD_ATTR_STACKSIZE)
/*
* Default to zero size. Unless changed explicitly this
* will allow Win32 to set the size to that of the
@@ -89,14 +89,14 @@ pthread_attr_init (pthread_attr_t * attr)
attr_result->stacksize = 0;
#endif
-#ifdef _POSIX_THREAD_ATTR_STACKADDR
+#if defined(_POSIX_THREAD_ATTR_STACKADDR)
/* FIXME: Set this to something sensible when we support it. */
attr_result->stackaddr = NULL;
#endif
attr_result->detachstate = PTHREAD_CREATE_JOINABLE;
-#if HAVE_SIGSET_T
+#if defined(HAVE_SIGSET_T)
memset (&(attr_result->sigmask), 0, sizeof (sigset_t));
#endif /* HAVE_SIGSET_T */
diff --git a/pthread_attr_setscope.c b/pthread_attr_setscope.c
index 9cef423..39a51df 100644
--- a/pthread_attr_setscope.c
+++ b/pthread_attr_setscope.c
@@ -38,14 +38,14 @@
#include "implement.h"
/* ignore warning "unreferenced formal parameter" */
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
#pragma warning( disable : 4100 )
#endif
int
pthread_attr_setscope (pthread_attr_t * attr, int contentionscope)
{
-#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
+#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
switch (contentionscope)
{
case PTHREAD_SCOPE_SYSTEM:
diff --git a/pthread_attr_setstacksize.c b/pthread_attr_setstacksize.c
index 9df46af..eb13589 100644
--- a/pthread_attr_setstacksize.c
+++ b/pthread_attr_setstacksize.c
@@ -80,7 +80,7 @@ pthread_attr_setstacksize (pthread_attr_t * attr, size_t stacksize)
* ------------------------------------------------------
*/
{
-#ifdef _POSIX_THREAD_ATTR_STACKSIZE
+#if defined(_POSIX_THREAD_ATTR_STACKSIZE)
#if PTHREAD_STACK_MIN > 0
diff --git a/pthread_detach.c b/pthread_detach.c
index 84bfe1a..9ff6587 100644
--- a/pthread_detach.c
+++ b/pthread_detach.c
@@ -42,7 +42,7 @@
* Not needed yet, but defining it should indicate clashes with build target
* environment that should be fixed.
*/
-#ifndef WINCE
+#if !defined(WINCE)
# include <signal.h>
#endif
diff --git a/pthread_exit.c b/pthread_exit.c
index a2d7f8f..37b3c09 100644
--- a/pthread_exit.c
+++ b/pthread_exit.c
@@ -37,7 +37,7 @@
#include "pthread.h"
#include "implement.h"
-#ifndef _UWIN
+#if !defined(_UWIN)
/*# include <process.h> */
#endif
@@ -73,7 +73,7 @@ pthread_exit (void *value_ptr)
*/
sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey);
-#ifdef _UWIN
+#if defined(_UWIN)
if (--pthread_count <= 0)
exit ((int) value_ptr);
#endif
diff --git a/pthread_join.c b/pthread_join.c
index c49484d..c2b7c1e 100644
--- a/pthread_join.c
+++ b/pthread_join.c
@@ -42,7 +42,7 @@
* Not needed yet, but defining it should indicate clashes with build target
* environment that should be fixed.
*/
-#ifndef WINCE
+#if !defined(WINCE)
# include <signal.h>
#endif
diff --git a/pthread_key_create.c b/pthread_key_create.c
index 0851c0b..bdeee09 100644
--- a/pthread_key_create.c
+++ b/pthread_key_create.c
@@ -39,7 +39,7 @@
/* TLS_OUT_OF_INDEXES not defined on WinCE */
-#ifndef TLS_OUT_OF_INDEXES
+#if !defined(TLS_OUT_OF_INDEXES)
#define TLS_OUT_OF_INDEXES 0xffffffff
#endif
diff --git a/pthread_kill.c b/pthread_kill.c
index 21939d8..5473b43 100644
--- a/pthread_kill.c
+++ b/pthread_kill.c
@@ -41,7 +41,7 @@
* Not needed yet, but defining it should indicate clashes with build target
* environment that should be fixed.
*/
-#ifndef WINCE
+#if !defined(WINCE)
# include <signal.h>
#endif
diff --git a/pthread_mutex_consistent.c b/pthread_mutex_consistent.c
index b5dcc15..681358c 100755
--- a/pthread_mutex_consistent.c
+++ b/pthread_mutex_consistent.c
@@ -66,7 +66,7 @@
* ■ If the thread that acquires the lock with EOWNERDEAD terminates without unlocking the
* mutex, the next owner acquires the lock with an EOWNERDEAD return code.
*/
-#ifndef _UWIN
+#if !defined(_UWIN)
/*# include <process.h> */
#endif
#include "pthread.h"
diff --git a/pthread_mutex_lock.c b/pthread_mutex_lock.c
index ba410a6..0d4fde8 100644
--- a/pthread_mutex_lock.c
+++ b/pthread_mutex_lock.c
@@ -34,7 +34,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-#ifndef _UWIN
+#if !defined(_UWIN)
/*# include <process.h> */
#endif
#include "pthread.h"
diff --git a/pthread_self.c b/pthread_self.c
index 8b85c61..9a1765f 100644
--- a/pthread_self.c
+++ b/pthread_self.c
@@ -63,7 +63,7 @@ pthread_self (void)
pthread_t nil = {NULL, 0};
ptw32_thread_t * sp;
-#ifdef _UWIN
+#if defined(_UWIN)
if (!ptw32_selfThreadKey)
return nil;
#endif
@@ -95,7 +95,7 @@ pthread_self (void)
sp->detachState = PTHREAD_CREATE_DETACHED;
sp->thread = GetCurrentThreadId ();
-#ifdef NEED_DUPLICATEHANDLE
+#if defined(NEED_DUPLICATEHANDLE)
/*
* DuplicateHandle does not exist on WinCE.
*
diff --git a/pthread_win32_attach_detach_np.c b/pthread_win32_attach_detach_np.c
index 65e0913..25bcb95 100644
--- a/pthread_win32_attach_detach_np.c
+++ b/pthread_win32_attach_detach_np.c
@@ -54,7 +54,7 @@ pthread_win32_process_attach_np ()
result = ptw32_processInitialize ();
-#ifdef _UWIN
+#if defined(_UWIN)
pthread_count++;
#endif
diff --git a/ptw32_InterlockedCompareExchange.c b/ptw32_InterlockedCompareExchange.c
index 74b9f15..2a42b22 100644
--- a/ptw32_InterlockedCompareExchange.c
+++ b/ptw32_InterlockedCompareExchange.c
@@ -36,7 +36,7 @@
*/
#if 0
-#ifndef _WIN64
+#if !defined(_WIN64)
#include "pthread.h"
#include "implement.h"
diff --git a/ptw32_MCS_lock.c b/ptw32_MCS_lock.c
index 02cdc5e..d63ef5a 100644
--- a/ptw32_MCS_lock.c
+++ b/ptw32_MCS_lock.c
@@ -149,7 +149,7 @@ ptw32_mcs_flag_wait (LONG * flag)
* Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors.
* ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991.
*/
-#ifdef PTW32_BUILD_INLINED
+#if defined(PTW32_BUILD_INLINED)
INLINE
#endif /* PTW32_BUILD_INLINED */
void
@@ -183,7 +183,7 @@ ptw32_mcs_lock_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node)
* Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors.
* ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991.
*/
-#ifdef PTW32_BUILD_INLINED
+#if defined(PTW32_BUILD_INLINED)
INLINE
#endif /* PTW32_BUILD_INLINED */
void
@@ -219,7 +219,7 @@ ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node)
/*
* ptw32_mcs_lock_try_acquire
*/
-#ifdef PTW32_BUILD_INLINED
+#if defined(PTW32_BUILD_INLINED)
INLINE
#endif /* PTW32_BUILD_INLINED */
int
@@ -247,7 +247,7 @@ ptw32_mcs_lock_try_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * no
*
* Should only be called by the thread that has the lock.
*/
-#ifdef PTW32_BUILD_INLINED
+#if defined(PTW32_BUILD_INLINED)
INLINE
#endif /* PTW32_BUILD_INLINED */
void
diff --git a/ptw32_callUserDestroyRoutines.c b/ptw32_callUserDestroyRoutines.c
index 8873f87..f290f7b 100644
--- a/ptw32_callUserDestroyRoutines.c
+++ b/ptw32_callUserDestroyRoutines.c
@@ -38,10 +38,20 @@
#include "pthread.h"
#include "implement.h"
-#ifdef __cplusplus
-# if ! defined (_MSC_VER) && ! (defined(__GNUC__) && __GNUC__ < 3) && ! defined(__WATCOMC__)
-using
- std::terminate;
+#if defined(__CLEANUP_CXX)
+# if defined(_MSC_VER)
+# include <eh.h>
+# elif defined(__WATCOMC__)
+# include <eh.h>
+# include <exceptio.h>
+# else
+# if defined(__GNUC__) && __GNUC__ < 3
+# include <new.h>
+# else
+# include <new>
+ using
+ std::terminate;
+# endif
# endif
#endif
@@ -172,7 +182,7 @@ ptw32_callUserDestroyRoutines (pthread_t thread)
assocsRemaining++;
-#ifdef __cplusplus
+#if defined(__cplusplus)
try
{
diff --git a/ptw32_calloc.c b/ptw32_calloc.c
index eea7c74..e7b9e64 100644
--- a/ptw32_calloc.c
+++ b/ptw32_calloc.c
@@ -38,7 +38,7 @@
#include "implement.h"
-#ifdef NEED_CALLOC
+#if defined(NEED_CALLOC)
void *
ptw32_calloc (size_t n, size_t s)
{
diff --git a/ptw32_relmillisecs.c b/ptw32_relmillisecs.c
index a82bfb7..c9224ff 100644
--- a/ptw32_relmillisecs.c
+++ b/ptw32_relmillisecs.c
@@ -36,12 +36,12 @@
#include "pthread.h"
#include "implement.h"
-#ifndef NEED_FTIME
+#if !defined(NEED_FTIME)
#include <sys/timeb.h>
#endif
-#ifdef PTW32_BUILD_INLINED
+#if defined(PTW32_BUILD_INLINED)
INLINE
#endif /* PTW32_BUILD_INLINED */
DWORD
@@ -52,7 +52,7 @@ ptw32_relmillisecs (const struct timespec * abstime)
DWORD milliseconds;
int64_t tmpAbsMilliseconds;
int64_t tmpCurrMilliseconds;
-#ifdef NEED_FTIME
+#if defined(NEED_FTIME)
struct timespec currSysTime;
FILETIME ft;
SYSTEMTIME st;
@@ -81,7 +81,7 @@ ptw32_relmillisecs (const struct timespec * abstime)
/* get current system time */
-#ifdef NEED_FTIME
+#if defined(NEED_FTIME)
GetSystemTime(&st);
SystemTimeToFileTime(&st, &ft);
@@ -98,7 +98,7 @@ ptw32_relmillisecs (const struct timespec * abstime)
#else /* ! NEED_FTIME */
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
_ftime64_s(&currSysTime);
#elif (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601
_ftime64(&currSysTime);
diff --git a/ptw32_reuse.c b/ptw32_reuse.c
index 31ebdc4..7325857 100644
--- a/ptw32_reuse.c
+++ b/ptw32_reuse.c
@@ -126,7 +126,7 @@ ptw32_threadReusePush (pthread_t thread)
tp->ptHandle = t;
/* Bump the reuse counter now */
-#ifdef PTW32_THREAD_ID_REUSE_INCREMENT
+#if defined(PTW32_THREAD_ID_REUSE_INCREMENT)
tp->ptHandle.x += PTW32_THREAD_ID_REUSE_INCREMENT;
#else
tp->ptHandle.x++;
diff --git a/ptw32_semwait.c b/ptw32_semwait.c
index 361366b..c3c4fd0 100644
--- a/ptw32_semwait.c
+++ b/ptw32_semwait.c
@@ -34,7 +34,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-#ifndef _UWIN
+#if !defined(_UWIN)
/*# include <process.h> */
#endif
#include "pthread.h"
@@ -96,7 +96,7 @@ ptw32_semwait (sem_t * sem)
/* Must wait */
if (WaitForSingleObject (s->sem, INFINITE) == WAIT_OBJECT_0)
{
-#ifdef NEED_SEM
+#if defined(NEED_SEM)
if (pthread_mutex_lock (&s->lock) == 0)
{
if (*sem == NULL)
diff --git a/ptw32_threadStart.c b/ptw32_threadStart.c
index 830ae2e..3315972 100644
--- a/ptw32_threadStart.c
+++ b/ptw32_threadStart.c
@@ -37,8 +37,9 @@
#include "pthread.h"
#include "implement.h"
+#include <stdio.h>
-#ifdef __CLEANUP_SEH
+#if defined(__CLEANUP_SEH)
static DWORD
ExceptionFilter (EXCEPTION_POINTERS * ep, DWORD * ei)
@@ -129,12 +130,12 @@ ptw32_threadStart (void *vthreadParms)
void *(*start) (void *);
void * arg;
-#ifdef __CLEANUP_SEH
+#if defined(__CLEANUP_SEH)
DWORD
ei[] = { 0, 0, 0 };
#endif
-#ifdef __CLEANUP_C
+#if defined(__CLEANUP_C)
int setjmp_rc;
#endif
@@ -169,7 +170,7 @@ ptw32_threadStart (void *vthreadParms)
sp->state = PThreadStateRunning;
ptw32_mcs_lock_release (&stateLock);
-#ifdef __CLEANUP_SEH
+#if defined(__CLEANUP_SEH)
__try
{
@@ -179,7 +180,7 @@ ptw32_threadStart (void *vthreadParms)
status = sp->exitStatus = (*start) (arg);
sp->state = PThreadStateExiting;
-#ifdef _UWIN
+#if defined(_UWIN)
if (--pthread_count <= 0)
exit (0);
#endif
@@ -191,7 +192,7 @@ ptw32_threadStart (void *vthreadParms)
{
case PTW32_EPS_CANCEL:
status = sp->exitStatus = PTHREAD_CANCELED;
-#ifdef _UWIN
+#if defined(_UWIN)
if (--pthread_count <= 0)
exit (0);
#endif
@@ -207,7 +208,7 @@ ptw32_threadStart (void *vthreadParms)
#else /* __CLEANUP_SEH */
-#ifdef __CLEANUP_C
+#if defined(__CLEANUP_C)
setjmp_rc = setjmp (sp->start_mark);
@@ -238,7 +239,7 @@ ptw32_threadStart (void *vthreadParms)
#else /* __CLEANUP_C */
-#ifdef __CLEANUP_CXX
+#if defined(__CLEANUP_CXX)
ptw32_oldTerminate = set_terminate (&ptw32_terminate);
diff --git a/ptw32_throw.c b/ptw32_throw.c
index 19f9e11..4846306 100644
--- a/ptw32_throw.c
+++ b/ptw32_throw.c
@@ -46,7 +46,7 @@
* 'implicit' POSIX threads for each of the possible language modes (C,
* C++, and SEH).
*/
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
/*
* Ignore the warning:
* "C++ exception specification ignored except to indicate that
@@ -56,7 +56,7 @@
#endif
void
ptw32_throw (DWORD exception)
-#ifdef __CLEANUP_CXX
+#if defined(__CLEANUP_CXX)
throw(ptw32_exception_cancel,ptw32_exception_exit)
#endif
{
@@ -66,7 +66,7 @@ ptw32_throw (DWORD exception)
*/
ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey);
-#ifdef __CLEANUP_SEH
+#if defined(__CLEANUP_SEH)
DWORD exceptionInformation[3];
#endif
@@ -117,7 +117,7 @@ ptw32_throw (DWORD exception)
}
-#ifdef __CLEANUP_SEH
+#if defined(__CLEANUP_SEH)
exceptionInformation[0] = (DWORD) (exception);
@@ -128,14 +128,14 @@ ptw32_throw (DWORD exception)
#else /* __CLEANUP_SEH */
-#ifdef __CLEANUP_C
+#if defined(__CLEANUP_C)
ptw32_pop_cleanup_all (1);
longjmp (sp->start_mark, exception);
#else /* __CLEANUP_C */
-#ifdef __CLEANUP_CXX
+#if defined(__CLEANUP_CXX)
switch (exception)
{
@@ -173,7 +173,7 @@ ptw32_pop_cleanup_all (int execute)
DWORD
ptw32_get_exception_services_code (void)
{
-#ifdef __CLEANUP_SEH
+#if defined(__CLEANUP_SEH)
return EXCEPTION_PTW32_SERVICES;
diff --git a/ptw32_timespec.c b/ptw32_timespec.c
index 6a2cb56..c448645 100644
--- a/ptw32_timespec.c
+++ b/ptw32_timespec.c
@@ -39,7 +39,7 @@
#include "implement.h"
-#ifdef NEED_FTIME
+#if defined(NEED_FTIME)
/*
* time between jan 1, 1601 and jan 1, 1970 in units of 100 nanoseconds
diff --git a/sched.h b/sched.h
index b85a967..7c4bd1b 100644
--- a/sched.h
+++ b/sched.h
@@ -36,37 +36,37 @@
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-#ifndef _SCHED_H
+#if !defined(_SCHED_H)
#define _SCHED_H
-#undef PTW32_LEVEL
+#undef PTW32_SCHED_LEVEL
#if defined(_POSIX_SOURCE)
-#define PTW32_LEVEL 0
+#define PTW32_SCHED_LEVEL 0
/* Early POSIX */
#endif
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
-#undef PTW32_LEVEL
-#define PTW32_LEVEL 1
+#undef PTW32_SCHED_LEVEL
+#define PTW32_SCHED_LEVEL 1
/* Include 1b, 1c and 1d */
#endif
#if defined(INCLUDE_NP)
-#undef PTW32_LEVEL
-#define PTW32_LEVEL 2
+#undef PTW32_SCHED_LEVEL
+#define PTW32_SCHED_LEVEL 2
/* Include Non-Portable extensions */
#endif
-#define PTW32_LEVEL_MAX 3
+#define PTW32_SCHED_LEVEL_MAX 3
#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_LEVEL)
-#define PTW32_LEVEL PTW32_LEVEL_MAX
+#define PTW32_SCHED_LEVEL PTW32_SCHED_LEVEL_MAX
/* Include everything */
#endif
-#if __GNUC__ && ! defined (__declspec)
+#if defined(__GNUC__) && !defined(__declspec)
# error Please upgrade your GNU compiler to one that supports __declspec.
#endif
@@ -77,7 +77,7 @@
* be imported correctly.
*/
#if !defined(PTW32_STATIC_LIB)
-# ifdef PTW32_BUILD
+# if defined(PTW32_BUILD)
# define PTW32_DLLPORT __declspec (dllexport)
# else
# define PTW32_DLLPORT __declspec (dllimport)
@@ -91,7 +91,7 @@
* which is only used when building the pthread-win32 libraries.
*/
-#ifndef PTW32_CONFIG_H
+#if !defined(PTW32_CONFIG_H)
# if defined(WINCE)
# define NEED_ERRNO
# define NEED_SEM
@@ -108,16 +108,16 @@
*
*/
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX
-#ifdef NEED_ERRNO
+#if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX
+#if defined(NEED_ERRNO)
#include "need_errno.h"
#else
#include <errno.h>
#endif
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
+#endif /* PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX */
#if (defined(__MINGW64__) || defined(__MINGW32__)) || defined(_UWIN)
-# if PTW32_LEVEL >= PTW32_LEVEL_MAX
+# if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX
/* For pid_t */
# include <sys/types.h>
/* Required by Unix 98 */
@@ -143,7 +143,7 @@ struct sched_param {
int sched_priority;
};
-#ifdef __cplusplus
+#if defined(__cplusplus)
extern "C"
{
#endif /* __cplusplus */
@@ -172,12 +172,12 @@ PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid);
( errno = ENOTSUP, (int) -1 )
-#ifdef __cplusplus
+#if defined(__cplusplus)
} /* End of extern "C" */
#endif /* __cplusplus */
-#undef PTW32_LEVEL
-#undef PTW32_LEVEL_MAX
+#undef PTW32_SCHED_LEVEL
+#undef PTW32_SCHED_LEVEL_MAX
#endif /* !_SCHED_H */
diff --git a/sem_close.c b/sem_close.c
index 2f95c87..6d7280f 100644
--- a/sem_close.c
+++ b/sem_close.c
@@ -46,7 +46,7 @@
#include "implement.h"
/* ignore warning "unreferenced formal parameter" */
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
#pragma warning( disable : 4100 )
#endif
diff --git a/sem_init.c b/sem_init.c
index 02acd90..f682f4b 100644
--- a/sem_init.c
+++ b/sem_init.c
@@ -112,7 +112,7 @@ sem_init (sem_t * sem, int pshared, unsigned int value)
if (pthread_mutex_init(&s->lock, NULL) == 0)
{
-#ifdef NEED_SEM
+#if defined(NEED_SEM)
s->sem = CreateEvent (NULL,
PTW32_FALSE, /* auto (not manual) reset */
diff --git a/sem_open.c b/sem_open.c
index bf48c83..fb1cc54 100644
--- a/sem_open.c
+++ b/sem_open.c
@@ -46,7 +46,7 @@
#include "implement.h"
/* ignore warning "unreferenced formal parameter" */
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
#pragma warning( disable : 4100 )
#endif
diff --git a/sem_post.c b/sem_post.c
index c7a7a3c..3483252 100644
--- a/sem_post.c
+++ b/sem_post.c
@@ -93,7 +93,7 @@ sem_post (sem_t * sem)
if (s->value < SEM_VALUE_MAX)
{
-#ifdef NEED_SEM
+#if defined(NEED_SEM)
if (++s->value <= 0
&& !SetEvent(s->sem))
{
diff --git a/sem_post_multiple.c b/sem_post_multiple.c
index 3d1e4ef..44c168c 100644
--- a/sem_post_multiple.c
+++ b/sem_post_multiple.c
@@ -101,7 +101,7 @@ sem_post_multiple (sem_t * sem, int count)
s->value += count;
if (waiters > 0)
{
-#ifdef NEED_SEM
+#if defined(NEED_SEM)
if (SetEvent(s->sem))
{
waiters--;
diff --git a/sem_timedwait.c b/sem_timedwait.c
index 1db6217..103fb9e 100644
--- a/sem_timedwait.c
+++ b/sem_timedwait.c
@@ -77,7 +77,7 @@ ptw32_sem_timedwait_cleanup (void * args)
{
/* Indicate we're no longer waiting */
s->value++;
-#ifdef NEED_SEM
+#if defined(NEED_SEM)
if (s->value > 0)
{
s->leftToUnblock = 0;
@@ -177,7 +177,7 @@ sem_timedwait (sem_t * sem, const struct timespec *abstime)
if (v < 0)
{
-#ifdef NEED_SEM
+#if defined(NEED_SEM)
int timedout;
#endif
sem_timedwait_cleanup_args_t cleanup_args;
@@ -190,7 +190,7 @@ sem_timedwait (sem_t * sem, const struct timespec *abstime)
#endif
/* Must wait */
pthread_cleanup_push(ptw32_sem_timedwait_cleanup, (void *) &cleanup_args);
-#ifdef NEED_SEM
+#if defined(NEED_SEM)
timedout =
#endif
result = pthreadCancelableTimedWait (s->sem, milliseconds);
@@ -199,7 +199,7 @@ sem_timedwait (sem_t * sem, const struct timespec *abstime)
#pragma inline_depth()
#endif
-#ifdef NEED_SEM
+#if defined(NEED_SEM)
if (!timedout && pthread_mutex_lock (&s->lock) == 0)
{
diff --git a/sem_unlink.c b/sem_unlink.c
index a6c6f81..fb80569 100644
--- a/sem_unlink.c
+++ b/sem_unlink.c
@@ -46,7 +46,7 @@
#include "implement.h"
/* ignore warning "unreferenced formal parameter" */
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
#pragma warning( disable : 4100 )
#endif
diff --git a/sem_wait.c b/sem_wait.c
index eeaae95..966afe6 100644
--- a/sem_wait.c
+++ b/sem_wait.c
@@ -63,7 +63,7 @@ ptw32_sem_wait_cleanup(void * sem)
if (*((sem_t *)sem) != NULL && !(WaitForSingleObject(s->sem, 0) == WAIT_OBJECT_0))
{
++s->value;
-#ifdef NEED_SEM
+#if defined(NEED_SEM)
if (s->value > 0)
{
s->leftToUnblock = 0;
@@ -151,7 +151,7 @@ sem_wait (sem_t * sem)
#pragma inline_depth()
#endif
}
-#ifdef NEED_SEM
+#if defined(NEED_SEM)
if (!result && pthread_mutex_lock (&s->lock) == 0)
{
diff --git a/semaphore.c b/semaphore.c
index 6b2b10e..64fc0e3 100644
--- a/semaphore.c
+++ b/semaphore.c
@@ -45,7 +45,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-#ifndef NEED_FTIME
+#if !defined(NEED_FTIME)
# include <sys/timeb.h>
#endif
diff --git a/semaphore.h b/semaphore.h
index 891c929..c6e9407 100644
--- a/semaphore.h
+++ b/semaphore.h
@@ -39,33 +39,33 @@
#if !defined( SEMAPHORE_H )
#define SEMAPHORE_H
-#undef PTW32_LEVEL
+#undef PTW32_SEMAPHORE_LEVEL
#if defined(_POSIX_SOURCE)
-#define PTW32_LEVEL 0
+#define PTW32_SEMAPHORE_LEVEL 0
/* Early POSIX */
#endif
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
-#undef PTW32_LEVEL
-#define PTW32_LEVEL 1
+#undef PTW32_SEMAPHORE_LEVEL
+#define PTW32_SEMAPHORE_LEVEL 1
/* Include 1b, 1c and 1d */
#endif
#if defined(INCLUDE_NP)
-#undef PTW32_LEVEL
-#define PTW32_LEVEL 2
+#undef PTW32_SEMAPHORE_LEVEL
+#define PTW32_SEMAPHORE_LEVEL 2
/* Include Non-Portable extensions */
#endif
-#define PTW32_LEVEL_MAX 3
+#define PTW32_SEMAPHORE_LEVEL_MAX 3
-#if !defined(PTW32_LEVEL)
-#define PTW32_LEVEL PTW32_LEVEL_MAX
+#if !defined(PTW32_SEMAPHORE_LEVEL)
+#define PTW32_SEMAPHORE_LEVEL PTW32_SEMAPHORE_LEVEL_MAX
/* Include everything */
#endif
-#if __GNUC__ && ! defined (__declspec)
+#if defined(__GNUC__) && ! defined (__declspec)
# error Please upgrade your GNU compiler to one that supports __declspec.
#endif
@@ -76,7 +76,7 @@
* be imported correctly.
*/
#if !defined(PTW32_STATIC_LIB)
-# ifdef PTW32_BUILD
+# if defined(PTW32_BUILD)
# define PTW32_DLLPORT __declspec (dllexport)
# else
# define PTW32_DLLPORT __declspec (dllimport)
@@ -90,7 +90,7 @@
* which is only used when building the pthread-win32 libraries.
*/
-#ifndef PTW32_CONFIG_H
+#if !defined(PTW32_CONFIG_H)
# if defined(WINCE)
# define NEED_ERRNO
# define NEED_SEM
@@ -107,22 +107,22 @@
*
*/
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX
-#ifdef NEED_ERRNO
+#if PTW32_SEMAPHORE_LEVEL >= PTW32_SEMAPHORE_LEVEL_MAX
+#if defined(NEED_ERRNO)
#include "need_errno.h"
#else
#include <errno.h>
#endif
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
+#endif /* PTW32_SEMAPHORE_LEVEL >= PTW32_SEMAPHORE_LEVEL_MAX */
#define _POSIX_SEMAPHORES
-#ifdef __cplusplus
+#if defined(__cplusplus)
extern "C"
{
#endif /* __cplusplus */
-#ifndef HAVE_MODE_T
+#if !defined(HAVE_MODE_T)
typedef unsigned int mode_t;
#endif
@@ -159,11 +159,11 @@ PTW32_DLLPORT int __cdecl sem_unlink (const char * name);
PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem,
int * sval);
-#ifdef __cplusplus
+#if defined(__cplusplus)
} /* End of extern "C" */
#endif /* __cplusplus */
-#undef PTW32_LEVEL
-#undef PTW32_LEVEL_MAX
+#undef PTW32_SEMAPHORE_LEVEL
+#undef PTW32_SEMAPHORE_LEVEL_MAX
#endif /* !SEMAPHORE_H */
diff --git a/signal.c b/signal.c
index 8f56c48..eef4669 100644
--- a/signal.c
+++ b/signal.c
@@ -84,7 +84,7 @@
#include "pthread.h"
#include "implement.h"
-#if HAVE_SIGSET_T
+#if defined(HAVE_SIGSET_T)
static void
ptw32_signal_thread ()
diff --git a/tests/ChangeLog b/tests/ChangeLog
index f5d8d08..843837f 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2011-05-11 Ross Johnson <ross.johnson at homemail.com.au>
+
+ * GNUmakefile (GCE-debug): New target; expects pthreadGCE2d.dll.
+
2011-05-05 Ross Johnson <ross.johnson at homemail.com.au>
* openmp1.c: Add missing test; used to comfirm that this
diff --git a/tests/GNUmakefile b/tests/GNUmakefile
index 9a46b2c..e0e9de5 100644
--- a/tests/GNUmakefile
+++ b/tests/GNUmakefile
@@ -204,6 +204,9 @@ GCE-bench:
GC-debug:
$(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-fopenmp -D__CLEANUP_C" OPT="${DOPT}" DLL_VER="$(DLL_VER)d" all-pass
+GCE-debug:
+ $(MAKE) TEST=GCE CC=$(CXX) XXCFLAGS="-fopenmp -D__CLEANUP_CXX" OPT="${DOPT}" DLL_VER="$(DLL_VER)d" all-pass
+
GC-bench-debug:
$(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-D__CLEANUP_C" XXLIBS="benchlib.o" OPT="${OPT}" DLL_VER="$(DLL_VER)d" all-bench
diff --git a/tests/SIZES.GCE b/tests/SIZES.GCE
index 7048d3a..709114d 100755
--- a/tests/SIZES.GCE
+++ b/tests/SIZES.GCE
@@ -1,11 +1,11 @@
Sizes of pthreads-win32 structs
-------------------------------
pthread_t 8
- ptw32_thread_t 76
+ ptw32_thread_t 96
pthread_attr_t_ 28
sem_t_ 12
- pthread_mutex_t_ 24
- pthread_mutexattr_t_ 8
+ pthread_mutex_t_ 28
+ pthread_mutexattr_t_ 12
pthread_spinlock_t_ 8
pthread_barrier_t_ 36
pthread_barrierattr_t_ 4
diff --git a/tests/SIZES.VCE b/tests/SIZES.VCE
index 7048d3a..709114d 100644
--- a/tests/SIZES.VCE
+++ b/tests/SIZES.VCE
@@ -1,11 +1,11 @@
Sizes of pthreads-win32 structs
-------------------------------
pthread_t 8
- ptw32_thread_t 76
+ ptw32_thread_t 96
pthread_attr_t_ 28
sem_t_ 12
- pthread_mutex_t_ 24
- pthread_mutexattr_t_ 8
+ pthread_mutex_t_ 28
+ pthread_mutexattr_t_ 12
pthread_spinlock_t_ 8
pthread_barrier_t_ 36
pthread_barrierattr_t_ 4
diff --git a/tests/cancel2.c b/tests/cancel2.c
index d7c7f86..83cb6eb 100644
--- a/tests/cancel2.c
+++ b/tests/cancel2.c
@@ -80,7 +80,7 @@
* Create NUMTHREADS threads in addition to the Main thread.
*/
enum {
- NUMTHREADS = 1
+ NUMTHREADS = 4
};
typedef struct bag_t_ bag_t;
diff --git a/tests/reuse2.c b/tests/reuse2.c
index c4db811..362e547 100644
--- a/tests/reuse2.c
+++ b/tests/reuse2.c
@@ -111,7 +111,8 @@ main()
for (i = 0; i < NUMTHREADS; i++)
{
- assert(pthread_create(&t[i], &attr, func, NULL) == 0);
+ while(pthread_create(&t[i], &attr, func, NULL) != 0)
+ Sleep(1);
}
while (NUMTHREADS > InterlockedExchangeAdd((LPLONG)&done, 0L))
diff --git a/version.rc b/version.rc
index 1317925..02d779c 100644
--- a/version.rc
+++ b/version.rc
@@ -41,13 +41,13 @@
* If using the default (no __CLEANUP_* defined), pthread.h will define it
* as __CLEANUP_C.
*/
-#ifdef _WIN64
+#if defined(_WIN64)
# define PTW32_ARCH "64 bit"
#else
# define PTW32_ARCH "32 bit"
#endif
-#ifdef PTW32_RC_MSC
+#if defined(PTW32_RC_MSC)
# if defined(__CLEANUP_C)
# define PTW32_VERSIONINFO_NAME "pthreadVC\0"
# define PTW32_VERSIONINFO_DESCRIPTION "MS C " PTW32_ARCH "\0"