Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
2002-10-09  Ulrich Drepper  <[email protected]>

	* Versions.def (libc): Add GLIBC_2.3.1.
	(libpthread): Add GLIBC_2.3.1.

	* include/signal.h: Add libc_hidden_proto for __sigwait, __sigwaitinfo,
	and __sigtimedwait.
	* signal/Versions: Add __sigtimedwait, __sigwait, and __sigwaitinfo.
	* sysdeps/unix/sysv/linux/sigtimedwait.c (__sigtimedwait): Add
	libc_hidden_def.
	* sysdeps/unix/sysv/linux/sigwait.c (__sigwait): Likewise.
	* sysdeps/unix/sysv/linux/sigwaitinfo.c (__sigwaitinfo): Likewise.

	* include/sys/msg.h: Declare __libc_msgrcv and __libc_msgsnd.
	* sysdeps/unix/sysv/linux/msgrcv.c (__msgrcv): Rename to __libc_msgrcv
	and make old name an alias.
	* sysdeps/unix/sysv/linux/msgsnd.c (__msgsnd): Rename to __libc_msgsnd
	and make old name an alias.
	* sysvipc/Versions (libc) [GLIBC_PRIVATE]: Add __libc_msgrcv and
	__libc_msgsnd.

	* include/sys/uio.h: Declare __libc_readv and __libc_writev.
	* misc/Versions (libc) [GLIBC_PRIVATE]: Add __libc_readv and
	__libc_writev.
	* sysdeps/generic/readv.c (__readv): Rename to __libc_readv and make
	old name an alias.
	* sysdeps/posix/readv.c: Likewise
	* sysdeps/unix/sysv/aix/readv.c: Likewise.
	* sysdeps/unix/sysv/linux/readv.c: Likewise.
	* sysdeps/generic/writev.c (__writev): Rename to __libc_writev and make
	old name an alias.
	* sysdeps/posix/writev.c: Likewise
	* sysdeps/unix/sysv/aix/writev.c: Likewise.
	* sysdeps/unix/sysv/linux/writev.c: Likewise.

	* include/sys/wait.h: Declare __waitid.
	* posix/Versions (libc) [GLIBC_PRIVATE]: Add __waitid.
	* sysdeps/generic/waitid.c (waitid): Rename to __waitid and make old
	name an alias.
	* sysdeps/posix/waitid.c: Likewise.
	* sysdeps/unix/sysv/aix/waitid.c: Likewise.

	* sysdeps/unix/sysv/linux/syscalls.list: Add creat syscall.

2002-10-07  Jakub Jelinek  <[email protected]>

	* include/alloca.h (__libc_use_alloca, __libc_alloca_cutoff): New
	prototypes.
	(__MAX_ALLOCA_CUTOFF): Define.
	Include allocalim.h.
	* resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname2_r,
	_nss_dns_gethostbyaddr_r): Use alloca or malloc to allocate
	host_buffer depending on __libc_use_alloca.
	* resolv/nss_dns/dns-network.c (_nss_dns_getnetbyname_r,
	_nss_dns_getnetbyaddr_r): Use alloca or malloc to allocate
	net_buffer depending on __libc_use_alloca.
	* resolv/res_query.c (res_nquery): Use alloca or malloc to allocate
	buf depending on __libc_use_alloca.
	* resolv/gethnamaddr.c (gethostbyname2, gethostbyaddr): Likewise.
	* stdio-common/vfprintf.c (vfprintf): Use __libc_use_alloca
	instead of hardcoded constants.
	Pass proper size argument to alloca and compute end for wide char
	version.
	* stdio-common/printf_fp.c (__printf_fp): Use __libc_use_alloca
	instead of hardcoded constants.
	* string/strcoll.c (strcoll): Likewise.
	* string/strxfrm.c (strxfrm): Likewise.
	* sysdeps/posix/readv.c (__readv): Likewise.
	* sysdeps/posix/writev.c (__writev): Likewise.
	* sysdeps/generic/allocalim.h: New file.
  • Loading branch information
Ulrich Drepper committed Oct 9, 2002
1 parent 4c2821f commit 6166815
Show file tree
Hide file tree
Showing 43 changed files with 424 additions and 200 deletions.
71 changes: 71 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,74 @@
2002-10-09 Ulrich Drepper <[email protected]>

* Versions.def (libc): Add GLIBC_2.3.1.
(libpthread): Add GLIBC_2.3.1.

* include/signal.h: Add libc_hidden_proto for __sigwait, __sigwaitinfo,
and __sigtimedwait.
* signal/Versions: Add __sigtimedwait, __sigwait, and __sigwaitinfo.
* sysdeps/unix/sysv/linux/sigtimedwait.c (__sigtimedwait): Add
libc_hidden_def.
* sysdeps/unix/sysv/linux/sigwait.c (__sigwait): Likewise.
* sysdeps/unix/sysv/linux/sigwaitinfo.c (__sigwaitinfo): Likewise.

* include/sys/msg.h: Declare __libc_msgrcv and __libc_msgsnd.
* sysdeps/unix/sysv/linux/msgrcv.c (__msgrcv): Rename to __libc_msgrcv
and make old name an alias.
* sysdeps/unix/sysv/linux/msgsnd.c (__msgsnd): Rename to __libc_msgsnd
and make old name an alias.
* sysvipc/Versions (libc) [GLIBC_PRIVATE]: Add __libc_msgrcv and
__libc_msgsnd.

* include/sys/uio.h: Declare __libc_readv and __libc_writev.
* misc/Versions (libc) [GLIBC_PRIVATE]: Add __libc_readv and
__libc_writev.
* sysdeps/generic/readv.c (__readv): Rename to __libc_readv and make
old name an alias.
* sysdeps/posix/readv.c: Likewise
* sysdeps/unix/sysv/aix/readv.c: Likewise.
* sysdeps/unix/sysv/linux/readv.c: Likewise.
* sysdeps/generic/writev.c (__writev): Rename to __libc_writev and make
old name an alias.
* sysdeps/posix/writev.c: Likewise
* sysdeps/unix/sysv/aix/writev.c: Likewise.
* sysdeps/unix/sysv/linux/writev.c: Likewise.

* include/sys/wait.h: Declare __waitid.
* posix/Versions (libc) [GLIBC_PRIVATE]: Add __waitid.
* sysdeps/generic/waitid.c (waitid): Rename to __waitid and make old
name an alias.
* sysdeps/posix/waitid.c: Likewise.
* sysdeps/unix/sysv/aix/waitid.c: Likewise.

* sysdeps/unix/sysv/linux/syscalls.list: Add creat syscall.

2002-10-07 Jakub Jelinek <[email protected]>

* include/alloca.h (__libc_use_alloca, __libc_alloca_cutoff): New
prototypes.
(__MAX_ALLOCA_CUTOFF): Define.
Include allocalim.h.
* resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname2_r,
_nss_dns_gethostbyaddr_r): Use alloca or malloc to allocate
host_buffer depending on __libc_use_alloca.
* resolv/nss_dns/dns-network.c (_nss_dns_getnetbyname_r,
_nss_dns_getnetbyaddr_r): Use alloca or malloc to allocate
net_buffer depending on __libc_use_alloca.
* resolv/res_query.c (res_nquery): Use alloca or malloc to allocate
buf depending on __libc_use_alloca.
* resolv/gethnamaddr.c (gethostbyname2, gethostbyaddr): Likewise.
* stdio-common/vfprintf.c (vfprintf): Use __libc_use_alloca
instead of hardcoded constants.
Pass proper size argument to alloca and compute end for wide char
version.
* stdio-common/printf_fp.c (__printf_fp): Use __libc_use_alloca
instead of hardcoded constants.
* string/strcoll.c (strcoll): Likewise.
* string/strxfrm.c (strxfrm): Likewise.
* sysdeps/posix/readv.c (__readv): Likewise.
* sysdeps/posix/writev.c (__writev): Likewise.
* sysdeps/generic/allocalim.h: New file.

2002-10-08 Roland McGrath <[email protected]>

* configure.in (aux_missing warning): Change "too old" to
Expand Down
7 changes: 7 additions & 0 deletions include/alloca.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,11 @@ extern void *__alloca (size_t __size);
# define __alloca(size) __builtin_alloca (size)
#endif /* GCC. */

extern int __libc_use_alloca (size_t size) __attribute__ ((const));
extern int __libc_alloca_cutoff (size_t size) __attribute__ ((const));

#define __MAX_ALLOCA_CUTOFF 65536

#include <allocalim.h>

#endif
3 changes: 3 additions & 0 deletions include/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ extern int __sigprocmask (int __how,
extern int __sigsuspend (__const sigset_t *__set);
libc_hidden_proto (__sigsuspend)
extern int __sigwait (__const sigset_t *__set, int *__sig);
libc_hidden_proto (__sigwait)
extern int __sigwaitinfo (__const sigset_t *__set, siginfo_t *__info);
libc_hidden_proto (__sigwaitinfo)
extern int __sigtimedwait (__const sigset_t *__set, siginfo_t *__info,
__const struct timespec *__timeout);
libc_hidden_proto (__sigtimedwait)
extern int __sigqueue (__pid_t __pid, int __sig,
__const union sigval __val);
extern int __sigvec (int __sig, __const struct sigvec *__vec,
Expand Down
8 changes: 8 additions & 0 deletions include/sys/msg.h
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
#ifndef _SYS_MSG_H
#include <sysvipc/sys/msg.h>

extern int __libc_msgrcv (int msqid, void *msgp, size_t msgsz, long int msgtyp,
int msgflg);
extern int __libc_msgsnd (int msqid, const void *msgp, size_t msgsz,
int msgflg);

#endif
4 changes: 4 additions & 0 deletions include/sys/uio.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
/* Now define the internal interfaces. */
extern ssize_t __readv (int __fd, __const struct iovec *__vector,
int __count);
extern ssize_t __libc_readv (int __fd, __const struct iovec *__vector,
int __count);
extern ssize_t __writev (int __fd, __const struct iovec *__vector,
int __count);
extern ssize_t __libc_writev (int __fd, __const struct iovec *__vector,
int __count);
#endif
1 change: 1 addition & 0 deletions include/sys/wait.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
extern __pid_t __waitpid (__pid_t __pid, int *__stat_loc,
int __options);
libc_hidden_proto (__waitpid)
extern int __waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options);

extern __pid_t __libc_waitpid (pid_t __pid, int *__stat_loc, int __options);
extern __pid_t __libc_wait (int *__stat_loc);
Expand Down
5 changes: 2 additions & 3 deletions linuxthreads/Versions
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ libc {
GLIBC_PRIVATE {
# Internal libc interface to libpthread
__libc_internal_tsd_get; __libc_internal_tsd_set;
__libc_internal_tsd_address;

__libc_internal_tsd_address; __libc_alloca_cutoff;
}
}

Expand Down Expand Up @@ -163,7 +162,7 @@ libpthread {
GLIBC_PRIVATE {
# Internal libc interface to libpthread
__libc_internal_tsd_get; __libc_internal_tsd_set;
__libc_internal_tsd_address;
__libc_internal_tsd_address; __libc_alloca_cutoff;
__pthread_kill_other_threads_np;
}
}
2 changes: 2 additions & 0 deletions linuxthreads/descr.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ struct _pthread_descr_struct {
#ifdef USE_TLS
char *p_stackaddr; /* Stack address. */
#endif
size_t p_alloca_cutoff; /* Maximum size which should be allocated
using alloca() instead of malloc(). */
/* New elements must be added at the end. */
} __attribute__ ((aligned(32))); /* We need to align the structure so that
doubles are aligned properly. This is 8
Expand Down
15 changes: 12 additions & 3 deletions linuxthreads/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
char ** out_new_thread,
char ** out_new_thread_bottom,
char ** out_guardaddr,
size_t * out_guardsize)
size_t * out_guardsize,
size_t * out_stacksize)
{
pthread_descr new_thread;
char * new_thread_bottom;
Expand Down Expand Up @@ -388,6 +389,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
/* Clear the thread data structure. */
memset (new_thread, '\0', sizeof (*new_thread));
#endif
stacksize = attr->__stacksize;
}
else
{
Expand Down Expand Up @@ -559,6 +561,11 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
*out_new_thread_bottom = new_thread_bottom;
*out_guardaddr = guardaddr;
*out_guardsize = guardsize;
#ifdef NEED_SEPARATE_REGISTER_STACK
*out_stacksize = stacksize / 2;
#else
*out_stacksize = stacksize;
#endif
return 0;
}

Expand All @@ -575,7 +582,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
char * new_thread_bottom;
pthread_t new_thread_id;
char *guardaddr = NULL;
size_t guardsize = 0;
size_t guardsize = 0, stksize = 0;
int pagesize = __getpagesize();
int saved_errno = 0;

