From: Carlos O'Donell <carlos@baldric.uwo.ca>
To: libc-alpha <libc-alpha@sources.redhat.com>
Cc: parisc-linux@lists.parisc-linux.org
Subject: [parisc-linux] [RFC] Where to put arch-dependant locking in malloc/thread-m.h
Date: Thu, 25 Sep 2003 17:15:09 -0400 [thread overview]
Message-ID: <20030925211509.GY14406@systemhalted> (raw)
libc,
Found the problem with bug-iconv3, it was related to the fact that
hppa's locks can't be initialized to zero (or left unitialized). When
running a non-threaded application and dlopening libpthread the
__libc_maybe_call2's start using the proper strong symbol of those
funcions. At this point malloc on hppa would in certain occassions
fget stuck in a lock that it thought was taken (value of zero).
The following patch fixes the issue, but I'm not content about it's
placement in malloc/thread-m.h. Any comments about where I might put
this in order to make maintenance easier?
Cheers,
Carlos.
diff -u -p -r1.23 thread-m.h
--- glibc/malloc/thread-m.h 1 Jul 2003 08:29:43 -0000 1.23
+++ glibc/malloc/thread-m.h 25 Sep 2003 20:43:55 -0000
@@ -59,6 +59,28 @@ __libc_lock_define (typedef, mutex_t)
#define mutex_unlock(m) \
__libc_maybe_call2 (pthread_mutex_unlock, (m), (*(int *)(m) = 0))
+# if(defined __hppa__)
+/* Since our lock structure does not tolerate being initialized to zero, we must
+ modify the standard function calls made by malloc */
+# undef mutex_init
+# undef mutex_lock
+# undef mutex_trylock
+# undef mutex_unlock
+# define mutex_init(m) \
+ __libc_maybe_call (__pthread_mutex_init, (m, NULL), \
+ (((m)->__m_lock.__spinlock = __LT_SPINLOCK_INIT),(*(int *)(m))) )
+# define mutex_lock(m) \
+ __libc_maybe_call (__pthread_mutex_lock, (m), \
+ (__load_and_clear(&((m)->__m_lock.__spinlock)), 0))
+# define mutex_trylock(m) \
+ __libc_maybe_call (__pthread_mutex_trylock, (m), \
+ (*(int *)(m) ? 1 : (__load_and_clear(&((m)->__m_lock.__spinlock)), 0)))
+# define mutex_unlock(m) \
+ __libc_maybe_call (__pthread_mutex_unlock, (m), \
+ (((m)->__m_lock.__spinlock = __LT_SPINLOCK_INIT), (*(int *)(m))) )
+# endif
+/* if(defined __hppa__) */
+
#else
#define mutex_init(m) \
next reply other threads:[~2003-09-25 21:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-25 21:15 Carlos O'Donell [this message]
2003-09-26 13:39 ` [parisc-linux] Re: [RFC] Where to put arch-dependant locking in malloc/thread-m.h wmglo
2003-09-26 13:39 ` wmglo
2003-09-26 14:24 ` Carlos O'Donell
2003-09-26 14:24 ` Carlos O'Donell
-- strict thread matches above, loose matches on Subject: below --
2003-09-25 21:15 [parisc-linux] " Carlos O'Donell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030925211509.GY14406@systemhalted \
--to=carlos@baldric.uwo.ca \
--cc=libc-alpha@sources.redhat.com \
--cc=parisc-linux@lists.parisc-linux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox