diff options
author | jasone <jasone@FreeBSD.org> | 2007-11-27 03:16:44 +0000 |
---|---|---|
committer | jasone <jasone@FreeBSD.org> | 2007-11-27 03:16:44 +0000 |
commit | 21bb948195adb6636c33738cab39bb89cac41bc7 (patch) | |
tree | bc0c2019e6f4f8b5aa0d67d7e3517c626797bb0e /lib/libkse/sys | |
parent | 2dd595aefe6b80476344fe4fc8b7934db055aaa2 (diff) | |
download | FreeBSD-src-21bb948195adb6636c33738cab39bb89cac41bc7.zip FreeBSD-src-21bb948195adb6636c33738cab39bb89cac41bc7.tar.gz |
Add _pthread_mutex_init_calloc_cb() to libthr and libkse, so that malloc(3)
(part of libc) can use pthreads mutexes without causing infinite recursion
during initialization.
Diffstat (limited to 'lib/libkse/sys')
-rw-r--r-- | lib/libkse/sys/lock.c | 7 | ||||
-rw-r--r-- | lib/libkse/sys/lock.h | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/libkse/sys/lock.c b/lib/libkse/sys/lock.c index 2ac8c0c..7c111bc 100644 --- a/lib/libkse/sys/lock.c +++ b/lib/libkse/sys/lock.c @@ -54,11 +54,12 @@ _lock_destroy(struct lock *lck) int _lock_init(struct lock *lck, enum lock_type ltype, - lock_handler_t *waitfunc, lock_handler_t *wakeupfunc) + lock_handler_t *waitfunc, lock_handler_t *wakeupfunc, + void *(calloc_cb)(size_t, size_t)) { if (lck == NULL) return (-1); - else if ((lck->l_head = malloc(sizeof(struct lockreq))) == NULL) + else if ((lck->l_head = calloc_cb(1, sizeof(struct lockreq))) == NULL) return (-1); else { lck->l_type = ltype; @@ -80,7 +81,7 @@ _lock_reinit(struct lock *lck, enum lock_type ltype, if (lck == NULL) return (-1); else if (lck->l_head == NULL) - return (_lock_init(lck, ltype, waitfunc, wakeupfunc)); + return (_lock_init(lck, ltype, waitfunc, wakeupfunc, calloc)); else { lck->l_head->lr_locked = 0; lck->l_head->lr_watcher = NULL; diff --git a/lib/libkse/sys/lock.h b/lib/libkse/sys/lock.h index 6102a0b..815e444 100644 --- a/lib/libkse/sys/lock.h +++ b/lib/libkse/sys/lock.h @@ -83,7 +83,7 @@ void _lock_acquire(struct lock *, struct lockuser *, int); void _lock_destroy(struct lock *); void _lock_grant(struct lock *, struct lockuser *); int _lock_init(struct lock *, enum lock_type, - lock_handler_t *, lock_handler_t *); + lock_handler_t *, lock_handler_t *, void *(size_t, size_t)); int _lock_reinit(struct lock *, enum lock_type, lock_handler_t *, lock_handler_t *); void _lock_release(struct lock *, struct lockuser *); |