Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update.
2003-07-22  Jakub Jelinek  <jakub@redhat.com>

	* include/resolv.h (__resp): Declare.  Define to __libc_resp
	if in libc.so.
	(_res): If USE___THREAD, define to (*__resp).
	* resolv/res_libc.c (_res): Normal .bss variable with compat_symbol
	even if USE___THREAD.
	(__resp): New __thread variable.
	(__libc_resp): New alias.
	* resolv/Versions (libc): Export _res@GLIBC_2.0 even if
	USE_TLS && HAVE___THREAD.  Export __resp@@GLIBC_PRIVATE.
	* sysdeps/generic/res-state.c (__res_state): Return __resp
	if USE___THREAD.
  • Loading branch information
Ulrich Drepper committed Jul 22, 2003
1 parent 11bf8ce commit 0e9d624
Show file tree
Hide file tree
Showing 21 changed files with 285 additions and 34 deletions.
14 changes: 14 additions & 0 deletions ChangeLog
@@ -1,3 +1,17 @@
2003-07-22 Jakub Jelinek <jakub@redhat.com>

* include/resolv.h (__resp): Declare. Define to __libc_resp
if in libc.so.
(_res): If USE___THREAD, define to (*__resp).
* resolv/res_libc.c (_res): Normal .bss variable with compat_symbol
even if USE___THREAD.
(__resp): New __thread variable.
(__libc_resp): New alias.
* resolv/Versions (libc): Export _res@GLIBC_2.0 even if
USE_TLS && HAVE___THREAD. Export __resp@@GLIBC_PRIVATE.
* sysdeps/generic/res-state.c (__res_state): Return __resp
if USE___THREAD.

2003-07-22 H.J. Lu <hongjiu.lu@intel.com>

* elf/dl-support.c (_dl_hwcap): New variable.
Expand Down
5 changes: 3 additions & 2 deletions include/resolv.h
Expand Up @@ -17,9 +17,10 @@
# if USE___THREAD
# undef _res
# ifndef NOT_IN_libc
# define _res __libc_res
# define __resp __libc_resp
# endif
extern __thread struct __res_state _res attribute_tls_model_ie;
# define _res (*__resp)
extern __thread struct __res_state *__resp attribute_tls_model_ie;
# endif
# else
# ifndef __BIND_NOSTATIC
Expand Down
14 changes: 14 additions & 0 deletions linuxthreads/Makefile
Expand Up @@ -119,8 +119,17 @@ endif

ifeq (yes,$(build-shared))
tests-nodelete-yes = unload
tests += tst-_res1
endif

modules-names = tst-_res1mod1 tst-_res1mod2
extra-objs += $(addsuffix .os,$(strip $(modules-names)))
test-extras += $(modules-names)
test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))

$(test-modules): $(objpfx)%.so: $(objpfx)%.os $(common-objpfx)shlib.lds
$(build-module)

all: # Make this the default target; it will be defined in Rules.

# What we install as libpthread.so for programs to link against is in fact a
Expand Down Expand Up @@ -288,6 +297,11 @@ otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
$(resolvobjdir)/libresolv.a
endif

ifeq (yes,$(build-shared))
$(objpfx)tst-_res1mod2.so: $(objpfx)tst-_res1mod1.so
$(objpfx)tst-_res1: $(objpfx)tst-_res1mod2.so $(shared-thread-library)
endif

ifeq (no,$(cross-compiling))
ifeq (yes,$(build-shared))
tests: $(objpfx)tst-signal.out $(objpfx)tst-cancel-wrappers.out
Expand Down
2 changes: 1 addition & 1 deletion linuxthreads/descr.h
Expand Up @@ -163,8 +163,8 @@ struct _pthread_descr_struct
int * p_h_errnop; /* pointer to used h_errno variable */
int p_h_errno; /* error returned by last netdb function */
struct __res_state *p_resp; /* Pointer to resolver state */
struct __res_state p_res; /* per-thread resolver state */
#endif
struct __res_state p_res; /* per-thread resolver state */
int p_userstack; /* nonzero if the user provided the stack */
void *p_guardaddr; /* address of guard area or NULL */
size_t p_guardsize; /* size of guard area */
Expand Down
2 changes: 1 addition & 1 deletion linuxthreads/libc-tls-loc.c
Expand Up @@ -43,7 +43,7 @@ __h_errno_location (void)
struct __res_state *
__res_state (void)
{
return &_res;
return __resp;
}

#endif
4 changes: 4 additions & 0 deletions linuxthreads/manager.c
Expand Up @@ -28,6 +28,7 @@
#include <sys/time.h>
#include <sys/wait.h> /* for waitpid macros */
#include <locale.h> /* for __uselocale */
#include <resolv.h> /* for __resp */

#include <ldsodefs.h>
#include "pthread.h"
Expand Down Expand Up @@ -287,6 +288,9 @@ pthread_start_thread(void *arg)
/* Initialize thread-locale current locale to point to the global one.
With __thread support, the variable's initializer takes care of this. */
__uselocale (LC_GLOBAL_LOCALE);
#else
/* Initialize __resp. */
__resp = &self->p_resp;
#endif
/* Make gdb aware of new thread */
if (__pthread_threads_debug && __pthread_sig_debug > 0) {
Expand Down
4 changes: 3 additions & 1 deletion linuxthreads/sysdeps/pthread/res-state.c
Expand Up @@ -39,7 +39,9 @@ __res_state (void)
pthread_descr self = thread_self();
return LIBC_THREAD_GETMEM (self, p_resp);
}
#endif
return &_res;
#else
return __resp;
#endif
}
libc_hidden_def (__res_state)
69 changes: 69 additions & 0 deletions linuxthreads/tst-_res1.c
@@ -0,0 +1,69 @@
/* Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */

/* Test whether _res in glibc 2.1.x and earlier (before __res_state()
was introduced) works. Portable programs should never do the
dirty things below. */

#include <pthread.h>
#include <resolv.h>
#include <stdlib.h>
#include <stdio.h>

void *tf (void *resp)
{
if (resp == &_res || resp == __res_state ())
abort ();
_res.retry = 24;
return NULL;
}

void do_test (struct __res_state *resp)
{
if (resp != &_res || resp != __res_state ())
abort ();
if (_res.retry != 12)
abort ();
}

int main (void)
{
#undef _res
extern struct __res_state _res;
pthread_t th;

_res.retry = 12;
if (pthread_create (&th, NULL, tf, &_res) != 0)
{
puts ("create failed");
exit (1);
}

do_test (&_res);

if (pthread_join (th, NULL) != 0)
{
puts ("join failed");
exit (1);
}

do_test (&_res);

exit (0);
}
23 changes: 23 additions & 0 deletions linuxthreads/tst-_res1mod1.c
@@ -0,0 +1,23 @@
/* Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */

#include <resolv.h>
#undef _res

struct __res_state _res;
1 change: 1 addition & 0 deletions linuxthreads/tst-_res1mod2.c
@@ -0,0 +1 @@
/* Nothing. */
16 changes: 16 additions & 0 deletions nptl/ChangeLog
@@ -1,3 +1,19 @@
2003-07-22 Jakub Jelinek <jakub@redhat.com>

* res.c (__res_state): Return __resp.
* descr.h: Include resolv.h.
(struct pthread): Add res field.
* pthread_create.c: Include resolv.h.
(start_thread): Initialize __resp.
* Makefile (tests): Add tst-_res1.
(module-names): Add tst-_res1mod1, tst-_res1mod2.
($(objpfx)tst-_res1mod2.so): Depend on $(objpfx)tst-_res1mod1.so.
($(objpfx)tst-_res1): Depend on $(objpfx)tst-_res1mod2.so and
libpthread.
* tst-_res1.c: New file.
* tst-_res1mod1.c: New file.
* tst-_res1mod2.c: New file.

2003-07-21 Ulrich Drepper <drepper@redhat.com>

* sysdeps/pthread/createthread.c: Don't define CLONE_STOPPED.
Expand Down
6 changes: 4 additions & 2 deletions nptl/Makefile
Expand Up @@ -250,10 +250,10 @@ tests += tst-cancelx2 tst-cancelx3 tst-cancelx4 tst-cancelx5 \
tst-oncex3 tst-oncex4
endif
ifeq ($(build-shared),yes)
tests += tst-atfork2 tst-tls3
tests += tst-atfork2 tst-tls3 tst-_res1
endif