Expand Down Expand Up @@ -608,7 +615,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
continue;
if (pthread_allocate_stack(attr, thread_segment(sseg),
pagesize, &stack_addr, &new_thread_bottom,
&guardaddr, &guardsize) == 0)
&guardaddr, &guardsize, &stksize) == 0)
{
#ifdef USE_TLS
new_thread->p_stackaddr = stack_addr;
Expand Down Expand Up @@ -639,6 +646,8 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
new_thread->p_guardsize = guardsize;
new_thread->p_nr = sseg;
new_thread->p_inheritsched = attr ? attr->__inheritsched : 0;
new_thread->p_alloca_cutoff = stksize / 4 > __MAX_ALLOCA_CUTOFF
? __MAX_ALLOCA_CUTOFF : stksize / 4;
/* Initialize the thread handle */
__pthread_init_lock(&__pthread_handles[sseg].h_lock);
__pthread_handles[sseg].h_descr = new_thread;
Expand Down
5 changes: 5 additions & 0 deletions linuxthreads/no-tsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ void **(*__libc_internal_tsd_address) (enum __libc_tsd_key_t)
__THROW __attribute__ ((__const__));

#endif /* !(USE_TLS && HAVE___THREAD) */

int __libc_alloca_cutoff (size_t size)
{
return size <= __MAX_ALLOCA_CUTOFF;
}
138 changes: 34 additions & 104 deletions linuxthreads/pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,58 +63,20 @@ static pthread_descr manager_thread;
/* Descriptor of the initial thread */

struct _pthread_descr_struct __pthread_initial_thread = {
{
{
.self = &__pthread_initial_thread /* pthread_descr self */
}
},
&__pthread_initial_thread, /* pthread_descr p_nextlive */
&__pthread_initial_thread, /* pthread_descr p_prevlive */
NULL, /* pthread_descr p_nextwaiting */
NULL, /* pthread_descr p_nextlock */
PTHREAD_THREADS_MAX, /* pthread_t p_tid */
0, /* int p_pid */
0, /* int p_priority */
&__pthread_handles[0].h_lock, /* struct _pthread_fastlock * p_lock */
0, /* int p_signal */
NULL, /* sigjmp_buf * p_signal_buf */
NULL, /* sigjmp_buf * p_cancel_buf */
0, /* char p_terminated */
0, /* char p_detached */
0, /* char p_exited */
NULL, /* void * p_retval */
0, /* int p_retval */
NULL, /* pthread_descr p_joining */
NULL, /* struct _pthread_cleanup_buffer * p_cleanup */
0, /* char p_cancelstate */
0, /* char p_canceltype */
0, /* char p_canceled */
NULL, /* char * p_in_sighandler */
0, /* char p_sigwaiting */
PTHREAD_START_ARGS_INITIALIZER(NULL),
/* struct pthread_start_args p_start_args */
{NULL}, /* void ** p_specific[PTHREAD_KEY_1STLEVEL_SIZE] */
{NULL}, /* void * p_libc_specific[_LIBC_TSD_KEY_N] */
&_errno, /* int *p_errnop */
0, /* int p_errno */
&_h_errno, /* int *p_h_errnop */
0, /* int p_h_errno */
&_res, /* struct __res_state *p_resp */
{}, /* struct __res_state p_res */
1, /* int p_userstack */
NULL, /* void * p_guardaddr */
0, /* size_t p_guardsize */
0, /* Always index 0 */
0, /* int p_report_events */
{{{0, }}, 0, NULL}, /* td_eventbuf_t p_eventbuf */
__ATOMIC_INITIALIZER, /* struct pthread_atomic p_resume_count */
0, /* char p_woken_by_cancel */
0, /* char p_condvar_avail */
0, /* char p_sem_avail */
NULL, /* struct pthread_extricate_if *p_extricate */
NULL, /* pthread_readlock_info *p_readlock_list; */
NULL, /* pthread_readlock_info *p_readlock_free; */
0 /* int p_untracked_readlock_count; */
.p_header.data.self = &__pthread_initial_thread,
.p_nextlive = &__pthread_initial_thread,
.p_prevlive = &__pthread_initial_thread,
.p_tid = PTHREAD_THREADS_MAX,
.p_lock = &__pthread_handles[0].h_lock,
.p_start_args = PTHREAD_START_ARGS_INITIALIZER(NULL),
#if !(USE_TLS && HAVE___THREAD)
.p_errnop = &_errno,
.p_h_errnop = &_h_errno,
.p_resp = &_res,
#endif
.p_userstack = 1,
.p_resume_count = __ATOMIC_INITIALIZER,
.p_alloca_cutoff = __MAX_ALLOCA_CUTOFF
};

/* Descriptor of the manager thread; none of this is used but the error
Expand All @@ -123,58 +85,15 @@ struct _pthread_descr_struct __pthread_initial_thread = {

#define manager_thread (&__pthread_manager_thread)
struct _pthread_descr_struct __pthread_manager_thread = {
{
{
.self = &__pthread_manager_thread /* pthread_descr self */
}
},
NULL, /* pthread_descr p_nextlive */
NULL, /* pthread_descr p_prevlive */
NULL, /* pthread_descr p_nextwaiting */
NULL, /* pthread_descr p_nextlock */
0, /* int p_tid */
0, /* int p_pid */
0, /* int p_priority */
&__pthread_handles[1].h_lock, /* struct _pthread_fastlock * p_lock */
0, /* int p_signal */
NULL, /* sigjmp_buf * p_signal_buf */
NULL, /* sigjmp_buf * p_cancel_buf */
0, /* char p_terminated */
0, /* char p_detached */
0, /* char p_exited */
NULL, /* void * p_retval */
0, /* int p_retval */
NULL, /* pthread_descr p_joining */
NULL, /* struct _pthread_cleanup_buffer * p_cleanup */
0, /* char p_cancelstate */
0, /* char p_canceltype */
0, /* char p_canceled */
NULL, /* char * p_in_sighandler */
0, /* char p_sigwaiting */
PTHREAD_START_ARGS_INITIALIZER(__pthread_manager),
/* struct pthread_start_args p_start_args */
{NULL}, /* void ** p_specific[PTHREAD_KEY_1STLEVEL_SIZE] */
{NULL}, /* void * p_libc_specific[_LIBC_TSD_KEY_N] */
&__pthread_manager_thread.p_errno, /* int *p_errnop */
0, /* int p_errno */
NULL, /* int *p_h_errnop */
0, /* int p_h_errno */
NULL, /* struct __res_state *p_resp */
{}, /* struct __res_state p_res */
0, /* int p_userstack */
NULL, /* void * p_guardaddr */
0, /* size_t p_guardsize */
1, /* Always index 1 */
0, /* int p_report_events */
{{{0, }}, 0, NULL}, /* td_eventbuf_t p_eventbuf */
__ATOMIC_INITIALIZER, /* struct pthread_atomic p_resume_count */
0, /* char p_woken_by_cancel */
0, /* char p_condvar_avail */
0, /* char p_sem_avail */
NULL, /* struct pthread_extricate_if *p_extricate */
NULL, /* pthread_readlock_info *p_readlock_list; */
NULL, /* pthread_readlock_info *p_readlock_free; */
0 /* int p_untracked_readlock_count; */
.p_header.data.self = &__pthread_manager_thread,
.p_lock = &__pthread_handles[1].h_lock,
.p_start_args = PTHREAD_START_ARGS_INITIALIZER(__pthread_manager),
#if !(USE_TLS && HAVE___THREAD)
.p_errnop = &__pthread_manager_thread.p_errno,
#endif
.p_nr = 1,
.p_resume_count = __ATOMIC_INITIALIZER,
.p_alloca_cutoff = PTHREAD_STACK_MIN / 4
};
#endif

