Skip to content
Snippets Groups Projects
Commit 867665ac authored by Christoph Hellwig's avatar Christoph Hellwig
Browse files

enable locking in libc

parent 2771d43f
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,6 @@ libc :=
libc += internal/floatscan.o
libc += internal/intscan.o
libc += internal/libc.o
libc += internal/__lock.o
libc += internal/shgetc.o
libc += ctype/__ctype_get_mb_cur_max.o
......
#include "libc.h"
void __lock(volatile int *l)
{
}
void __unlock(volatile int *l)
{
}
......@@ -2,6 +2,7 @@
#define LIBC_H
#include <stdlib.h>
#include <osv/mutex.h>
#include "stdio.h"
/* as long as we use the glibc header we'll need this hack */
......@@ -20,7 +21,7 @@ struct __libc {
volatile int threads_minus_1;
// int canceldisable;
FILE *ofl_head;
int ofl_lock[2];
mutex_t ofl_lock;
// size_t tls_size;
};
......@@ -30,12 +31,10 @@ extern struct __libc __libc ATTR_LIBC_VISIBILITY;
#define libc __libc
/* Designed to avoid any overhead in non-threaded processes */
void __lock(volatile int *) ATTR_LIBC_VISIBILITY;
void __unlock(volatile int *) ATTR_LIBC_VISIBILITY;
int __lockfile(FILE *) ATTR_LIBC_VISIBILITY;
void __unlockfile(FILE *) ATTR_LIBC_VISIBILITY;
#define LOCK(x) (libc.threads_minus_1 ? (__lock(x),1) : ((void)(x),1))
#define UNLOCK(x) (libc.threads_minus_1 ? (__unlock(x),1) : ((void)(x),1))
#define LOCK(x) (libc.threads_minus_1 ? (mutex_lock(&(x)),1) : ((void)(x),1))
#define UNLOCK(x) (libc.threads_minus_1 ? (mutex_unlock(&(x)),1) : ((void)(x),1))
extern char **__environ;
#define environ __environ
......
......@@ -108,7 +108,8 @@ void tzset(void)
void __tzset(void)
{
static int lock[2], init;
static mutex_t lock;
static int init;
if (init) return;
LOCK(lock);
if (!init) tzset();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment