diff options
author | Marco S Hyman <marc@cvs.openbsd.org> | 2002-11-07 03:51:22 +0000 |
---|---|---|
committer | Marco S Hyman <marc@cvs.openbsd.org> | 2002-11-07 03:51:22 +0000 |
commit | 7fca135058293137732acb571680d5a85f7e7790 (patch) | |
tree | 69db19a6488dcc7fa58ec08668586828d1276461 /lib/libc_r/uthread | |
parent | 213264c1bc5c250790d78dd190c2d5511ba7d163 (diff) |
Add needed table of strong functions that override weak functions
in libc so static linking works with -lpthreads. There is a
(linker?) problem that still shows up with static -pthread, though.
Solution to problem from freebsd.
Diffstat (limited to 'lib/libc_r/uthread')
-rw-r--r-- | lib/libc_r/uthread/uthread_file.c | 15 | ||||
-rw-r--r-- | lib/libc_r/uthread/uthread_init.c | 104 |
2 files changed, 97 insertions, 22 deletions
diff --git a/lib/libc_r/uthread/uthread_file.c b/lib/libc_r/uthread/uthread_file.c index cf84ffdb88b..73f8cda30f5 100644 --- a/lib/libc_r/uthread/uthread_file.c +++ b/lib/libc_r/uthread/uthread_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_file.c,v 1.8 2001/09/04 22:17:45 fgsch Exp $ */ +/* $OpenBSD: uthread_file.c,v 1.9 2002/11/07 03:51:21 marc Exp $ */ /* * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. * All rights reserved. @@ -46,13 +46,6 @@ #include "pthread_private.h" /* - * Weak symbols for externally visible functions in this file: - */ -#pragma weak flockfile=_flockfile -#pragma weak ftrylockfile=_ftrylockfile -#pragma weak funlockfile=_funlockfile - -/* * The FILE lock structure. The FILE *fp is locked if the owner is * not NULL. If not locked, the file lock structure can be * reassigned to a different file by setting fp. @@ -244,14 +237,14 @@ _flockfile_debug(FILE * fp, char *fname, int lineno) } void -_flockfile(FILE * fp) +flockfile(FILE * fp) { _flockfile_debug(fp, "?", 1); return; } int -_ftrylockfile(FILE * fp) +ftrylockfile(FILE * fp) { int ret = -1; int idx = file_idx(fp); @@ -303,7 +296,7 @@ _ftrylockfile(FILE * fp) } void -_funlockfile(FILE * fp) +funlockfile(FILE * fp) { int idx = file_idx(fp); struct file_lock *p; diff --git a/lib/libc_r/uthread/uthread_init.c b/lib/libc_r/uthread/uthread_init.c index 858f6aebd34..445fd6b69f5 100644 --- a/lib/libc_r/uthread/uthread_init.c +++ b/lib/libc_r/uthread/uthread_init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_init.c,v 1.23 2002/10/30 20:05:12 marc Exp $ */ +/* $OpenBSD: uthread_init.c,v 1.24 2002/11/07 03:51:21 marc Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> * All rights reserved. @@ -36,21 +36,29 @@ /* Allocate space for global thread variables here: */ #define GLOBAL_PTHREAD_PRIVATE -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> -#include <paths.h> -#include <poll.h> -#include <unistd.h> -#include <sys/ioctl.h> +#include <sys/types.h> #include <sys/param.h> + +#include <sys/ioctl.h> +#include <sys/mman.h> +#include <sys/mount.h> +#include <sys/socket.h> +#include <sys/stat.h> #include <sys/sysctl.h> #include <sys/time.h> #include <sys/ttycom.h> -#include <sys/param.h> #include <sys/user.h> -#include <sys/mman.h> +#include <sys/wait.h> + +#include <dirent.h> +#include <errno.h> +#include <fcntl.h> +#include <paths.h> +#include <poll.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + #ifdef _THREAD_SAFE #include <machine/reg.h> #include <pthread.h> @@ -62,6 +70,77 @@ _stack_list_t _stackq; extern int _thread_autoinit_dummy_decl; /* + * All weak references used within libc that are redefined in libc_r + * or libpthread MUST be in this table. This is necessary to force the + * proper version to be used when linking -static. + */ +static void *references[] = { + &_exit, + &accept, + &bind, + &close, + &connect, + &dup, + &dup2, + &execve, + &fchflags, + &fchmod, + &fchown, + &fcntl, + &flock, + &fork, + &fpathconf, + &fstat, + &fstatfs, + &fsync, + &getdirentries, + &getpeername, + &getsockname, + &getsockopt, + &ioctl, + &kevent, + &listen, + &msync, + &nanosleep, + &open, + &pipe, + &poll, + &read, + &readv, + &recvfrom, + &recvmsg, + &select, + &sendmsg, + &sendto, + &setsockopt, + &shutdown, + &sigaction, + &sigaltstack, + &sigpending, + &sigprocmask, + &sigsuspend, + &socket, + &socketpair, + &vfork, + &wait4, + &write, + &writev, + /* libc thread-safe helper functions */ + &_thread_fd_lock, + &_thread_fd_unlock, + &_thread_malloc_init, + &_thread_malloc_lock, + &_thread_malloc_unlock, + &_libc_private_storage, + &_libc_private_storage_lock, + &_libc_private_storage_unlock, + &flockfile, + &_flockfile_debug, + &ftrylockfile, + &funlockfile +}; + +/* * Threaded process initialization */ void @@ -80,6 +159,9 @@ _thread_init(void) /* Only initialise the threaded application once. */ return; + if (references[0] == NULL) + PANIC("Failed loading mandatory references in _thread_init"); + /* * Check for the special case of this process running as * or in place of init as pid = 1: |