Expand Down Expand Up @@ -418,6 +337,7 @@ __pthread_initialize_minimal(void)
# if __LT_SPINLOCK_INIT != 0
self->p_resume_count = (struct pthread_atomic) __ATOMIC_INITIALIZER;
# endif
self->p_alloca_cutoff = __MAX_ALLOCA_CUTOFF;

/* Another variable which points to the thread descriptor. */
__pthread_main_thread = self;
Expand Down Expand Up @@ -487,6 +407,15 @@ __pthread_init_max_stacksize(void)
}
#endif
__pthread_max_stacksize = max_stack;
if (max_stack / 4 < __MAX_ALLOCA_CUTOFF)
{
#ifdef USE_TLS
pthread_descr self = THREAD_SELF;
self->p_alloca_cutoff = max_stack / 4;
#else
__pthread_initial_thread.p_alloca_cutoff = max_stack / 4;
#endif
}
}


Expand Down Expand Up @@ -629,6 +558,7 @@ int __pthread_initialize_manager(void)
# if __LT_SPINLOCK_INIT != 0
self->p_resume_count = (struct pthread_atomic) __ATOMIC_INITIALIZER;
# endif
tcb->p_alloca_cutoff = PTHREAD_STACK_MIN / 4;
#else
tcb = &__pthread_manager_thread;
#endif
Expand Down
Loading

0 comments on commit 6166815

Please sign in to comment.