Index: stable/11/include/mqueue.h =================================================================== --- stable/11/include/mqueue.h (revision 306904) +++ stable/11/include/mqueue.h (revision 306905) @@ -1,56 +1,58 @@ /*- * Copyright (c) 2005 David Xu * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #ifndef _MQUEUE_H_ #define _MQUEUE_H_ #include #include #include #include struct timespec; __BEGIN_DECLS int mq_close(mqd_t); int mq_getattr(mqd_t, struct mq_attr *); int mq_notify(mqd_t, const struct sigevent *); mqd_t mq_open(const char *, int, ...); ssize_t mq_receive(mqd_t, char *, size_t, unsigned *); int mq_send(mqd_t, const char *, size_t, unsigned); int mq_setattr(mqd_t, const struct mq_attr *__restrict, struct mq_attr *__restrict); ssize_t mq_timedreceive(mqd_t, char *__restrict, size_t, unsigned *__restrict, const struct timespec *__restrict); int mq_timedsend(mqd_t, const char *, size_t, unsigned, const struct timespec *); int mq_unlink(const char *); -int __mq_oshandle(mqd_t mqd); +#if __BSD_VISIBLE +int mq_getfd_np(mqd_t mqd); +#endif /* __BSD_VISIBLE */ __END_DECLS #endif Index: stable/11/include/time.h =================================================================== --- stable/11/include/time.h (revision 306904) +++ stable/11/include/time.h (revision 306905) @@ -1,204 +1,205 @@ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)time.h 8.3 (Berkeley) 1/21/94 */ /* * $FreeBSD$ */ #ifndef _TIME_H_ #define _TIME_H_ #include #include #include #if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE /* * Frequency of the clock ticks reported by times(). Deprecated - use * sysconf(_SC_CLK_TCK) instead. (Removed in 1003.1-2001.) */ #define CLK_TCK 128 #endif /* Frequency of the clock ticks reported by clock(). */ #define CLOCKS_PER_SEC 128 #ifndef _CLOCK_T_DECLARED typedef __clock_t clock_t; #define _CLOCK_T_DECLARED #endif #ifndef _TIME_T_DECLARED typedef __time_t time_t; #define _TIME_T_DECLARED #endif #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif #if __POSIX_VISIBLE >= 199309 /* * New in POSIX 1003.1b-1993. */ #ifndef _CLOCKID_T_DECLARED typedef __clockid_t clockid_t; #define _CLOCKID_T_DECLARED #endif #ifndef _TIMER_T_DECLARED typedef __timer_t timer_t; #define _TIMER_T_DECLARED #endif #include #endif /* __POSIX_VISIBLE >= 199309 */ #if __POSIX_VISIBLE >= 200112 #ifndef _PID_T_DECLARED typedef __pid_t pid_t; #define _PID_T_DECLARED #endif #endif /* These macros are also in sys/time.h. */ #if !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 #define CLOCK_REALTIME 0 #ifdef __BSD_VISIBLE #define CLOCK_VIRTUAL 1 #define CLOCK_PROF 2 #endif #define CLOCK_MONOTONIC 4 #define CLOCK_UPTIME 5 /* FreeBSD-specific. */ #define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */ #define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */ #define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */ #define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */ #define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */ #define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */ #define CLOCK_SECOND 13 /* FreeBSD-specific. */ #define CLOCK_THREAD_CPUTIME_ID 14 #define CLOCK_PROCESS_CPUTIME_ID 15 #endif /* !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 */ #if !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112 #if __BSD_VISIBLE #define TIMER_RELTIME 0x0 /* relative timer */ #endif #define TIMER_ABSTIME 0x1 /* absolute timer */ #endif /* !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112 */ struct tm { int tm_sec; /* seconds after the minute [0-60] */ int tm_min; /* minutes after the hour [0-59] */ int tm_hour; /* hours since midnight [0-23] */ int tm_mday; /* day of the month [1-31] */ int tm_mon; /* months since January [0-11] */ int tm_year; /* years since 1900 */ int tm_wday; /* days since Sunday [0-6] */ int tm_yday; /* days since January 1 [0-365] */ int tm_isdst; /* Daylight Savings Time flag */ long tm_gmtoff; /* offset from UTC in seconds */ char *tm_zone; /* timezone abbreviation */ }; #if __POSIX_VISIBLE extern char *tzname[]; #endif __BEGIN_DECLS char *asctime(const struct tm *); clock_t clock(void); char *ctime(const time_t *); double difftime(time_t, time_t); /* XXX missing: getdate() */ struct tm *gmtime(const time_t *); struct tm *localtime(const time_t *); time_t mktime(struct tm *); size_t strftime(char * __restrict, size_t, const char * __restrict, const struct tm * __restrict); time_t time(time_t *); #if __POSIX_VISIBLE >= 200112 struct sigevent; int timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict); int timer_delete(timer_t); int timer_gettime(timer_t, struct itimerspec *); int timer_getoverrun(timer_t); int timer_settime(timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict); #endif #if __POSIX_VISIBLE void tzset(void); #endif #if __POSIX_VISIBLE >= 199309 int clock_getres(clockid_t, struct timespec *); int clock_gettime(clockid_t, struct timespec *); int clock_settime(clockid_t, const struct timespec *); /* XXX missing: clock_nanosleep() */ int nanosleep(const struct timespec *, struct timespec *); #endif /* __POSIX_VISIBLE >= 199309 */ #if __POSIX_VISIBLE >= 200112 int clock_getcpuclockid(pid_t, clockid_t *); #endif #if __POSIX_VISIBLE >= 199506 char *asctime_r(const struct tm *, char *); char *ctime_r(const time_t *, char *); struct tm *gmtime_r(const time_t *, struct tm *); struct tm *localtime_r(const time_t *, struct tm *); #endif #if __XSI_VISIBLE char *strptime(const char * __restrict, const char * __restrict, struct tm * __restrict); #endif #if __BSD_VISIBLE char *timezone(int, int); /* XXX XSI conflict */ void tzsetwall(void); time_t timelocal(struct tm * const); time_t timegm(struct tm * const); +int timer_oshandle_np(timer_t timerid); #endif /* __BSD_VISIBLE */ #if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_) #include #endif __END_DECLS #endif /* !_TIME_H_ */ Index: stable/11/lib/librt/Symbol.map =================================================================== --- stable/11/lib/librt/Symbol.map (revision 306904) +++ stable/11/lib/librt/Symbol.map (revision 306905) @@ -1,69 +1,74 @@ /* * $FreeBSD$ */ FBSD_1.0 { aio_read; aio_write; aio_return; aio_waitcomplete; aio_fsync; mq_open; mq_close; mq_notify; mq_getattr; mq_setattr; mq_timedreceive; mq_timedsend; mq_unlink; mq_send; mq_receive; timer_create; timer_delete; timer_gettime; timer_settime; timer_getoverrun; }; +FBSD_1.5 { + mq_getfd_np; + timer_oshandle_np; +}; + FBSDprivate_1.0 { _aio_read; _aio_write; _aio_return; _aio_waitcomplete; _aio_fsync; __aio_read; __aio_write; __aio_return; __aio_waitcomplete; __aio_fsync; _mq_open; _mq_close; _mq_notify; _mq_getattr; _mq_setattr; _mq_timedreceive; _mq_timedsend; _mq_unlink; _mq_send; _mq_receive; __mq_open; __mq_close; __mq_notify; __mq_getattr; __mq_setattr; __mq_timedreceive; __mq_timedsend; __mq_unlink; __mq_send; __mq_receive; _timer_create; _timer_delete; _timer_gettime; _timer_settime; _timer_getoverrun; __timer_create; __timer_delete; __timer_gettime; __timer_settime; __timer_getoverrun; }; Index: stable/11/lib/librt/mq.c =================================================================== --- stable/11/lib/librt/mq.c (revision 306904) +++ stable/11/lib/librt/mq.c (revision 306905) @@ -1,280 +1,281 @@ /*- * Copyright (c) 2006 David Xu * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include "namespace.h" #include #include #include #include #include #include "sigev_thread.h" #include "un-namespace.h" #include "libc_private.h" extern int __sys_kmq_notify(int, const struct sigevent *); extern int __sys_kmq_open(const char *, int, mode_t, const struct mq_attr *); extern int __sys_kmq_setattr(int, const struct mq_attr *__restrict, struct mq_attr *__restrict); extern ssize_t __sys_kmq_timedreceive(int, char *__restrict, size_t, unsigned *__restrict, const struct timespec *__restrict); extern int __sys_kmq_timedsend(int, const char *, size_t, unsigned, const struct timespec *); extern int __sys_kmq_unlink(const char *); extern int __sys_close(int fd); struct __mq { int oshandle; struct sigev_node *node; }; __weak_reference(__mq_open, mq_open); __weak_reference(__mq_open, _mq_open); __weak_reference(__mq_close, mq_close); __weak_reference(__mq_close, _mq_close); __weak_reference(__mq_notify, mq_notify); __weak_reference(__mq_notify, _mq_notify); __weak_reference(__mq_getattr, mq_getattr); __weak_reference(__mq_getattr, _mq_getattr); __weak_reference(__mq_setattr, mq_setattr); __weak_reference(__mq_setattr, _mq_setattr); __weak_reference(__mq_timedreceive_cancel, mq_timedreceive); __weak_reference(__mq_timedreceive, _mq_timedreceive); __weak_reference(__mq_timedsend_cancel, mq_timedsend); __weak_reference(__mq_timedsend, _mq_timedsend); __weak_reference(__mq_unlink, mq_unlink); __weak_reference(__mq_unlink, _mq_unlink); __weak_reference(__mq_send_cancel, mq_send); __weak_reference(__mq_send, _mq_send); __weak_reference(__mq_receive_cancel, mq_receive); __weak_reference(__mq_receive, _mq_receive); mqd_t __mq_open(const char *name, int oflag, mode_t mode, const struct mq_attr *attr) { struct __mq *mq; int err; mq = malloc(sizeof(struct __mq)); if (mq == NULL) return (NULL); mq->oshandle = __sys_kmq_open(name, oflag, mode, attr); if (mq->oshandle != -1) { mq->node = NULL; return (mq); } err = errno; free(mq); errno = err; return ((mqd_t)-1L); } int __mq_close(mqd_t mqd) { int h; if (mqd->node != NULL) { __sigev_list_lock(); __sigev_delete_node(mqd->node); __sigev_list_unlock(); } h = mqd->oshandle; free(mqd); return (__sys_close(h)); } typedef void (*mq_func)(union sigval val); static void mq_dispatch(struct sigev_node *sn) { mq_func f = sn->sn_func; /* * Check generation before calling user function, * this should avoid expired notification. */ if (sn->sn_gen == sn->sn_info.si_value.sival_int) f(sn->sn_value); } int __mq_notify(mqd_t mqd, const struct sigevent *evp) { struct sigevent ev; struct sigev_node *sn; int ret; if (evp == NULL || evp->sigev_notify != SIGEV_THREAD) { if (mqd->node != NULL) { __sigev_list_lock(); __sigev_delete_node(mqd->node); mqd->node = NULL; __sigev_list_unlock(); } return __sys_kmq_notify(mqd->oshandle, evp); } if (__sigev_check_init()) { /* * Thread library is not enabled. */ errno = EINVAL; return (-1); } sn = __sigev_alloc(SI_MESGQ, evp, mqd->node, 1); if (sn == NULL) { errno = EAGAIN; return (-1); } sn->sn_id = mqd->oshandle; sn->sn_dispatch = mq_dispatch; __sigev_get_sigevent(sn, &ev, sn->sn_gen); __sigev_list_lock(); if (mqd->node != NULL) __sigev_delete_node(mqd->node); mqd->node = sn; __sigev_register(sn); ret = __sys_kmq_notify(mqd->oshandle, &ev); __sigev_list_unlock(); return (ret); } int __mq_getattr(mqd_t mqd, struct mq_attr *attr) { return __sys_kmq_setattr(mqd->oshandle, NULL, attr); } int __mq_setattr(mqd_t mqd, const struct mq_attr *newattr, struct mq_attr *oldattr) { return __sys_kmq_setattr(mqd->oshandle, newattr, oldattr); } ssize_t __mq_timedreceive(mqd_t mqd, char *buf, size_t len, unsigned *prio, const struct timespec *timeout) { return __sys_kmq_timedreceive(mqd->oshandle, buf, len, prio, timeout); } ssize_t __mq_timedreceive_cancel(mqd_t mqd, char *buf, size_t len, unsigned *prio, const struct timespec *timeout) { int ret; _pthread_cancel_enter(1); ret = __sys_kmq_timedreceive(mqd->oshandle, buf, len, prio, timeout); _pthread_cancel_leave(ret == -1); return (ret); } ssize_t __mq_receive(mqd_t mqd, char *buf, size_t len, unsigned *prio) { return __sys_kmq_timedreceive(mqd->oshandle, buf, len, prio, NULL); } ssize_t __mq_receive_cancel(mqd_t mqd, char *buf, size_t len, unsigned *prio) { int ret; _pthread_cancel_enter(1); ret = __sys_kmq_timedreceive(mqd->oshandle, buf, len, prio, NULL); _pthread_cancel_leave(ret == -1); return (ret); } ssize_t __mq_timedsend(mqd_t mqd, char *buf, size_t len, unsigned prio, const struct timespec *timeout) { return __sys_kmq_timedsend(mqd->oshandle, buf, len, prio, timeout); } ssize_t __mq_timedsend_cancel(mqd_t mqd, char *buf, size_t len, unsigned prio, const struct timespec *timeout) { int ret; _pthread_cancel_enter(1); ret = __sys_kmq_timedsend(mqd->oshandle, buf, len, prio, timeout); _pthread_cancel_leave(ret == -1); return (ret); } ssize_t __mq_send(mqd_t mqd, char *buf, size_t len, unsigned prio) { return __sys_kmq_timedsend(mqd->oshandle, buf, len, prio, NULL); } ssize_t __mq_send_cancel(mqd_t mqd, char *buf, size_t len, unsigned prio) { int ret; _pthread_cancel_enter(1); ret = __sys_kmq_timedsend(mqd->oshandle, buf, len, prio, NULL); _pthread_cancel_leave(ret == -1); return (ret); } int __mq_unlink(const char *path) { return __sys_kmq_unlink(path); } +#pragma weak mq_getfd_np int -__mq_oshandle(mqd_t mqd) +mq_getfd_np(mqd_t mqd) { return (mqd->oshandle); } Index: stable/11/lib/librt/timer.c =================================================================== --- stable/11/lib/librt/timer.c (revision 306904) +++ stable/11/lib/librt/timer.c (revision 306905) @@ -1,183 +1,184 @@ /* * Copyright (c) 2006 David Xu * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice unmodified, this list of conditions, and the following * disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD$ * */ #include #include #include #include "namespace.h" #include #include #include #include #include #include "sigev_thread.h" #include "un-namespace.h" extern int __sys_ktimer_create(clockid_t, struct sigevent *__restrict, int *__restrict); extern int __sys_ktimer_delete(int); extern int __sys_ktimer_gettime(int, struct itimerspec *); extern int __sys_ktimer_getoverrun(int); extern int __sys_ktimer_settime(int, int, const struct itimerspec *__restrict, struct itimerspec *__restrict); struct __timer { int oshandle; struct sigev_node *node; }; __weak_reference(__timer_create, timer_create); __weak_reference(__timer_create, _timer_create); __weak_reference(__timer_delete, timer_delete); __weak_reference(__timer_delete, _timer_delete); __weak_reference(__timer_gettime, timer_gettime); __weak_reference(__timer_gettime, _timer_gettime); __weak_reference(__timer_settime, timer_settime); __weak_reference(__timer_settime, _timer_settime); __weak_reference(__timer_getoverrun, timer_getoverrun); __weak_reference(__timer_getoverrun, _timer_getoverrun); typedef void (*timer_func)(union sigval val, int overrun); static void timer_dispatch(struct sigev_node *sn) { timer_func f = sn->sn_func; /* I want to avoid expired notification. */ if (sn->sn_info.si_value.sival_int == sn->sn_gen) f(sn->sn_value, sn->sn_info.si_overrun); } int __timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid) { struct __timer *timer; struct sigevent ev; struct sigev_node *sn; int ret, err; timer = malloc(sizeof(struct __timer)); if (timer == NULL) return (-1); if (evp == NULL || evp->sigev_notify != SIGEV_THREAD) { ret = __sys_ktimer_create(clockid, evp, &timer->oshandle); if (ret == -1) { err = errno; free(timer); errno = err; return (ret); } timer->node = NULL; *timerid = timer; return (0); } if (__sigev_check_init()) { free(timer); errno = EINVAL; return (-1); } sn = __sigev_alloc(SI_TIMER, evp, NULL, 0); if (sn == NULL) { free(timer); errno = EAGAIN; return (-1); } __sigev_get_sigevent(sn, &ev, sn->sn_gen); ret = __sys_ktimer_create(clockid, &ev, &timer->oshandle); if (ret != 0) { err = errno; __sigev_free(sn); free(timer); errno = err; return (-1); } sn->sn_flags |= SNF_SYNC; sn->sn_dispatch = timer_dispatch; sn->sn_id = timer->oshandle; timer->node = sn; __sigev_list_lock(); __sigev_register(sn); __sigev_list_unlock(); *timerid = timer; return (0); } int __timer_delete(timer_t timerid) { int ret, err; if (timerid->node != NULL) { __sigev_list_lock(); __sigev_delete_node(timerid->node); __sigev_list_unlock(); } ret = __sys_ktimer_delete(timerid->oshandle); err = errno; free(timerid); errno = err; return (ret); } int __timer_gettime(timer_t timerid, struct itimerspec *value) { return __sys_ktimer_gettime(timerid->oshandle, value); } int __timer_getoverrun(timer_t timerid) { return __sys_ktimer_getoverrun(timerid->oshandle); } int __timer_settime(timer_t timerid, int flags, const struct itimerspec *__restrict value, struct itimerspec *__restrict ovalue) { return __sys_ktimer_settime(timerid->oshandle, flags, value, ovalue); } +#pragma weak timer_oshandle_np int -__timer_oshandle(timer_t timerid) +timer_oshandle_np(timer_t timerid) { return (timerid->oshandle); } Index: stable/11/tests/sys/mqueue/Makefile =================================================================== --- stable/11/tests/sys/mqueue/Makefile (revision 306904) +++ stable/11/tests/sys/mqueue/Makefile (revision 306905) @@ -1,21 +1,21 @@ # $FreeBSD$ TESTSDIR= ${TESTSBASE}/sys/mqueue ATF_TESTS_SH= mqueue_test BINDIR= ${TESTSDIR} CFLAGS+= -I${SRCTOP}/tests PROGS+= mqtest1 PROGS+= mqtest2 -#PROGS+= mqtest3 -#PROGS+= mqtest4 +PROGS+= mqtest3 +PROGS+= mqtest4 PROGS+= mqtest5 LIBADD+= rt WARNS?= 6 .include Index: stable/11/tests/sys/mqueue/mqtest3.c =================================================================== --- stable/11/tests/sys/mqueue/mqtest3.c (revision 306904) +++ stable/11/tests/sys/mqueue/mqtest3.c (revision 306905) @@ -1,116 +1,118 @@ /* $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include "freebsd_test_suite/macros.h" #define MQNAME "/mytstqueue3" #define LOOPS 1000 #define PRIO 10 static void sighandler(int sig __unused) { write(1, "timeout\n", 8); _exit(1); } int main(void) { fd_set set; struct mq_attr attr; int status; mqd_t mq; pid_t pid; PLAIN_REQUIRE_KERNEL_MODULE("mqueuefs", 0); mq_unlink(MQNAME); attr.mq_maxmsg = 5; attr.mq_msgsize = 128; mq = mq_open(MQNAME, O_CREAT | O_RDWR | O_EXCL, 0666, &attr); if (mq == (mqd_t)-1) err(1, "mq_open()"); status = mq_getattr(mq, &attr); if (status) err(1, "mq_getattr()"); pid = fork(); if (pid == 0) { /* child */ char *buf; int j, i; unsigned int prio; mq_close(mq); signal(SIGALRM, sighandler); mq = mq_open(MQNAME, O_RDWR); if (mq == (mqd_t)-1) err(1, "child process: mq_open"); buf = malloc(attr.mq_msgsize); for (j = 0; j < LOOPS; ++j) { FD_ZERO(&set); - FD_SET(__mq_oshandle(mq), &set); + FD_SET(mq_getfd_np(mq), &set); alarm(3); - status = select(__mq_oshandle(mq)+1, &set, NULL, NULL, NULL); + status = select(mq_getfd_np(mq) + 1, &set, NULL, + NULL, NULL); if (status != 1) err(1, "child process: select()"); status = mq_receive(mq, buf, attr.mq_msgsize, &prio); if (status == -1) err(2, "child process: mq_receive"); for (i = 0; i < attr.mq_msgsize; ++i) if (buf[i] != i) err(3, "message data corrupted"); if (prio != PRIO) err(4, "priority is incorrect: %d", prio); } alarm(0); free(buf); mq_close(mq); return (0); } else if (pid == -1) { err(1, "fork()"); } else { char *buf; int i, j; signal(SIGALRM, sighandler); buf = malloc(attr.mq_msgsize); for (j = 0; j < LOOPS; ++j) { for (i = 0; i < attr.mq_msgsize; ++i) { buf[i] = i; } alarm(3); FD_ZERO(&set); - FD_SET(__mq_oshandle(mq), &set); - status = select(__mq_oshandle(mq)+1, NULL, &set, NULL, NULL); + FD_SET(mq_getfd_np(mq), &set); + status = select(mq_getfd_np(mq) + 1, NULL, &set, + NULL, NULL); if (status != 1) err(1, "select()"); status = mq_send(mq, buf, attr.mq_msgsize, PRIO); if (status) { kill(pid, SIGKILL); err(2, "mq_send()"); } } alarm(3); wait(&status); alarm(0); } status = mq_close(mq); if (status) err(1, "mq_close"); mq_unlink(MQNAME); return (0); } Index: stable/11/tests/sys/mqueue/mqtest4.c =================================================================== --- stable/11/tests/sys/mqueue/mqtest4.c (revision 306904) +++ stable/11/tests/sys/mqueue/mqtest4.c (revision 306905) @@ -1,120 +1,120 @@ /* $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include "freebsd_test_suite/macros.h" #define MQNAME "/mytstqueue4" #define LOOPS 1000 #define PRIO 10 static void sighandler(int sig __unused) { write(1, "timeout\n", 8); _exit(1); } int main(void) { struct kevent kev; struct mq_attr attr; mqd_t mq; int kq, status; pid_t pid; PLAIN_REQUIRE_KERNEL_MODULE("mqueuefs", 0); mq_unlink(MQNAME); attr.mq_maxmsg = 5; attr.mq_msgsize = 128; mq = mq_open(MQNAME, O_CREAT | O_RDWR | O_EXCL, 0666, &attr); if (mq == (mqd_t) -1) err(1, "mq_open()"); status = mq_getattr(mq, &attr); if (status) err(1, "mq_getattr()"); pid = fork(); if (pid == 0) { /* child */ char *buf; int j, i; unsigned int prio; mq_close(mq); kq = kqueue(); mq = mq_open(MQNAME, O_RDWR); if (mq == (mqd_t)-1) err(1, "child: mq_open"); - EV_SET(&kev, __mq_oshandle(mq), EVFILT_READ, EV_ADD, 0, 0, 0); + EV_SET(&kev, mq_getfd_np(mq), EVFILT_READ, EV_ADD, 0, 0, 0); status = kevent(kq, &kev, 1, NULL, 0, NULL); if (status == -1) err(1, "child: kevent"); buf = malloc(attr.mq_msgsize); for (j = 0; j < LOOPS; ++j) { alarm(3); status = kevent(kq, NULL, 0, &kev, 1, NULL); if (status != 1) err(1, "child: kevent 2"); status = mq_receive(mq, buf, attr.mq_msgsize, &prio); if (status == -1) err(2, "child: mq_receive"); for (i = 0; i < attr.mq_msgsize; ++i) if (buf[i] != i) err(3, "child: message data corrupted"); if (prio != PRIO) err(4, "child: priority is incorrect: %d", prio); } alarm(0); free(buf); mq_close(mq); return (0); } else if (pid == -1) { err(1, "fork()"); } else { char *buf; int i, j; signal(SIGALRM, sighandler); kq = kqueue(); - EV_SET(&kev, __mq_oshandle(mq), EVFILT_WRITE, EV_ADD, 0, 0, 0); + EV_SET(&kev, mq_getfd_np(mq), EVFILT_WRITE, EV_ADD, 0, 0, 0); status = kevent(kq, &kev, 1, NULL, 0, NULL); if (status == -1) err(1, "kevent"); buf = malloc(attr.mq_msgsize); for (j = 0; j < LOOPS; ++j) { for (i = 0; i < attr.mq_msgsize; ++i) { buf[i] = i; } alarm(3); status = kevent(kq, NULL, 0, &kev, 1, NULL); if (status != 1) err(1, "child: kevent 2"); status = mq_send(mq, buf, attr.mq_msgsize, PRIO); if (status) { err(2, "mq_send()"); } } free(buf); alarm(3); wait(&status); alarm(0); } status = mq_close(mq); if (status) err(1, "mq_close"); mq_unlink(MQNAME); return (0); } Index: stable/11 =================================================================== --- stable/11 (revision 306904) +++ stable/11 (revision 306905) Property changes on: stable/11 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r306588