Re: [parisc-linux] Re: NPTL for hppa-linux is not backwards compatible with Linuxthreads.
"Carlos O'Donell" <[email protected]>
| Newsgroups | gmane.linux.debian.devel.glibc,gmane.linux.ports.hppa |
|---|---|
| Message-ID | <[email protected]> |
On 2/22/07, Roland McGrath <[email protected]> wrote: > > All statically initialized locks are broken. We made locks smaller, > > and changed the value of the static initialization. > > Smaller? Smaller is easy. And you didn't actually reduce > __SIZEOF_PTHREAD_MUTEX_T, did you? This seems like it would not be at all > hard to accommodate just with symbol versioning and not break any > compatibility. Off hand, it seems like it would be some simple code in one > new file in your sysdeps/ tree and a smattering of sysdeps Versions files. Thanks for your feedback Roland. Yes, our locks are smaller, we went from a 4 word structure to a 1 word integer. I did not reduce __SIZEOF_PTHREAD_MUTEX_T. NPTL and Linuxthreads pthread_mutex_t are the same size. Everything has been kept the same size, but not in exactly the same position (probably a bug on my part). In Linuxthreads an initialized _pthread_fastlock is {{1,1,1,1},0} e.g. {__spinlock, __status} Old RW Locks 116 /* Read-write locks. */ 117 typedef struct _pthread_rwlock_t 118 { 119 struct _pthread_fastlock __rw_lock; /* Lock to guarantee mutual exclusion */ 120 int __rw_readers; /* Number of readers */ 121 _pthread_descr __rw_writer; /* Identity of writer, or NULL if none */ 122 _pthread_descr __rw_read_waiting; /* Threads waiting for reading */ 123 _pthread_descr __rw_write_waiting; /* Threads waiting for writing */ 124 int __rw_kind; /* Reader/Writer preference selection */ 125 int __rw_pshared; /* Shared between processes or not */ 126 } pthread_rwlock_t; New RW Locks 137 /* Data structure for read-write lock variable handling. The 138 structure of the attribute type is not exposed on purpose. */ 139 typedef union 140 { 141 struct 142 { 143 int __lock; 144 unsigned int __nr_readers; 145 unsigned int __readers_wakeup; 146 unsigned int __writer_wakeup; 147 unsigned int __nr_readers_queued; 148 unsigned int __nr_writers_queued; 149 /* FLAGS must stay at this position in the structure to maintain 150 binary compatibility. */ 151 unsigned int __flags; 152 int __writer; 153 } __data; 154 char __size[__SIZEOF_PTHREAD_RWLOCK_T]; 155 long int __align; 156 } pthread_rwlock_t; In the new structure we have shifted everything up because __lock is now an integer, instead of a _pthread_fastlock with a 4 word lock structure. Should I add padding after "__lock" e.g. int pad[3]? In an old executable the following static initializers: PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INTIALIZER, PTHREAD_RWLOCK_INITIALIZER will setup the __spinlock structure to {1,1,1,1} e.g. unlocked in our Linuxthreads implementation. To be clear are you suggesting I write compat wrappers for the pthread_mutex_*, pthread_cond_*, and pthread_rwlock_* functions to detect old style initialized locks, and reinitialize the lock word? > But if your community is happy with a soname change and not worrying about > its various impacts, by all means just do that. It's a lovely thing to be > able to stop compiling in all the compat stuff. > > To do that, all you need is sysdeps/unix/sysv/linux/hppa/nptl/shlib-versions: > > hppa.*-.*-linux.* libc=6.1 GLIBC_2.6 > hppa.*-.*-linux.* libpthread=0.1 GLIBC_2.6 I would like to avoid breaking backwards compatibility, but I don't quite understand all the issues. Your feedback is much appreciated. Cheers, Carlos.