Skip to content

Commit

Permalink
More 64 bit cast fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
rpj committed Mar 6, 2011
1 parent 1e42dcd commit 839ca1c
Show file tree
Hide file tree
Showing 41 changed files with 84 additions and 69 deletions.
2 changes: 1 addition & 1 deletion Bmakefile
Expand Up @@ -21,7 +21,7 @@ OPTIM = /O2
RC = brcc32 RC = brcc32
RCFLAGS = -i. RCFLAGS = -i.


CFLAGS = /q /I. /D_WIN32_WINNT=0x400 /DHAVE_CONFIG_H=1 /4 /tWD /tWM \ CFLAGS = /q /I. /D_WIN32_WINNT=0x400 /DHAVE_PTW32_CONFIG_H=1 /4 /tWD /tWM \
/w-aus /w-asc /w-par /w-aus /w-asc /w-par


#C cleanup code #C cleanup code
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTORS
Expand Up @@ -7,7 +7,7 @@ Ben Elliston bje at cygnus dot com
Initiated the project; Initiated the project;
setup the project infrastructure (CVS, web page, etc.); setup the project infrastructure (CVS, web page, etc.);
early prototype routines. early prototype routines.
Ross Johnson rpj at callisto dot canberra dot edu dot au Ross Johnson Ross dot Johnson at dot homemail dot com dot au
early prototype routines; early prototype routines;
ongoing project coordination/maintenance; ongoing project coordination/maintenance;
implementation of spin locks and barriers; implementation of spin locks and barriers;
Expand Down Expand Up @@ -131,4 +131,4 @@ Vladimir Kliatchko vladimir at kliatchko dot com
Ramiro Polla ramiro.polla at gmail.com Ramiro Polla ramiro.polla at gmail.com
static library auto init/cleanup on application static library auto init/cleanup on application
start/exit via RT hooks (MSC and GCC compilers only). start/exit via RT hooks (MSC and GCC compilers only).


2 changes: 1 addition & 1 deletion GNUmakefile
Expand Up @@ -99,7 +99,7 @@ GCE_CFLAGS = $(PTW32_FLAGS) -mthreads


## Mingw32 ## Mingw32
MAKE ?= make MAKE ?= make
CFLAGS = $(OPT) $(XOPT) -I. -DHAVE_CONFIG_H -Wall CFLAGS = $(OPT) $(XOPT) -I. -DHAVE_PTW32_CONFIG_H -Wall


DLL_INLINED_OBJS = \ DLL_INLINED_OBJS = \
pthread.o \ pthread.o \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -27,7 +27,7 @@ STATIC_STAMPS = pthreadVCE$(DLL_VER).static pthreadVSE$(DLL_VER).static pthreadV
OPTIM = /O2 /Ob2 OPTIM = /O2 /Ob2
OPTIMD = OPTIMD =


CFLAGS = /W3 /MD /nologo /I. /D_WIN32_WINNT=0x400 /DHAVE_CONFIG_H CFLAGS = /W3 /MD /nologo /I. /D_WIN32_WINNT=0x400 /DHAVE_PTW32_CONFIG_H
CFLAGSD = /Z7 $(CFLAGS) CFLAGSD = /Z7 $(CFLAGS)


# Uncomment this if config.h defines RETAIN_WSALASTERROR # Uncomment this if config.h defines RETAIN_WSALASTERROR
Expand Down
2 changes: 1 addition & 1 deletion Nmakefile
Expand Up @@ -4,7 +4,7 @@


