[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: test-lock compilation failure on mingw
From: |
Paul Eggert |
Subject: |
Re: test-lock compilation failure on mingw |
Date: |
Wed, 08 Jun 2011 09:43:00 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Thunderbird/3.1.10 |
On 06/08/11 07:43, Eric Blake wrote:
> test-lock.c: In function lock_mutator_thread:
> test-lock.c:146:7: error: cannot convert to a pointer type
>
> and many more like it; apparently, the new cygwin cross-compiler for mingw:
>
> i686-pc-mingw32-gcc (GCC) 4.5.2
>
> doesn't like converting gl_thread_self() into void* as a printf() argument.
POSIX doesn't guarantee that pthread_t is a pointer type, so
test-lock.c shouldn't be trying to print gl_thread_self ()
with %p; that's not portable. Perhaps all instances of
code like this:
dbgprintf ("Mutator %p before lock\n", gl_thread_self ());
should be rewritten like this:
dbgprintf ("Mutator %p before lock\n", gl_thread_self_pointer ());
where gl_thread_self_pointer is a new primitive that is guaranteed to
yield a pointer value? The value could be null on platforms where
pthread_t doesn't fit into void *.
Also, isn't there another problem here? thread.h assumes
that NULL is an 'int', which surely isn't a portable assumption.
Here's a proposed patch:
diff --git a/lib/glthread/thread.h b/lib/glthread/thread.h
index 5d72040..b52646d 100644
--- a/lib/glthread/thread.h
+++ b/lib/glthread/thread.h
@@ -322,7 +322,7 @@ typedef int gl_thread_t;
# define glthread_create(THREADP, FUNC, ARG) ENOSYS
# define glthread_sigmask(HOW, SET, OSET) 0
# define glthread_join(THREAD, RETVALP) 0
-# define gl_thread_self() NULL
+# define gl_thread_self() 0
# define gl_thread_exit(RETVAL) 0
# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0