1#include <sys/cdefs.h> 2__FBSDID("$FreeBSD: head/lib/libc/resolv/mtctxres.c 156956 2006-03-21 15:37:16Z ume $"); 3 |
4#include <port_before.h> 5#ifdef DO_PTHREADS 6#include <pthread.h> |
7#ifdef _LIBC 8#include <pthread_np.h> |
9#endif |
10#endif |
11#include <errno.h> 12#include <netdb.h> 13#include <stdlib.h> 14#include <string.h> 15#include <resolv_mt.h> |
16#include <port_after.h> 17 18#ifdef DO_PTHREADS 19static pthread_key_t key; 20static int mt_key_initialized = 0; 21 22static int __res_init_ctx(void); 23static void __res_destroy_ctx(void *); --- 16 unchanged lines hidden (view full) --- 40 int pthread_keycreate_ret; 41 42 pthread_keycreate_ret = pthread_key_create(&key, __res_destroy_ctx); 43 if (pthread_keycreate_ret == 0) 44 mt_key_initialized = 1; 45} 46#endif 47 |
48#ifndef _LIBC |
49/* 50 * To support binaries that used the private MT-safe interface in 51 * Solaris 8, we still need to provide the __res_enable_mt() 52 * and __res_disable_mt() entry points. They're do-nothing routines. 53 */ 54int 55__res_enable_mt(void) { 56 return (-1); 57} 58 59int 60__res_disable_mt(void) { 61 return (0); 62} |
63#endif |
64 65#ifdef DO_PTHREADS 66static int 67__res_init_ctx(void) { 68 69 mtctxres_t *mt; 70 int ret; 71 --- 29 unchanged lines hidden (view full) --- 101} 102#endif 103 104mtctxres_t * 105___mtctxres(void) { 106#ifdef DO_PTHREADS 107 mtctxres_t *mt; 108 |
109#ifdef _LIBC 110 if (pthread_main_np() != 0) 111 return (&sharedctx); 112#endif 113 |
114 /* 115 * This if clause should only be executed if we are linking 116 * statically. When linked dynamically _mtctxres_init() should 117 * be called at binding time due the #pragma above. 118 */ 119 if (!mt_key_initialized) { 120 static pthread_mutex_t keylock = PTHREAD_MUTEX_INITIALIZER; 121 pthread_mutex_lock(&keylock); --- 19 unchanged lines hidden --- |