VERSION = - VERSION = -
CCFLAGS = -V -g $(CC.DLL) CCFLAGS = -V -g $(CC.DLL)
HAVE_CONFIG_H == 1 HAVE_PTW32_CONFIG_H == 1
_MT == 1 _MT == 1
_timeb == timeb _timeb == timeb
_ftime == ftime _ftime == ftime
Expand Down
4 changes: 2 additions & 2 deletions autostatic.c
@@ -1,8 +1,8 @@
/* /*
* pthread_barrier_wait.c * autostatic.c
* *
* Description: * Description:
* This translation unit implements barrier primitives. * This translation unit implements static auto-init and auto-exit logic.
* *
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* *
Expand Down
4 changes: 2 additions & 2 deletions builddmc.bat
Expand Up @@ -3,7 +3,7 @@
set DMCDIR=c:\dm set DMCDIR=c:\dm


; RELEASE ; RELEASE
%DMCDIR%\bin\dmc -D_WIN32_WINNT -D_MT -DHAVE_CONFIG_H -I.;c:\dm\include -o+all -WD pthread.c user32.lib+kernel32.lib+wsock32.lib -L/impl -L/NODEBUG -L/SU:WINDOWS %DMCDIR%\bin\dmc -D_WIN32_WINNT -D_MT -DHAVE_PTW32_CONFIG_H -I.;c:\dm\include -o+all -WD pthread.c user32.lib+kernel32.lib+wsock32.lib -L/impl -L/NODEBUG -L/SU:WINDOWS


; DEBUG ; DEBUG
%DMCDIR%\bin\dmc -g -D_WIN32_WINNT -D_MT -DHAVE_CONFIG_H -I.;c:\dm\include -o+all -WD pthread.c user32.lib+kernel32.lib+wsock32.lib -L/impl -L/SU:WINDOWS %DMCDIR%\bin\dmc -g -D_WIN32_WINNT -D_MT -DHAVE_PTW32_CONFIG_H -I.;c:\dm\include -o+all -WD pthread.c user32.lib+kernel32.lib+wsock32.lib -L/impl -L/SU:WINDOWS
4 changes: 2 additions & 2 deletions need_errno.h
Expand Up @@ -20,8 +20,8 @@
#ifndef _INC_ERRNO #ifndef _INC_ERRNO
#define _INC_ERRNO #define _INC_ERRNO


#if !defined(_WIN32) && !defined(_MAC) #if !defined(_WIN32)
#error ERROR: Only Mac or Win32 targets supported! #error ERROR: Only Win32 targets supported!
#endif #endif


#include <winsock.h> #include <winsock.h>
Expand Down
6 changes: 3 additions & 3 deletions pthread.h
Expand Up @@ -112,7 +112,7 @@
#ifdef _UWIN #ifdef _UWIN
# define HAVE_STRUCT_TIMESPEC 1 # define HAVE_STRUCT_TIMESPEC 1
# define HAVE_SIGNAL_H 1 # define HAVE_SIGNAL_H 1
# undef HAVE_CONFIG_H # undef HAVE_PTW32_CONFIG_H
# pragma comment(lib, "pthread") # pragma comment(lib, "pthread")
#endif #endif


Expand Down Expand Up @@ -210,9 +210,9 @@ typedef unsigned long DWORD_PTR;
* ----------------- * -----------------
*/ */


#if HAVE_CONFIG_H #if HAVE_PTW32_CONFIG_H
#include "config.h" #include "config.h"
#endif /* HAVE_CONFIG_H */ #endif /* HAVE_PTW32_CONFIG_H */


#ifndef NEED_FTIME #ifndef NEED_FTIME
#include <time.h> #include <time.h>
Expand Down
2 changes: 1 addition & 1 deletion pthread_cancel.c
Expand Up @@ -47,7 +47,7 @@ ptw32_cancel_self (void)
} }


