[PATCH] linuxthreads pthread_cond_t
Jakub Jelinek
jakub@redhat.com
Thu Jan 2 18:03:00 GMT 2003
Hi!
pthread_cond_t in NPTL wants long long alignment, so linuxthreads
should do the same, otherwise on 32-bit arches where
__alignof(long long) > 4 binaries/libs compiled against linuxthreads
-lpthread might not work with NPTL libs.
Haven't used __attribute__((aligned (__alignof__ (long long))))
to cope with non-GCC compilers.
2003-01-02 Jakub Jelinek <jakub@redhat.com>
* sysdeps/pthread/bits/pthreadtypes.h (__pthread_cond_align_t): New
type.
(pthread_cond_t): Add __align member, shorten __padding.
* sysdeps/pthread/pthread.h (PHTREAD_COND_INITIALIZER): Initialize
__padding and __align too.
--- libc/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h.jj 2003-01-02 14:49:58.000000000 +0100
+++ libc/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h 2003-01-02 19:57:25.000000000 +0100
@@ -53,12 +53,20 @@ typedef struct __pthread_attr_s
/* Conditions (not abstract because of PTHREAD_COND_INITIALIZER */
+
+#ifdef __GLIBC_HAVE_LONG_LONG
+__extension__ typedef long long __pthread_cond_align_t;
+#else
+typedef long __pthread_cond_align_t;
+#endif
+
typedef struct
{
struct _pthread_fastlock __c_lock; /* Protect against concurrent access */
_pthread_descr __c_waiting; /* Threads waiting on this condition */
char __padding[48 - sizeof (struct _pthread_fastlock)
- - sizeof (_pthread_descr)];
+ - sizeof (_pthread_descr) - sizeof (__pthread_cond_align_t)];
+ __pthread_cond_align_t __align;
} pthread_cond_t;
--- libc/linuxthreads/sysdeps/pthread/pthread.h.jj 2002-06-05 10:27:29.000000000 +0200
+++ libc/linuxthreads/sysdeps/pthread/pthread.h 2003-01-02 20:20:34.000000000 +0100
@@ -41,7 +41,7 @@ __BEGIN_DECLS
{0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __LOCK_INITIALIZER}
#endif
-#define PTHREAD_COND_INITIALIZER {__LOCK_INITIALIZER, 0}
+#define PTHREAD_COND_INITIALIZER {__LOCK_INITIALIZER, 0, "", 0}
#ifdef __USE_UNIX98
# define PTHREAD_RWLOCK_INITIALIZER \
Jakub
More information about the Libc-hacker
mailing list