libc: speed-up flockfile()/funlockfile()

For Honeycomb, we added proper file thread-safety for
all FILE* operations. However, we did implement that by
using an out-of-band hash table to map FILE* pointers
to phtread_mutex_t mutexes, because we couldn't change
the size of 'struct _sFILE' without breaking the ABI.

It turns out that our BSD-derived code already has
some support code to extend FILE* objects, so use it
instead. See libc/stdio/fileext.h

This patch gets rid of the hash table, and put the
mutex directly into the sFILE extension.

Change-Id: If1c3fe0a0a89da49c568e9a7560b7827737ff4d0
This commit is contained in:
David 'Digit' Turner
2011-08-29 21:43:46 +02:00
parent 4b469eae40
commit 9831ad3ce6
4 changed files with 44 additions and 153 deletions

View File

@@ -58,7 +58,12 @@ static struct glue uglue = { 0, FOPEN_MAX - 3, usual };
static struct glue *lastglue = &uglue;
_THREAD_PRIVATE_MUTEX(__sfp_mutex);
static struct __sfileext __sFext[3];
static struct __sfileext __sFext[3] = {
_FILEEXT_INITIALIZER,
_FILEEXT_INITIALIZER,
_FILEEXT_INITIALIZER,
};
FILE __sF[3] = {
std(__SRD, STDIN_FILENO), /* stdin */
std(__SWR, STDOUT_FILENO), /* stdout */