static void CALLBACK static void CALLBACK
ptw32_cancel_callback (DWORD unused) ptw32_cancel_callback (ULONG_PTR unused)
{ {
ptw32_throw (PTW32_EPS_CANCEL); ptw32_throw (PTW32_EPS_CANCEL);


Expand Down
20 changes: 16 additions & 4 deletions ptw32_MCS_lock.c
Expand Up @@ -148,7 +148,10 @@ ptw32_mcs_flag_wait (LONG * flag)
* Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors. * Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors.
* ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991. * ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991.
*/ */
INLINE void #ifdef PTW32_BUILD_INLINED
INLINE
#endif /* PTW32_BUILD_INLINED */
void
ptw32_mcs_lock_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node) ptw32_mcs_lock_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node)
{ {
ptw32_mcs_local_node_t *pred; ptw32_mcs_local_node_t *pred;
Expand Down Expand Up @@ -179,7 +182,10 @@ ptw32_mcs_lock_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node)
* Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors. * Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors.
* ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991. * ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991.
*/ */
INLINE void #ifdef PTW32_BUILD_INLINED
INLINE
#endif /* PTW32_BUILD_INLINED */
void
ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node) ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node)
{ {
ptw32_mcs_lock_t *lock = node->lock; ptw32_mcs_lock_t *lock = node->lock;
Expand Down Expand Up @@ -212,7 +218,10 @@ ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node)
/* /*
* ptw32_mcs_lock_try_acquire * ptw32_mcs_lock_try_acquire
*/ */
INLINE int #ifdef PTW32_BUILD_INLINED
INLINE
#endif /* PTW32_BUILD_INLINED */
int
ptw32_mcs_lock_try_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node) ptw32_mcs_lock_try_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node)
{ {
node->lock = lock; node->lock = lock;
Expand All @@ -238,7 +247,10 @@ 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. * Should only be called by the thread that has the lock.
*/ */
INLINE void #ifdef PTW32_BUILD_INLINED
INLINE
#endif /* PTW32_BUILD_INLINED */
void
ptw32_mcs_node_transfer (ptw32_mcs_local_node_t * new_node, ptw32_mcs_local_node_t * old_node) ptw32_mcs_node_transfer (ptw32_mcs_local_node_t * new_node, ptw32_mcs_local_node_t * old_node)
{ {
new_node->lock = old_node->lock; new_node->lock = old_node->lock;
Expand Down
5 changes: 4 additions & 1 deletion ptw32_relmillisecs.c
Expand Up @@ -41,7 +41,10 @@
#endif #endif




INLINE DWORD #ifdef PTW32_BUILD_INLINED
INLINE
#endif /* PTW32_BUILD_INLINED */
DWORD
ptw32_relmillisecs (const struct timespec * abstime) ptw32_relmillisecs (const struct timespec * abstime)
{ {
const int64_t NANOSEC_PER_MILLISEC = 1000000; const int64_t NANOSEC_PER_MILLISEC = 1000000;
Expand Down
28 changes: 14 additions & 14 deletions tests/SIZES.GCE
@@ -1,21 +1,21 @@
Sizes of pthreads-win32 structs Sizes of pthreads-win32 structs
------------------------------- -------------------------------
pthread_t 8 pthread_t 8
ptw32_thread_t 76 ptw32_thread_t 76
pthread_attr_t_ 28 pthread_attr_t_ 28
sem_t_ 12 sem_t_ 12
pthread_mutex_t_ 24 pthread_mutex_t_ 24
pthread_mutexattr_t_ 8 pthread_mutexattr_t_ 8
pthread_spinlock_t_ 8 pthread_spinlock_t_ 8
pthread_barrier_t_ 36 pthread_barrier_t_ 36
pthread_barrierattr_t_ 4 pthread_barrierattr_t_ 4
pthread_key_t_ 16 pthread_key_t_ 16
pthread_cond_t_ 32 pthread_cond_t_ 32
pthread_condattr_t_ 4 pthread_condattr_t_ 4
pthread_rwlock_t_ 28 pthread_rwlock_t_ 28
pthread_rwlockattr_t_ 4 pthread_rwlockattr_t_ 4
pthread_once_t_ 16 pthread_once_t_ 16
ptw32_cleanup_t 12 ptw32_cleanup_t 12
ptw32_mcs_node_t_ 16 ptw32_mcs_node_t_ 16
sched_param 4 sched_param 4
------------------------------- -------------------------------
2 changes: 1 addition & 1 deletion tests/barrier3.c
Expand Up @@ -60,7 +60,7 @@ main()


assert(pthread_create(&t, NULL, func, NULL) == 0); assert(pthread_create(&t, NULL, func, NULL) == 0);


assert(pthread_join(t, (void *) &result) == 0); assert(pthread_join(t, &result) == 0);


assert((int)(size_t)result == PTHREAD_BARRIER_SERIAL_THREAD); assert((int)(size_t)result == PTHREAD_BARRIER_SERIAL_THREAD);


Expand Down
2 changes: 1 addition & 1 deletion tests/barrier5.c
Expand Up @@ -103,7 +103,7 @@ main()
serialThreadsTotal = 0; serialThreadsTotal = 0;
for (i = 1; i <= j; i++) for (i = 1; i <= j; i++)
{ {
assert(pthread_join(t[i], (void *) &result) == 0); assert(pthread_join(t[i], &result) == 0);
serialThreadsTotal += (int)(size_t)result; serialThreadsTotal += (int)(size_t)result;
} }


Expand Down
2 changes: 1 addition & 1 deletion tests/cancel2.c
Expand Up @@ -219,7 +219,7 @@ main()
int fail = 0; int fail = 0;
void* result = (void*)0; void* result = (void*)0;


assert(pthread_join(t[i], (void *) &result) == 0); assert(pthread_join(t[i], &result) == 0);
fail = ((int)(size_t)result != (int) PTHREAD_CANCELED); fail = ((int)(size_t)result != (int) PTHREAD_CANCELED);
if (fail) if (fail)
{ {
Expand Down
2 changes: 1 addition & 1 deletion tests/cleanup0.c
Expand Up @@ -191,7 +191,7 @@ main()
int fail = 0; int fail = 0;
void* result = (void*)0; void* result = (void*)0;


assert(pthread_join(t[i], (void *) &result) == 0); assert(pthread_join(t[i], &result) == 0);


fail = ((int)(size_t)result == (int) PTHREAD_CANCELED); fail = ((int)(size_t)result == (int) PTHREAD_CANCELED);


Expand Down
2 changes: 1 addition & 1 deletion tests/cleanup1.c
Expand Up @@ -205,7 +205,7 @@ main()
int fail = 0; int fail = 0;
void* result = (void*)0; void* result = (void*)0;


assert(pthread_join(t[i], (void *) &result) == 0); assert(pthread_join(t[i], &result) == 0);


fail = ((int)(size_t)result != (int) PTHREAD_CANCELED); fail = ((int)(size_t)result != (int) PTHREAD_CANCELED);


Expand Down
2 changes: 1 addition & 1 deletion tests/cleanup2.c
Expand Up @@ -180,7 +180,7 @@ main()
int fail = 0; int fail = 0;
void* result = (void*)0; void* result = (void*)0;


assert(pthread_join(t[i], (void *) &result) == 0); assert(pthread_join(t[i], &result) == 0);


fail = ((int)(size_t)result != 0); fail = ((int)(size_t)result != 0);


Expand Down
2 changes: 1 addition & 1 deletion tests/cleanup3.c
Expand Up @@ -185,7 +185,7 @@ main()
int fail = 0; int fail = 0;
void* result = (void*)0; void* result = (void*)0;


assert(pthread_join(t[i], (void *) &result) == 0); assert(pthread_join(t[i], &result) == 0);


fail = ((int)(size_t)result != 0); fail = ((int)(size_t)result != 0);


Expand Down
2 changes: 1 addition & 1 deletion tests/condvar1_2.c
Expand Up @@ -116,7 +116,7 @@ main()
} }
while (j > 0); while (j > 0);


assert(pthread_join(t, (void *) &result) == 0); assert(pthread_join(t, &result) == 0);
assert ((int)(size_t)result == 0); assert ((int)(size_t)result == 0);
} }


Expand Down
2 changes: 1 addition & 1 deletion tests/condvar2_1.c
Expand Up @@ -136,7 +136,7 @@ main()


for (i = 1; i <= NUMTHREADS; i++) for (i = 1; i <= NUMTHREADS; i++)
{ {
assert(pthread_join(t[i], (void *) &result) == 0); assert(pthread_join(t[i], &result) == 0);
assert((int)(size_t)result == i); assert((int)(size_t)result == i);
} }


Expand Down
2 changes: 1 addition & 1 deletion tests/condvar3_1.c
Expand Up @@ -172,7 +172,7 @@ main()


for (i = 1; i <= NUMTHREADS; i++) for (i = 1; i <= NUMTHREADS; i++)
{ {
assert(pthread_join(t[i], (void *) &result) == 0); assert(pthread_join(t[i], &result) == 0);
assert((int)(size_t)result == i); assert((int)(size_t)result == i);
} }


Expand Down
2 changes: 1 addition & 1 deletion tests/condvar3_2.c
Expand Up @@ -156,7 +156,7 @@ main()


for (i = 1; i <= NUMTHREADS; i++) for (i = 1; i <= NUMTHREADS; i++)
{ {
assert(pthread_join(t[i], (void *) &result) == 0); assert(pthread_join(t[i], &result) == 0);
assert((int)(size_t)result == i); assert((int)(size_t)result == i);
/* /*
* Approximately 2/3rds of the threads are expected to time out. * Approximately 2/3rds of the threads are expected to time out.
Expand Down
2 changes: 1 addition & 1 deletion tests/delay2.c
Expand Up @@ -74,7 +74,7 @@ main(int argc, char * argv[])


assert(pthread_mutex_unlock(&mx) == 0); assert(pthread_mutex_unlock(&mx) == 0);


assert(pthread_join(t, (void *) &result) == 0); assert(pthread_join(t, &result) == 0);
assert(result == (void*)PTHREAD_CANCELED); assert(result == (void*)PTHREAD_CANCELED);


return 0; return 0;
Expand Down
2 changes: 1 addition & 1 deletion tests/exception1.c
Expand Up @@ -235,7 +235,7 @@ main()
failed = (failed || fail); failed = (failed || fail);


/* Exceptioned thread */ /* Exceptioned thread */
assert(pthread_join(et[i], (void *) &result) == 0); assert(pthread_join(et[i], &result) == 0);
assert(!(fail = (result != (void*)((int)(size_t)PTHREAD_CANCELED + 2)))); assert(!(fail = (result != (void*)((int)(size_t)PTHREAD_CANCELED + 2))));


failed = (failed || fail); failed = (failed || fail);
Expand Down
2 changes: 1 addition & 1 deletion tests/exception2.c
Expand Up @@ -113,7 +113,7 @@ exceptionedThread(void * arg)
} }


int int
main(int argc, char argv[]) main(int argc, char* argv[])
{ {
int i; int i;
pthread_t mt; pthread_t mt;
Expand Down
2 changes: 1 addition & 1 deletion tests/join0.c
Expand Up @@ -58,7 +58,7 @@ main(int argc, char * argv[])
/* Create a single thread and wait for it to exit. */ /* Create a single thread and wait for it to exit. */
assert(pthread_create(&id, NULL, func, (void *) 123) == 0); assert(pthread_create(&id, NULL, func, (void *) 123) == 0);


assert(pthread_join(id, (void *) &result) == 0); assert(pthread_join(id, &result) == 0);


assert((int)(size_t)result == 123); assert((int)(size_t)result == 123);


Expand Down
2 changes: 1 addition & 1 deletion tests/join1.c
Expand Up @@ -69,7 +69,7 @@ main(int argc, char * argv[])


for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
assert(pthread_join(id[i], (void *) &result) == 0); assert(pthread_join(id[i], &result) == 0);
assert((int)(size_t)result == i); assert((int)(size_t)result == i);
} }


Expand Down
2 changes: 1 addition & 1 deletion tests/join2.c
Expand Up @@ -60,7 +60,7 @@ main(int argc, char * argv[])


for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
assert(pthread_join(id[i], (void *) &result) == 0); assert(pthread_join(id[i], &result) == 0);
assert((int)(size_t)result == i); assert((int)(size_t)result == i);
} }


Expand Down
2 changes: 1 addition & 1 deletion tests/join3.c
Expand Up @@ -66,7 +66,7 @@ main(int argc, char * argv[])


for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
assert(pthread_join(id[i], (void *) &result) == 0); assert(pthread_join(id[i], &result) == 0);
assert((int)(size_t)result == i); assert((int)(size_t)result == i);
} }


