summaryrefslogtreecommitdiff
path: root/lib/libc_r
diff options
context:
space:
mode:
authorDavid Leonard <d@cvs.openbsd.org>1999-01-18 00:00:34 +0000
committerDavid Leonard <d@cvs.openbsd.org>1999-01-18 00:00:34 +0000
commit7b9d8c26923e22e249d8fccca1b678c46ca2b4de (patch)
tree28ebd21a982d7c31007aa22724282631b071b210 /lib/libc_r
parent46b689c0962ca1c667dfdfc76b8e6fafc1eef2bc (diff)
sync with previous changes
Diffstat (limited to 'lib/libc_r')
-rw-r--r--lib/libc_r/TEST/Makefile2
-rw-r--r--lib/libc_r/include/pthread.h33
-rw-r--r--lib/libc_r/man/Makefile.inc15
-rw-r--r--lib/libc_r/uthread/Makefile.inc9
-rw-r--r--lib/libc_r/uthread/pthread_private.h41
5 files changed, 70 insertions, 30 deletions
diff --git a/lib/libc_r/TEST/Makefile b/lib/libc_r/TEST/Makefile
index 9b95619ccdf..f1f07e5fac0 100644
--- a/lib/libc_r/TEST/Makefile
+++ b/lib/libc_r/TEST/Makefile
@@ -23,7 +23,7 @@ TESTS = test_create test_pthread_join test_switch test_sleep test_readdir \
test_fork test_execve test_preemption \
test_sock_1 test_sock_2 test_stdio_1 test_pthread_mutex \
test_pthread_cond_timedwait test_netdb test_pw test_cwd \
- test_sock_2a
+ test_sock_2a test_cancel
SRCS = ${TESTS:=.c}
CLEANFILES += ${TESTS}
diff --git a/lib/libc_r/include/pthread.h b/lib/libc_r/include/pthread.h
index 3215c445a40..0c935fabc97 100644
--- a/lib/libc_r/include/pthread.h
+++ b/lib/libc_r/include/pthread.h
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: pthread.h,v 1.4 1998/12/21 07:30:25 d Exp $
+ * $OpenBSD: pthread.h,v 1.5 1999/01/18 00:00:31 d Exp $
*
*/
#ifndef _PTHREAD_H_
@@ -91,6 +91,15 @@
#define PTHREAD_PROCESS_SHARED 1
/*
+ * Flags for cancelling threads
+ */
+#define PTHREAD_CANCEL_ENABLE 0
+#define PTHREAD_CANCEL_DISABLE 1
+#define PTHREAD_CANCEL_DEFERRED 0
+#define PTHREAD_CANCEL_ASYNCHRONOUS 1
+#define PTHREAD_CANCELED ((void *) 1)
+
+/*
* Forward structure definitions.
*
* These are mostly opaque to the user.
@@ -174,24 +183,26 @@ enum pthread_mutextype {
* Thread function prototype definitions:
*/
__BEGIN_DECLS
+int pthread_atfork(void (*)(void), void (*)(void), void (*)(void));
int pthread_attr_destroy __P((pthread_attr_t *));
-int pthread_attr_getinheritsched __P((pthread_attr_t *, int *));
-int pthread_attr_getschedparam __P((pthread_attr_t *,
+int pthread_attr_getinheritsched __P((const pthread_attr_t *, int *));
+int pthread_attr_getschedparam __P((const pthread_attr_t *,
struct sched_param *));
-int pthread_attr_getschedpolicy __P((pthread_attr_t *, int *));
-int pthread_attr_getscope __P((pthread_attr_t *, int *));
+int pthread_attr_getschedpolicy __P((const pthread_attr_t *, int *));
+int pthread_attr_getscope __P((const pthread_attr_t *, int *));
int pthread_attr_getstacksize __P((pthread_attr_t *, size_t *));
int pthread_attr_getstackaddr __P((pthread_attr_t *, void **));
int pthread_attr_getdetachstate __P((pthread_attr_t *, int *));
int pthread_attr_init __P((pthread_attr_t *));
int pthread_attr_setinheritsched __P((pthread_attr_t *, int));
int pthread_attr_setschedparam __P((pthread_attr_t *,
- struct sched_param *));
+ const struct sched_param *));
int pthread_attr_setschedpolicy __P((pthread_attr_t *, int));
int pthread_attr_setscope __P((pthread_attr_t *, int));
int pthread_attr_setstacksize __P((pthread_attr_t *, size_t));
int pthread_attr_setstackaddr __P((pthread_attr_t *, void *));
int pthread_attr_setdetachstate __P((pthread_attr_t *, int));
+int pthread_cancel __P((pthread_t));
void pthread_cleanup_pop __P((int execute));
void pthread_cleanup_push __P((void (*routine) (void *),
void *routine_arg));
@@ -264,14 +275,14 @@ int pthread_setcancelstate __P((int, int *));
int pthread_setcanceltype __P((int, int *));
int pthread_setspecific __P((pthread_key_t, const void *));
int pthread_sigmask __P((int, const sigset_t *, sigset_t *));
-int pthread_testcancel __P((void));
+void pthread_testcancel __P((void));
int pthread_getprio __P((pthread_t));
int pthread_setprio __P((pthread_t, int));
void pthread_yield __P((void));
int pthread_setschedparam __P((pthread_t pthread, int policy,
- struct sched_param * param));
+ const struct sched_param * param));
int pthread_getschedparam __P((pthread_t pthread, int *policy,
struct sched_param * param));
int pthread_attr_setfloatstate __P((pthread_attr_t *, int));
@@ -284,11 +295,7 @@ int pthread_attr_setcleanup __P((pthread_attr_t *,
/*
* Single Unix Specification v2 (UNIX98) also wants these:
*/
-#define PTHREAD_CANCEL_ASYNCHRONOUS
-#define PTHREAD_CANCEL_ENABLE
-#define PTHREAD_CANCEL_DEFERRED
-#define PTHREAD_CANCEL_DISABLE
-#define PTHREAD_CANCELED
+
#define PTHREAD_PRIO_INHERIT
#define PTHREAD_PRIO_NONE
#define PTHREAD_PRIO_PROTECT
diff --git a/lib/libc_r/man/Makefile.inc b/lib/libc_r/man/Makefile.inc
index f3ff1ba09a2..f637c4a88cf 100644
--- a/lib/libc_r/man/Makefile.inc
+++ b/lib/libc_r/man/Makefile.inc
@@ -1,11 +1,12 @@
-# $Id: Makefile.inc,v 1.3 1998/11/20 15:15:06 d Exp $
-# $OpenBSD: Makefile.inc,v 1.3 1998/11/20 15:15:06 d Exp $
+# $Id: Makefile.inc,v 1.4 1999/01/18 00:00:32 d Exp $
+# $OpenBSD: Makefile.inc,v 1.4 1999/01/18 00:00:32 d Exp $
# POSIX thread man files
.PATH: ${.CURDIR}/man
-MAN+= pthread_cleanup_pop.3 \
+MAN+= pthread_atfork.3 \
+ pthread_cleanup_pop.3 \
pthread_cleanup_push.3 \
pthread_cond_broadcast.3 \
pthread_cond_destroy.3 \
@@ -13,6 +14,7 @@ MAN+= pthread_cleanup_pop.3 \
pthread_cond_signal.3 \
pthread_cond_timedwait.3 \
pthread_cond_wait.3 \
+ pthread_cancel.3 \
pthread_create.3 \
pthread_detach.3 \
pthread_equal.3 \
@@ -37,7 +39,8 @@ MAN+= pthread_cleanup_pop.3 \
pthread_rwlockattr_init.3 \
pthread_rwlockattr_setpshared.3 \
pthread_self.3 \
- pthread_setspecific.3
+ pthread_setspecific.3 \
+ pthread_testcancel.3
MAN+= pthreads.3 \
flockfile.3 \
@@ -46,5 +49,7 @@ MAN+= pthreads.3 \
MLINKS+=flockfile.3 funlockfile.3 \
flockfile.3 ftrylockfile.3 \
pthread_rwlock_rdlock.3 pthread_rwlock_tryrdlock.3 \
- pthread_rwlock_wrlock.3 pthread_rwlock_trywrlock.3
+ pthread_rwlock_wrlock.3 pthread_rwlock_trywrlock.3 \
+ pthread_cancel.3 pthread_setcancelstate.3 \
+ pthread_cancel.3 pthread_getcancelstate.3 \
diff --git a/lib/libc_r/uthread/Makefile.inc b/lib/libc_r/uthread/Makefile.inc
index bbaea92c049..e525110ebb3 100644
--- a/lib/libc_r/uthread/Makefile.inc
+++ b/lib/libc_r/uthread/Makefile.inc
@@ -1,5 +1,5 @@
-# $Id: Makefile.inc,v 1.5 1999/01/08 05:42:18 d Exp $
-# $OpenBSD: Makefile.inc,v 1.5 1999/01/08 05:42:18 d Exp $
+# $Id: Makefile.inc,v 1.6 1999/01/18 00:00:32 d Exp $
+# $OpenBSD: Makefile.inc,v 1.6 1999/01/18 00:00:32 d Exp $
# uthread sources
.PATH: ${.CURDIR}/uthread
@@ -8,17 +8,21 @@ CFLAGS += -I${.CURDIR}/arch/${MACHINE_ARCH}
SRCS+= \
uthread_accept.c \
+ uthread_atfork.c \
uthread_attr_destroy.c \
uthread_attr_init.c \
uthread_attr_getdetachstate.c \
uthread_attr_getstackaddr.c \
uthread_attr_getstacksize.c \
+ uthread_attr_priosched.c \
uthread_attr_setcreatesuspend_np.c \
uthread_attr_setdetachstate.c \
uthread_attr_setstackaddr.c \
uthread_attr_setstacksize.c \
uthread_autoinit.c \
uthread_bind.c \
+ uthread_fchflags.c \
+ uthread_cancel.c \
uthread_clean.c \
uthread_close.c \
uthread_cond.c \
@@ -60,6 +64,7 @@ SRCS+= \
uthread_listen.c \
uthread_mattr_init.c \
uthread_mattr_kind_np.c \
+ uthread_msync.c \
uthread_multi_np.c \
uthread_mutex.c \
uthread_mutexattr_destroy.c \
diff --git a/lib/libc_r/uthread/pthread_private.h b/lib/libc_r/uthread/pthread_private.h
index 28cfcfa7ae7..ff318b3b611 100644
--- a/lib/libc_r/uthread/pthread_private.h
+++ b/lib/libc_r/uthread/pthread_private.h
@@ -31,7 +31,7 @@
*
* Private thread definitions for the uthread kernel.
*
- * $OpenBSD: pthread_private.h,v 1.10 1999/01/10 22:32:23 d Exp $
+ * $OpenBSD: pthread_private.h,v 1.11 1999/01/18 00:00:32 d Exp $
*
*/
@@ -50,7 +50,9 @@
#include <sys/time.h>
#include <sched.h>
#include <spinlock.h>
+#ifndef _NO_UTHREAD_MACHDEP
#include "uthread_machdep.h"
+#endif
/*
* Kernel fatal error handler macro.
@@ -197,6 +199,10 @@ struct pthread_attr {
#define PTHREAD_MIN_PRIORITY 0
#define _POSIX_THREAD_ATTR_STACKSIZE
+#define PTHREAD_ATFORK_PREPARE 0
+#define PTHREAD_ATFORK_PARENT 1
+#define PTHREAD_ATFORK_CHILD 2
+
/*
* Clock resolution in nanoseconds.
*/
@@ -349,12 +355,6 @@ struct pthread {
*/
struct sigcontext saved_sigcontext;
- /*
- * Saved jump buffer used in call to longjmp by _thread_kern_sched
- * if sig_saved is FALSE.
- */
- jmp_buf saved_jmp_buf;
-
/*
* TRUE if the last state saved was a signal context. FALSE if the
* last state saved was a jump buffer.
@@ -362,6 +362,12 @@ struct pthread {
int sig_saved;
/*
+ * Cancelability state.
+ */
+ int cancelstate;
+ int canceltype;
+
+ /*
* Current signal mask and pending signals.
*/
sigset_t sigmask;
@@ -441,8 +447,10 @@ struct pthread {
int signo;
/* Miscellaneous data. */
- char flags;
-#define PTHREAD_EXITING 0x0100
+ int flags;
+#define PTHREAD_EXITING (0x0100)
+#define PTHREAD_CANCELLING (0x0200) /* thread has been cancelled */
+#define PTHREAD_AT_CANCEL_POINT (0x0400) /* thread at cancel point */
char pthread_priority;
void *ret;
const void **specific_data;
@@ -453,8 +461,16 @@ struct pthread {
const char *fname; /* Ptr to source file name */
int lineno; /* Source line number. */
+ /*
+ * Saved jump buffer used in call to longjmp by _thread_kern_sched
+ * if sig_saved is FALSE.
+ */
+ _machdep_jmp_buf saved_jmp_buf;
+
+#ifndef _UTHREAD_MACHDEP
/* Machine dependent information */
struct _machdep_struct _machdep;
+#endif
};
/*
@@ -577,6 +593,10 @@ int _thread_fd_table_init(int fd);
struct pthread *_thread_queue_get(struct pthread_queue *);
struct pthread *_thread_queue_deq(struct pthread_queue *);
pthread_addr_t _thread_gc(pthread_addr_t);
+void _thread_enter_cancellation_point(void);
+void _thread_leave_cancellation_point(void);
+void _thread_cancellation_point(void);
+void _thread_atfork(int);
/* #include <signal.h> */
#ifdef _USER_SIGNAL_H
@@ -761,6 +781,9 @@ pid_t _thread_sys_wait4(pid_t, int *, int, struct rusage *);
int _thread_sys_poll(struct pollfd[], int, int);
#endif
+/* #include <sys/mman.h> */
+int _thread_sys_msync(void *, size_t, int);
+
__END_DECLS
#endif /* !_PTHREAD_PRIVATE_H */