This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Fix recent <bits/stdio-lock.h> breakage


Hi!

All GCCs which are using libio (ie. < 3.0) depend on _IO_lock_t in
<bits/stdio-lock.h> being an complete type if _MTSAFE_IO (until now 
linuxthread's bits/stdio-lock.h simply declared
typedef pthread_mutex_t _IO_lock_t).
On the other side, bits/libc-lock.h does not want its locks to be used
outside of _LIBC, so it defined its locks as opaque structures, so that apps
can use only pointers to locks.
But as stdio-lock.h is not modeled on top of libc-lock.h's locks, this means
one cannot rebuild GCC < 3.0 any more.
Here is a possible solution, which tries to keep status quo in that standard
libc-lock.h's types are opaque outside of glibc, _IO_lock_t is not opaque
and stdio-lock.h can be shared.
Other possibilities include separate stdio-lock.h headers for each
implementation, including some other new per-implementation header in
stdio-lock.h (like bits/libc-io-lock.h) or giving up and using non-opaque
libc-lock.h types for recursive lock.

2001-08-26  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/pthread/bits/libc-lock.h (__libc_iolock_recursive_t): New
	type.
	(__libc_iolock_define_recursive): Define.

	* sysdeps/generic/bits/stdio-lock.h (_IO_lock_t): Use
	__libc_iolock_define_recursive.
	* sysdeps/generic/bits/libc-lock.h (__libc_iolock_define_recursive):
	Define.
	* sysdeps/mach/hurd/bits/libc-lock.h (__libc_iolock_recursive_t):
	New type.
	(__libc_iolock_define_recursive): Define.

--- libc/linuxthreads/sysdeps/pthread/bits/libc-lock.h.jj	Fri Aug 24 11:09:51 2001
+++ libc/linuxthreads/sysdeps/pthread/bits/libc-lock.h	Sun Aug 26 21:41:04 2001
@@ -27,10 +27,12 @@
 typedef pthread_mutex_t __libc_lock_t;
 typedef pthread_rwlock_t __libc_rwlock_t;
 typedef struct { pthread_mutex_t mutex; } __libc_lock_recursive_t;
+#define __libc_iolock_recursive_t __libc_lock_recursive_t
 #else
 typedef struct __libc_lock_opaque__ __libc_lock_t;
 typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;
 typedef struct __libc_rwlock_opaque__ __libc_rwlock_t;
+typedef struct { pthread_mutex_t mutex; } __libc_iolock_recursive_t;
 #endif
 
 /* Type for key to thread-specific data.  */
@@ -49,6 +51,8 @@ typedef pthread_key_t __libc_key_t;
   CLASS __libc_rwlock_t NAME;
 #define __libc_lock_define_recursive(CLASS,NAME) \
   CLASS __libc_lock_recursive_t NAME;
+#define __libc_iolock_define_recursive(CLASS,NAME) \
+  CLASS __libc_iolock_recursive_t NAME;
 
 /* Define an initialized lock variable NAME with storage class CLASS.
 
--- libc/sysdeps/generic/bits/stdio-lock.h.jj	Fri Aug 24 11:10:54 2001
+++ libc/sysdeps/generic/bits/stdio-lock.h	Sun Aug 26 21:41:53 2001
@@ -22,7 +22,7 @@
 
 #include <bits/libc-lock.h>
 
-__libc_lock_define_recursive (typedef, _IO_lock_t)
+__libc_iolock_define_recursive (typedef, _IO_lock_t)
 
 /* We need recursive (counting) mutexes.  */
 #ifdef _LIBC_LOCK_RECURSIVE_INITIALIZER
--- libc/sysdeps/generic/bits/libc-lock.h.jj	Fri Aug 24 11:10:54 2001
+++ libc/sysdeps/generic/bits/libc-lock.h	Sun Aug 26 21:45:01 2001
@@ -30,6 +30,7 @@
    of libc.  */
 #define __libc_lock_define(CLASS,NAME)
 #define __libc_lock_define_recursive(CLASS,NAME)
+#define __libc_iolock_define_recursive(CLASS,NAME)
 #define __libc_rwlock_define(CLASS,NAME)
 
 /* Define an initialized lock variable NAME with storage class CLASS.  */
--- libc/sysdeps/mach/hurd/bits/libc-lock.h.jj	Fri Aug 24 05:21:28 2001
+++ libc/sysdeps/mach/hurd/bits/libc-lock.h	Sun Aug 26 21:47:58 2001
@@ -33,10 +33,16 @@ typedef struct
 } __libc_lock_recursive_t;
 
 #define __libc_lock_owner_self() ((void *) __hurd_threadvar_location (0))
-
+#define __libc_iolock_recursive_t __libc_lock_recursive_t
 #else
 typedef struct __libc_lock_opaque__ __libc_lock_t;
 typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;
+typedef struct
+{
+  struct mutex mutex;
+  void *owner;
+  int count;
+} __libc_iolock_recursive_t;
 #endif
 
 /* Define a lock variable NAME with storage class CLASS.  The lock must be
@@ -76,6 +82,8 @@ typedef struct __libc_lock_recursive_opa
 
 #define __libc_lock_define_recursive(CLASS,NAME) \
   CLASS __libc_lock_recursive_t NAME;
+#define __libc_iolock_define_recursive(CLASS,NAME) \
+  CLASS __libc_iolock_recursive_t NAME;
 #define _LIBC_LOCK_RECURSIVE_INITIALIZER { MUTEX_INITIALIZER, 0, 0 }
 #define __libc_lock_define_initialized_recursive(CLASS,NAME) \
   CLASS __libc_lock_recursive_t NAME = _LIBC_LOCK_RECURSIVE_INITIALIZER;


	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]