Add cancellation stubs in libpthread for POSIX messages queues and

asynchronous I/O.

OK by <ad>.
This commit is contained in:
rmind 2007-10-09 18:18:33 +00:00
parent 0b82374265
commit 25e540085b
4 changed files with 101 additions and 11 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.176 2007/07/17 17:42:07 joerg Exp $
# $NetBSD: Makefile.inc,v 1.177 2007/10/09 18:18:33 rmind Exp $
# @(#)Makefile.inc 8.3 (Berkeley) 10/24/94
# sys sources
@ -97,9 +97,10 @@ ASM= access.S acct.S \
umask.S undelete.S unlink.S unmount.S utimes.S utrace.S uuidgen.S \
vadvise.S
WEAKASM= accept.S close.S connect.S execve.S \
WEAKASM= accept.S aio_suspend.S close.S connect.S execve.S \
fcntl.S fdatasync.S fsync.S fsync_range.S \
kill.S msgrcv.S msgsnd.S __msync13.S \
kill.S mq_receive.S mq_send.S mq_timedreceive.S mq_timedsend.S \
msgrcv.S msgsnd.S __msync13.S \
nanosleep.S open.S poll.S pollts.S pselect.S read.S readlink.S readv.S \
sched_yield.S select.S __sigprocmask14.S __sigsuspend14.S sysarch.S \
wait4.S write.S writev.S

View File

@ -1,5 +1,5 @@
#!/bin/sh -
# $NetBSD: makelintstub,v 1.18 2007/02/09 22:08:48 ad Exp $
# $NetBSD: makelintstub,v 1.19 2007/10/09 18:18:33 rmind Exp $
#
# Copyright (c) 1996, 1997 Christopher G. Demetriou
# All rights reserved.
@ -53,6 +53,7 @@ header()
*/
#include <sys/param.h>
#include <sys/aio.h>
#include <sys/time.h>
#include <sys/mount.h>
#include <sys/stat.h>
@ -62,6 +63,7 @@ header()
#include <sys/poll.h>
#include <sys/uio.h>
#include <sys/ipc.h>
#include <sys/mqueue.h>
#include <sys/msg.h>
#include <sys/sem.h>
#include <sys/shm.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: pthread_cancelstub.c,v 1.14 2007/03/04 20:07:13 ad Exp $ */
/* $NetBSD: pthread_cancelstub.c,v 1.15 2007/10/09 18:18:33 rmind Exp $ */
/*-
* Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: pthread_cancelstub.c,v 1.14 2007/03/04 20:07:13 ad Exp $");
__RCSID("$NetBSD: pthread_cancelstub.c,v 1.15 2007/10/09 18:18:33 rmind Exp $");
/*
* This is necessary because the names are always weak (they are not
@ -58,7 +58,9 @@ __RCSID("$NetBSD: pthread_cancelstub.c,v 1.14 2007/03/04 20:07:13 ad Exp $");
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/wait.h>
#include <aio.h>
#include <fcntl.h>
#include <mqueue.h>
#include <poll.h>
#include <stdarg.h>
#include <unistd.h>
@ -76,12 +78,20 @@ __RCSID("$NetBSD: pthread_cancelstub.c,v 1.14 2007/03/04 20:07:13 ad Exp $");
int pthread__cancel_stub_binder;
int _sys_accept(int, struct sockaddr *, socklen_t *);
int _sys_aio_suspend(const struct aiocb * const [], int,
const struct timespec *);
int _sys_close(int);
int _sys_connect(int, const struct sockaddr *, socklen_t);
int _sys_fcntl(int, int, ...);
int _sys_fdatasync(int);
int _sys_fsync(int);
int _sys_fsync_range(int, int, off_t, off_t);
int _sys_mq_send(mqd_t, const char *, size_t, unsigned);
ssize_t _sys_mq_receive(mqd_t, char *, size_t, unsigned *);
int _sys_mq_timedsend(mqd_t, const char *, size_t, unsigned,
const struct timespec *);
ssize_t _sys_mq_timedreceive(mqd_t, char *, size_t, unsigned *,
const struct timespec *);
ssize_t _sys_msgrcv(int, void *, size_t, long, int);
int _sys_msgsnd(int, const void *, size_t, int);
int _sys___msync13(void *, size_t, int);
@ -124,6 +134,21 @@ accept(int s, struct sockaddr *addr, socklen_t *addrlen)
return retval;
}
int
aio_suspend(const struct aiocb * const list[], int nent,
const struct timespec *timeout)
{
int retval;
pthread_t self;
self = pthread__self();
TESTCANCEL(self);
retval = _sys_aio_suspend(list, nent, timeout);
TESTCANCEL(self);
return retval;
}
int
close(int d)
{
@ -211,6 +236,64 @@ fsync_range(int d, int f, off_t s, off_t e)
return retval;
}
int
mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio)
{
int retval;
pthread_t self;
self = pthread__self();
TESTCANCEL(self);
retval = _sys_mq_send(mqdes, msg_ptr, msg_len, msg_prio);
TESTCANCEL(self);
return retval;
}
ssize_t
mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio)
{
int retval;
pthread_t self;
self = pthread__self();
TESTCANCEL(self);
retval = _sys_mq_receive(mqdes, msg_ptr, msg_len, msg_prio);
TESTCANCEL(self);
return retval;
}
int
mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
unsigned msg_prio, const struct timespec *abst)
{
int retval;
pthread_t self;
self = pthread__self();
TESTCANCEL(self);
retval = _sys_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, abst);
TESTCANCEL(self);
return retval;
}
ssize_t
mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio,
const struct timespec *abst)
{
int retval;
pthread_t self;
self = pthread__self();
TESTCANCEL(self);
retval = _sys_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, abst);
TESTCANCEL(self);
return retval;
}
ssize_t
msgrcv(int msgid, void *msgp, size_t msgsz, long msgtyp, int msgflg)
{
@ -457,11 +540,16 @@ sigtimedwait(const sigset_t * __restrict set, siginfo_t * __restrict info,
return retval;
}
__strong_alias(_aio_suspend, aio_suspend)
__strong_alias(_close, close)
__strong_alias(_fcntl, fcntl)
__strong_alias(_fdatasync, fdatasync)
__strong_alias(_fsync, fsync)
__weak_alias(fsync_range, _fsync_range)
__strong_alias(_mq_send, mq_send)
__strong_alias(_mq_receive, mq_receive)
__strong_alias(_mq_timedsend, mq_timedsend)
__strong_alias(_mq_timedreceive, mq_timedreceive)
__strong_alias(_msgrcv, msgrcv)
__strong_alias(_msgsnd, msgsnd)
__strong_alias(___msync13, __msync13)

View File

@ -1,12 +1,11 @@
# $NetBSD: Makefile.inc,v 1.3 2007/09/07 18:56:05 rmind Exp $
# $NetBSD: Makefile.inc,v 1.4 2007/10/09 18:18:33 rmind Exp $
.PATH: ${.CURDIR}/sys
ASM= aio_cancel.S aio_error.S aio_fsync.S aio_read.S aio_return.S \
aio_suspend.S aio_write.S lio_listio.S \
mq_close.S mq_getattr.S mq_notify.S mq_open.S mq_receive.S \
mq_send.S mq_setattr.S mq_timedreceive.S mq_timedsend.S \
mq_unlink.S
aio_write.S lio_listio.S \
mq_close.S mq_getattr.S mq_notify.S mq_open.S \
mq_setattr.S mq_unlink.S
SRCS+= ${ASM}
CLEANFILES+= ${ASM}