[Xcb] [PATCH 1/2] pthread_self(): do not assume pthread_t and int are compatible

Rémi Denis-Courmont remi at remlab.net
Mon Dec 13 18:12:40 PST 2010


POSIX does not warrant much about pthread_t.
It is not necessarily the same convertible to int as far as the calling
conventions are concerned.
---
 list.m4    |    2 +-
 stubs.c.m4 |   11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/list.m4 b/list.m4
index 7d23c3c..79b5b59 100644
--- a/list.m4
+++ b/list.m4
@@ -1,4 +1,4 @@
-alias(zero,	int,  pthread_self)
+alias(self,	pthread_t,  pthread_self)
 alias(zero,	int,  pthread_mutex_init)
 alias(zero,	int,  pthread_mutex_destroy)
 alias(zero,	int,  pthread_mutex_lock)
diff --git a/stubs.c.m4 b/stubs.c.m4
index 1616c0a..8e51745 100644
--- a/stubs.c.m4
+++ b/stubs.c.m4
@@ -47,6 +47,7 @@ m4_divert(0)m4_dnl
 
 #include <pthread.h>
 #include <stdlib.h>
+#include <string.h>
 #include "config.h"
 
 m4_include([list.m4])
@@ -65,6 +66,16 @@ static int __pthread_abort_stub()
 }
 #endif
 
+#ifdef NEED_SELF_STUB
+static pthread_t __pthread_self_stub(void)
+{
+    pthread_t th;
+
+    memset(&th, 0, sizeof (th));
+    return th;
+}
+#endif
+
 #ifdef NEED_EQUAL_STUB
 static int __pthread_equal_stub(pthread_t t1, pthread_t t2)
 {
-- 
1.7.2.3



More information about the Xcb mailing list