modules-names = tst-atfork2mod tst-tls3mod
modules-names = tst-atfork2mod tst-tls3mod tst-_res1mod1 tst-_res1mod2
extra-objs += $(addsuffix .os,$(strip $(modules-names)))
test-extras += $(modules-names)
test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
Expand Down Expand Up @@ -400,6 +400,8 @@ $(objpfx)tst-cancelx17: $(common-objpfx)rt/librt.so
$(objpfx)tst-cancel18: $(common-objpfx)rt/librt.so
$(objpfx)tst-cancelx18: $(common-objpfx)rt/librt.so
$(objpfx)tst-clock2: $(common-objpfx)rt/librt.so
$(objpfx)tst-_res1mod2.so: $(objpfx)tst-_res1mod1.so
$(objpfx)tst-_res1: $(objpfx)tst-_res1mod2.so $(shared-thread-library)
else
$(objpfx)tst-cond11: $(common-objpfx)rt/librt.a
$(objpfx)tst-cancel17: $(common-objpfx)rt/librt.a
Expand Down
6 changes: 5 additions & 1 deletion nptl/descr.h
Expand Up @@ -35,7 +35,8 @@
#ifdef HAVE_FORCED_UNWIND
# include <unwind.h>
#endif

#define __need_res_state
#include <resolv.h>

#ifndef TCB_ALIGNMENT
# define TCB_ALIGNMENT sizeof (double)
Expand Down Expand Up @@ -235,6 +236,9 @@ struct pthread
size_t stackblock_size;
/* Size of the included guard area. */
size_t guardsize;

/* Resolver state. */
struct __res_state res;
} __attribute ((aligned (TCB_ALIGNMENT)));


Expand Down
4 changes: 4 additions & 0 deletions nptl/pthread_create.c
Expand Up @@ -26,6 +26,7 @@
#include <ldsodefs.h>
#include <atomic.h>
#include <libc-internal.h>
#include <resolv.h>

#include <shlib-compat.h>

Expand Down Expand Up @@ -238,6 +239,9 @@ start_thread (void *arg)
THREAD_SETMEM (pd, cpuclock_offset, now);
#endif

/* Initialize resolver state pointer. */
__resp = &pd->res;

/* This is where the try/finally block should be created. For
compilers without that support we do use setjmp. */
struct pthread_unwind_buf unwind_buf;
Expand Down
10 changes: 2 additions & 8 deletions nptl/res.c
@@ -1,4 +1,4 @@
/* Copyright (C) 2002 Free Software Foundation, Inc.
/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand All @@ -18,16 +18,10 @@

#include <features.h>
#include <resolv.h>
#undef _res

#include <tls.h>

/* With __thread support, this per-thread variable is used in all cases. */
extern __thread struct __res_state _res;


struct __res_state *
__res_state (void)
{
return &_res;
return __resp;
}
69 changes: 69 additions & 0 deletions nptl/tst-_res1.c
@@ -0,0 +1,69 @@
/* Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */

/* Test whether _res in glibc 2.1.x and earlier (before __res_state()
was introduced) works. Portable programs should never do the
dirty things below. */

#include <pthread.h>
#include <resolv.h>
#include <stdlib.h>
#include <stdio.h>

void *tf (void *resp)
{
if (resp == &_res || resp == __res_state ())
abort ();
_res.retry = 24;
return NULL;
}

void do_test (struct __res_state *resp)
{
if (resp != &_res || resp != __res_state ())
abort ();
if (_res.retry != 12)
abort ();
}

int main (void)
{
#undef _res
extern struct __res_state _res;
pthread_t th;

_res.retry = 12;
if (pthread_create (&th, NULL, tf, &_res) != 0)
{
puts ("create failed");
exit (1);
}

do_test (&_res);

if (pthread_join (th, NULL) != 0)
{
puts ("join failed");
exit (1);
}

do_test (&_res);

exit (0);
}

0 comments on commit 0e9d624

Please sign in to comment.