From 7168861fac7920c84a218b39542625a08168c1cb Mon Sep 17 00:00:00 2001 From: christos Date: Sat, 22 May 2004 15:44:26 +0000 Subject: [PATCH] Provide access to _res in the non-threaded case, and abort in the threaded case. --- lib/libc/resolv/res_state.c | 12 +++++++----- lib/libpthread/res_state.c | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lib/libc/resolv/res_state.c b/lib/libc/resolv/res_state.c index 8351c35e27f7..a8a7cf327658 100644 --- a/lib/libc/resolv/res_state.c +++ b/lib/libc/resolv/res_state.c @@ -1,4 +1,4 @@ -/* $NetBSD: res_state.c,v 1.2 2004/05/21 16:02:40 christos Exp $ */ +/* $NetBSD: res_state.c,v 1.3 2004/05/22 15:44:26 christos Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: res_state.c,v 1.2 2004/05/21 16:02:40 christos Exp $"); +__RCSID("$NetBSD: res_state.c,v 1.3 2004/05/22 15:44:26 christos Exp $"); #endif #include @@ -46,16 +46,19 @@ __RCSID("$NetBSD: res_state.c,v 1.2 2004/05/21 16:02:40 christos Exp $"); #include #include -/* Binary Compatibility */ +#undef _res + +/* Binary Compatibility; this symbol does not appear in a header file */ struct __res_state _res; -#ifdef _REENTRANT res_state __res_get_state_nothread(void); void __res_put_state_nothread(res_state); #ifdef __weak_alias __weak_alias(__res_get_state, __res_get_state_nothread) __weak_alias(__res_put_state, __res_put_state_nothread) +/* Source compatibility; only for single threaded programs */ +__weak_alias(__res_state, __res_get_state_nothread) #endif res_state @@ -69,4 +72,3 @@ void __res_put_state_nothread(res_state res) { } -#endif diff --git a/lib/libpthread/res_state.c b/lib/libpthread/res_state.c index 698e2a497c31..62e2be8a528a 100644 --- a/lib/libpthread/res_state.c +++ b/lib/libpthread/res_state.c @@ -1,4 +1,4 @@ -/* $NetBSD: res_state.c,v 1.1 2004/05/21 03:40:51 christos Exp $ */ +/* $NetBSD: res_state.c,v 1.2 2004/05/22 15:44:26 christos Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: res_state.c,v 1.1 2004/05/21 03:40:51 christos Exp $"); +__RCSID("$NetBSD: res_state.c,v 1.2 2004/05/22 15:44:26 christos Exp $"); #endif #include @@ -72,6 +72,7 @@ union _res_st { static pthread_mutex_t res_mtx = PTHREAD_MUTEX_INITIALIZER; +res_state __res_state(void); res_state __res_get_state(void); void __res_put_state(res_state); @@ -118,3 +119,17 @@ __res_put_state(res_state res) LIST_INSERT_HEAD(&res_list, (union _res_st *)(void *)res, st_list); pthread_mutex_unlock(&res_mtx); } + +/* + * This is aliased via a macro to _res; don't allow multi-threaded programs + * to use it. + */ +res_state +__res_state(void) +{ + static const char res[] = "_res is not supported for multi-threaded" + " programs.\n"; + (void)write(STDERR_FILENO, res, sizeof(res) - 1); + abort(); + return NULL; +}