diff options
Diffstat (limited to 'src/lib/libc')
| -rw-r--r-- | src/lib/libc/include/thread_private.h | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/src/lib/libc/include/thread_private.h b/src/lib/libc/include/thread_private.h index c5acc4b5e4..a365c25e66 100644 --- a/src/lib/libc/include/thread_private.h +++ b/src/lib/libc/include/thread_private.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: thread_private.h,v 1.19 2006/09/26 14:18:28 kurt Exp $ */ | 1 | /* $OpenBSD: thread_private.h,v 1.20 2007/06/05 18:11:48 kurt Exp $ */ |
| 2 | 2 | ||
| 3 | /* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */ | 3 | /* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */ |
| 4 | 4 | ||
| @@ -54,10 +54,24 @@ extern int __isthreaded; | |||
| 54 | * return a pointer to per thread instance of data associated | 54 | * return a pointer to per thread instance of data associated |
| 55 | * with the given tag. If the given tag is NULL a tag is first | 55 | * with the given tag. If the given tag is NULL a tag is first |
| 56 | * allocated. | 56 | * allocated. |
| 57 | * | ||
| 58 | * _thread_mutex_lock: | ||
| 59 | * lock the given mutex. If the given mutex is NULL, | ||
| 60 | * rely on rthreads/pthreads implementation to initialize | ||
| 61 | * the mutex before locking. | ||
| 62 | * | ||
| 63 | * _thread_mutex_unlock: | ||
| 64 | * unlock the given mutex. | ||
| 65 | * | ||
| 66 | * _thread_mutex_destroy: | ||
| 67 | * destroy the given mutex. | ||
| 57 | */ | 68 | */ |
| 58 | void _thread_tag_lock(void **); | 69 | void _thread_tag_lock(void **); |
| 59 | void _thread_tag_unlock(void **); | 70 | void _thread_tag_unlock(void **); |
| 60 | void *_thread_tag_storage(void **, void *, size_t, void *); | 71 | void *_thread_tag_storage(void **, void *, size_t, void *); |
| 72 | void _thread_mutex_lock(void **); | ||
| 73 | void _thread_mutex_unlock(void **); | ||
| 74 | void _thread_mutex_destroy(void **); | ||
| 61 | 75 | ||
| 62 | /* | 76 | /* |
| 63 | * Macros used in libc to access thread mutex, keys, and per thread storage. | 77 | * Macros used in libc to access thread mutex, keys, and per thread storage. |
| @@ -77,32 +91,32 @@ void *_thread_tag_storage(void **, void *, size_t, void *); | |||
| 77 | #define _THREAD_PRIVATE(keyname, storage, error) \ | 91 | #define _THREAD_PRIVATE(keyname, storage, error) \ |
| 78 | _thread_tag_storage(&(__THREAD_NAME(keyname)), &(storage), \ | 92 | _thread_tag_storage(&(__THREAD_NAME(keyname)), &(storage), \ |
| 79 | sizeof (storage), error) | 93 | sizeof (storage), error) |
| 80 | /* | ||
| 81 | * Resolver code is special cased in that it uses global keys. | ||
| 82 | */ | ||
| 83 | extern void *__THREAD_NAME(_res); | ||
| 84 | extern void *__THREAD_NAME(_res_ext); | ||
| 85 | extern void *__THREAD_NAME(serv_mutex); | ||
| 86 | 94 | ||
| 87 | /* | 95 | /* |
| 88 | * File descriptor locking definitions. | 96 | * Macros used in libc to access non-static mutexes. |
| 89 | */ | 97 | */ |
| 90 | #define FD_READ 0x1 | 98 | #define _MUTEX_LOCK(mutex) \ |
| 91 | #define FD_WRITE 0x2 | 99 | do { \ |
| 92 | #define FD_RDWR (FD_READ | FD_WRITE) | 100 | if (__isthreaded) \ |
| 93 | #define FD_RDWR_CLOSE (FD_RDWR | 0x4) | 101 | _thread_mutex_lock(mutex); \ |
| 94 | 102 | } while (0) | |
| 95 | struct timespec; | 103 | #define _MUTEX_UNLOCK(mutex) \ |
| 96 | int _thread_fd_lock(int, int, struct timespec *); | 104 | do { \ |
| 97 | void _thread_fd_unlock(int, int); | 105 | if (__isthreaded) \ |
| 106 | _thread_mutex_unlock(mutex); \ | ||
| 107 | } while (0) | ||
| 108 | #define _MUTEX_DESTROY(mutex) \ | ||
| 109 | do { \ | ||
| 110 | if (__isthreaded) \ | ||
| 111 | _thread_mutex_destroy(mutex); \ | ||
| 112 | } while (0) | ||
| 98 | 113 | ||
| 99 | /* | 114 | /* |
| 100 | * Macros are used in libc code for historical (debug) reasons. | 115 | * Resolver code is special cased in that it uses global keys. |
| 101 | * Define them here. | ||
| 102 | */ | 116 | */ |
| 103 | #define _FD_LOCK(_fd,_type,_ts) _thread_fd_lock(_fd, _type, _ts) | 117 | extern void *__THREAD_NAME(_res); |
| 104 | #define _FD_UNLOCK(_fd,_type) _thread_fd_unlock(_fd, _type) | 118 | extern void *__THREAD_NAME(_res_ext); |
| 105 | 119 | extern void *__THREAD_NAME(serv_mutex); | |
| 106 | 120 | ||
| 107 | /* | 121 | /* |
| 108 | * malloc lock/unlock prototypes and definitions | 122 | * malloc lock/unlock prototypes and definitions |