Expand Down
2 changes: 1 addition & 1 deletion tests/mutex6e.c
Expand Up @@ -86,7 +86,7 @@ main()


assert(pthread_create(&t, NULL, locker, NULL) == 0); assert(pthread_create(&t, NULL, locker, NULL) == 0);


assert(pthread_join(t, (void *) &result) == 0); assert(pthread_join(t, &result) == 0);
assert((int)(size_t)result == 555); assert((int)(size_t)result == 555);


assert(lockCount == 2); assert(lockCount == 2);
Expand Down
2 changes: 1 addition & 1 deletion tests/mutex6es.c
Expand Up @@ -79,7 +79,7 @@ main()


assert(pthread_create(&t, NULL, locker, NULL) == 0); assert(pthread_create(&t, NULL, locker, NULL) == 0);


assert(pthread_join(t, (void *) &result) == 0); assert(pthread_join(t, &result) == 0);
assert((int)(size_t)result == 555); assert((int)(size_t)result == 555);


assert(lockCount == 2); assert(lockCount == 2);
Expand Down
2 changes: 1 addition & 1 deletion tests/mutex6r.c
Expand Up @@ -85,7 +85,7 @@ main()


assert(pthread_create(&t, NULL, locker, NULL) == 0); assert(pthread_create(&t, NULL, locker, NULL) == 0);


assert(pthread_join(t, (void *) &result) == 0); assert(pthread_join(t, &result) == 0);
assert((int)(size_t)result == 555); assert((int)(size_t)result == 555);


assert(lockCount == 2); assert(lockCount == 2);
Expand Down

0 comments on commit 839ca1c

Please sign in to comment.