diff options
Diffstat (limited to 'rt')
80 files changed, 0 insertions, 9027 deletions
diff --git a/rt/Depend b/rt/Depend deleted file mode 100644 index 6c1aa44e6e..0000000000 --- a/rt/Depend +++ /dev/null @@ -1 +0,0 @@ -nptl diff --git a/rt/Makefile b/rt/Makefile deleted file mode 100644 index 9740dc2ad8..0000000000 --- a/rt/Makefile +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright (C) 1997-2017 Free Software Foundation, Inc. -# This file is part of the GNU C Library. - -# The GNU C Library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. - -# The GNU C Library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. - -# You should have received a copy of the GNU Lesser General Public -# License along with the GNU C Library; if not, see -# <http://www.gnu.org/licenses/>. - -# -# Sub-makefile for real-time portion of the library. -# -subdir := rt - -include ../Makeconfig - -headers := aio.h mqueue.h bits/mqueue.h bits/mqueue2.h - -aio-routines := aio_cancel aio_error aio_fsync aio_misc aio_read \ - aio_read64 aio_return aio_suspend aio_write \ - aio_write64 lio_listio lio_listio64 aio_sigqueue \ - aio_notify -clock-routines := get_clockfreq clock_getcpuclockid \ - clock_getres clock_gettime clock_settime \ - clock_nanosleep -timer-routines := timer_create timer_delete timer_getoverr \ - timer_gettime timer_settime -shm-routines := shm_open shm_unlink -mq-routines := mq_open mq_close mq_unlink mq_getattr mq_setattr \ - mq_notify mq_send mq_receive mq_timedsend \ - mq_timedreceive - -routines = $(clock-routines) - -librt-routines = $(aio-routines) \ - $(timer-routines) \ - $(shm-routines) $(mq-routines) \ - clock-compat - -tests := tst-shm tst-clock tst-clock_nanosleep tst-timer tst-timer2 \ - tst-aio tst-aio64 tst-aio2 tst-aio3 tst-aio4 tst-aio5 tst-aio6 \ - tst-aio7 tst-aio8 tst-aio9 tst-aio10 \ - tst-mqueue1 tst-mqueue2 tst-mqueue3 tst-mqueue4 \ - tst-mqueue5 tst-mqueue6 tst-mqueue7 tst-mqueue8 tst-mqueue9 \ - tst-timer3 tst-timer4 tst-timer5 \ - tst-cpuclock1 tst-cpuclock2 \ - tst-cputimer1 tst-cputimer2 tst-cputimer3 \ - tst-clock2 tst-shm-cancel - -extra-libs := librt -extra-libs-others := $(extra-libs) - -include ../Rules - -CFLAGS-aio_suspend.c = -fexceptions -CFLAGS-mq_timedreceive.c = -fexceptions -fasynchronous-unwind-tables -CFLAGS-mq_timedsend.c = -fexceptions -fasynchronous-unwind-tables -CFLAGS-clock_nanosleep.c = -fexceptions -fasynchronous-unwind-tables -CFLAGS-librt-cancellation.c = -fasynchronous-unwind-tables - -LDFLAGS-rt.so = -Wl,--enable-new-dtags,-z,nodelete - -$(objpfx)librt.so: $(shared-thread-library) - -ifeq (yes,$(build-shared)) -$(addprefix $(objpfx),$(tests)): $(objpfx)librt.so $(shared-thread-library) -else -$(addprefix $(objpfx),$(tests)): $(objpfx)librt.a $(static-thread-library) -endif - -tst-mqueue7-ARGS = -- $(host-test-program-cmd) diff --git a/rt/Versions b/rt/Versions deleted file mode 100644 index 91e3fd2a20..0000000000 --- a/rt/Versions +++ /dev/null @@ -1,40 +0,0 @@ -libc { - GLIBC_2.17 { - # c* - clock_getres; clock_gettime; clock_settime; clock_getcpuclockid; - clock_nanosleep; - } - GLIBC_PRIVATE { - __clock_getres; __clock_gettime; __clock_settime; __clock_getcpuclockid; - __clock_nanosleep; - } -} - -librt { - GLIBC_2.1 { - # AIO functions. - aio_cancel; aio_cancel64; aio_error; aio_error64; aio_fsync; aio_fsync64; - aio_init; aio_read; aio_read64; aio_return; aio_return64; aio_suspend; - aio_suspend64; aio_write; aio_write64; lio_listio; lio_listio64; - } - GLIBC_2.2 { - # These have moved to libc and are still here only for compatibility. - clock_getres; clock_gettime; clock_settime; clock_getcpuclockid; - clock_nanosleep; - - # s* - shm_open; shm_unlink; - - # t* - timer_create; timer_delete; timer_getoverrun; timer_gettime; - timer_settime; - } - GLIBC_2.3.4 { - # m* - mq_open; mq_close; mq_unlink; mq_getattr; mq_setattr; - mq_notify; mq_send; mq_receive; mq_timedsend; mq_timedreceive; - } - GLIBC_2.7 { - __mq_open_2; - } -} diff --git a/rt/aio.h b/rt/aio.h deleted file mode 100644 index d72ad5d97d..0000000000 --- a/rt/aio.h +++ /dev/null @@ -1,245 +0,0 @@ -/* Copyright (C) 1996-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -/* - * ISO/IEC 9945-1:1996 6.7: Asynchronous Input and Output - */ - -#ifndef _AIO_H -#define _AIO_H 1 - -#include <features.h> -#include <sys/types.h> -#include <bits/types/sigevent_t.h> -#include <bits/sigevent-consts.h> -#include <bits/types/struct_timespec.h> - -__BEGIN_DECLS - -/* Asynchronous I/O control block. */ -struct aiocb -{ - int aio_fildes; /* File desriptor. */ - int aio_lio_opcode; /* Operation to be performed. */ - int aio_reqprio; /* Request priority offset. */ - volatile void *aio_buf; /* Location of buffer. */ - size_t aio_nbytes; /* Length of transfer. */ - struct sigevent aio_sigevent; /* Signal number and value. */ - - /* Internal members. */ - struct aiocb *__next_prio; - int __abs_prio; - int __policy; - int __error_code; - __ssize_t __return_value; - -#ifndef __USE_FILE_OFFSET64 - __off_t aio_offset; /* File offset. */ - char __pad[sizeof (__off64_t) - sizeof (__off_t)]; -#else - __off64_t aio_offset; /* File offset. */ -#endif - char __glibc_reserved[32]; -}; - -/* The same for the 64bit offsets. Please note that the members aio_fildes - to __return_value have to be the same in aiocb and aiocb64. */ -#ifdef __USE_LARGEFILE64 -struct aiocb64 -{ - int aio_fildes; /* File desriptor. */ - int aio_lio_opcode; /* Operation to be performed. */ - int aio_reqprio; /* Request priority offset. */ - volatile void *aio_buf; /* Location of buffer. */ - size_t aio_nbytes; /* Length of transfer. */ - struct sigevent aio_sigevent; /* Signal number and value. */ - - /* Internal members. */ - struct aiocb *__next_prio; - int __abs_prio; - int __policy; - int __error_code; - __ssize_t __return_value; - - __off64_t aio_offset; /* File offset. */ - char __glibc_reserved[32]; -}; -#endif - - -#ifdef __USE_GNU -/* To customize the implementation one can use the following struct. - This implementation follows the one in Irix. */ -struct aioinit - { - int aio_threads; /* Maximal number of threads. */ - int aio_num; /* Number of expected simultanious requests. */ - int aio_locks; /* Not used. */ - int aio_usedba; /* Not used. */ - int aio_debug; /* Not used. */ - int aio_numusers; /* Not used. */ - int aio_idle_time; /* Number of seconds before idle thread - terminates. */ - int aio_reserved; - }; -#endif - - -/* Return values of cancelation function. */ -enum -{ - AIO_CANCELED, -#define AIO_CANCELED AIO_CANCELED - AIO_NOTCANCELED, -#define AIO_NOTCANCELED AIO_NOTCANCELED - AIO_ALLDONE -#define AIO_ALLDONE AIO_ALLDONE -}; - - -/* Operation codes for `aio_lio_opcode'. */ -enum -{ - LIO_READ, -#define LIO_READ LIO_READ - LIO_WRITE, -#define LIO_WRITE LIO_WRITE - LIO_NOP -#define LIO_NOP LIO_NOP -}; - - -/* Synchronization options for `lio_listio' function. */ -enum -{ - LIO_WAIT, -#define LIO_WAIT LIO_WAIT - LIO_NOWAIT -#define LIO_NOWAIT LIO_NOWAIT -}; - - -/* Allow user to specify optimization. */ -#ifdef __USE_GNU -extern void aio_init (const struct aioinit *__init) __THROW __nonnull ((1)); -#endif - - -#ifndef __USE_FILE_OFFSET64 -/* Enqueue read request for given number of bytes and the given priority. */ -extern int aio_read (struct aiocb *__aiocbp) __THROW __nonnull ((1)); -/* Enqueue write request for given number of bytes and the given priority. */ -extern int aio_write (struct aiocb *__aiocbp) __THROW __nonnull ((1)); - -/* Initiate list of I/O requests. */ -extern int lio_listio (int __mode, - struct aiocb *const __list[__restrict_arr], - int __nent, struct sigevent *__restrict __sig) - __THROW __nonnull ((2)); - -/* Retrieve error status associated with AIOCBP. */ -extern int aio_error (const struct aiocb *__aiocbp) __THROW __nonnull ((1)); -/* Return status associated with AIOCBP. */ -extern __ssize_t aio_return (struct aiocb *__aiocbp) __THROW __nonnull ((1)); - -/* Try to cancel asynchronous I/O requests outstanding against file - descriptor FILDES. */ -extern int aio_cancel (int __fildes, struct aiocb *__aiocbp) __THROW; - -/* Suspend calling thread until at least one of the asynchronous I/O - operations referenced by LIST has completed. - - This function is a cancellation point and therefore not marked with - __THROW. */ -extern int aio_suspend (const struct aiocb *const __list[], int __nent, - const struct timespec *__restrict __timeout) - __nonnull ((1)); - -/* Force all operations associated with file desriptor described by - `aio_fildes' member of AIOCBP. */ -extern int aio_fsync (int __operation, struct aiocb *__aiocbp) - __THROW __nonnull ((2)); -#else -# ifdef __REDIRECT_NTH -extern int __REDIRECT_NTH (aio_read, (struct aiocb *__aiocbp), aio_read64) - __nonnull ((1)); -extern int __REDIRECT_NTH (aio_write, (struct aiocb *__aiocbp), aio_write64) - __nonnull ((1)); - -extern int __REDIRECT_NTH (lio_listio, - (int __mode, - struct aiocb *const __list[__restrict_arr], - int __nent, struct sigevent *__restrict __sig), - lio_listio64) __nonnull ((2)); - -extern int __REDIRECT_NTH (aio_error, (const struct aiocb *__aiocbp), - aio_error64) __nonnull ((1)); -extern __ssize_t __REDIRECT_NTH (aio_return, (struct aiocb *__aiocbp), - aio_return64) __nonnull ((1)); - -extern int __REDIRECT_NTH (aio_cancel, - (int __fildes, struct aiocb *__aiocbp), - aio_cancel64); - -extern int __REDIRECT_NTH (aio_suspend, - (const struct aiocb *const __list[], int __nent, - const struct timespec *__restrict __timeout), - aio_suspend64) __nonnull ((1)); - -extern int __REDIRECT_NTH (aio_fsync, - (int __operation, struct aiocb *__aiocbp), - aio_fsync64) __nonnull ((2)); - -# else -# define aio_read aio_read64 -# define aio_write aio_write64 -# define lio_listio lio_listio64 -# define aio_error aio_error64 -# define aio_return aio_return64 -# define aio_cancel aio_cancel64 -# define aio_suspend aio_suspend64 -# define aio_fsync aio_fsync64 -# endif -#endif - -#ifdef __USE_LARGEFILE64 -extern int aio_read64 (struct aiocb64 *__aiocbp) __THROW __nonnull ((1)); -extern int aio_write64 (struct aiocb64 *__aiocbp) __THROW __nonnull ((1)); - -extern int lio_listio64 (int __mode, - struct aiocb64 *const __list[__restrict_arr], - int __nent, struct sigevent *__restrict __sig) - __THROW __nonnull ((2)); - -extern int aio_error64 (const struct aiocb64 *__aiocbp) - __THROW __nonnull ((1)); -extern __ssize_t aio_return64 (struct aiocb64 *__aiocbp) - __THROW __nonnull ((1)); - -extern int aio_cancel64 (int __fildes, struct aiocb64 *__aiocbp) __THROW; - -extern int aio_suspend64 (const struct aiocb64 *const __list[], int __nent, - const struct timespec *__restrict __timeout) - __THROW __nonnull ((1)); - -extern int aio_fsync64 (int __operation, struct aiocb64 *__aiocbp) - __THROW __nonnull ((2)); -#endif - -__END_DECLS - -#endif /* aio.h */ diff --git a/rt/aio_cancel.c b/rt/aio_cancel.c deleted file mode 100644 index c50883e6df..0000000000 --- a/rt/aio_cancel.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Cancel requests associated with given file descriptor. Stub version. - Copyright (C) 2001-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - - -/* We use an UGLY hack to prevent gcc from finding us cheating. The - implementation of aio_cancel and aio_cancel64 are identical and so - we want to avoid code duplication by using aliases. But gcc sees - the different parameter lists and prints a warning. We define here - a function so that aio_cancel64 has no prototype. */ -#define aio_cancel64 XXX -#include <aio.h> -/* And undo the hack. */ -#undef aio_cancel64 - -#include <errno.h> - -int -aio_cancel (int fildes, struct aiocb *aiocbp) -{ - __set_errno (ENOSYS); - return -1; -} - -weak_alias (aio_cancel, aio_cancel64) - -stub_warning (aio_cancel) -stub_warning (aio_cancel64) diff --git a/rt/aio_error.c b/rt/aio_error.c deleted file mode 100644 index 3e29cfcc8c..0000000000 --- a/rt/aio_error.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Return error status of asynchronous I/O request. - Copyright (C) 1997-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - - -/* We use an UGLY hack to prevent gcc from finding us cheating. The - implementation of aio_error and aio_error64 are identical and so - we want to avoid code duplication by using aliases. But gcc sees - the different parameter lists and prints a warning. We define here - a function so that aio_error64 has no prototype. */ -#define aio_error64 XXX -#include <aio.h> -/* And undo the hack. */ -#undef aio_error64 - - -int -aio_error (const struct aiocb *aiocbp) -{ - return aiocbp->__error_code; -} - -weak_alias (aio_error, aio_error64) diff --git a/rt/aio_fsync.c b/rt/aio_fsync.c deleted file mode 100644 index 2eb97ea5e0..0000000000 --- a/rt/aio_fsync.c +++ /dev/null @@ -1,49 +0,0 @@ -/* Synchronize I/O in given file descriptor. Stub version. - Copyright (C) 2001-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - - -/* We use an UGLY hack to prevent gcc from finding us cheating. The - implementation of aio_fsync and aio_fsync64 are identical and so - we want to avoid code duplication by using aliases. But gcc sees - the different parameter lists and prints a warning. We define here - a function so that aio_fsync64 has no prototype. */ -#define aio_fsync64 XXX -#include <aio.h> -/* And undo the hack. */ -#undef aio_fsync64 - -#include <errno.h> -#include <fcntl.h> - -int -aio_fsync (int op, struct aiocb *aiocbp) -{ - if (op != O_SYNC && op != O_DSYNC) - { - __set_errno (EINVAL); - return -1; - } - - __set_errno (ENOSYS); - return -1; -} - -weak_alias (aio_fsync, aio_fsync64) - -stub_warning (aio_fsync) -stub_warning (aio_fsync64) diff --git a/rt/aio_misc.c b/rt/aio_misc.c deleted file mode 100644 index f94b7a9d23..0000000000 --- a/rt/aio_misc.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Handle general operations. Stub version. - Copyright (C) 2001-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <aio.h> -#include <aio_misc.h> - -/* This file is for internal code needed by the aio_* implementation. */ - -void -__aio_init (const struct aioinit *init) -{ -} -weak_alias (__aio_init, aio_init) diff --git a/rt/aio_notify.c b/rt/aio_notify.c deleted file mode 100644 index 52256a6377..0000000000 --- a/rt/aio_notify.c +++ /dev/null @@ -1,23 +0,0 @@ -/* Notify initiator of AIO request. Stub version. - Copyright (C) 2001-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <aio.h> -#include <aio_misc.h> - -/* This file contains only internal functions used by - the particular aio_* implementation code. */ diff --git a/rt/aio_read.c b/rt/aio_read.c deleted file mode 100644 index a1300d1eca..0000000000 --- a/rt/aio_read.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Asynchronous read. Stub version. - Copyright (C) 2001-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <aio.h> -#include <errno.h> - -#ifdef BE_AIO64 -#define aiocb aiocb64 -#define aio_read aio_read64 -#endif - -int -aio_read (struct aiocb *aiocbp) -{ - __set_errno (ENOSYS); - return -1; -} - -stub_warning (aio_read) diff --git a/rt/aio_read64.c b/rt/aio_read64.c deleted file mode 100644 index e9994aefcb..0000000000 --- a/rt/aio_read64.c +++ /dev/null @@ -1,2 +0,0 @@ -#define BE_AIO64 -#include <aio_read.c> diff --git a/rt/aio_return.c b/rt/aio_return.c deleted file mode 100644 index c322f25edd..0000000000 --- a/rt/aio_return.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Return exit value of asynchronous I/O request. - Copyright (C) 1997-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - - -/* We use an UGLY hack to prevent gcc from finding us cheating. The - implementation of aio_return and aio_return64 are identical and so - we want to avoid code duplication by using aliases. But gcc sees - the different parameter lists and prints a warning. We define here - a function so that aio_return64 has no prototype. */ -#define aio_return64 XXX -#include <aio.h> -/* And undo the hack. */ -#undef aio_return64 - - -ssize_t -aio_return (struct aiocb *aiocbp) -{ - return aiocbp->__return_value; -} - -weak_alias (aio_return, aio_return64) diff --git a/rt/aio_sigqueue.c b/rt/aio_sigqueue.c deleted file mode 100644 index fd8a6b2387..0000000000 --- a/rt/aio_sigqueue.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 1997-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <aio.h> -#include <errno.h> -#include <signal.h> - -#include <aio_misc.h> - -int -attribute_hidden internal_function -__aio_sigqueue (int sig, const union sigval val, pid_t caller_pid) -{ - __set_errno (ENOSYS); - return -1; -} - -stub_warning (__aio_sigqueue) diff --git a/rt/aio_suspend.c b/rt/aio_suspend.c deleted file mode 100644 index 8920f9361a..0000000000 --- a/rt/aio_suspend.c +++ /dev/null @@ -1,44 +0,0 @@ -/* Suspend until termination of a requests. Stub version. - Copyright (C) 2001-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - - -/* We use an UGLY hack to prevent gcc from finding us cheating. The - implementations of aio_suspend and aio_suspend64 are identical and so - we want to avoid code duplication by using aliases. But gcc sees - the different parameter lists and prints a warning. We define here - a function so that aio_suspend64 has no prototype. */ -#define aio_suspend64 XXX -#include <aio.h> -/* And undo the hack. */ -#undef aio_suspend64 - -#include <errno.h> -#include <sys/time.h> - - -int -aio_suspend (const struct aiocb *const list[], int nent, - const struct timespec *timeout) -{ - __set_errno (ENOSYS); - return -1; -} -weak_alias (aio_suspend, aio_suspend64) - -stub_warning (aio_suspend) -stub_warning (aio_suspend64) diff --git a/rt/aio_write.c b/rt/aio_write.c deleted file mode 100644 index a5b3b829d4..0000000000 --- a/rt/aio_write.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Asynchronous write. Stub version. - Copyright (C) 2001-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <aio.h> -#include <errno.h> - -#ifdef BE_AIO64 -#define aiocb aiocb64 -#define aio_write aio_write64 -#endif - -int -aio_write (struct aiocb *aiocbp) -{ - __set_errno (ENOSYS); - return -1; -} - -stub_warning (aio_write) diff --git a/rt/aio_write64.c b/rt/aio_write64.c deleted file mode 100644 index 88d5c001ce..0000000000 --- a/rt/aio_write64.c +++ /dev/null @@ -1,2 +0,0 @@ -#define BE_AIO64 -#include <aio_write.c> diff --git a/rt/bits/mqueue2.h b/rt/bits/mqueue2.h deleted file mode 100644 index 70ac65550e..0000000000 --- a/rt/bits/mqueue2.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Checking macros for mq functions. - Copyright (C) 2007-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#ifndef _FCNTL_H -# error "Never include <bits/mqueue2.h> directly; use <mqueue.h> instead." -#endif - -/* Check that calls to mq_open with O_CREAT set have an appropriate third and fourth - parameter. */ -extern mqd_t mq_open (const char *__name, int __oflag, ...) - __THROW __nonnull ((1)); -extern mqd_t __mq_open_2 (const char *__name, int __oflag) - __THROW __nonnull ((1)); -extern mqd_t __REDIRECT_NTH (__mq_open_alias, (const char *__name, - int __oflag, ...), mq_open) - __nonnull ((1)); -__errordecl (__mq_open_wrong_number_of_args, - "mq_open can be called either with 2 or 4 arguments"); -__errordecl (__mq_open_missing_mode_and_attr, - "mq_open with O_CREAT in second argument needs 4 arguments"); - -__fortify_function mqd_t -__NTH (mq_open (const char *__name, int __oflag, ...)) -{ - if (__va_arg_pack_len () != 0 && __va_arg_pack_len () != 2) - __mq_open_wrong_number_of_args (); - - if (__builtin_constant_p (__oflag)) - { - if ((__oflag & O_CREAT) != 0 && __va_arg_pack_len () == 0) - { - __mq_open_missing_mode_and_attr (); - return __mq_open_2 (__name, __oflag); - } - return __mq_open_alias (__name, __oflag, __va_arg_pack ()); - } - - if (__va_arg_pack_len () == 0) - return __mq_open_2 (__name, __oflag); - - return __mq_open_alias (__name, __oflag, __va_arg_pack ()); -} diff --git a/rt/clock-compat.c b/rt/clock-compat.c deleted file mode 100644 index 61ebecd5d6..0000000000 --- a/rt/clock-compat.c +++ /dev/null @@ -1,61 +0,0 @@ -/* ABI compatibility redirects for clock_* symbols in librt. - Copyright (C) 2012-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <shlib-compat.h> - -/* The clock_* symbols were originally defined in librt and so - are part of its ABI. As of 2.17, they have moved to libc. - So we supply definitions for librt that just redirect to - their libc counterparts. */ - -#if SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_17) - -#include <time.h> - -#if HAVE_IFUNC -# undef INIT_ARCH -# define INIT_ARCH() -# define COMPAT_REDIRECT(name, proto, arglist) libc_ifunc (name, &__##name) -#else -# define COMPAT_REDIRECT(name, proto, arglist) \ - int \ - name proto \ - { \ - return __##name arglist; \ - } -#endif - -COMPAT_REDIRECT (clock_getres, - (clockid_t clock_id, struct timespec *res), - (clock_id, res)) -COMPAT_REDIRECT (clock_gettime, - (clockid_t clock_id, struct timespec *tp), - (clock_id, tp)) -COMPAT_REDIRECT (clock_settime, - (clockid_t clock_id, const struct timespec *tp), - (clock_id, tp)) -COMPAT_REDIRECT (clock_getcpuclockid, - (pid_t pid, clockid_t *clock_id), - (pid, clock_id)) -COMPAT_REDIRECT (clock_nanosleep, - (clockid_t clock_id, int flags, - const struct timespec *req, - struct timespec *rem), - (clock_id, flags, req, rem)) - -#endif diff --git a/rt/clock_getcpuclockid.c b/rt/clock_getcpuclockid.c deleted file mode 100644 index 37e6a328a1..0000000000 --- a/rt/clock_getcpuclockid.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Get a clockid_t for the process CPU clock of a given process. Generic. - Copyright (C) 2000-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <time.h> -#include <unistd.h> - -int -__clock_getcpuclockid (pid_t pid, clockid_t *clock_id) -{ - /* We don't allow any process ID but our own. */ - if (pid != 0 && pid != getpid ()) - return EPERM; - -#ifdef CLOCK_PROCESS_CPUTIME_ID - /* Store the number. */ - *clock_id = CLOCK_PROCESS_CPUTIME_ID; - - return 0; -#else - /* We don't have a timer for that. */ - return ENOENT; -#endif -} -weak_alias (__clock_getcpuclockid, clock_getcpuclockid) diff --git a/rt/clock_getres.c b/rt/clock_getres.c deleted file mode 100644 index e97af4d811..0000000000 --- a/rt/clock_getres.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Get the resolution of a clock. Stub version. - Copyright (C) 1999-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <time.h> - -/* Get resolution of clock. */ -int -__clock_getres (clockid_t clock_id, struct timespec *res) -{ - __set_errno (ENOSYS); - return -1; -} -weak_alias (__clock_getres, clock_getres) -stub_warning (clock_getres) diff --git a/rt/clock_gettime.c b/rt/clock_gettime.c deleted file mode 100644 index a9eafd66c0..0000000000 --- a/rt/clock_gettime.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Get the current value of a clock. Stub version. - Copyright (C) 1999-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <time.h> - -/* Get current value of CLOCK and store it in TP. */ -int -__clock_gettime (clockid_t clock_id, struct timespec *tp) -{ - __set_errno (ENOSYS); - return -1; -} -weak_alias (__clock_gettime, clock_gettime) -libc_hidden_def (__clock_gettime) -stub_warning (clock_gettime) diff --git a/rt/clock_nanosleep.c b/rt/clock_nanosleep.c deleted file mode 100644 index d3147b316b..0000000000 --- a/rt/clock_nanosleep.c +++ /dev/null @@ -1,37 +0,0 @@ -/* High-resolution sleep with the specified clock. Stub version. - Copyright (C) 2000-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <time.h> - -int -__clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req, - struct timespec *rem) -{ - if (__builtin_expect (req->tv_nsec, 0) < 0 - || __builtin_expect (req->tv_nsec, 0) >= 1000000000) - return EINVAL; - - if (flags != TIMER_ABSTIME && flags != 0) - return EINVAL; - - /* Not implemented. */ - return ENOSYS; -} -weak_alias (__clock_nanosleep, clock_nanosleep) -stub_warning (clock_nanosleep) diff --git a/rt/clock_settime.c b/rt/clock_settime.c deleted file mode 100644 index 51412f45c8..0000000000 --- a/rt/clock_settime.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Set a clock to a given value. Stub version. - Copyright (C) 1999-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <time.h> - -/* Set CLOCK to value TP. */ -int -__clock_settime (clockid_t clock_id, const struct timespec *tp) -{ - __set_errno (ENOSYS); - return -1; -} -weak_alias (__clock_settime, clock_settime) -stub_warning (clock_settime) diff --git a/rt/get_clockfreq.c b/rt/get_clockfreq.c deleted file mode 100644 index 474534940d..0000000000 --- a/rt/get_clockfreq.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Get frequency of the system processor. - Copyright (C) 2000-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <libc-internal.h> - -hp_timing_t -__get_clockfreq (void) -{ - /* There is no generic way to find this out since we have in general - no counter register either. */ - return 0; -} diff --git a/rt/lio_listio.c b/rt/lio_listio.c deleted file mode 100644 index e6a92002e8..0000000000 --- a/rt/lio_listio.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Enqueue a list of read or write requests. Stub version. - Copyright (C) 2001-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <aio.h> -#include <errno.h> - -#ifdef BE_AIO64 -#define lio_listio lio_listio64 -#define aiocb aiocb64 -#define aio_read aio_read64 -#define aio_write aio_write64 -#define aio_suspend aio_suspend64 -#endif - - -int -lio_listio (int mode, - struct aiocb *const list[], int nent, - struct sigevent *sig) -{ - __set_errno (ENOSYS); - return -1; -} - -stub_warning (lio_listio) diff --git a/rt/lio_listio64.c b/rt/lio_listio64.c deleted file mode 100644 index 35a571c685..0000000000 --- a/rt/lio_listio64.c +++ /dev/null @@ -1,2 +0,0 @@ -#define BE_AIO64 -#include <lio_listio.c> diff --git a/rt/mq_close.c b/rt/mq_close.c deleted file mode 100644 index 1bec8c5852..0000000000 --- a/rt/mq_close.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <mqueue.h> - -/* Removes the association between message queue descriptor MQDES and its - message queue. */ -int -mq_close (mqd_t mqdes) -{ - __set_errno (ENOSYS); - return -1; -} -stub_warning (mq_close) diff --git a/rt/mq_getattr.c b/rt/mq_getattr.c deleted file mode 100644 index 0a26b0ebca..0000000000 --- a/rt/mq_getattr.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <mqueue.h> - -/* Query status and attributes of message queue MQDES. */ -int -mq_getattr (mqd_t mqdes, struct mq_attr *mqstat) -{ - __set_errno (ENOSYS); - return -1; -} -stub_warning (mq_getattr) diff --git a/rt/mq_notify.c b/rt/mq_notify.c deleted file mode 100644 index a2d0ecf48d..0000000000 --- a/rt/mq_notify.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <mqueue.h> - -/* Register notification upon message arrival to an empty message queue - MQDES. */ -int -mq_notify (mqd_t mqdes, const struct sigevent *notification) -{ - __set_errno (ENOSYS); - return -1; -} -stub_warning (mq_notify) diff --git a/rt/mq_open.c b/rt/mq_open.c deleted file mode 100644 index c584375a5a..0000000000 --- a/rt/mq_open.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <mqueue.h> -#include <stdio.h> - -/* Establish connection between a process and a message queue NAME and - return message queue descriptor or (mqd_t) -1 on error. OFLAG determines - the type of access used. If O_CREAT is on OFLAG, the third argument is - taken as a `mode_t', the mode of the created message queue, and the fourth - argument is taken as `struct mq_attr *', pointer to message queue - attributes. If the fourth argument is NULL, default attributes are - used. */ -mqd_t -__mq_open (const char *name, int oflag, ...) -{ - __set_errno (ENOSYS); - return (mqd_t) -1; -} -strong_alias (__mq_open, mq_open); -stub_warning (mq_open) - -mqd_t -__mq_open_2 (const char *name, int oflag) -{ - if (oflag & O_CREAT) - __fortify_fail ("invalid mq_open call: O_CREAT without mode and attr"); - - return __mq_open (name, oflag); -} -stub_warning (__mq_open_2) diff --git a/rt/mq_receive.c b/rt/mq_receive.c deleted file mode 100644 index 8c47bcbbe3..0000000000 --- a/rt/mq_receive.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <mqueue.h> - -/* Receive the oldest from highest priority messages in message queue - MQDES. */ -ssize_t -mq_receive (mqd_t mqdes, char *msg_ptr, size_t msg_len, - unsigned int *msg_prio) -{ - __set_errno (ENOSYS); - return -1; -} -stub_warning (mq_receive) diff --git a/rt/mq_send.c b/rt/mq_send.c deleted file mode 100644 index e9ca06cfd7..0000000000 --- a/rt/mq_send.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <mqueue.h> - -/* Add message pointed by MSG_PTR to message queue MQDES. */ -int -mq_send (mqd_t mqdes, const char *msg_ptr, size_t msg_len, - unsigned int msg_prio) -{ - __set_errno (ENOSYS); - return -1; -} -stub_warning (mq_send) diff --git a/rt/mq_setattr.c b/rt/mq_setattr.c deleted file mode 100644 index 6678198139..0000000000 --- a/rt/mq_setattr.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <mqueue.h> - -/* Set attributes associated with message queue MQDES and if OMQSTAT is - not NULL also query its old attributes. */ -int -mq_setattr (mqd_t mqdes, const struct mq_attr *__restrict mqstat, - struct mq_attr *__restrict omqstat) -{ - __set_errno (ENOSYS); - return -1; -} -hidden_def (mq_setattr) -stub_warning (mq_setattr) diff --git a/rt/mq_timedreceive.c b/rt/mq_timedreceive.c deleted file mode 100644 index e6786ebc65..0000000000 --- a/rt/mq_timedreceive.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <mqueue.h> - -/* Receive the oldest from highest priority messages in message queue - MQDES, stop waiting if ABS_TIMEOUT expires. */ -ssize_t -__mq_timedreceive (mqd_t mqdes, char *__restrict msg_ptr, size_t msg_len, - unsigned int *__restrict msg_prio, - const struct timespec *__restrict abs_timeout) -{ - __set_errno (ENOSYS); - return -1; -} -hidden_def (__mq_timedreceive) -weak_alias (__mq_timedreceive, mq_timedreceive) -hidden_weak (mq_timedreceive) -stub_warning (mq_timedreceive) diff --git a/rt/mq_timedsend.c b/rt/mq_timedsend.c deleted file mode 100644 index c48c9f7b13..0000000000 --- a/rt/mq_timedsend.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <mqueue.h> - -/* Add message pointed by MSG_PTR to message queue MQDES, stop blocking - on full message queue if ABS_TIMEOUT expires. */ -int -__mq_timedsend (mqd_t mqdes, const char *msg_ptr, size_t msg_len, - unsigned int msg_prio, const struct timespec *abs_timeout) -{ - __set_errno (ENOSYS); - return -1; -} -hidden_def (__mq_timedsend) -weak_alias (__mq_timedsend, mq_timedsend) -hidden_weak (mq_timedsend) -stub_warning (mq_timedsend) diff --git a/rt/mq_unlink.c b/rt/mq_unlink.c deleted file mode 100644 index 7139f8e1be..0000000000 --- a/rt/mq_unlink.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <mqueue.h> - -/* Remove message queue named NAME. */ -int -mq_unlink (const char *name) -{ - __set_errno (ENOSYS); - return -1; -} -stub_warning (mq_unlink) diff --git a/rt/mqueue.h b/rt/mqueue.h deleted file mode 100644 index c79aa53b94..0000000000 --- a/rt/mqueue.h +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#ifndef _MQUEUE_H -#define _MQUEUE_H 1 - -#include <features.h> -#include <sys/types.h> -#include <fcntl.h> -#include <bits/types/sigevent_t.h> -#include <bits/types/struct_timespec.h> -/* Get the definition of mqd_t and struct mq_attr. */ -#include <bits/mqueue.h> - -__BEGIN_DECLS - -/* Establish connection between a process and a message queue NAME and - return message queue descriptor or (mqd_t) -1 on error. OFLAG determines - the type of access used. If O_CREAT is on OFLAG, the third argument is - taken as a `mode_t', the mode of the created message queue, and the fourth - argument is taken as `struct mq_attr *', pointer to message queue - attributes. If the fourth argument is NULL, default attributes are - used. */ -extern mqd_t mq_open (const char *__name, int __oflag, ...) - __THROW __nonnull ((1)); - -/* Removes the association between message queue descriptor MQDES and its - message queue. */ -extern int mq_close (mqd_t __mqdes) __THROW; - -/* Query status and attributes of message queue MQDES. */ -extern int mq_getattr (mqd_t __mqdes, struct mq_attr *__mqstat) - __THROW __nonnull ((2)); - -/* Set attributes associated with message queue MQDES and if OMQSTAT is - not NULL also query its old attributes. */ -extern int mq_setattr (mqd_t __mqdes, - const struct mq_attr *__restrict __mqstat, - struct mq_attr *__restrict __omqstat) - __THROW __nonnull ((2)); - -/* Remove message queue named NAME. */ -extern int mq_unlink (const char *__name) __THROW __nonnull ((1)); - -/* Register notification issued upon message arrival to an empty - message queue MQDES. */ -extern int mq_notify (mqd_t __mqdes, const struct sigevent *__notification) - __THROW; - -/* Receive the oldest from highest priority messages in message queue - MQDES. */ -extern ssize_t mq_receive (mqd_t __mqdes, char *__msg_ptr, size_t __msg_len, - unsigned int *__msg_prio) __nonnull ((2)); - -/* Add message pointed by MSG_PTR to message queue MQDES. */ -extern int mq_send (mqd_t __mqdes, const char *__msg_ptr, size_t __msg_len, - unsigned int __msg_prio) __nonnull ((2)); - -#ifdef __USE_XOPEN2K -/* Receive the oldest from highest priority messages in message queue - MQDES, stop waiting if ABS_TIMEOUT expires. */ -extern ssize_t mq_timedreceive (mqd_t __mqdes, char *__restrict __msg_ptr, - size_t __msg_len, - unsigned int *__restrict __msg_prio, - const struct timespec *__restrict __abs_timeout) - __nonnull ((2, 5)); - -/* Add message pointed by MSG_PTR to message queue MQDES, stop blocking - on full message queue if ABS_TIMEOUT expires. */ -extern int mq_timedsend (mqd_t __mqdes, const char *__msg_ptr, - size_t __msg_len, unsigned int __msg_prio, - const struct timespec *__abs_timeout) - __nonnull ((2, 5)); -#endif - -/* Define some inlines helping to catch common problems. */ -#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function \ - && defined __va_arg_pack_len -# include <bits/mqueue2.h> -#endif - -__END_DECLS - -#endif /* mqueue.h */ diff --git a/rt/shm_open.c b/rt/shm_open.c deleted file mode 100644 index 4bd1e51568..0000000000 --- a/rt/shm_open.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2000-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <sys/mman.h> - -/* Open shared memory object. */ -int -shm_open (const char *name, int oflag, mode_t mode) -{ - __set_errno (ENOSYS); - return -1; -} -stub_warning (shm_open) diff --git a/rt/shm_unlink.c b/rt/shm_unlink.c deleted file mode 100644 index 1a55867066..0000000000 --- a/rt/shm_unlink.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2000-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <sys/mman.h> - -/* Remove shared memory object. */ -int -shm_unlink (const char *name) -{ - __set_errno (ENOSYS); - return -1; -} -stub_warning (shm_unlink) diff --git a/rt/timer_create.c b/rt/timer_create.c deleted file mode 100644 index 0579154ba6..0000000000 --- a/rt/timer_create.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 1999-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <time.h> - -/* Create new per-process timer using CLOCK. */ -int -timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid) -{ - __set_errno (ENOSYS); - return -1; -} -stub_warning (timer_create) diff --git a/rt/timer_delete.c b/rt/timer_delete.c deleted file mode 100644 index b1dd1ad5c5..0000000000 --- a/rt/timer_delete.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 1999-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <time.h> - -/* Delete timer TIMERID. */ -int -timer_delete (timer_t timerid) -{ - __set_errno (ENOSYS); - return -1; -} -stub_warning (timer_delete) diff --git a/rt/timer_getoverr.c b/rt/timer_getoverr.c deleted file mode 100644 index f543202159..0000000000 --- a/rt/timer_getoverr.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 1999-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <time.h> - -/* Get expiration overrun for timer TIMERID. */ -int -timer_getoverrun (timer_t timerid) -{ - __set_errno (ENOSYS); - return -1; -} -stub_warning (timer_getoverrun) diff --git a/rt/timer_gettime.c b/rt/timer_gettime.c deleted file mode 100644 index ee8e214fe1..0000000000 --- a/rt/timer_gettime.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 1999-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <time.h> - -/* Get current value of timer TIMERID and store it in VLAUE. */ -int -timer_gettime (timer_t timerid, struct itimerspec *value) -{ - __set_errno (ENOSYS); - return -1; -} -stub_warning (timer_gettime) diff --git a/rt/timer_settime.c b/rt/timer_settime.c deleted file mode 100644 index 1e70c89bc0..0000000000 --- a/rt/timer_settime.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 1999-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <time.h> - -/* Set timer TIMERID to VALUE, returning old value in OVLAUE. */ -int -timer_settime (timer_t timerid, int flags, const struct itimerspec *value, - struct itimerspec *ovalue) -{ - __set_errno (ENOSYS); - return -1; -} -stub_warning (timer_settime) diff --git a/rt/tst-aio.c b/rt/tst-aio.c deleted file mode 100644 index 27035e19aa..0000000000 --- a/rt/tst-aio.c +++ /dev/null @@ -1,289 +0,0 @@ -/* Tests for AIO in librt. - Copyright (C) 1998-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <aio.h> -#include <errno.h> -#include <error.h> -#include <fcntl.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <sys/stat.h> - - -/* Prototype for our test function. */ -extern void do_prepare (int argc, char *argv[]); -extern int do_test (int argc, char *argv[]); - -/* We have a preparation function. */ -#define PREPARE do_prepare - -/* We might need a bit longer timeout. */ -#define TIMEOUT 20 /* sec */ - -/* This defines the `main' function and some more. */ -#include <test-skeleton.c> - - -/* These are for the temporary file we generate. */ -char *name; -int fd; - -void -do_prepare (int argc, char *argv[]) -{ - size_t name_len; - - name_len = strlen (test_dir); - name = xmalloc (name_len + sizeof ("/aioXXXXXX")); - mempcpy (mempcpy (name, test_dir, name_len), - "/aioXXXXXX", sizeof ("/aioXXXXXX")); - - /* Open our test file. */ - fd = mkstemp (name); - if (fd == -1) - error (EXIT_FAILURE, errno, "cannot open test file `%s'", name); - add_temp_file (name); -} - - -static int -test_file (const void *buf, size_t size, int fd, const char *msg) -{ - struct stat st; - char tmp[size]; - - errno = 0; - if (fstat (fd, &st) < 0) - { - error (0, errno, "%s: failed stat", msg); - return 1; - } - - if (st.st_size != (off_t) size) - { - error (0, errno, "%s: wrong size: %lu, should be %lu", - msg, (unsigned long int) st.st_size, (unsigned long int) size); - return 1; - } - - if (pread (fd, tmp, size, 0) != (ssize_t) size) - { - error (0, errno, "%s: failed pread", msg); - return 1; - } - - if (memcmp (buf, tmp, size) != 0) - { - error (0, errno, "%s: failed comparison", msg); - return 1; - } - - printf ("%s test ok\n", msg); - - return 0; -} - - -static int -do_wait (struct aiocb **cbp, size_t nent, int allowed_err) -{ - int go_on; - size_t cnt; - int result = 0; - - do - { - aio_suspend ((const struct aiocb *const *) cbp, nent, NULL); - go_on = 0; - for (cnt = 0; cnt < nent; ++cnt) - if (cbp[cnt] != NULL) - { - if (aio_error (cbp[cnt]) == EINPROGRESS) - go_on = 1; - else - { - if (aio_return (cbp[cnt]) == -1 - && (allowed_err == 0 - || aio_error (cbp[cnt]) != allowed_err)) - { - error (0, aio_error (cbp[cnt]), "Operation failed\n"); - result = 1; - } - cbp[cnt] = NULL; - } - } - } - while (go_on); - - return result; -} - - -int -do_test (int argc, char *argv[]) -{ - struct aiocb cbs[10]; - struct aiocb cbs_fsync; - struct aiocb *cbp[10]; - struct aiocb *cbp_fsync[1]; - char buf[1000]; - size_t cnt; - int result = 0; - - /* Preparation. */ - for (cnt = 0; cnt < 10; ++cnt) - { - cbs[cnt].aio_fildes = fd; - cbs[cnt].aio_reqprio = 0; - cbs[cnt].aio_buf = memset (&buf[cnt * 100], '0' + cnt, 100); - cbs[cnt].aio_nbytes = 100; - cbs[cnt].aio_offset = cnt * 100; - cbs[cnt].aio_sigevent.sigev_notify = SIGEV_NONE; - - cbp[cnt] = &cbs[cnt]; - } - - /* First a simple test. */ - for (cnt = 10; cnt > 0; ) - if (aio_write (cbp[--cnt]) < 0 && errno == ENOSYS) - { - error (0, 0, "no aio support in this configuration"); - return 0; - } - /* Wait 'til the results are there. */ - result |= do_wait (cbp, 10, 0); - /* Test this. */ - result |= test_file (buf, sizeof (buf), fd, "aio_write"); - - /* Read now as we've written it. */ - memset (buf, '\0', sizeof (buf)); - /* Issue the commands. */ - for (cnt = 10; cnt > 0; ) - { - --cnt; - cbp[cnt] = &cbs[cnt]; - aio_read (cbp[cnt]); - } - /* Wait 'til the results are there. */ - result |= do_wait (cbp, 10, 0); - /* Test this. */ - for (cnt = 0; cnt < 1000; ++cnt) - if (buf[cnt] != '0' + (cnt / 100)) - { - result = 1; - error (0, 0, "comparison failed for aio_read test"); - break; - } - - if (cnt == 1000) - puts ("aio_read test ok"); - - /* Remove the test file contents. */ - if (ftruncate (fd, 0) < 0) - { - error (0, errno, "ftruncate failed\n"); - result = 1; - } - - /* Test lio_listio. */ - for (cnt = 0; cnt < 10; ++cnt) - { - cbs[cnt].aio_lio_opcode = LIO_WRITE; - cbp[cnt] = &cbs[cnt]; - } - /* Issue the command. */ - lio_listio (LIO_WAIT, cbp, 10, NULL); - /* ...and immediately test it since we started it in wait mode. */ - result |= test_file (buf, sizeof (buf), fd, "lio_listio (write)"); - - /* Test aio_fsync. */ - cbs_fsync.aio_fildes = fd; - cbs_fsync.aio_sigevent.sigev_notify = SIGEV_NONE; - cbp_fsync[0] = &cbs_fsync; - - /* Remove the test file contents first. */ - if (ftruncate (fd, 0) < 0) - { - error (0, errno, "ftruncate failed\n"); - result = 1; - } - - /* Write again. */ - for (cnt = 10; cnt > 0; ) - aio_write (cbp[--cnt]); - - if (aio_fsync (O_SYNC, &cbs_fsync) < 0) - { - error (0, errno, "aio_fsync failed\n"); - result = 1; - } - result |= do_wait (cbp_fsync, 1, 0); - - /* ...and test since all data should be on disk now. */ - result |= test_file (buf, sizeof (buf), fd, "aio_fsync (aio_write)"); - - /* Test aio_cancel. */ - /* Remove the test file contents first. */ - if (ftruncate (fd, 0) < 0) - { - error (0, errno, "ftruncate failed\n"); - result = 1; - } - - /* Write again. */ - for (cnt = 10; cnt > 0; ) - aio_write (cbp[--cnt]); - - /* Cancel all requests. */ - if (aio_cancel (fd, NULL) == -1) - printf ("aio_cancel (fd, NULL) cannot cancel anything\n"); - - result |= do_wait (cbp, 10, ECANCELED); - - /* Another test for aio_cancel. */ - /* Remove the test file contents first. */ - if (ftruncate (fd, 0) < 0) - { - error (0, errno, "ftruncate failed\n"); - result = 1; - } - - /* Write again. */ - for (cnt = 10; cnt > 0; ) - { - --cnt; - cbp[cnt] = &cbs[cnt]; - aio_write (cbp[cnt]); - } - puts ("finished3"); - - /* Cancel all requests. */ - for (cnt = 10; cnt > 0; ) - if (aio_cancel (fd, cbp[--cnt]) == -1) - /* This is not an error. The request can simply be finished. */ - printf ("aio_cancel (fd, cbp[%Zd]) cannot be canceled\n", cnt); - puts ("finished2"); - - result |= do_wait (cbp, 10, ECANCELED); - - puts ("finished"); - - return result; -} diff --git a/rt/tst-aio10.c b/rt/tst-aio10.c deleted file mode 100644 index 6e8f7b78c0..0000000000 --- a/rt/tst-aio10.c +++ /dev/null @@ -1,119 +0,0 @@ -#include <aio.h> -#include <errno.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <pthread.h> -#include <unistd.h> - -static pthread_barrier_t b; -static pthread_t main_thread; -static int flag; - - -static void * -tf (void *arg) -{ - int e = pthread_barrier_wait (&b); - if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) - { - puts ("child: barrier_wait failed"); - exit (1); - } - - /* There is unfortunately no other way to try to make sure the other - thread reached the aio_suspend call. This test could fail on - highly loaded machines. */ - sleep (2); - - pthread_kill (main_thread, SIGUSR1); - - while (1) - sleep (1000); - - return NULL; -} - - -static void -sh (int sig) -{ - flag = 1; -} - - -static int -do_test (void) -{ - main_thread = pthread_self (); - - struct sigaction sa; - - sa.sa_handler = sh; - sa.sa_flags = 0; - sigemptyset (&sa.sa_mask); - - if (sigaction (SIGUSR1, &sa, NULL) != 0) - { - puts ("sigaction failed"); - return 1; - } - - if (pthread_barrier_init (&b, NULL, 2) != 0) - { - puts ("barrier_init"); - return 1; - } - - int fds[2]; - if (pipe (fds) != 0) - { - puts ("pipe failed"); - return 1; - } - - char buf[42]; - struct aiocb req; - req.aio_fildes = fds[0]; - req.aio_lio_opcode = LIO_READ; - req.aio_reqprio = 0; - req.aio_offset = 0; - req.aio_buf = buf; - req.aio_nbytes = sizeof (buf); - req.aio_sigevent.sigev_notify = SIGEV_NONE; - - pthread_t th; - if (pthread_create (&th, NULL, tf, NULL) != 0) - { - puts ("create failed"); - return 1; - } - - int e = pthread_barrier_wait (&b); - if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) - { - puts ("parent: barrier_wait failed"); - exit (1); - } - - struct aiocb *list[1]; - list[0] = &req; - - e = lio_listio (LIO_WAIT, list, 1, NULL); - if (e != -1) - { - puts ("lio_listio succeeded"); - return 1; - } - if (errno != EINTR) - { - printf ("lio_listio did not return EINTR: %d (%d = %m)\n", e, errno); - return 1; - } - - return 0; -} - -#define TEST_FUNCTION do_test () -#define TIMEOUT 5 -#include "../test-skeleton.c" diff --git a/rt/tst-aio2.c b/rt/tst-aio2.c deleted file mode 100644 index 27cf78e984..0000000000 --- a/rt/tst-aio2.c +++ /dev/null @@ -1,106 +0,0 @@ -/* Test for notification mechanism in lio_listio. - Copyright (C) 2000-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <aio.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <errno.h> -#include <pthread.h> - - -static pthread_barrier_t b; - - -static void -thrfct (sigval_t arg) -{ - int e = pthread_barrier_wait (&b); - if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) - { - puts ("thread: barrier_wait failed"); - exit (1); - } -} - - -static int -do_test (int argc, char *argv[]) -{ - char name[] = "/tmp/aio2.XXXXXX"; - int fd; - struct aiocb *arr[1]; - struct aiocb cb; - static const char buf[] = "Hello World\n"; - - fd = mkstemp (name); - if (fd == -1) - { - printf ("cannot open temp name: %m\n"); - return 1; - } - - unlink (name); - - if (pthread_barrier_init (&b, NULL, 2) != 0) - { - puts ("barrier_init failed"); - return 1; - } - - arr[0] = &cb; - - cb.aio_fildes = fd; - cb.aio_lio_opcode = LIO_WRITE; - cb.aio_reqprio = 0; - cb.aio_buf = (void *) buf; - cb.aio_nbytes = sizeof (buf) - 1; - cb.aio_offset = 0; - cb.aio_sigevent.sigev_notify = SIGEV_THREAD; - cb.aio_sigevent.sigev_notify_function = thrfct; - cb.aio_sigevent.sigev_notify_attributes = NULL; - cb.aio_sigevent.sigev_value.sival_ptr = NULL; - - if (lio_listio (LIO_WAIT, arr, 1, NULL) < 0) - { - if (errno == ENOSYS) - { - puts ("no aio support in this configuration"); - return 0; - } - printf ("lio_listio failed: %m\n"); - return 1; - } - - puts ("lio_listio returned"); - - int e = pthread_barrier_wait (&b); - if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) - { - puts ("barrier_wait failed"); - return 1; - } - - puts ("all OK"); - - return 0; -} - -#include "../test-skeleton.c" diff --git a/rt/tst-aio3.c b/rt/tst-aio3.c deleted file mode 100644 index fbe18af374..0000000000 --- a/rt/tst-aio3.c +++ /dev/null @@ -1,108 +0,0 @@ -/* Test for notification mechanism in lio_listio. - Copyright (C) 2000-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <aio.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <errno.h> -#include <pthread.h> - -static pthread_barrier_t b; - - -static void -thrfct (sigval_t arg) -{ - int e = pthread_barrier_wait (&b); - if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) - { - puts ("child: barrier_wait failed"); - exit (1); - } -} - - -static int -do_test (int argc, char *argv[]) -{ - char name[] = "/tmp/aio3.XXXXXX"; - int fd; - struct aiocb *arr[1]; - struct aiocb cb; - static const char buf[] = "Hello World\n"; - - fd = mkstemp (name); - if (fd == -1) - { - printf ("cannot open temp name: %m\n"); - return 1; - } - - unlink (name); - - if (pthread_barrier_init (&b, NULL, 2) != 0) - { - puts ("barrier_init failed"); - return 1; - } - - arr[0] = &cb; - - cb.aio_fildes = fd; - cb.aio_lio_opcode = LIO_WRITE; - cb.aio_reqprio = 0; - cb.aio_buf = (void *) buf; - cb.aio_nbytes = sizeof (buf) - 1; - cb.aio_offset = 0; - cb.aio_sigevent.sigev_notify = SIGEV_THREAD; - cb.aio_sigevent.sigev_notify_function = thrfct; - cb.aio_sigevent.sigev_notify_attributes = NULL; - cb.aio_sigevent.sigev_value.sival_ptr = NULL; - - if (lio_listio (LIO_NOWAIT, arr, 1, NULL) < 0) - { - if (errno == ENOSYS) - { - puts ("no aio support in this configuration"); - return 0; - } - printf ("lio_listio failed: %m\n"); - return 1; - } - - if (aio_suspend ((const struct aiocb *const *) arr, 1, NULL) < 0) - { - printf ("aio_suspend failed: %m\n"); - return 1; - } - - int e = pthread_barrier_wait (&b); - if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) - { - puts ("parent: barrier_wait failed"); - return 1; - } - - puts ("all OK"); - - return 0; -} - -#include "../test-skeleton.c" diff --git a/rt/tst-aio4.c b/rt/tst-aio4.c deleted file mode 100644 index 01ed485d52..0000000000 --- a/rt/tst-aio4.c +++ /dev/null @@ -1,159 +0,0 @@ -/* Test for completion signal handling. - Copyright (C) 2000-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <aio.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <errno.h> - -/* We might need a bit longer timeout. */ -#define TIMEOUT 10 /* sec */ - -int my_signo; - -volatile sig_atomic_t flag; - - -static void -sighandler (const int signo) -{ - flag = signo; -} - -static int -wait_flag (void) -{ - while (flag == 0) - { - puts ("Sleeping..."); - sleep (1); - } - - if (flag != my_signo) - { - printf ("signal handler received wrong signal, flag is %d\n", flag); - return 1; - } - - return 0; -} - -#ifndef SIGRTMIN -# define SIGRTMIN -1 -# define SIGRTMAX -1 -#endif - -static int -do_test (int argc, char *argv[]) -{ - char name[] = "/tmp/aio4.XXXXXX"; - int fd; - struct aiocb *arr[1]; - struct aiocb cb; - static const char buf[] = "Hello World\n"; - struct aioinit init = {10, 20, 0}; - struct sigaction sa; - struct sigevent ev; - - if (SIGRTMIN == -1) - { - printf ("RT signals not supported.\n"); - return 0; - } - - /* Select a signal from the middle of the available choices... */ - my_signo = (SIGRTMAX + SIGRTMIN) / 2; - - fd = mkstemp (name); - if (fd == -1) - { - printf ("cannot open temp name: %m\n"); - return 1; - } - - unlink (name); - - /* Test also aio_init. */ - aio_init (&init); - - arr[0] = &cb; - - cb.aio_fildes = fd; - cb.aio_lio_opcode = LIO_WRITE; - cb.aio_reqprio = 0; - cb.aio_buf = (void *) buf; - cb.aio_nbytes = sizeof (buf) - 1; - cb.aio_offset = 0; - cb.aio_sigevent.sigev_notify = SIGEV_SIGNAL; - cb.aio_sigevent.sigev_notify_function = NULL; - cb.aio_sigevent.sigev_notify_attributes = NULL; - cb.aio_sigevent.sigev_signo = my_signo; - cb.aio_sigevent.sigev_value.sival_ptr = NULL; - - ev.sigev_notify = SIGEV_SIGNAL; - ev.sigev_notify_function = NULL; - ev.sigev_notify_attributes = NULL; - ev.sigev_signo = my_signo; - - sa.sa_handler = sighandler; - sigemptyset (&sa.sa_mask); - sa.sa_flags = SA_RESTART; - - if (sigaction (my_signo, &sa, NULL) < 0) - { - printf ("sigaction failed: %m\n"); - return 1; - } - - flag = 0; - /* First use aio_write. */ - if (aio_write (arr[0]) < 0) - { - if (errno == ENOSYS) - { - puts ("no aio support in this configuration"); - return 0; - } - printf ("aio_write failed: %m\n"); - return 1; - } - - if (wait_flag ()) - return 1; - - puts ("aio_write OK"); - - flag = 0; - /* Again with lio_listio. */ - if (lio_listio (LIO_NOWAIT, arr, 1, &ev) < 0) - { - printf ("lio_listio failed: %m\n"); - return 1; - } - - if (wait_flag ()) - return 1; - - puts ("all OK"); - - return 0; -} - -#include "../test-skeleton.c" diff --git a/rt/tst-aio5.c b/rt/tst-aio5.c deleted file mode 100644 index 6097f1a8cc..0000000000 --- a/rt/tst-aio5.c +++ /dev/null @@ -1,129 +0,0 @@ -/* Test for completion thread handling. - Copyright (C) 2000-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <aio.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <errno.h> - -/* We might need a bit longer timeout. */ -#define TIMEOUT 10 /* sec */ - -#define MY_SIVAL 27 - -volatile sig_atomic_t flag; - - -static void -callback (sigval_t s) -{ - flag = s.sival_int; -} - -static int -wait_flag (void) -{ - while (flag == 0) - { - puts ("Sleeping..."); - sleep (1); - } - - if (flag != MY_SIVAL) - { - printf ("signal handler received wrong signal, flag is %d\n", flag); - return 1; - } - - return 0; -} - - -static int -do_test (int argc, char *argv[]) -{ - char name[] = "/tmp/aio5.XXXXXX"; - int fd; - struct aiocb *arr[1]; - struct aiocb cb; - static const char buf[] = "Hello World\n"; - struct sigevent ev; - - fd = mkstemp (name); - if (fd == -1) - { - printf ("cannot open temp name: %m\n"); - return 1; - } - - unlink (name); - - arr[0] = &cb; - - cb.aio_fildes = fd; - cb.aio_lio_opcode = LIO_WRITE; - cb.aio_reqprio = 0; - cb.aio_buf = (void *) buf; - cb.aio_nbytes = sizeof (buf) - 1; - cb.aio_offset = 0; - cb.aio_sigevent.sigev_notify = SIGEV_THREAD; - cb.aio_sigevent.sigev_notify_function = callback; - cb.aio_sigevent.sigev_notify_attributes = NULL; - cb.aio_sigevent.sigev_value.sival_int = MY_SIVAL; - - ev.sigev_notify = SIGEV_THREAD; - ev.sigev_notify_function = callback; - ev.sigev_notify_attributes = NULL; - ev.sigev_value.sival_int = MY_SIVAL; - - /* First use aio_write. */ - if (aio_write (arr[0]) < 0) - { - if (errno == ENOSYS) - { - puts ("no aio support in this configuration"); - return 0; - } - printf ("aio_write failed: %m\n"); - return 1; - } - - if (wait_flag ()) - return 1; - - puts ("aio_write OK"); - - flag = 0; - /* Again with lio_listio. */ - if (lio_listio (LIO_NOWAIT, arr, 1, &ev) < 0) - { - printf ("lio_listio failed: %m\n"); - return 1; - } - - if (wait_flag ()) - return 1; - - puts ("all OK"); - - return 0; -} - -#include "../test-skeleton.c" diff --git a/rt/tst-aio6.c b/rt/tst-aio6.c deleted file mode 100644 index 7adbb3dede..0000000000 --- a/rt/tst-aio6.c +++ /dev/null @@ -1,101 +0,0 @@ -/* Test for timeout handling. - Copyright (C) 2000-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <aio.h> -#include <errno.h> -#include <stdio.h> -#include <unistd.h> -#include <sys/time.h> - - -/* We expect to wait for 3 seconds so we have to increase the timeout. */ -#define TIMEOUT 10 /* sec */ - - -#define TEST_FUNCTION do_test () -static int -do_test (void) -{ - struct aiocb *arr[1]; - struct aiocb cb; - char buf[100]; - struct timeval before; - struct timeval after; - struct timespec timeout; - int fd[2]; - int result = 0; - - if (pipe (fd) != 0) - { - printf ("cannot create pipe: %m\n"); - return 1; - } - - arr[0] = &cb; - - cb.aio_fildes = fd[0]; - cb.aio_lio_opcode = LIO_WRITE; - cb.aio_reqprio = 0; - cb.aio_buf = (void *) buf; - cb.aio_nbytes = sizeof (buf) - 1; - cb.aio_offset = 0; - cb.aio_sigevent.sigev_notify = SIGEV_NONE; - - /* Try to read from stdin where nothing will be available. */ - if (aio_read (arr[0]) < 0) - { - if (errno == ENOSYS) - { - puts ("no aio support in this configuration"); - return 0; - } - printf ("aio_read failed: %m\n"); - return 1; - } - - /* Get the current time. */ - gettimeofday (&before, NULL); - - /* Wait for input which is unsuccessful and therefore the function will - time out. */ - timeout.tv_sec = 3; - timeout.tv_nsec = 0; - if (aio_suspend ((const struct aiocb *const*) arr, 1, &timeout) != -1) - { - puts ("aio_suspend() didn't return -1"); - result = 1; - } - else if (errno != EAGAIN) - { - puts ("error not set to EAGAIN"); - result = 1; - } - else - { - gettimeofday (&after, NULL); - if (after.tv_sec < before.tv_sec + 1) - { - puts ("timeout came too early"); - result = 1; - } - } - - return result; -} - -#include "../test-skeleton.c" diff --git a/rt/tst-aio64.c b/rt/tst-aio64.c deleted file mode 100644 index c05aa48238..0000000000 --- a/rt/tst-aio64.c +++ /dev/null @@ -1,290 +0,0 @@ -/* Tests for 64bit AIO in librt. - Copyright (C) 1998-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#define _LARGEFILE_SOURCE 1 -#include <aio.h> -#include <errno.h> -#include <error.h> -#include <fcntl.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <sys/stat.h> - - -/* Prototype for our test function. */ -extern void do_prepare (int argc, char *argv[]); -extern int do_test (int argc, char *argv[]); - -/* We have a preparation function. */ -#define PREPARE do_prepare - -/* We might need a bit longer timeout. */ -#define TIMEOUT 20 /* sec */ - -/* This defines the `main' function and some more. */ -#include <test-skeleton.c> - - -/* These are for the temporary file we generate. */ -char *name; -int fd; - -void -do_prepare (int argc, char *argv[]) -{ - size_t name_len; - - name_len = strlen (test_dir); - name = xmalloc (name_len + sizeof ("/aioXXXXXX")); - mempcpy (mempcpy (name, test_dir, name_len), - "/aioXXXXXX", sizeof ("/aioXXXXXX")); - - /* Open our test file. */ - fd = mkstemp (name); - if (fd == -1) - error (EXIT_FAILURE, errno, "cannot open test file `%s'", name); - add_temp_file (name); -} - - -static int -test_file (const void *buf, size_t size, int fd, const char *msg) -{ - struct stat st; - char tmp[size]; - - errno = 0; - if (fstat (fd, &st) < 0) - { - error (0, errno, "%s: failed stat", msg); - return 1; - } - - if (st.st_size != (off_t) size) - { - error (0, errno, "%s: wrong size: %lu, should be %lu", - msg, (unsigned long int) st.st_size, (unsigned long int) size); - return 1; - } - - if (pread (fd, tmp, size, 0) != (ssize_t) size) - { - error (0, errno, "%s: failed pread", msg); - return 1; - } - - if (memcmp (buf, tmp, size) != 0) - { - error (0, errno, "%s: failed comparison", msg); - return 1; - } - - printf ("%s test ok\n", msg); - - return 0; -} - - -static int -do_wait (struct aiocb64 **cbp, size_t nent, int allowed_err) -{ - int go_on; - size_t cnt; - int result = 0; - - do - { - aio_suspend64 ((const struct aiocb64 *const *) cbp, nent, NULL); - go_on = 0; - for (cnt = 0; cnt < nent; ++cnt) - if (cbp[cnt] != NULL) - { - if (aio_error64 (cbp[cnt]) == EINPROGRESS) - go_on = 1; - else - { - if (aio_return64 (cbp[cnt]) == -1 - && (allowed_err == 0 - || aio_error64 (cbp[cnt]) != allowed_err)) - { - error (0, aio_error64 (cbp[cnt]), "Operation failed\n"); - result = 1; - } - cbp[cnt] = NULL; - } - } - } - while (go_on); - - return result; -} - - -int -do_test (int argc, char *argv[]) -{ - struct aiocb64 cbs[10]; - struct aiocb64 cbs_fsync; - struct aiocb64 *cbp[10]; - struct aiocb64 *cbp_fsync[1]; - char buf[1000]; - size_t cnt; - int result = 0; - - /* Preparation. */ - for (cnt = 0; cnt < 10; ++cnt) - { - cbs[cnt].aio_fildes = fd; - cbs[cnt].aio_reqprio = 0; - cbs[cnt].aio_buf = memset (&buf[cnt * 100], '0' + cnt, 100); - cbs[cnt].aio_nbytes = 100; - cbs[cnt].aio_offset = cnt * 100; - cbs[cnt].aio_sigevent.sigev_notify = SIGEV_NONE; - - cbp[cnt] = &cbs[cnt]; - } - - /* First a simple test. */ - for (cnt = 10; cnt > 0; ) - if (aio_write64 (cbp[--cnt]) < 0 && errno == ENOSYS) - { - error (0, 0, "no aio support in this configuration"); - return 0; - } - /* Wait 'til the results are there. */ - result |= do_wait (cbp, 10, 0); - /* Test this. */ - result |= test_file (buf, sizeof (buf), fd, "aio_write"); - - /* Read now as we've written it. */ - memset (buf, '\0', sizeof (buf)); - /* Issue the commands. */ - for (cnt = 10; cnt > 0; ) - { - --cnt; - cbp[cnt] = &cbs[cnt]; - aio_read64 (cbp[cnt]); - } - /* Wait 'til the results are there. */ - result |= do_wait (cbp, 10, 0); - /* Test this. */ - for (cnt = 0; cnt < 1000; ++cnt) - if (buf[cnt] != '0' + (cnt / 100)) - { - result = 1; - error (0, 0, "comparison failed for aio_read test"); - break; - } - - if (cnt == 1000) - puts ("aio_read test ok"); - - /* Remove the test file contents. */ - if (ftruncate64 (fd, 0) < 0) - { - error (0, errno, "ftruncate failed\n"); - result = 1; - } - - /* Test lio_listio. */ - for (cnt = 0; cnt < 10; ++cnt) - { - cbs[cnt].aio_lio_opcode = LIO_WRITE; - cbp[cnt] = &cbs[cnt]; - } - /* Issue the command. */ - lio_listio64 (LIO_WAIT, cbp, 10, NULL); - /* ...and immediately test it since we started it in wait mode. */ - result |= test_file (buf, sizeof (buf), fd, "lio_listio (write)"); - - /* Test aio_fsync. */ - cbs_fsync.aio_fildes = fd; - cbs_fsync.aio_sigevent.sigev_notify = SIGEV_NONE; - cbp_fsync[0] = &cbs_fsync; - - /* Remove the test file contents first. */ - if (ftruncate64 (fd, 0) < 0) - { - error (0, errno, "ftruncate failed\n"); - result = 1; - } - - /* Write again. */ - for (cnt = 10; cnt > 0; ) - aio_write64 (cbp[--cnt]); - - if (aio_fsync64 (O_SYNC, &cbs_fsync) < 0) - { - error (0, errno, "aio_fsync failed\n"); - result = 1; - } - result |= do_wait (cbp_fsync, 1, 0); - - /* ...and test since all data should be on disk now. */ - result |= test_file (buf, sizeof (buf), fd, "aio_fsync (aio_write)"); - - /* Test aio_cancel. */ - /* Remove the test file contents first. */ - if (ftruncate64 (fd, 0) < 0) - { - error (0, errno, "ftruncate failed\n"); - result = 1; - } - - /* Write again. */ - for (cnt = 10; cnt > 0; ) - aio_write64 (cbp[--cnt]); - - /* Cancel all requests. */ - if (aio_cancel64 (fd, NULL) == -1) - printf ("aio_cancel64 (fd, NULL) cannot cancel anything\n"); - - result |= do_wait (cbp, 10, ECANCELED); - - /* Another test for aio_cancel. */ - /* Remove the test file contents first. */ - if (ftruncate64 (fd, 0) < 0) - { - error (0, errno, "ftruncate failed\n"); - result = 1; - } - - /* Write again. */ - for (cnt = 10; cnt > 0; ) - { - --cnt; - cbp[cnt] = &cbs[cnt]; - aio_write64 (cbp[cnt]); - } - puts ("finished3"); - - /* Cancel all requests. */ - for (cnt = 10; cnt > 0; ) - if (aio_cancel64 (fd, cbp[--cnt]) == -1) - /* This is not an error. The request can simply be finished. */ - printf ("aio_cancel64 (fd, cbp[%Zd]) cannot be canceled\n", cnt); - puts ("finished2"); - - result |= do_wait (cbp, 10, ECANCELED); - - puts ("finished"); - - return result; -} diff --git a/rt/tst-aio7.c b/rt/tst-aio7.c deleted file mode 100644 index c8b094606b..0000000000 --- a/rt/tst-aio7.c +++ /dev/null @@ -1,177 +0,0 @@ -/* Test for AIO POSIX compliance. - Copyright (C) 2001-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <aio.h> -#include <error.h> -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - - -/* We might wait for 3 seconds, so increase timeout to 10 seconds. */ -#define TIMEOUT 10 - - -#define TEST_FUNCTION do_test () -static int -do_test (void) -{ - int result = 0; - int piped[2]; - - /* Make a pipe that we will never write to, so we can block reading it. */ - if (pipe (piped) < 0) - { - perror ("pipe"); - return 1; - } - - /* Test for aio_cancel() detecting invalid file descriptor. */ - { - struct aiocb cb; - int fd = -1; - - cb.aio_fildes = fd; - cb.aio_offset = 0; - cb.aio_buf = NULL; - cb.aio_nbytes = 0; - cb.aio_reqprio = 0; - cb.aio_sigevent.sigev_notify = SIGEV_NONE; - - errno = 0; - - /* Case one: invalid fds that match. */ - if (aio_cancel (fd, &cb) != -1 || errno != EBADF) - { - if (errno == ENOSYS) - { - puts ("no aio support in this configuration"); - return 0; - } - - puts ("aio_cancel( -1, {-1..} ) did not return -1 or errno != EBADF"); - ++result; - } - - cb.aio_fildes = -2; - errno = 0; - - /* Case two: invalid fds that do not match; just print warning. */ - if (aio_cancel (fd, &cb) != -1 || errno != EBADF) - puts ("aio_cancel( -1, {-2..} ) did not return -1 or errno != EBADF"); - } - - /* Test for aio_fsync() detecting bad fd. */ - { - struct aiocb cb; - int fd = -1; - - cb.aio_fildes = fd; - cb.aio_offset = 0; - cb.aio_buf = NULL; - cb.aio_nbytes = 0; - cb.aio_reqprio = 0; - cb.aio_sigevent.sigev_notify = SIGEV_NONE; - - errno = 0; - - /* Case one: invalid fd. */ - if (aio_fsync (O_SYNC, &cb) != -1 || errno != EBADF) - { - puts ("aio_fsync( op, {-1..} ) did not return -1 or errno != EBADF"); - ++result; - } - } - - /* Test for aio_suspend() suspending even if completed elements in list. */ - { -#define BYTES 8 - const int ELEMS = 2; - int i, r, fd; - static char buff[BYTES]; - char name[] = "/tmp/aio7.XXXXXX"; - struct timespec timeout; - static struct aiocb cb0, cb1; - struct aiocb *list[ELEMS]; - - fd = mkstemp (name); - if (fd < 0) - error (1, errno, "creating temp file"); - - if (unlink (name)) - error (1, errno, "unlinking temp file"); - - if (write (fd, "01234567", BYTES) != BYTES) - error (1, errno, "writing to temp file"); - - cb0.aio_fildes = fd; - cb0.aio_offset = 0; - cb0.aio_buf = buff; - cb0.aio_nbytes = BYTES; - cb0.aio_reqprio = 0; - cb0.aio_sigevent.sigev_notify = SIGEV_NONE; - - r = aio_read (&cb0); - if (r != 0) - error (1, errno, "reading from file"); - - while (aio_error (&(cb0)) == EINPROGRESS) - usleep (10); - - for (i = 0; i < BYTES; i++) - printf ("%c ", buff[i]); - printf ("\n"); - - /* At this point, the first read is completed, so start another one on - the read half of a pipe on which nothing will be written. */ - cb1.aio_fildes = piped[0]; - cb1.aio_offset = 0; - cb1.aio_buf = buff; - cb1.aio_nbytes = BYTES; - cb1.aio_reqprio = 0; - cb1.aio_sigevent.sigev_notify = SIGEV_NONE; - - r = aio_read (&cb1); - if (r != 0) - error (1, errno, "reading from file"); - - /* Now call aio_suspend() with the two reads. It should return - * immediately according to the POSIX spec. - */ - list[0] = &cb0; - list[1] = &cb1; - timeout.tv_sec = 3; - timeout.tv_nsec = 0; - r = aio_suspend ((const struct aiocb * const *) list, ELEMS, &timeout); - - if (r == -1 && errno == EAGAIN) - { - puts ("aio_suspend([done,blocked],2,3) suspended thread"); - ++result; - } - - /* Note that CB1 is still pending, and so cannot be an auto variable. - Thus we also test that exiting with an outstanding request works. */ - } - - return result; -} - -#include "../test-skeleton.c" diff --git a/rt/tst-aio8.c b/rt/tst-aio8.c deleted file mode 100644 index b03639dabd..0000000000 --- a/rt/tst-aio8.c +++ /dev/null @@ -1,39 +0,0 @@ -#include <aio.h> -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> - -static int -do_test (void) -{ - int fd = open ("/dev/full", O_RDWR); - if (fd == -1) - { - puts ("could not open /dev/full"); - return 0; - } - - struct aiocb req; - req.aio_fildes = fd; - req.aio_lio_opcode = LIO_WRITE; - req.aio_reqprio = 0; - req.aio_buf = (void *) "hello"; - req.aio_nbytes = 5; - req.aio_offset = 0; - req.aio_sigevent.sigev_notify = SIGEV_NONE; - - struct aiocb *list[1]; - list[0] = &req; - - int r = lio_listio (LIO_WAIT, list, 1, NULL); - int e = errno; - - printf ("r = %d, e = %d (%s)\n", r, e, strerror (e)); - - return r != -1 || e != EIO; -} - -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" diff --git a/rt/tst-aio9.c b/rt/tst-aio9.c deleted file mode 100644 index eab4f6859a..0000000000 --- a/rt/tst-aio9.c +++ /dev/null @@ -1,124 +0,0 @@ -#include <aio.h> -#include <errno.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <pthread.h> -#include <unistd.h> - -static pthread_barrier_t b; -static pthread_t main_thread; -static int flag; - - -static void * -tf (void *arg) -{ - int e = pthread_barrier_wait (&b); - if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) - { - puts ("child: barrier_wait failed"); - exit (1); - } - - /* There is unfortunately no other way to try to make sure the other - thread reached the aio_suspend call. This test could fail on - highly loaded machines. */ - sleep (2); - - pthread_kill (main_thread, SIGUSR1); - - while (1) - sleep (1000); - - return NULL; -} - - -static void -sh (int sig) -{ - flag = 1; -} - - -static int -do_test (void) -{ - main_thread = pthread_self (); - - struct sigaction sa; - - sa.sa_handler = sh; - sa.sa_flags = 0; - sigemptyset (&sa.sa_mask); - - if (sigaction (SIGUSR1, &sa, NULL) != 0) - { - puts ("sigaction failed"); - return 1; - } - - if (pthread_barrier_init (&b, NULL, 2) != 0) - { - puts ("barrier_init"); - return 1; - } - - int fds[2]; - if (pipe (fds) != 0) - { - puts ("pipe failed"); - return 1; - } - - char buf[42]; - struct aiocb req; - req.aio_fildes = fds[0]; - req.aio_reqprio = 0; - req.aio_offset = 0; - req.aio_buf = buf; - req.aio_nbytes = sizeof (buf); - req.aio_sigevent.sigev_notify = SIGEV_NONE; - - if (aio_read (&req) != 0) - { - puts ("aio_read failed"); - return 1; - } - - pthread_t th; - if (pthread_create (&th, NULL, tf, NULL) != 0) - { - puts ("create failed"); - return 1; - } - - int e = pthread_barrier_wait (&b); - if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) - { - puts ("parent: barrier_wait failed"); - exit (1); - } - - const struct aiocb *list[1]; - list[0] = &req; - - e = aio_suspend (list, 1, NULL); - if (e != -1) - { - puts ("aio_suspend succeeded"); - return 1; - } - if (errno != EINTR) - { - puts ("aio_suspend did not return EINTR"); - return 1; - } - - return 0; -} - -#define TEST_FUNCTION do_test () -#define TIMEOUT 5 -#include "../test-skeleton.c" diff --git a/rt/tst-clock.c b/rt/tst-clock.c deleted file mode 100644 index 05d9bb8c89..0000000000 --- a/rt/tst-clock.c +++ /dev/null @@ -1,124 +0,0 @@ -/* Test program for POSIX clock_* functions. - Copyright (C) 2000-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <stdio.h> -#include <string.h> -#include <time.h> -#include <stdint.h> - - -/* We want to see output immediately. */ -#define STDOUT_UNBUFFERED - -/* We expect to run at least 10 seconds. */ -#define TIMEOUT 15 - -static int -clock_test (clockid_t cl) -{ - struct timespec old_ts; - struct timespec ts; - struct timespec waitit; - int result = 0; - int i; - - memset (&ts, '\0', sizeof ts); - - waitit.tv_sec = 0; - waitit.tv_nsec = 500000000; - - /* Get and print resolution of the clock. */ - if (clock_getres (cl, &ts) == 0) - { - if (ts.tv_nsec < 0 || ts.tv_nsec >= 1000000000) - { - printf ("clock %d: nanosecond value of resolution wrong\n", cl); - result = 1; - } - else - printf ("clock %d: resolution = %jd.%09jd secs\n", - cl, (intmax_t) ts.tv_sec, (intmax_t) ts.tv_nsec); - } - else - { - printf ("clock %d: cannot get resolution\n", cl); - result = 1; - } - - memset (&ts, '\0', sizeof ts); - memset (&old_ts, '\0', sizeof old_ts); - - /* Next get the current time value a few times. */ - for (i = 0; i < 10; ++i) - { - if (clock_gettime (cl, &ts) == 0) - { - if (ts.tv_nsec < 0 || ts.tv_nsec >= 1000000000) - { - printf ("clock %d: nanosecond value of time wrong (try %d)\n", - cl, i); - result = 1; - } - else - { - printf ("clock %d: time = %jd.%09jd secs\n", - cl, (intmax_t) ts.tv_sec, (intmax_t) ts.tv_nsec); - - if (memcmp (&ts, &old_ts, sizeof ts) == 0) - { - printf ("clock %d: time hasn't changed (try %d)\n", cl, i); - result = 1; - - old_ts = ts; - } - } - } - else - { - printf ("clock %d: cannot get time (try %d)\n", cl, i); - result = 1; - } - - /* Wait a bit before the next iteration. */ - nanosleep (&waitit, NULL); - } - - return result; -} - -static int -do_test (void) -{ - clockid_t cl; - int result; - - result = clock_test (CLOCK_REALTIME); - - if (clock_getcpuclockid (0, &cl) == 0) - /* XXX It's not yet a bug when this fails. */ - clock_test (cl); - else - printf("CPU clock unavailble, skipping test\n"); - - return result; -} -#define TEST_FUNCTION do_test () - - -#include "../test-skeleton.c" diff --git a/rt/tst-clock2.c b/rt/tst-clock2.c deleted file mode 100644 index 4c8fb9f247..0000000000 --- a/rt/tst-clock2.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Test setting the monotonic clock. */ - -#include <time.h> -#include <unistd.h> - -#if defined CLOCK_MONOTONIC && defined _POSIX_MONOTONIC_CLOCK - -# include <errno.h> -# include <stdio.h> - -static int -do_test (void) -{ - if (sysconf (_SC_MONOTONIC_CLOCK) <= 0) - return 0; - - struct timespec ts; - if (clock_gettime (CLOCK_MONOTONIC, &ts) != 0) - { - puts ("clock_gettime(CLOCK_MONOTONIC) failed"); - return 1; - } - - /* Setting the monotonic clock must fail. */ - if (clock_settime (CLOCK_MONOTONIC, &ts) != -1) - { - puts ("clock_settime(CLOCK_MONOTONIC) did not fail"); - return 1; - } - if (errno != EINVAL) - { - printf ("clock_settime(CLOCK_MONOTONIC) set errno to %d, expected %d\n", - errno, EINVAL); - return 1; - } - return 0; -} -# define TEST_FUNCTION do_test () - -#else -# define TEST_FUNCTION 0 -#endif -#include "../test-skeleton.c" diff --git a/rt/tst-clock_nanosleep.c b/rt/tst-clock_nanosleep.c deleted file mode 100644 index dba6f53ec3..0000000000 --- a/rt/tst-clock_nanosleep.c +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2003-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <stdio.h> -#include <unistd.h> -#include <sys/time.h> -#include <time.h> - - -/* Test that clock_nanosleep() does sleep. */ -static int -do_test (void) -{ - /* Current time. */ - struct timeval tv1; - (void) gettimeofday (&tv1, NULL); - - struct timespec ts; - ts.tv_sec = 1; - ts.tv_nsec = 0; - TEMP_FAILURE_RETRY (clock_nanosleep (CLOCK_REALTIME, 0, &ts, &ts)); - - /* At least one second must have passed. */ - struct timeval tv2; - (void) gettimeofday (&tv2, NULL); - - tv2.tv_sec -= tv1.tv_sec; - tv2.tv_usec -= tv1.tv_usec; - if (tv2.tv_usec < 0) - --tv2.tv_sec; - - if (tv2.tv_sec < 1) - { - puts ("clock_nanosleep didn't sleep long enough"); - return 1; - } - - return 0; -} - -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" diff --git a/rt/tst-cpuclock1.c b/rt/tst-cpuclock1.c deleted file mode 100644 index 71bd695253..0000000000 --- a/rt/tst-cpuclock1.c +++ /dev/null @@ -1,321 +0,0 @@ -/* Test program for process CPU clocks. - Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <stdio.h> -#include <stdlib.h> -#include <time.h> -#include <unistd.h> -#include <fcntl.h> -#include <string.h> -#include <errno.h> -#include <signal.h> -#include <stdint.h> -#include <sys/wait.h> - -/* This function is intended to rack up both user and system time. */ -static void -chew_cpu (void) -{ - while (1) - { - static volatile char buf[4096]; - for (int i = 0; i < 100; ++i) - for (size_t j = 0; j < sizeof buf; ++j) - buf[j] = 0xaa; - int nullfd = open ("/dev/null", O_WRONLY); - for (int i = 0; i < 100; ++i) - for (size_t j = 0; j < sizeof buf; ++j) - buf[j] = 0xbb; - write (nullfd, (char *) buf, sizeof buf); - close (nullfd); - if (getppid () == 1) - _exit (2); - } -} - -static int -do_test (void) -{ - int result = 0; - clockid_t cl; - int e; - pid_t dead_child, child; - - /* Fork a child and let it die, to give us a PID known not be valid - (assuming PIDs don't wrap around during the test). */ - { - dead_child = fork (); - if (dead_child == 0) - _exit (0); - if (dead_child < 0) - { - perror ("fork"); - return 1; - } - int x; - if (wait (&x) != dead_child) - { - perror ("wait"); - return 2; - } - } - - /* POSIX says we should get ESRCH for this. */ - e = clock_getcpuclockid (dead_child, &cl); - if (e != ENOSYS && e != ESRCH && e != EPERM) - { - printf ("clock_getcpuclockid on dead PID %d => %s\n", - dead_child, strerror (e)); - result = 1; - } - - /* Now give us a live child eating up CPU time. */ - child = fork (); - if (child == 0) - { - chew_cpu (); - _exit (1); - } - if (child < 0) - { - perror ("fork"); - return 1; - } - - e = clock_getcpuclockid (child, &cl); - if (e == EPERM) - { - puts ("clock_getcpuclockid does not support other processes"); - goto done; - } - if (e != 0) - { - printf ("clock_getcpuclockid on live PID %d => %s\n", - child, strerror (e)); - result = 1; - goto done; - } - - const clockid_t child_clock = cl; - struct timespec res; - if (clock_getres (child_clock, &res) < 0) - { - printf ("clock_getres on live PID %d clock %lx => %s\n", - child, (unsigned long int) child_clock, strerror (errno)); - result = 1; - goto done; - } - printf ("live PID %d clock %lx resolution %ju.%.9ju\n", - child, (unsigned long int) child_clock, - (uintmax_t) res.tv_sec, (uintmax_t) res.tv_nsec); - - struct timespec before, after; - if (clock_gettime (child_clock, &before) < 0) - { - printf ("clock_gettime on live PID %d clock %lx => %s\n", - child, (unsigned long int) child_clock, strerror (errno)); - result = 1; - goto done; - } - /* Should be close to 0.0. */ - printf ("live PID %d before sleep => %ju.%.9ju\n", - child, (uintmax_t) before.tv_sec, (uintmax_t) before.tv_nsec); - - struct timespec sleeptime = { .tv_nsec = 500000000 }; - if (nanosleep (&sleeptime, NULL) != 0) - { - perror ("nanosleep"); - result = 1; - goto done; - } - - if (clock_gettime (child_clock, &after) < 0) - { - printf ("clock_gettime on live PID %d clock %lx => %s\n", - child, (unsigned long int) child_clock, strerror (errno)); - result = 1; - goto done; - } - /* Should be close to 0.5. */ - printf ("live PID %d after sleep => %ju.%.9ju\n", - child, (uintmax_t) after.tv_sec, (uintmax_t) after.tv_nsec); - - struct timespec diff = { .tv_sec = after.tv_sec - before.tv_sec, - .tv_nsec = after.tv_nsec - before.tv_nsec }; - if (diff.tv_nsec < 0) - { - --diff.tv_sec; - diff.tv_nsec += 1000000000; - } - if (diff.tv_sec != 0 - || diff.tv_nsec > 600000000 - || diff.tv_nsec < 100000000) - { - printf ("before - after %ju.%.9ju outside reasonable range\n", - (uintmax_t) diff.tv_sec, (uintmax_t) diff.tv_nsec); - result = 1; - } - - sleeptime.tv_nsec = 100000000; - e = clock_nanosleep (child_clock, 0, &sleeptime, NULL); - if (e == EINVAL || e == ENOTSUP || e == ENOSYS) - { - printf ("clock_nanosleep not supported for other process clock: %s\n", - strerror (e)); - } - else if (e != 0) - { - printf ("clock_nanosleep on other process clock: %s\n", strerror (e)); - result = 1; - } - else - { - struct timespec afterns; - if (clock_gettime (child_clock, &afterns) < 0) - { - printf ("clock_gettime on live PID %d clock %lx => %s\n", - child, (unsigned long int) child_clock, strerror (errno)); - result = 1; - } - else - { - struct timespec d = { .tv_sec = afterns.tv_sec - after.tv_sec, - .tv_nsec = afterns.tv_nsec - after.tv_nsec }; - if (d.tv_nsec < 0) - { - --d.tv_sec; - d.tv_nsec += 1000000000; - } - if (d.tv_sec > 0 - || d.tv_nsec < sleeptime.tv_nsec - || d.tv_nsec > sleeptime.tv_nsec * 2) - { - printf ("nanosleep time %ju.%.9ju outside reasonable range\n", - (uintmax_t) d.tv_sec, (uintmax_t) d.tv_nsec); - result = 1; - } - } - } - - if (kill (child, SIGKILL) != 0) - { - perror ("kill"); - result = 2; - goto done; - } - - /* Wait long enough to let the child finish dying. */ - - sleeptime.tv_nsec = 200000000; - if (nanosleep (&sleeptime, NULL) != 0) - { - perror ("nanosleep"); - result = 1; - goto done; - } - - struct timespec dead; - if (clock_gettime (child_clock, &dead) < 0) - { - printf ("clock_gettime on dead PID %d clock %lx => %s\n", - child, (unsigned long int) child_clock, strerror (errno)); - result = 1; - goto done; - } - /* Should be close to 0.6. */ - printf ("dead PID %d => %ju.%.9ju\n", - child, (uintmax_t) dead.tv_sec, (uintmax_t) dead.tv_nsec); - - diff.tv_sec = dead.tv_sec - after.tv_sec; - diff.tv_nsec = dead.tv_nsec - after.tv_nsec; - if (diff.tv_nsec < 0) - { - --diff.tv_sec; - diff.tv_nsec += 1000000000; - } - if (diff.tv_sec != 0 || diff.tv_nsec > 200000000) - { - printf ("dead - after %ju.%.9ju outside reasonable range\n", - (uintmax_t) diff.tv_sec, (uintmax_t) diff.tv_nsec); - result = 1; - } - - /* Now reap the child and verify that its clock is no longer valid. */ - { - int x; - if (waitpid (child, &x, 0) != child) - { - perror ("waitpid"); - result = 1; - } - } - - if (clock_gettime (child_clock, &dead) == 0) - { - printf ("clock_gettime on reaped PID %d clock %lx => %ju%.9ju\n", - child, (unsigned long int) child_clock, - (uintmax_t) dead.tv_sec, (uintmax_t) dead.tv_nsec); - result = 1; - } - else - { - if (errno != EINVAL) - result = 1; - printf ("clock_gettime on reaped PID %d clock %lx => %s\n", - child, (unsigned long int) child_clock, strerror (errno)); - } - - if (clock_getres (child_clock, &dead) == 0) - { - printf ("clock_getres on reaped PID %d clock %lx => %ju%.9ju\n", - child, (unsigned long int) child_clock, - (uintmax_t) dead.tv_sec, (uintmax_t) dead.tv_nsec); - result = 1; - } - else - { - if (errno != EINVAL) - result = 1; - printf ("clock_getres on reaped PID %d clock %lx => %s\n", - child, (unsigned long int) child_clock, strerror (errno)); - } - - return result; - - done: - { - if (kill (child, SIGKILL) != 0 && errno != ESRCH) - { - perror ("kill"); - return 2; - } - int x; - if (waitpid (child, &x, 0) != child && errno != ECHILD) - { - perror ("waitpid"); - return 2; - } - } - - return result; -} - - -#define TIMEOUT 5 -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" diff --git a/rt/tst-cpuclock2.c b/rt/tst-cpuclock2.c deleted file mode 100644 index cf58a3f1dd..0000000000 --- a/rt/tst-cpuclock2.c +++ /dev/null @@ -1,337 +0,0 @@ -/* Test program for process and thread CPU clocks. - Copyright (C) 2005-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <unistd.h> -#include <stdint.h> - -#if (_POSIX_THREADS - 0) <= 0 - -# define TEST_FUNCTION 0 - -#else - -#include <stdio.h> -#include <stdlib.h> -#include <time.h> -#include <fcntl.h> -#include <string.h> -#include <errno.h> -#include <pthread.h> - -static pthread_barrier_t barrier; - -/* This function is intended to rack up both user and system time. */ -static void * -chew_cpu (void *arg) -{ - pthread_barrier_wait (&barrier); - - while (1) - { - static volatile char buf[4096]; - for (int i = 0; i < 100; ++i) - for (size_t j = 0; j < sizeof buf; ++j) - buf[j] = 0xaa; - int nullfd = open ("/dev/null", O_WRONLY); - for (int i = 0; i < 100; ++i) - for (size_t j = 0; j < sizeof buf; ++j) - buf[j] = 0xbb; - write (nullfd, (char *) buf, sizeof buf); - close (nullfd); - } - - return NULL; -} - -static unsigned long long int -tsdiff (const struct timespec *before, const struct timespec *after) -{ - struct timespec diff = { .tv_sec = after->tv_sec - before->tv_sec, - .tv_nsec = after->tv_nsec - before->tv_nsec }; - while (diff.tv_nsec < 0) - { - --diff.tv_sec; - diff.tv_nsec += 1000000000; - } - return diff.tv_sec * 1000000000ULL + diff.tv_nsec; -} - -static unsigned long long int -test_nanosleep (clockid_t clock, const char *which, - const struct timespec *before, int *bad) -{ - const struct timespec sleeptime = { .tv_nsec = 100000000 }; - int e = clock_nanosleep (clock, 0, &sleeptime, NULL); - if (e == EINVAL || e == ENOTSUP || e == ENOSYS) - { - printf ("clock_nanosleep not supported for %s CPU clock: %s\n", - which, strerror (e)); - return 0; - } - if (e != 0) - { - printf ("clock_nanosleep on %s CPU clock: %s\n", which, strerror (e)); - *bad = 1; - return 0; - } - - struct timespec after; - if (clock_gettime (clock, &after) < 0) - { - printf ("clock_gettime on %s CPU clock %lx => %s\n", - which, (unsigned long int) clock, strerror (errno)); - *bad = 1; - return 0; - } - - unsigned long long int diff = tsdiff (before, &after); - if (diff < sleeptime.tv_nsec || diff > sleeptime.tv_nsec * 2) - { - printf ("clock_nanosleep on %s slept %llu (outside reasonable range)\n", - which, diff); - *bad = 1; - return diff; - } - - struct timespec sleeptimeabs = sleeptime; - sleeptimeabs.tv_sec += after.tv_sec; - sleeptimeabs.tv_nsec += after.tv_nsec; - while (sleeptimeabs.tv_nsec >= 1000000000) - { - ++sleeptimeabs.tv_sec; - sleeptimeabs.tv_nsec -= 1000000000; - } - e = clock_nanosleep (clock, TIMER_ABSTIME, &sleeptimeabs, NULL); - if (e != 0) - { - printf ("absolute clock_nanosleep on %s CPU clock: %s\n", - which, strerror (e)); - *bad = 1; - return diff; - } - - struct timespec afterabs; - if (clock_gettime (clock, &afterabs) < 0) - { - printf ("clock_gettime on %s CPU clock %lx => %s\n", - which, (unsigned long int) clock, strerror (errno)); - *bad = 1; - return diff; - } - - unsigned long long int sleepdiff = tsdiff (&sleeptimeabs, &afterabs); - if (sleepdiff > sleeptime.tv_nsec) - { - printf ("\ -absolute clock_nanosleep on %s %llu past target (outside reasonable range)\n", - which, sleepdiff); - *bad = 1; - } - - unsigned long long int diffabs = tsdiff (&after, &afterabs); - if (diffabs < sleeptime.tv_nsec || diffabs > sleeptime.tv_nsec * 2) - { - printf ("\ -absolute clock_nanosleep on %s slept %llu (outside reasonable range)\n", - which, diffabs); - *bad = 1; - } - - return diff + diffabs; -} - - - -static int -do_test (void) -{ - int result = 0; - clockid_t process_clock, th_clock, my_thread_clock; - int e; - pthread_t th; - - e = clock_getcpuclockid (0, &process_clock); - if (e != 0) - { - printf ("clock_getcpuclockid on self => %s\n", strerror (e)); - return 1; - } - - e = pthread_getcpuclockid (pthread_self (), &my_thread_clock); - if (e != 0) - { - printf ("pthread_getcpuclockid on self => %s\n", strerror (e)); - return 1; - } - - /* This is a kludge. This test fails if the semantics of thread and - process clocks are wrong. The old code using hp-timing without kernel - support has bogus semantics if there are context switches. We don't - fail to report failure when the proper functionality is not available - in the kernel. It so happens that Linux kernels without correct CPU - clock support also lack CPU timer support, so we use use that to guess - that we are using the bogus code and not test it. */ - timer_t t; - if (timer_create (my_thread_clock, NULL, &t) != 0) - { - printf ("timer_create: %m\n"); - puts ("No support for CPU clocks with good semantics, skipping test"); - return 0; - } - timer_delete (t); - - - pthread_barrier_init (&barrier, NULL, 2); - - e = pthread_create (&th, NULL, chew_cpu, NULL); - if (e != 0) - { - printf ("pthread_create: %s\n", strerror (e)); - return 1; - } - - e = pthread_getcpuclockid (th, &th_clock); - if (e == ENOENT || e == ENOSYS || e == ENOTSUP) - { - puts ("pthread_getcpuclockid does not support other threads"); - return 1; - } - - pthread_barrier_wait (&barrier); - - struct timespec res; - if (clock_getres (th_clock, &res) < 0) - { - printf ("clock_getres on live thread clock %lx => %s\n", - (unsigned long int) th_clock, strerror (errno)); - result = 1; - return 1; - } - printf ("live thread clock %lx resolution %ju.%.9ju\n", - (unsigned long int) th_clock, - (uintmax_t) res.tv_sec, (uintmax_t) res.tv_nsec); - - struct timespec process_before, process_after; - if (clock_gettime (process_clock, &process_before) < 0) - { - printf ("clock_gettime on process clock %lx => %s\n", - (unsigned long int) process_clock, strerror (errno)); - return 1; - } - - struct timespec before, after; - if (clock_gettime (th_clock, &before) < 0) - { - printf ("clock_gettime on live thread clock %lx => %s\n", - (unsigned long int) th_clock, strerror (errno)); - return 1; - } - printf ("live thread before sleep => %ju.%.9ju\n", - (uintmax_t) before.tv_sec, (uintmax_t) before.tv_nsec); - - struct timespec me_before, me_after; - if (clock_gettime (my_thread_clock, &me_before) < 0) - { - printf ("clock_gettime on self thread clock %lx => %s\n", - (unsigned long int) my_thread_clock, strerror (errno)); - return 1; - } - printf ("self thread before sleep => %ju.%.9ju\n", - (uintmax_t) me_before.tv_sec, (uintmax_t) me_before.tv_nsec); - - struct timespec sleeptime = { .tv_nsec = 500000000 }; - if (nanosleep (&sleeptime, NULL) != 0) - { - perror ("nanosleep"); - return 1; - } - - if (clock_gettime (th_clock, &after) < 0) - { - printf ("clock_gettime on live thread clock %lx => %s\n", - (unsigned long int) th_clock, strerror (errno)); - return 1; - } - printf ("live thread after sleep => %ju.%.9ju\n", - (uintmax_t) after.tv_sec, (uintmax_t) after.tv_nsec); - - if (clock_gettime (process_clock, &process_after) < 0) - { - printf ("clock_gettime on process clock %lx => %s\n", - (unsigned long int) process_clock, strerror (errno)); - return 1; - } - - if (clock_gettime (my_thread_clock, &me_after) < 0) - { - printf ("clock_gettime on self thread clock %lx => %s\n", - (unsigned long int) my_thread_clock, strerror (errno)); - return 1; - } - printf ("self thread after sleep => %ju.%.9ju\n", - (uintmax_t) me_after.tv_sec, (uintmax_t) me_after.tv_nsec); - - unsigned long long int th_diff = tsdiff (&before, &after); - unsigned long long int pdiff = tsdiff (&process_before, &process_after); - unsigned long long int my_diff = tsdiff (&me_before, &me_after); - - if (th_diff < 100000000 || th_diff > 600000000) - { - printf ("live thread before - after %llu outside reasonable range\n", - th_diff); - result = 1; - } - - if (my_diff > 100000000) - { - printf ("self thread before - after %llu outside reasonable range\n", - my_diff); - result = 1; - } - - if (pdiff < th_diff) - { - printf ("process before - after %llu outside reasonable range (%llu)\n", - pdiff, th_diff); - result = 1; - } - - process_after.tv_nsec += test_nanosleep (th_clock, "live thread", - &after, &result); - process_after.tv_nsec += test_nanosleep (process_clock, "process", - &process_after, &result); - test_nanosleep (CLOCK_PROCESS_CPUTIME_ID, - "PROCESS_CPUTIME_ID", &process_after, &result); - - pthread_cancel (th); - - e = clock_nanosleep (CLOCK_THREAD_CPUTIME_ID, 0, &sleeptime, NULL); - if (e != EINVAL) - { - printf ("clock_nanosleep CLOCK_THREAD_CPUTIME_ID: %s\n", - strerror (e)); - result = 1; - } - - return result; -} -# define TIMEOUT 8 -# define TEST_FUNCTION do_test () -#endif - -#include "../test-skeleton.c" diff --git a/rt/tst-cputimer1.c b/rt/tst-cputimer1.c deleted file mode 100644 index 8f5dd76cf2..0000000000 --- a/rt/tst-cputimer1.c +++ /dev/null @@ -1,68 +0,0 @@ -/* Tests for POSIX timer implementation using process CPU clock. */ - -#include <unistd.h> - -#if _POSIX_THREADS && defined _POSIX_CPUTIME - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> -#include <time.h> -#include <pthread.h> - -#define TEST_CLOCK CLOCK_PROCESS_CPUTIME_ID -#define TEST_CLOCK_MISSING(clock) \ - (setup_test () ? "process CPU clock timer support" : NULL) - -/* This function is intended to rack up both user and system time. */ -static void * -chew_cpu (void *arg) -{ - while (1) - { - static volatile char buf[4096]; - for (int i = 0; i < 100; ++i) - for (size_t j = 0; j < sizeof buf; ++j) - buf[j] = 0xaa; - int nullfd = open ("/dev/null", O_WRONLY); - for (int i = 0; i < 100; ++i) - for (size_t j = 0; j < sizeof buf; ++j) - buf[j] = 0xbb; - write (nullfd, (char *) buf, sizeof buf); - close (nullfd); - } - - return NULL; -} - -static int -setup_test (void) -{ - /* Test timers on our own process CPU clock by having a worker thread - eating CPU. First make sure we can make such timers at all. */ - - timer_t t; - if (timer_create (TEST_CLOCK, NULL, &t) != 0) - { - printf ("timer_create: %m\n"); - return 1; - } - timer_delete (t); - - pthread_t th; - int e = pthread_create (&th, NULL, chew_cpu, NULL); - if (e != 0) - { - printf ("pthread_create: %s\n", strerror (e)); - exit (1); - } - - return 0; -} - -#else -# define TEST_CLOCK_MISSING(clock) "process clocks" -#endif - -#include "tst-timer4.c" diff --git a/rt/tst-cputimer2.c b/rt/tst-cputimer2.c deleted file mode 100644 index 397d7998c0..0000000000 --- a/rt/tst-cputimer2.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Tests for POSIX timer implementation using thread CPU clock. */ - -#include <unistd.h> - -#if _POSIX_THREADS && defined _POSIX_CPUTIME - -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> -#include <time.h> -#include <pthread.h> - -static clockid_t worker_thread_clock; - -#define TEST_CLOCK worker_thread_clock -#define TEST_CLOCK_MISSING(clock) \ - (setup_test () ? "thread CPU clock timer support" : NULL) - -/* This function is intended to rack up both user and system time. */ -static void * -chew_cpu (void *arg) -{ - while (1) - { - static volatile char buf[4096]; - for (int i = 0; i < 100; ++i) - for (size_t j = 0; j < sizeof buf; ++j) - buf[j] = 0xaa; - int nullfd = open ("/dev/null", O_WRONLY); - for (int i = 0; i < 100; ++i) - for (size_t j = 0; j < sizeof buf; ++j) - buf[j] = 0xbb; - write (nullfd, (char *) buf, sizeof buf); - close (nullfd); - } - - return NULL; -} - -static int -setup_test (void) -{ - /* Test timers on a thread CPU clock by having a worker thread eating - CPU. First make sure we can make such timers at all. */ - - pthread_t th; - int e = pthread_create (&th, NULL, chew_cpu, NULL); - if (e != 0) - { - printf ("pthread_create: %s\n", strerror (e)); - exit (1); - } - - e = pthread_getcpuclockid (th, &worker_thread_clock); - if (e == EPERM || e == ENOENT || e == ENOTSUP) - { - puts ("pthread_getcpuclockid does not support other threads"); - return 1; - } - if (e != 0) - { - printf ("pthread_getcpuclockid: %s\n", strerror (e)); - exit (1); - } - - timer_t t; - if (timer_create (TEST_CLOCK, NULL, &t) != 0) - { - printf ("timer_create: %m\n"); - return 1; - } - timer_delete (t); - - return 0; -} - -#else -# define TEST_CLOCK_MISSING(clock) "process clocks" -#endif - -#include "tst-timer4.c" diff --git a/rt/tst-cputimer3.c b/rt/tst-cputimer3.c deleted file mode 100644 index 056766a377..0000000000 --- a/rt/tst-cputimer3.c +++ /dev/null @@ -1,130 +0,0 @@ -/* Tests for POSIX timer implementation using another process's CPU clock. */ - -#include <unistd.h> - -#if _POSIX_THREADS && defined _POSIX_CPUTIME - -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> -#include <time.h> -#include <signal.h> -#include <sys/wait.h> - -static clockid_t child_clock; - -#define TEST_CLOCK child_clock -#define TEST_CLOCK_MISSING(clock) \ - (setup_test () ? "other-process CPU clock timer support" : NULL) - -/* This function is intended to rack up both user and system time. */ -static void -chew_cpu (void) -{ - while (1) - { - static volatile char buf[4096]; - for (int i = 0; i < 100; ++i) - for (size_t j = 0; j < sizeof buf; ++j) - buf[j] = 0xaa; - int nullfd = open ("/dev/null", O_WRONLY); - for (int i = 0; i < 100; ++i) - for (size_t j = 0; j < sizeof buf; ++j) - buf[j] = 0xbb; - write (nullfd, (char *) buf, sizeof buf); - close (nullfd); - if (getppid () == 1) - _exit (2); - } -} - -static pid_t child; -static void -cleanup_child (void) -{ - if (child <= 0) - return; - if (kill (child, SIGKILL) < 0 && errno != ESRCH) - printf ("cannot kill child %d: %m\n", child); - else - { - int status; - errno = 0; - if (waitpid (child, &status, 0) != child) - printf ("waitpid %d: %m\n", child); - } -} -#define CLEANUP_HANDLER cleanup_child () - -static int -setup_test (void) -{ - /* Test timers on a process CPU clock by having a child process eating - CPU. First make sure we can make such timers at all. */ - - int pipefd[2]; - if (pipe (pipefd) < 0) - { - printf ("pipe: %m\n"); - exit (1); - } - - child = fork (); - - if (child == 0) - { - char c; - close (pipefd[1]); - if (read (pipefd[0], &c, 1) == 1) - chew_cpu (); - _exit (1); - } - - if (child < 0) - { - printf ("fork: %m\n"); - exit (1); - } - - atexit (&cleanup_child); - - close (pipefd[0]); - - int e = clock_getcpuclockid (child, &child_clock); - if (e == EPERM) - { - puts ("clock_getcpuclockid does not support other processes"); - return 1; - } - if (e != 0) - { - printf ("clock_getcpuclockid: %s\n", strerror (e)); - exit (1); - } - - timer_t t; - if (timer_create (TEST_CLOCK, NULL, &t) != 0) - { - printf ("timer_create: %m\n"); - return 1; - } - timer_delete (t); - - /* Get the child started chewing. */ - if (write (pipefd[1], "x", 1) != 1) - { - printf ("write to pipe: %m\n"); - return 1; - } - close (pipefd[1]); - - return 0; -} - -#else -# define TEST_CLOCK_MISSING(clock) "process clocks" -#endif - -#include "tst-timer4.c" diff --git a/rt/tst-mqueue.h b/rt/tst-mqueue.h deleted file mode 100644 index 7bf446b546..0000000000 --- a/rt/tst-mqueue.h +++ /dev/null @@ -1,83 +0,0 @@ -/* Common code for message queue passing tests. - Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek <jakub@redhat.com>, 2004. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <mqueue.h> -#include <search.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <sys/uio.h> -#include <unistd.h> - -static int temp_mq_fd; - -/* Add temporary files in list. */ -static void -__attribute__ ((unused)) -add_temp_mq (const char *name) -{ - struct iovec iov[2]; - iov[0].iov_base = (char *) name; - iov[0].iov_len = strlen (name); - iov[1].iov_base = (char *) "\n"; - iov[1].iov_len = 1; - if (writev (temp_mq_fd, iov, 2) != iov[0].iov_len + 1) - printf ("Could not record temp mq filename %s\n", name); -} - -/* Delete all temporary message queues. */ -static void -do_cleanup (void) -{ - if (lseek (temp_mq_fd, 0, SEEK_SET) != 0) - return; - - FILE *f = fdopen (temp_mq_fd, "r"); - if (f == NULL) - return; - - char *line = NULL; - size_t n = 0; - ssize_t rets; - while ((rets = getline (&line, &n, f)) > 0) - { - if (line[rets - 1] != '\n') - continue; - - line[rets - 1] = '\0'; - mq_unlink (line); - } - fclose (f); -} - -static void -do_prepare (void) -{ - char name [] = "/tmp/tst-mqueueN.XXXXXX"; - temp_mq_fd = mkstemp (name); - if (temp_mq_fd == -1) - { - printf ("Could not create temporary file %s: %m\n", name); - exit (1); - } - unlink (name); -} - -#define PREPARE(argc, argv) do_prepare () -#define CLEANUP_HANDLER do_cleanup () diff --git a/rt/tst-mqueue1.c b/rt/tst-mqueue1.c deleted file mode 100644 index feb88c8350..0000000000 --- a/rt/tst-mqueue1.c +++ /dev/null @@ -1,418 +0,0 @@ -/* Test message queue passing. - Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek <jakub@redhat.com>, 2004. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <fcntl.h> -#include <mqueue.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/wait.h> -#include <time.h> -#include <unistd.h> -#include <stdint.h> -#include "tst-mqueue.h" - -static int -intcmp (const void *a, const void *b) -{ - if (*(unsigned char *)a < *(unsigned char *)b) - return 1; - if (*(unsigned char *)a > *(unsigned char *)b) - return -1; - return 0; -} - -static int -check_attrs (struct mq_attr *attr, int nonblock, long cnt) -{ - int result = 0; - - if (attr->mq_maxmsg != 10 || attr->mq_msgsize != 1) - { - printf ("attributes don't match those passed to mq_open\n" - "mq_maxmsg %jd, mq_msgsize %jd\n", - (intmax_t) attr->mq_maxmsg, (intmax_t) attr->mq_msgsize); - result = 1; - } - - if ((attr->mq_flags & O_NONBLOCK) != nonblock) - { - printf ("mq_flags %jx != %x\n", - (intmax_t) (attr->mq_flags & O_NONBLOCK), nonblock); - result = 1; - } - - if (attr->mq_curmsgs != cnt) - { - printf ("mq_curmsgs %jd != %ld\n", (intmax_t) attr->mq_curmsgs, cnt); - result = 1; - } - - return result; -} - -static int -do_one_test (mqd_t q, const char *name, int nonblock) -{ - int result = 0; - - unsigned char v [] - = { 0x32, 0x62, 0x22, 0x31, 0x11, 0x73, 0x61, 0x21, 0x72, 0x71, 0x81 }; - - struct mq_attr attr; - memset (&attr, 0xaa, sizeof (attr)); - if (mq_getattr (q, &attr) != 0) - { - printf ("mq_getattr failed: %m\n"); - result = 1; - } - else - result |= check_attrs (&attr, nonblock, 0); - - if (mq_receive (q, (char *) &v[0], 1, NULL) != -1) - { - puts ("mq_receive on O_WRONLY mqd_t unexpectedly succeeded"); - result = 1; - } - else if (errno != EBADF) - { - printf ("mq_receive on O_WRONLY mqd_t did not fail with EBADF: %m\n"); - result = 1; - } - - struct timespec ts; - if (clock_gettime (CLOCK_REALTIME, &ts) == 0) - --ts.tv_sec; - else - { - ts.tv_sec = time (NULL) - 1; - ts.tv_nsec = 0; - } - - int ret; - for (int i = 0; i < 10; ++i) - { - if (i & 1) - ret = mq_send (q, (char *) &v[i], 1, v[i] >> 4); - else - ret = mq_timedsend (q, (char *) &v[i], 1, v[i] >> 4, &ts); - - if (ret) - { - printf ("mq_%ssend failed: %m\n", (i & 1) ? "" : "timed"); - result = 1; - } - } - - ret = mq_timedsend (q, (char *) &v[10], 1, 8, &ts); - if (ret != -1) - { - puts ("mq_timedsend on full queue did not fail"); - result = 1; - } - else if (errno != (nonblock ? EAGAIN : ETIMEDOUT)) - { - printf ("mq_timedsend on full queue did not fail with %s: %m\n", - nonblock ? "EAGAIN" : "ETIMEDOUT"); - result = 1; - } - - if (nonblock) - { - ret = mq_send (q, (char *) &v[10], 1, 8); - if (ret != -1) - { - puts ("mq_send on full non-blocking queue did not fail"); - result = 1; - } - else if (errno != EAGAIN) - { - printf ("mq_send on full non-blocking queue did not fail" - "with EAGAIN: %m\n"); - result = 1; - } - } - - memset (&attr, 0xaa, sizeof (attr)); - if (mq_getattr (q, &attr) != 0) - { - printf ("mq_getattr failed: %m\n"); - result = 1; - } - else - result |= check_attrs (&attr, nonblock, 10); - - pid_t pid = fork (); - if (pid == -1) - { - printf ("fork failed: %m\n"); - result = 1; - } - else if (pid == 0) - { - result = 0; - - if (mq_close (q) != 0) - { - printf ("mq_close in child failed: %m\n"); - result = 1; - } - - q = mq_open (name, O_RDONLY | nonblock); - if (q == (mqd_t) -1) - { - printf ("mq_open in child failed: %m\n"); - exit (1); - } - - memset (&attr, 0xaa, sizeof (attr)); - if (mq_getattr (q, &attr) != 0) - { - printf ("mq_getattr failed: %m\n"); - result = 1; - } - else - result |= check_attrs (&attr, nonblock, 10); - - unsigned char vr[11] = { }; - unsigned int prio; - ssize_t rets; - - if (mq_send (q, (char *) &v[0], 1, 1) != -1) - { - puts ("mq_send on O_RDONLY mqd_t unexpectedly succeeded"); - result = 1; - } - else if (errno != EBADF) - { - printf ("mq_send on O_WRONLY mqd_t did not fail with EBADF: %m\n"); - result = 1; - } - - for (int i = 0; i < 10; ++i) - { - if (i & 1) - rets = mq_receive (q, (char *) &vr[i], 1, &prio); - else - rets = mq_timedreceive (q, (char *) &vr[i], 1, &prio, &ts); - - if (rets != 1) - { - if (rets == -1) - printf ("mq_%sreceive failed: %m\n", (i & 1) ? "" : "timed"); - else - printf ("mq_%sreceive returned %zd != 1\n", - (i & 1) ? "" : "timed", rets); - result = 1; - } - else if (prio != (unsigned int) vr[i] >> 4) - { - printf ("unexpected priority %x for value %02x\n", prio, - vr[i]); - result = 1; - } - } - - qsort (v, 10, 1, intcmp); - if (memcmp (v, vr, 10) != 0) - { - puts ("messages not received in expected order"); - result = 1; - } - - rets = mq_timedreceive (q, (char *) &vr[10], 1, &prio, &ts); - if (rets != -1) - { - puts ("mq_timedreceive on empty queue did not fail"); - result = 1; - } - else if (errno != (nonblock ? EAGAIN : ETIMEDOUT)) - { - printf ("mq_timedreceive on empty queue did not fail with %s: %m\n", - nonblock ? "EAGAIN" : "ETIMEDOUT"); - result = 1; - } - - if (nonblock) - { - ret = mq_receive (q, (char *) &vr[10], 1, &prio); - if (ret != -1) - { - puts ("mq_receive on empty non-blocking queue did not fail"); - result = 1; - } - else if (errno != EAGAIN) - { - printf ("mq_receive on empty non-blocking queue did not fail" - "with EAGAIN: %m\n"); - result = 1; - } - } - - memset (&attr, 0xaa, sizeof (attr)); - if (mq_getattr (q, &attr) != 0) - { - printf ("mq_getattr failed: %m\n"); - result = 1; - } - else - result |= check_attrs (&attr, nonblock, 0); - - if (mq_close (q) != 0) - { - printf ("mq_close in child failed: %m\n"); - result = 1; - } - - exit (result); - } - - int status; - if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid) - { - printf ("waitpid failed: %m\n"); - kill (pid, SIGKILL); - result = 1; - } - else if (!WIFEXITED (status) || WEXITSTATUS (status)) - { - printf ("child failed: %d\n", status); - result = 1; - } - - memset (&attr, 0xaa, sizeof (attr)); - if (mq_getattr (q, &attr) != 0) - { - printf ("mq_getattr failed: %m\n"); - result = 1; - } - else - result |= check_attrs (&attr, nonblock, 0); - - return result; -} - -#define TEST_FUNCTION do_test () -static int -do_test (void) -{ - int result = 0; - - char name[sizeof "/tst-mqueue1-" + sizeof (pid_t) * 3]; - snprintf (name, sizeof (name), "/tst-mqueue1-%u", getpid ()); - - struct mq_attr attr = { .mq_maxmsg = 10, .mq_msgsize = 1 }; - mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_WRONLY, 0600, &attr); - - if (q == (mqd_t) -1) - { - printf ("mq_open failed with: %m\n"); - return result; - } - else - add_temp_mq (name); - - result |= do_one_test (q, name, 0); - - mqd_t q2 = mq_open (name, O_WRONLY | O_NONBLOCK); - if (q2 == (mqd_t) -1) - { - printf ("mq_open failed with: %m\n"); - q2 = q; - result = 1; - } - else - { - if (mq_close (q) != 0) - { - printf ("mq_close in parent failed: %m\n"); - result = 1; - } - - q = q2; - result |= do_one_test (q, name, O_NONBLOCK); - - if (mq_getattr (q, &attr) != 0) - { - printf ("mq_getattr failed: %m\n"); - result = 1; - } - else - { - attr.mq_flags ^= O_NONBLOCK; - - struct mq_attr attr2; - memset (&attr2, 0x55, sizeof (attr2)); - if (mq_setattr (q, &attr, &attr2) != 0) - { - printf ("mq_setattr failed: %m\n"); - result = 1; - } - else if (attr.mq_flags != (attr2.mq_flags ^ O_NONBLOCK) - || attr.mq_maxmsg != attr2.mq_maxmsg - || attr.mq_msgsize != attr2.mq_msgsize - || attr.mq_curmsgs != 0 - || attr2.mq_curmsgs != 0) - { - puts ("mq_setattr returned unexpected values in *omqstat"); - result = 1; - } - else - { - result |= do_one_test (q, name, 0); - - if (mq_setattr (q, &attr2, NULL) != 0) - { - printf ("mq_setattr failed: %m\n"); - result = 1; - } - else - result |= do_one_test (q, name, O_NONBLOCK); - } - } - } - - if (mq_unlink (name) != 0) - { - printf ("mq_unlink failed: %m\n"); - result = 1; - } - - if (mq_close (q) != 0) - { - printf ("mq_close in parent failed: %m\n"); - result = 1; - } - - if (mq_close (q) != -1) - { - puts ("second mq_close did not fail"); - result = 1; - } - else if (errno != EBADF) - { - printf ("second mq_close did not fail with EBADF: %m\n"); - result = 1; - } - - return result; -} - -#include "../test-skeleton.c" diff --git a/rt/tst-mqueue2.c b/rt/tst-mqueue2.c deleted file mode 100644 index 357dcdffef..0000000000 --- a/rt/tst-mqueue2.c +++ /dev/null @@ -1,476 +0,0 @@ -/* Test message queue passing. - Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek <jakub@redhat.com>, 2004. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <fcntl.h> -#include <mqueue.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/time.h> -#include <sys/wait.h> -#include <time.h> -#include <unistd.h> -#include "tst-mqueue.h" - -static void -alrm_handler (int sig) -{ -} - -#define TIMEOUT 10 -#define TEST_FUNCTION do_test () -static int -do_test (void) -{ - int result = 0; - - char name[sizeof "/tst-mqueue2-" + sizeof (pid_t) * 3]; - snprintf (name, sizeof (name), "/tst-mqueue2-%u", getpid ()); - - struct mq_attr attr = { .mq_maxmsg = 2, .mq_msgsize = 2 }; - mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr); - - if (q == (mqd_t) -1) - { - printf ("mq_open failed with: %m\n"); - return result; - } - else - add_temp_mq (name); - - mqd_t q2 = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr); - if (q2 != (mqd_t) -1) - { - puts ("mq_open with O_EXCL unexpectedly succeeded"); - result = 1; - } - else if (errno != EEXIST) - { - printf ("mq_open did not fail with EEXIST: %m\n"); - result = 1; - } - - char name2[sizeof "/tst-mqueue2-2-" + sizeof (pid_t) * 3]; - snprintf (name2, sizeof (name2), "/tst-mqueue2-2-%u", getpid ()); - - attr.mq_maxmsg = -2; - q2 = mq_open (name2, O_CREAT | O_EXCL | O_RDWR, 0600, &attr); - if (q2 != (mqd_t) -1) - { - puts ("mq_open with invalid mq_maxmsg unexpectedly succeeded"); - add_temp_mq (name2); - result = 1; - } - else if (errno != EINVAL) - { - printf ("mq_open with invalid mq_maxmsg did not fail with " - "EINVAL: %m\n"); - result = 1; - } - - attr.mq_maxmsg = 2; - attr.mq_msgsize = -56; - q2 = mq_open (name2, O_CREAT | O_EXCL | O_RDWR, 0600, &attr); - if (q2 != (mqd_t) -1) - { - puts ("mq_open with invalid mq_msgsize unexpectedly succeeded"); - add_temp_mq (name2); - result = 1; - } - else if (errno != EINVAL) - { - printf ("mq_open with invalid mq_msgsize did not fail with " - "EINVAL: %m\n"); - result = 1; - } - - char buf[3]; - struct timespec ts; - if (clock_gettime (CLOCK_REALTIME, &ts) == 0) - ts.tv_sec += 10; - else - { - ts.tv_sec = time (NULL) + 10; - ts.tv_nsec = 0; - } - - if (mq_timedreceive (q, buf, 1, NULL, &ts) == 0) - { - puts ("mq_timedreceive with too small msg_len did not fail"); - result = 1; - } - else if (errno != EMSGSIZE) - { - printf ("mq_timedreceive with too small msg_len did not fail with " - "EMSGSIZE: %m\n"); - result = 1; - } - - ts.tv_nsec = -1; - if (mq_timedreceive (q, buf, 2, NULL, &ts) == 0) - { - puts ("mq_timedreceive with negative tv_nsec did not fail"); - result = 1; - } - else if (errno != EINVAL) - { - printf ("mq_timedreceive with negative tv_nsec did not fail with " - "EINVAL: %m\n"); - result = 1; - } - - ts.tv_nsec = 1000000000; - if (mq_timedreceive (q, buf, 2, NULL, &ts) == 0) - { - puts ("mq_timedreceive with tv_nsec >= 1000000000 did not fail"); - result = 1; - } - else if (errno != EINVAL) - { - printf ("mq_timedreceive with tv_nsec >= 1000000000 did not fail with " - "EINVAL: %m\n"); - result = 1; - } - - struct sigaction sa = { .sa_handler = alrm_handler, .sa_flags = 0 }; - sigemptyset (&sa.sa_mask); - sigaction (SIGALRM, &sa, NULL); - - struct itimerval it = { .it_value = { .tv_sec = 1 } }; - setitimer (ITIMER_REAL, &it, NULL); - - if (mq_receive (q, buf, 2, NULL) == 0) - { - puts ("mq_receive on empty queue did not block"); - result = 1; - } - else if (errno != EINTR) - { - printf ("mq_receive on empty queue did not fail with EINTR: %m\n"); - result = 1; - } - - setitimer (ITIMER_REAL, &it, NULL); - - ts.tv_nsec = 0; - if (mq_timedreceive (q, buf, 2, NULL, &ts) == 0) - { - puts ("mq_timedreceive on empty queue did not block"); - result = 1; - } - else if (errno != EINTR) - { - printf ("mq_timedreceive on empty queue did not fail with EINTR: %m\n"); - result = 1; - } - - buf[0] = '6'; - buf[1] = '7'; - if (mq_send (q, buf, 2, 3) != 0 - || (buf[0] = '8', mq_send (q, buf, 1, 4) != 0)) - { - printf ("mq_send failed: %m\n"); - result = 1; - } - - memset (buf, ' ', sizeof (buf)); - - unsigned int prio; - ssize_t rets = mq_receive (q, buf, 3, &prio); - if (rets != 1) - { - if (rets == -1) - printf ("mq_receive failed: %m\n"); - else - printf ("mq_receive returned %zd != 1\n", rets); - result = 1; - } - else if (prio != 4 || memcmp (buf, "8 ", 3) != 0) - { - printf ("mq_receive prio %u (4) buf \"%c%c%c\" (\"8 \")\n", - prio, buf[0], buf[1], buf[2]); - result = 1; - } - - rets = mq_receive (q, buf, 2, NULL); - if (rets != 2) - { - if (rets == -1) - printf ("mq_receive failed: %m\n"); - else - printf ("mq_receive returned %zd != 2\n", rets); - result = 1; - } - else if (memcmp (buf, "67 ", 3) != 0) - { - printf ("mq_receive buf \"%c%c%c\" != \"67 \"\n", - buf[0], buf[1], buf[2]); - result = 1; - } - - buf[0] = '2'; - buf[1] = '1'; - if (clock_gettime (CLOCK_REALTIME, &ts) != 0) - ts.tv_sec = time (NULL); - ts.tv_nsec = -1000000001; - if ((mq_timedsend (q, buf, 2, 5, &ts) != 0 - && (errno != EINVAL || mq_send (q, buf, 2, 5) != 0)) - || (buf[0] = '3', ts.tv_nsec = -ts.tv_nsec, - (mq_timedsend (q, buf, 1, 4, &ts) != 0 - && (errno != EINVAL || mq_send (q, buf, 1, 4) != 0)))) - { - printf ("mq_timedsend failed: %m\n"); - result = 1; - } - - buf[0] = '-'; - ts.tv_nsec = 1000000001; - if (mq_timedsend (q, buf, 1, 6, &ts) == 0) - { - puts ("mq_timedsend with tv_nsec >= 1000000000 did not fail"); - result = 1; - } - else if (errno != EINVAL) - { - printf ("mq_timedsend with tv_nsec >= 1000000000 did not fail with " - "EINVAL: %m\n"); - result = 1; - } - - ts.tv_nsec = -2; - if (mq_timedsend (q, buf, 1, 6, &ts) == 0) - { - puts ("mq_timedsend with negative tv_nsec did not fail"); - result = 1; - } - else if (errno != EINVAL) - { - printf ("mq_timedsend with megatove tv_nsec did not fail with " - "EINVAL: %m\n"); - result = 1; - } - - setitimer (ITIMER_REAL, &it, NULL); - - if (mq_send (q, buf, 2, 8) == 0) - { - puts ("mq_send on full queue did not block"); - result = 1; - } - else if (errno != EINTR) - { - printf ("mq_send on full queue did not fail with EINTR: %m\n"); - result = 1; - } - - setitimer (ITIMER_REAL, &it, NULL); - - ts.tv_sec += 10; - ts.tv_nsec = 0; - if (mq_timedsend (q, buf, 2, 7, &ts) == 0) - { - puts ("mq_timedsend on full queue did not block"); - result = 1; - } - else if (errno != EINTR) - { - printf ("mq_timedsend on full queue did not fail with EINTR: %m\n"); - result = 1; - } - - memset (buf, ' ', sizeof (buf)); - - if (clock_gettime (CLOCK_REALTIME, &ts) != 0) - ts.tv_sec = time (NULL); - ts.tv_nsec = -1000000001; - rets = mq_timedreceive (q, buf, 2, &prio, &ts); - if (rets == -1 && errno == EINVAL) - rets = mq_receive (q, buf, 2, &prio); - if (rets != 2) - { - if (rets == -1) - printf ("mq_timedreceive failed: %m\n"); - else - printf ("mq_timedreceive returned %zd != 2\n", rets); - result = 1; - } - else if (prio != 5 || memcmp (buf, "21 ", 3) != 0) - { - printf ("mq_timedreceive prio %u (5) buf \"%c%c%c\" (\"21 \")\n", - prio, buf[0], buf[1], buf[2]); - result = 1; - } - - if (mq_receive (q, buf, 1, NULL) == 0) - { - puts ("mq_receive with too small msg_len did not fail"); - result = 1; - } - else if (errno != EMSGSIZE) - { - printf ("mq_receive with too small msg_len did not fail with " - "EMSGSIZE: %m\n"); - result = 1; - } - - ts.tv_nsec = -ts.tv_nsec; - rets = mq_timedreceive (q, buf, 2, NULL, &ts); - if (rets == -1 && errno == EINVAL) - rets = mq_receive (q, buf, 2, NULL); - if (rets != 1) - { - if (rets == -1) - printf ("mq_timedreceive failed: %m\n"); - else - printf ("mq_timedreceive returned %zd != 1\n", rets); - result = 1; - } - else if (memcmp (buf, "31 ", 3) != 0) - { - printf ("mq_timedreceive buf \"%c%c%c\" != \"31 \"\n", - buf[0], buf[1], buf[2]); - result = 1; - } - - if (mq_send (q, "", 0, 2) != 0) - { - printf ("mq_send with msg_len 0 failed: %m\n"); - result = 1; - } - - rets = mq_receive (q, buf, 2, &prio); - if (rets) - { - if (rets == -1) - printf ("mq_receive failed: %m\n"); - else - printf ("mq_receive returned %zd != 0\n", rets); - result = 1; - } - - long mq_prio_max = sysconf (_SC_MQ_PRIO_MAX); - if (mq_prio_max > 0 && (unsigned int) mq_prio_max == mq_prio_max) - { - if (mq_send (q, buf, 1, mq_prio_max) == 0) - { - puts ("mq_send with MQ_PRIO_MAX priority unpexpectedly succeeded"); - result = 1; - } - else if (errno != EINVAL) - { - printf ("mq_send with MQ_PRIO_MAX priority did not fail with " - "EINVAL: %m\n"); - result = 1; - } - - if (mq_send (q, buf, 1, mq_prio_max - 1) != 0) - { - printf ("mq_send with MQ_PRIO_MAX-1 priority failed: %m\n"); - result = 1; - } - } - - if (mq_unlink (name) != 0) - { - printf ("mq_unlink failed: %m\n"); - result = 1; - } - - q2 = mq_open (name, O_RDWR); - if (q2 != (mqd_t) -1) - { - printf ("mq_open of unlinked %s without O_CREAT unexpectedly" - "succeeded\n", name); - result = 1; - } - else if (errno != ENOENT) - { - printf ("mq_open of unlinked %s without O_CREAT did not fail with " - "ENOENT: %m\n", name); - result = 1; - } - - if (mq_close (q) != 0) - { - printf ("mq_close in parent failed: %m\n"); - result = 1; - } - - if (mq_receive (q, buf, 2, NULL) == 0) - { - puts ("mq_receive on invalid mqd_t did not fail"); - result = 1; - } - else if (errno != EBADF) - { - printf ("mq_receive on invalid mqd_t did not fail with EBADF: %m\n"); - result = 1; - } - - if (mq_send (q, buf, 1, 2) == 0) - { - puts ("mq_send on invalid mqd_t did not fail"); - result = 1; - } - else if (errno != EBADF) - { - printf ("mq_send on invalid mqd_t did not fail with EBADF: %m\n"); - result = 1; - } - - if (mq_getattr (q, &attr) == 0) - { - puts ("mq_getattr on invalid mqd_t did not fail"); - result = 1; - } - else if (errno != EBADF) - { - printf ("mq_getattr on invalid mqd_t did not fail with EBADF: %m\n"); - result = 1; - } - - memset (&attr, 0, sizeof (attr)); - if (mq_setattr (q, &attr, NULL) == 0) - { - puts ("mq_setattr on invalid mqd_t did not fail"); - result = 1; - } - else if (errno != EBADF) - { - printf ("mq_setattr on invalid mqd_t did not fail with EBADF: %m\n"); - result = 1; - } - - if (mq_unlink ("/tst-mqueue2-which-should-never-exist") != -1) - { - puts ("mq_unlink of non-existant message queue unexpectedly succeeded"); - result = 1; - } - else if (errno != ENOENT) - { - printf ("mq_unlink of non-existant message queue did not fail with " - "ENOENT: %m\n"); - result = 1; - } - return result; -} - -#include "../test-skeleton.c" diff --git a/rt/tst-mqueue3.c b/rt/tst-mqueue3.c deleted file mode 100644 index 55f9fc0dce..0000000000 --- a/rt/tst-mqueue3.c +++ /dev/null @@ -1,243 +0,0 @@ -/* Test SIGEV_THREAD handling for POSIX message queues. - Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@redhat.com>, 2004. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <mqueue.h> -#include <signal.h> -#include <stddef.h> -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/mman.h> -#include <sys/wait.h> -#include <unistd.h> - -#if _POSIX_THREADS -# include <pthread.h> - -static pid_t pid; -static mqd_t m; -static const char message[] = "hello"; - -# define MAXMSG 10 -# define MSGSIZE 10 -# define UNIQUE 42 - - -static void -fct (union sigval s) -{ - /* Put the mq in non-blocking mode. */ - struct mq_attr attr; - if (mq_getattr (m, &attr) != 0) - { - printf ("%s: mq_getattr failed: %m\n", __FUNCTION__); - exit (1); - } - attr.mq_flags |= O_NONBLOCK; - if (mq_setattr (m, &attr, NULL) != 0) - { - printf ("%s: mq_setattr failed: %m\n", __FUNCTION__); - exit (1); - } - - /* Check the values. */ - if (attr.mq_maxmsg != MAXMSG) - { - printf ("%s: mq_maxmsg wrong: is %jd, expecte %d\n", - __FUNCTION__, (intmax_t) attr.mq_maxmsg, MAXMSG); - exit (1); - } - if (attr.mq_msgsize != MAXMSG) - { - printf ("%s: mq_msgsize wrong: is %jd, expecte %d\n", - __FUNCTION__, (intmax_t) attr.mq_msgsize, MSGSIZE); - exit (1); - } - - /* Read the message. */ - char buf[attr.mq_msgsize]; - ssize_t n = TEMP_FAILURE_RETRY (mq_receive (m, buf, attr.mq_msgsize, NULL)); - if (n != sizeof (message)) - { - printf ("%s: length of message wrong: is %zd, expected %zu\n", - __FUNCTION__, n, sizeof (message)); - exit (1); - } - if (memcmp (buf, message, sizeof (message)) != 0) - { - printf ("%s: message wrong: is \"%s\", expected \"%s\"\n", - __FUNCTION__, buf, message); - exit (1); - } - - exit (UNIQUE); -} - - -int -do_test (void) -{ - char tmpfname[] = "/tmp/tst-mqueue3-barrier.XXXXXX"; - int fd = mkstemp (tmpfname); - if (fd == -1) - { - printf ("cannot open temporary file: %m\n"); - return 1; - } - - /* Make sure it is always removed. */ - unlink (tmpfname); - - /* Create one page of data. */ - size_t ps = sysconf (_SC_PAGESIZE); - char data[ps]; - memset (data, '\0', ps); - - /* Write the data to the file. */ - if (write (fd, data, ps) != (ssize_t) ps) - { - puts ("short write"); - return 1; - } - - void *mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (mem == MAP_FAILED) - { - printf ("mmap failed: %m\n"); - return 1; - } - - pthread_barrier_t *b; - b = (pthread_barrier_t *) (((uintptr_t) mem + __alignof (pthread_barrier_t)) - & ~(__alignof (pthread_barrier_t) - 1)); - - pthread_barrierattr_t a; - if (pthread_barrierattr_init (&a) != 0) - { - puts ("barrierattr_init failed"); - return 1; - } - - if (pthread_barrierattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0) - { - puts ("barrierattr_setpshared failed, could not test"); - return 0; - } - - if (pthread_barrier_init (b, &a, 2) != 0) - { - puts ("barrier_init failed"); - return 1; - } - - if (pthread_barrierattr_destroy (&a) != 0) - { - puts ("barrierattr_destroy failed"); - return 1; - } - - /* Name for the message queue. */ - char mqname[sizeof ("/tst-mqueue3-") + 3 * sizeof (pid_t)]; - snprintf (mqname, sizeof (mqname) - 1, "/tst-mqueue3-%ld", - (long int) getpid ()); - - /* Create the message queue. */ - struct mq_attr attr = { .mq_maxmsg = MAXMSG, .mq_msgsize = MSGSIZE }; - m = mq_open (mqname, O_CREAT | O_EXCL | O_RDWR, 0600, &attr); - if (m == -1) - { - if (errno == ENOSYS) - { - puts ("not implemented"); - return 0; - } - - puts ("mq_open failed"); - return 1; - } - - /* Unlink the message queue right away. */ - if (mq_unlink (mqname) != 0) - { - puts ("mq_unlink failed"); - return 1; - } - - pid = fork (); - if (pid == -1) - { - puts ("fork failed"); - return 1; - } - if (pid == 0) - { - /* Request notification via thread. */ - struct sigevent ev; - ev.sigev_notify = SIGEV_THREAD; - ev.sigev_notify_function = fct; - ev.sigev_value.sival_ptr = NULL; - ev.sigev_notify_attributes = NULL; - - /* Tell the kernel. */ - if (mq_notify (m,&ev) != 0) - { - puts ("mq_notify failed"); - exit (1); - } - - /* Tell the parent we are ready. */ - (void) pthread_barrier_wait (b); - - /* Make sure the process goes away eventually. */ - alarm (10); - - /* Do nothing forever. */ - while (1) - pause (); - } - - /* Wait for the child process to register to notification method. */ - (void) pthread_barrier_wait (b); - - /* Send the message. */ - if (mq_send (m, message, sizeof (message), 1) != 0) - { - kill (pid, SIGKILL); - puts ("mq_send failed"); - return 1; - } - - int r; - if (TEMP_FAILURE_RETRY (waitpid (pid, &r, 0)) != pid) - { - kill (pid, SIGKILL); - puts ("waitpid failed"); - return 1; - } - - return WIFEXITED (r) && WEXITSTATUS (r) == UNIQUE ? 0 : 1; -} -# define TEST_FUNCTION do_test () -#else -# define TEST_FUNCTION 0 -#endif - -#include "../test-skeleton.c" diff --git a/rt/tst-mqueue4.c b/rt/tst-mqueue4.c deleted file mode 100644 index 8992193cac..0000000000 --- a/rt/tst-mqueue4.c +++ /dev/null @@ -1,290 +0,0 @@ -/* Test message queue passing. - Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek <jakub@redhat.com>, 2004. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <fcntl.h> -#include <mqueue.h> -#include <limits.h> -#include <signal.h> -#include <stdio.h> -#include <stdint.h> -#include <stdlib.h> -#include <string.h> -#include <sys/time.h> -#include <sys/wait.h> -#include <time.h> -#include <unistd.h> -#include "tst-mqueue.h" - -#define TIMEOUT 4 -#define TEST_FUNCTION do_test () -static int -do_test (void) -{ - int result = 0; - - char name[sizeof "/tst-mqueue4-" + sizeof (pid_t) * 3 + NAME_MAX]; - char *p; - p = name + snprintf (name, sizeof (name), "/tst-mqueue4-%u", getpid ()); - struct mq_attr attr = { .mq_maxmsg = 2, .mq_msgsize = 2 }; - mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr); - - if (q == (mqd_t) -1) - { - printf ("mq_open failed with: %m\n"); - return result; - } - else - add_temp_mq (name); - - *p = '.'; - memset (p + 1, 'x', NAME_MAX + 1 - (p - name)); - name[NAME_MAX + 1] = '\0'; - - mqd_t q2 = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr); - if (q2 == (mqd_t) -1) - { - printf ("mq_open with NAME_MAX long name compoment failed with: %m\n"); - result = 1; - } - - if (mq_unlink (name) != 0) - { - printf ("mq_unlink failed: %m\n"); - result = 1; - } - - if (mq_close (q2) != 0) - { - printf ("mq_close failed: %m\n"); - result = 1; - } - - name[NAME_MAX + 1] = 'x'; - name[NAME_MAX + 2] = '\0'; - q2 = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr); - if (q2 != (mqd_t) -1) - { - puts ("mq_open with too long name component unexpectedly succeeded"); - mq_unlink (name); - mq_close (q2); - result = 1; - } - else if (errno != ENAMETOOLONG) - { - printf ("mq_open with too long name component did not fail with " - "ENAMETOOLONG: %m\n"); - result = 1; - } - - if (mq_unlink (name) == 0) - { - puts ("mq_unlink with too long name component unexpectedly succeeded"); - result = 1; - } - else if (errno != ENAMETOOLONG) - { - printf ("mq_unlink with too long name component did not fail with " - "ENAMETOOLONG: %m\n"); - result = 1; - } - - *p = '\0'; - attr.mq_maxmsg = 1; - attr.mq_msgsize = 3; - q2 = mq_open (name, O_CREAT | O_RDWR, 0600, &attr); - if (q2 == (mqd_t) -1) - { - printf ("mq_open without O_EXCL failed with %m\n"); - result = 1; - } - - char buf[3]; - strcpy (buf, "jk"); - if (mq_send (q, buf, 2, 4) != 0) - { - printf ("mq_send failed: %m\n"); - result = 1; - } - - if (mq_send (q, buf + 1, 1, 5) != 0) - { - printf ("mq_send failed: %m\n"); - result = 1; - } - - if (mq_getattr (q2, &attr) != 0) - { - printf ("mq_getattr failed: %m\n"); - result = 1; - } - - if ((attr.mq_flags & O_NONBLOCK) - || attr.mq_maxmsg != 2 - || attr.mq_msgsize != 2 - || attr.mq_curmsgs != 2) - { - printf ("mq_getattr returned unexpected { .mq_flags = %jd,\n" - ".mq_maxmsg = %jd, .mq_msgsize = %jd, .mq_curmsgs = %jd }\n", - (intmax_t) attr.mq_flags, (intmax_t) attr.mq_maxmsg, - (intmax_t) attr.mq_msgsize, (intmax_t) attr.mq_curmsgs); - result = 1; - } - - struct timespec ts; - if (clock_gettime (CLOCK_REALTIME, &ts) == 0) - ++ts.tv_sec; - else - { - ts.tv_sec = time (NULL) + 1; - ts.tv_nsec = 0; - } - - if (mq_timedsend (q2, buf, 1, 1, &ts) == 0) - { - puts ("mq_timedsend unexpectedly succeeded"); - result = 1; - } - else if (errno != ETIMEDOUT) - { - printf ("mq_timedsend did not fail with ETIMEDOUT: %m\n"); - result = 1; - } - - if (mq_close (q2) != 0) - { - printf ("mq_close failed: %m\n"); - result = 1; - } - - q2 = mq_open (name, O_RDONLY, 0600); - if (q2 == (mqd_t) -1) - { - printf ("mq_open without O_CREAT failed with %m\n"); - result = 1; - } - - mqd_t q3 = mq_open (name, O_RDONLY, 0600); - if (q3 == (mqd_t) -1) - { - printf ("mq_open without O_CREAT failed with %m\n"); - result = 1; - } - - memset (buf, ' ', sizeof (buf)); - - unsigned int prio; - ssize_t rets = mq_receive (q2, buf, 2, &prio); - if (rets != 1) - { - if (rets == -1) - printf ("mq_receive failed with: %m\n"); - else - printf ("mq_receive returned %zd != 1\n", rets); - result = 1; - } - else if (prio != 5 || memcmp (buf, "k ", 3) != 0) - { - printf ("mq_receive returned prio %u (2) buf \"%c%c%c\" (\"k \")\n", - prio, buf[0], buf[1], buf[2]); - result = 1; - } - - if (mq_getattr (q3, &attr) != 0) - { - printf ("mq_getattr failed: %m\n"); - result = 1; - } - - if ((attr.mq_flags & O_NONBLOCK) - || attr.mq_maxmsg != 2 - || attr.mq_msgsize != 2 - || attr.mq_curmsgs != 1) - { - printf ("mq_getattr returned unexpected { .mq_flags = %jd,\n" - ".mq_maxmsg = %jd, .mq_msgsize = %jd, .mq_curmsgs = %jd }\n", - (intmax_t) attr.mq_flags, (intmax_t) attr.mq_maxmsg, - (intmax_t) attr.mq_msgsize, (intmax_t) attr.mq_curmsgs); - result = 1; - } - - rets = mq_receive (q3, buf, 2, NULL); - if (rets != 2) - { - if (rets == -1) - printf ("mq_receive failed with: %m\n"); - else - printf ("mq_receive returned %zd != 2\n", rets); - result = 1; - } - else if (memcmp (buf, "jk ", 3) != 0) - { - printf ("mq_receive returned buf \"%c%c%c\" != \"jk \"\n", - buf[0], buf[1], buf[2]); - result = 1; - } - - if (clock_gettime (CLOCK_REALTIME, &ts) == 0) - ++ts.tv_sec; - else - { - ts.tv_sec = time (NULL) + 1; - ts.tv_nsec = 0; - } - - if (mq_timedreceive (q2, buf, 2, NULL, &ts) != -1) - { - puts ("mq_timedreceive on empty queue unexpectedly succeeded"); - result = 1; - } - else if (errno != ETIMEDOUT) - { - printf ("mq_timedreceive on empty queue did not fail with " - "ETIMEDOUT: %m\n"); - result = 1; - } - - if (mq_unlink (name) != 0) - { - printf ("mq_unlink failed: %m\n"); - result = 1; - } - - if (mq_close (q) != 0) - { - printf ("mq_close failed: %m\n"); - result = 1; - } - - if (mq_close (q2) != 0) - { - printf ("mq_close failed: %m\n"); - result = 1; - } - - if (mq_close (q3) != 0) - { - printf ("mq_close failed: %m\n"); - result = 1; - } - - return result; -} - -#include "../test-skeleton.c" diff --git a/rt/tst-mqueue5.c b/rt/tst-mqueue5.c deleted file mode 100644 index 814b0081c3..0000000000 --- a/rt/tst-mqueue5.c +++ /dev/null @@ -1,1030 +0,0 @@ -/* Test mq_notify. - Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek <jakub@redhat.com>, 2004. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <fcntl.h> -#include <mqueue.h> -#include <limits.h> -#include <signal.h> -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/mman.h> -#include <sys/time.h> -#include <sys/wait.h> -#include <time.h> -#include <unistd.h> -#include "tst-mqueue.h" - -#define TIMEOUT 3 - -#if _POSIX_THREADS && defined SIGRTMIN && defined SA_SIGINFO -# include <pthread.h> - -volatile int rtmin_cnt; -volatile pid_t rtmin_pid; -volatile uid_t rtmin_uid; -volatile int rtmin_code; -volatile union sigval rtmin_sigval; - -static void -rtmin_handler (int sig, siginfo_t *info, void *ctx) -{ - if (sig != SIGRTMIN) - abort (); - ++rtmin_cnt; - rtmin_pid = info->si_pid; - rtmin_uid = info->si_uid; - rtmin_code = info->si_code; - rtmin_sigval = info->si_value; -} - -#define mqsend(q) (mqsend) (q, __LINE__) -static int -(mqsend) (mqd_t q, int line) -{ - char c; - if (mq_send (q, &c, 1, 1) != 0) - { - printf ("mq_send on line %d failed with: %m\n", line); - return 1; - } - return 0; -} - -#define mqrecv(q) (mqrecv) (q, __LINE__) -static int -(mqrecv) (mqd_t q, int line) -{ - char c; - ssize_t rets = TEMP_FAILURE_RETRY (mq_receive (q, &c, 1, NULL)); - if (rets != 1) - { - if (rets == -1) - printf ("mq_receive on line %d failed with: %m\n", line); - else - printf ("mq_receive on line %d returned %zd != 1\n", - line, rets); - return 1; - } - return 0; -} - -struct thr_data -{ - const char *name; - pthread_barrier_t *b3; - mqd_t q; -}; - -static void * -thr (void *arg) -{ - pthread_barrier_t *b3 = ((struct thr_data *)arg)->b3; - mqd_t q = ((struct thr_data *)arg)->q; - const char *name = ((struct thr_data *)arg)->name; - int result = 0; - - result |= mqrecv (q); - - (void) pthread_barrier_wait (b3); - - /* Child verifies SIGRTMIN has not been sent. */ - - (void) pthread_barrier_wait (b3); - - /* Parent calls mqsend (q), which should trigger notification. */ - - (void) pthread_barrier_wait (b3); - - if (rtmin_cnt != 2) - { - puts ("SIGRTMIN signal in thread did not arrive"); - result = 1; - } - else if (rtmin_pid != getppid () - || rtmin_uid != getuid () - || rtmin_code != SI_MESGQ - || rtmin_sigval.sival_int != 0xdeadbeef) - { - printf ("unexpected siginfo_t fields: pid %u (%u), uid %u (%u), code %d (%d), si_int %d (%d)\n", - rtmin_pid, getppid (), rtmin_uid, getuid (), - rtmin_code, SI_MESGQ, rtmin_sigval.sival_int, 0xdeadbeef); - result = 1; - } - - struct sigevent ev; - memset (&ev, 0x82, sizeof (ev)); - ev.sigev_notify = SIGEV_NONE; - if (mq_notify (q, &ev) != 0) - { - printf ("mq_notify in thread (q, { SIGEV_NONE }) failed with: %m\n"); - result = 1; - } - - if (mq_notify (q, NULL) != 0) - { - printf ("mq_notify in thread (q, NULL) failed with: %m\n"); - result = 1; - } - - result |= mqrecv (q); - - (void) pthread_barrier_wait (b3); - - /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */ - - (void) pthread_barrier_wait (b3); - - if (mq_notify (q, NULL) != 0) - { - printf ("second mq_notify in thread (q, NULL) failed with: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b3); - - /* Parent calls mqsend (q), which should not trigger notification. */ - - (void) pthread_barrier_wait (b3); - - /* Child verifies SIGRTMIN has not been received. */ - /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */ - - (void) pthread_barrier_wait (b3); - - mqd_t q4 = mq_open (name, O_RDONLY); - if (q4 == (mqd_t) -1) - { - printf ("mq_open in thread failed with: %m\n"); - result = 1; - } - - if (mq_notify (q4, NULL) != 0) - { - printf ("mq_notify in thread (q4, NULL) failed with: %m\n"); - result = 1; - } - - if (mq_close (q4) != 0) - { - printf ("mq_close in thread failed with: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b3); - - /* Parent calls mqsend (q), which should not trigger notification. */ - - (void) pthread_barrier_wait (b3); - - /* Child verifies SIGRTMIN has not been received. */ - /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */ - - (void) pthread_barrier_wait (b3); - - mqd_t q5 = mq_open (name, O_WRONLY); - if (q5 == (mqd_t) -1) - { - printf ("mq_open O_WRONLY in thread failed with: %m\n"); - result = 1; - } - - if (mq_notify (q5, NULL) != 0) - { - printf ("mq_notify in thread (q5, NULL) failed with: %m\n"); - result = 1; - } - - if (mq_close (q5) != 0) - { - printf ("mq_close in thread failed with: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b3); - - /* Parent calls mqsend (q), which should not trigger notification. */ - - (void) pthread_barrier_wait (b3); - - /* Child verifies SIGRTMIN has not been received. */ - - return (void *) (long) result; -} - -static void -do_child (const char *name, pthread_barrier_t *b2, pthread_barrier_t *b3, - mqd_t q) -{ - int result = 0; - - struct sigevent ev; - memset (&ev, 0x55, sizeof (ev)); - ev.sigev_notify = SIGEV_SIGNAL; - ev.sigev_signo = SIGRTMIN; - ev.sigev_value.sival_ptr = &ev; - if (mq_notify (q, &ev) == 0) - { - puts ("first mq_notify in child (q, { SIGEV_SIGNAL }) unexpectedly succeeded"); - result = 1; - } - else if (errno != EBUSY) - { - printf ("first mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b2); - - /* Parent calls mqsend (q), which makes notification available. */ - - (void) pthread_barrier_wait (b2); - - rtmin_cnt = 0; - - if (mq_notify (q, &ev) != 0) - { - printf ("second mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n"); - result = 1; - } - - if (rtmin_cnt != 0) - { - puts ("SIGRTMIN signal in child caught too early"); - result = 1; - } - - (void) pthread_barrier_wait (b2); - - /* Parent unsuccessfully attempts to mq_notify. */ - /* Parent calls mqsend (q), which makes notification available - and triggers a signal in the child. */ - /* Parent successfully calls mq_notify SIGEV_SIGNAL. */ - - (void) pthread_barrier_wait (b2); - - if (rtmin_cnt != 1) - { - puts ("SIGRTMIN signal in child did not arrive"); - result = 1; - } - else if (rtmin_pid != getppid () - || rtmin_uid != getuid () - || rtmin_code != SI_MESGQ - || rtmin_sigval.sival_ptr != &ev) - { - printf ("unexpected siginfo_t fields: pid %u (%u), uid %u (%u), code %d (%d), si_ptr %p (%p)\n", - rtmin_pid, getppid (), rtmin_uid, getuid (), - rtmin_code, SI_MESGQ, rtmin_sigval.sival_ptr, &ev); - result = 1; - } - - result |= mqsend (q); - - (void) pthread_barrier_wait (b2); - - /* Parent verifies caught SIGRTMIN. */ - - mqd_t q2 = mq_open (name, O_RDWR); - if (q2 == (mqd_t) -1) - { - printf ("mq_open in child failed with: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b2); - - /* Parent mq_open's another mqd_t for the same queue (q3). */ - - memset (&ev, 0x11, sizeof (ev)); - ev.sigev_notify = SIGEV_SIGNAL; - ev.sigev_signo = SIGRTMIN; - ev.sigev_value.sival_ptr = &ev; - if (mq_notify (q2, &ev) != 0) - { - printf ("mq_notify in child (q2, { SIGEV_SIGNAL }) failed with: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b2); - - /* Parent unsuccessfully attempts to mq_notify { SIGEV_NONE } on q. */ - - (void) pthread_barrier_wait (b2); - - if (mq_close (q2) != 0) - { - printf ("mq_close failed: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b2); - - /* Parent successfully calls mq_notify { SIGEV_NONE } on q3. */ - - (void) pthread_barrier_wait (b2); - - memset (&ev, 0xbb, sizeof (ev)); - ev.sigev_notify = SIGEV_SIGNAL; - ev.sigev_signo = SIGRTMIN; - ev.sigev_value.sival_ptr = &b2; - if (mq_notify (q, &ev) == 0) - { - puts ("third mq_notify in child (q, { SIGEV_SIGNAL }) unexpectedly succeeded"); - result = 1; - } - else if (errno != EBUSY) - { - printf ("third mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b2); - - /* Parent calls mq_close on q3, which makes the queue available again for - notification. */ - - (void) pthread_barrier_wait (b2); - - memset (&ev, 0x13, sizeof (ev)); - ev.sigev_notify = SIGEV_NONE; - if (mq_notify (q, &ev) != 0) - { - printf ("mq_notify in child (q, { SIGEV_NONE }) failed with: %m\n"); - result = 1; - } - - if (mq_notify (q, NULL) != 0) - { - printf ("mq_notify in child (q, NULL) failed with: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b2); - - struct thr_data thr_data = { .name = name, .b3 = b3, .q = q }; - pthread_t th; - int ret = pthread_create (&th, NULL, thr, &thr_data); - if (ret) - { - errno = ret; - printf ("pthread_created failed with: %m\n"); - result = 1; - } - - /* Wait till thr calls mq_receive on the empty queue q and blocks on it. */ - sleep (1); - - memset (&ev, 0x5f, sizeof (ev)); - ev.sigev_notify = SIGEV_SIGNAL; - ev.sigev_signo = SIGRTMIN; - ev.sigev_value.sival_int = 0xdeadbeef; - if (mq_notify (q, &ev) != 0) - { - printf ("fourth mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n"); - result = 1; - } - - /* Ensure the thr thread gets the signal, not us. */ - sigset_t set; - sigemptyset (&set); - sigaddset (&set, SIGRTMIN); - if (pthread_sigmask (SIG_BLOCK, &set, NULL)) - { - printf ("Failed to block SIGRTMIN in child: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b2); - - /* Parent calls mqsend (q), which should wake up mqrecv (q) - in the thread but no notification should be sent. */ - - (void) pthread_barrier_wait (b3); - - if (rtmin_cnt != 1) - { - puts ("SIGRTMIN signal caught while thr was blocked on mq_receive"); - result = 1; - } - - (void) pthread_barrier_wait (b3); - - /* Parent calls mqsend (q), which should trigger notification. */ - - (void) pthread_barrier_wait (b3); - - /* Thread verifies SIGRTMIN has been received. */ - /* Thread calls mq_notify (q, { SIGEV_NONE }) to verify notification is now - available for registration. */ - /* Thread calls mq_notify (q, NULL). */ - - (void) pthread_barrier_wait (b3); - - memset (&ev, 0x6a, sizeof (ev)); - ev.sigev_notify = SIGEV_SIGNAL; - ev.sigev_signo = SIGRTMIN; - ev.sigev_value.sival_ptr = do_child; - if (mq_notify (q, &ev) != 0) - { - printf ("fifth mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b3); - - /* Thread calls mq_notify (q, NULL), which should unregister the above - notification. */ - - (void) pthread_barrier_wait (b3); - - /* Parent calls mqsend (q), which should not trigger notification. */ - - (void) pthread_barrier_wait (b3); - - if (rtmin_cnt != 2) - { - puts ("SIGRTMIN signal caught while notification has been disabled"); - result = 1; - } - - memset (&ev, 0x7b, sizeof (ev)); - ev.sigev_notify = SIGEV_SIGNAL; - ev.sigev_signo = SIGRTMIN; - ev.sigev_value.sival_ptr = thr; - if (mq_notify (q, &ev) != 0) - { - printf ("sixth mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b3); - - /* Thread opens a new O_RDONLY mqd_t (q4). */ - /* Thread calls mq_notify (q4, NULL), which should unregister the above - notification. */ - /* Thread calls mq_close (q4). */ - - (void) pthread_barrier_wait (b3); - - /* Parent calls mqsend (q), which should not trigger notification. */ - - (void) pthread_barrier_wait (b3); - - if (rtmin_cnt != 2) - { - puts ("SIGRTMIN signal caught while notification has been disabled"); - result = 1; - } - - memset (&ev, 0xe1, sizeof (ev)); - ev.sigev_notify = SIGEV_SIGNAL; - ev.sigev_signo = SIGRTMIN; - ev.sigev_value.sival_int = 127; - if (mq_notify (q, &ev) != 0) - { - printf ("seventh mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b3); - - /* Thread opens a new O_WRONLY mqd_t (q5). */ - /* Thread calls mq_notify (q5, NULL), which should unregister the above - notification. */ - /* Thread calls mq_close (q5). */ - - (void) pthread_barrier_wait (b3); - - /* Parent calls mqsend (q), which should not trigger notification. */ - - (void) pthread_barrier_wait (b3); - - if (rtmin_cnt != 2) - { - puts ("SIGRTMIN signal caught while notification has been disabled"); - result = 1; - } - - /* Reenable test signals before cleaning up the thread. */ - if (pthread_sigmask (SIG_UNBLOCK, &set, NULL)) - { - printf ("Failed to unblock SIGRTMIN in child: %m\n"); - result = 1; - } - - void *thr_ret; - ret = pthread_join (th, &thr_ret); - if (ret) - { - errno = ret; - printf ("pthread_join failed: %m\n"); - result = 1; - } - else if (thr_ret) - result = 1; - - if (mq_close (q) != 0) - { - printf ("mq_close failed: %m\n"); - result = 1; - } - - exit (result); -} - -#define TEST_FUNCTION do_test () -static int -do_test (void) -{ - int result = 0; - - char tmpfname[] = "/tmp/tst-mqueue5-barrier.XXXXXX"; - int fd = mkstemp (tmpfname); - if (fd == -1) - { - printf ("cannot open temporary file: %m\n"); - return 1; - } - - /* Make sure it is always removed. */ - unlink (tmpfname); - - /* Create one page of data. */ - size_t ps = sysconf (_SC_PAGESIZE); - char data[ps]; - memset (data, '\0', ps); - - /* Write the data to the file. */ - if (write (fd, data, ps) != (ssize_t) ps) - { - puts ("short write"); - return 1; - } - - void *mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (mem == MAP_FAILED) - { - printf ("mmap failed: %m\n"); - return 1; - } - - pthread_barrier_t *b2; - b2 = (pthread_barrier_t *) (((uintptr_t) mem + __alignof (pthread_barrier_t)) - & ~(__alignof (pthread_barrier_t) - 1)); - - pthread_barrier_t *b3; - b3 = b2 + 1; - - pthread_barrierattr_t a; - if (pthread_barrierattr_init (&a) != 0) - { - puts ("barrierattr_init failed"); - return 1; - } - - if (pthread_barrierattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0) - { - puts ("barrierattr_setpshared failed, could not test"); - return 0; - } - - if (pthread_barrier_init (b2, &a, 2) != 0) - { - puts ("barrier_init failed"); - return 1; - } - - if (pthread_barrier_init (b3, &a, 3) != 0) - { - puts ("barrier_init failed"); - return 1; - } - - if (pthread_barrierattr_destroy (&a) != 0) - { - puts ("barrierattr_destroy failed"); - return 1; - } - - char name[sizeof "/tst-mqueue5-" + sizeof (pid_t) * 3]; - snprintf (name, sizeof (name), "/tst-mqueue5-%u", getpid ()); - - struct mq_attr attr = { .mq_maxmsg = 1, .mq_msgsize = 1 }; - mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr); - - if (q == (mqd_t) -1) - { - printf ("mq_open failed with: %m\n"); - return result; - } - else - add_temp_mq (name); - - struct sigevent ev; - memset (&ev, 0xaa, sizeof (ev)); - ev.sigev_notify = SIGEV_NONE; - if (mq_notify (q, &ev) != 0) - { - printf ("mq_notify (q, { SIGEV_NONE }) failed with: %m\n"); - result = 1; - } - - if (mq_notify (q, &ev) == 0) - { - puts ("second mq_notify (q, { SIGEV_NONE }) unexpectedly succeeded"); - result = 1; - } - else if (errno != EBUSY) - { - printf ("second mq_notify (q, { SIGEV_NONE }) failed with: %m\n"); - result = 1; - } - - result |= mqsend (q); - - if (mq_notify (q, &ev) != 0) - { - printf ("third mq_notify (q, { SIGEV_NONE }) failed with: %m\n"); - result = 1; - } - - result |= mqrecv (q); - - if (mq_notify (q, NULL) != 0) - { - printf ("mq_notify (q, NULL) failed with: %m\n"); - result = 1; - } - - if (mq_notify (q, NULL) != 0) - { - /* Implementation-defined behaviour, so don't fail, - just inform. */ - printf ("second mq_notify (q, NULL) failed with: %m\n"); - } - - struct sigaction sa = { .sa_sigaction = rtmin_handler, - .sa_flags = SA_SIGINFO }; - sigemptyset (&sa.sa_mask); - sigaction (SIGRTMIN, &sa, NULL); - - memset (&ev, 0x55, sizeof (ev)); - ev.sigev_notify = SIGEV_SIGNAL; - ev.sigev_signo = SIGRTMIN; - ev.sigev_value.sival_int = 26; - if (mq_notify (q, &ev) != 0) - { - printf ("mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n"); - result = 1; - } - - ev.sigev_value.sival_ptr = &ev; - if (mq_notify (q, &ev) == 0) - { - puts ("second mq_notify (q, { SIGEV_SIGNAL }) unexpectedly succeeded"); - result = 1; - } - else if (errno != EBUSY) - { - printf ("second mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n"); - result = 1; - } - - if (rtmin_cnt != 0) - { - puts ("SIGRTMIN signal caught too early"); - result = 1; - } - - result |= mqsend (q); - - if (rtmin_cnt != 1) - { - puts ("SIGRTMIN signal did not arrive"); - result = 1; - } - else if (rtmin_pid != getpid () - || rtmin_uid != getuid () - || rtmin_code != SI_MESGQ - || rtmin_sigval.sival_int != 26) - { - printf ("unexpected siginfo_t fields: pid %u (%u), uid %u (%u), code %d (%d), si_int %d (26)\n", - rtmin_pid, getpid (), rtmin_uid, getuid (), - rtmin_code, SI_MESGQ, rtmin_sigval.sival_int); - result = 1; - } - - ev.sigev_value.sival_int = 75; - if (mq_notify (q, &ev) != 0) - { - printf ("third mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n"); - result = 1; - } - - result |= mqrecv (q); - - if (mq_notify (q, NULL) != 0) - { - printf ("mq_notify (q, NULL) failed with: %m\n"); - result = 1; - } - - memset (&ev, 0x33, sizeof (ev)); - ev.sigev_notify = SIGEV_NONE; - if (mq_notify (q, &ev) != 0) - { - printf ("fourth mq_notify (q, { SIGEV_NONE }) failed with: %m\n"); - result = 1; - } - - pid_t pid = fork (); - if (pid == -1) - { - printf ("fork () failed: %m\n"); - mq_unlink (name); - return 1; - } - - if (pid == 0) - do_child (name, b2, b3, q); - - /* Child unsuccessfully attempts to mq_notify. */ - - (void) pthread_barrier_wait (b2); - - result |= mqsend (q); - - (void) pthread_barrier_wait (b2); - - /* Child successfully calls mq_notify SIGEV_SIGNAL now. */ - - result |= mqrecv (q); - - (void) pthread_barrier_wait (b2); - - memset (&ev, 0xbb, sizeof (ev)); - ev.sigev_notify = SIGEV_SIGNAL; - ev.sigev_signo = SIGRTMIN; - ev.sigev_value.sival_int = 15; - if (mq_notify (q, &ev) == 0) - { - puts ("fourth mq_notify (q, { SIGEV_SIGNAL }) unexpectedly succeeded"); - result = 1; - } - else if (errno != EBUSY) - { - printf ("fourth mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n"); - result = 1; - } - - result |= mqsend (q); - - if (mq_notify (q, &ev) != 0) - { - printf ("fifth mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n"); - result = 1; - } - - if (rtmin_cnt != 1) - { - puts ("SIGRTMIN signal caught too early"); - result = 1; - } - - result |= mqrecv (q); - - (void) pthread_barrier_wait (b2); - - /* Child verifies caught SIGRTMIN signal. */ - /* Child calls mq_send (q) which triggers SIGRTMIN signal here. */ - - (void) pthread_barrier_wait (b2); - - /* Child mq_open's another mqd_t for the same queue (q2). */ - - if (rtmin_cnt != 2) - { - puts ("SIGRTMIN signal did not arrive"); - result = 1; - } - else if (rtmin_pid != pid - || rtmin_uid != getuid () - || rtmin_code != SI_MESGQ - || rtmin_sigval.sival_int != 15) - { - printf ("unexpected siginfo_t fields: pid %u (%u), uid %u (%u), code %d (%d), si_int %d (15)\n", - rtmin_pid, pid, rtmin_uid, getuid (), - rtmin_code, SI_MESGQ, rtmin_sigval.sival_int); - result = 1; - } - - result |= mqrecv (q); - - (void) pthread_barrier_wait (b2); - - /* Child successfully calls mq_notify { SIGEV_SIGNAL } on q2. */ - - (void) pthread_barrier_wait (b2); - - memset (&ev, 0xbb, sizeof (ev)); - ev.sigev_notify = SIGEV_NONE; - if (mq_notify (q, &ev) == 0) - { - puts ("fifth mq_notify (q, { SIGEV_NONE }) unexpectedly succeeded"); - result = 1; - } - else if (errno != EBUSY) - { - printf ("fifth mq_notify (q, { SIGEV_NONE }) failed with: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b2); - - /* Child calls mq_close on q2, which makes the queue available again for - notification. */ - - mqd_t q3 = mq_open (name, O_RDWR); - if (q3 == (mqd_t) -1) - { - printf ("mq_open q3 in parent failed with: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b2); - - memset (&ev, 0x12, sizeof (ev)); - ev.sigev_notify = SIGEV_NONE; - if (mq_notify (q3, &ev) != 0) - { - printf ("mq_notify (q3, { SIGEV_NONE }) failed with: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b2); - - /* Child unsuccessfully attempts to mq_notify { SIGEV_SIGNAL } on q. */ - - (void) pthread_barrier_wait (b2); - - if (mq_close (q3) != 0) - { - printf ("mq_close failed: %m\n"); - result = 1; - } - - (void) pthread_barrier_wait (b2); - - /* Child successfully calls mq_notify { SIGEV_NONE } on q. */ - /* Child successfully calls mq_notify NULL on q. */ - - (void) pthread_barrier_wait (b2); - - /* Child creates new thread. */ - /* Thread blocks on mqrecv (q). */ - /* Child sleeps for 1sec so that thread has time to reach that point. */ - /* Child successfully calls mq_notify { SIGEV_SIGNAL } on q. */ - - (void) pthread_barrier_wait (b2); - - result |= mqsend (q); - - (void) pthread_barrier_wait (b3); - - /* Child verifies SIGRTMIN has not been sent. */ - - (void) pthread_barrier_wait (b3); - - result |= mqsend (q); - - (void) pthread_barrier_wait (b3); - - /* Thread verifies SIGRTMIN has been caught. */ - /* Thread calls mq_notify (q, { SIGEV_NONE }) to verify notification is now - available for registration. */ - /* Thread calls mq_notify (q, NULL). */ - - (void) pthread_barrier_wait (b3); - - /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */ - - (void) pthread_barrier_wait (b3); - - /* Thread calls mq_notify (q, NULL). */ - - (void) pthread_barrier_wait (b3); - - result |= mqsend (q); - result |= mqrecv (q); - - (void) pthread_barrier_wait (b3); - - /* Child verifies SIGRTMIN has not been sent. */ - /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */ - - (void) pthread_barrier_wait (b3); - - /* Thread opens a new O_RDONLY mqd_t (q4). */ - /* Thread calls mq_notify (q4, NULL). */ - /* Thread calls mq_close (q4). */ - - (void) pthread_barrier_wait (b3); - - result |= mqsend (q); - result |= mqrecv (q); - - (void) pthread_barrier_wait (b3); - - /* Child verifies SIGRTMIN has not been sent. */ - /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */ - - (void) pthread_barrier_wait (b3); - - /* Thread opens a new O_WRONLY mqd_t (q5). */ - /* Thread calls mq_notify (q5, NULL). */ - /* Thread calls mq_close (q5). */ - - (void) pthread_barrier_wait (b3); - - result |= mqsend (q); - result |= mqrecv (q); - - (void) pthread_barrier_wait (b3); - - /* Child verifies SIGRTMIN has not been sent. */ - - int status; - if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid) - { - puts ("waitpid failed"); - kill (pid, SIGKILL); - result = 1; - } - else if (!WIFEXITED (status) || WEXITSTATUS (status)) - { - printf ("child failed with status %d\n", status); - result = 1; - } - - if (mq_unlink (name) != 0) - { - printf ("mq_unlink failed: %m\n"); - result = 1; - } - - if (mq_close (q) != 0) - { - printf ("mq_close failed: %m\n"); - result = 1; - } - - if (mq_notify (q, NULL) == 0) - { - puts ("mq_notify on closed mqd_t unexpectedly succeeded"); - result = 1; - } - else if (errno != EBADF) - { - printf ("mq_notify on closed mqd_t did not fail with EBADF: %m\n"); - result = 1; - } - - memset (&ev, 0x55, sizeof (ev)); - ev.sigev_notify = SIGEV_NONE; - if (mq_notify (q, &ev) == 0) - { - puts ("mq_notify on closed mqd_t unexpectedly succeeded"); - result = 1; - } - else if (errno != EBADF) - { - printf ("mq_notify on closed mqd_t did not fail with EBADF: %m\n"); - result = 1; - } - - return result; -} -#else -# define TEST_FUNCTION 0 -#endif - -#include "../test-skeleton.c" diff --git a/rt/tst-mqueue6.c b/rt/tst-mqueue6.c deleted file mode 100644 index e6dc54f9e3..0000000000 --- a/rt/tst-mqueue6.c +++ /dev/null @@ -1,304 +0,0 @@ -/* Test mq_notify. - Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek <jakub@redhat.com>, 2004. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <fcntl.h> -#include <mqueue.h> -#include <limits.h> -#include <signal.h> -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/mman.h> -#include <sys/time.h> -#include <sys/wait.h> -#include <time.h> -#include <unistd.h> -#include "tst-mqueue.h" - -#if _POSIX_THREADS -# include <pthread.h> - -# define mqsend(q) (mqsend) (q, __LINE__) -static int -(mqsend) (mqd_t q, int line) -{ - char c; - if (mq_send (q, &c, 1, 1) != 0) - { - printf ("mq_send on line %d failed with: %m\n", line); - return 1; - } - return 0; -} - -# define mqrecv(q) (mqrecv) (q, __LINE__) -static int -(mqrecv) (mqd_t q, int line) -{ - char c; - ssize_t rets = TEMP_FAILURE_RETRY (mq_receive (q, &c, 1, NULL)); - if (rets != 1) - { - if (rets == -1) - printf ("mq_receive on line %d failed with: %m\n", line); - else - printf ("mq_receive on line %d returned %zd != 1\n", - line, rets); - return 1; - } - return 0; -} - -volatile int fct_cnt, fct_err; -size_t fct_guardsize; - -static void -fct (union sigval s) -{ - mqd_t q = *(mqd_t *) s.sival_ptr; - - pthread_attr_t nattr; - int ret = pthread_getattr_np (pthread_self (), &nattr); - if (ret) - { - errno = ret; - printf ("pthread_getattr_np failed: %m\n"); - fct_err = 1; - } - else - { - ret = pthread_attr_getguardsize (&nattr, &fct_guardsize); - if (ret) - { - errno = ret; - printf ("pthread_attr_getguardsize failed: %m\n"); - fct_err = 1; - } - if (pthread_attr_destroy (&nattr) != 0) - { - puts ("pthread_attr_destroy failed"); - fct_err = 1; - } - } - - ++fct_cnt; - fct_err |= mqsend (q); -} - -# define TEST_FUNCTION do_test () -static int -do_test (void) -{ - int result = 0; - - char name[sizeof "/tst-mqueue6-" + sizeof (pid_t) * 3]; - snprintf (name, sizeof (name), "/tst-mqueue6-%u", getpid ()); - - struct mq_attr attr = { .mq_maxmsg = 1, .mq_msgsize = 1 }; - mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr); - - if (q == (mqd_t) -1) - { - printf ("mq_open failed with: %m\n"); - return result; - } - else - add_temp_mq (name); - - pthread_attr_t nattr; - if (pthread_attr_init (&nattr) - || pthread_attr_setguardsize (&nattr, 0)) - { - puts ("pthread_attr_t setup failed"); - result = 1; - } - - fct_guardsize = 1; - - struct sigevent ev; - memset (&ev, 0xaa, sizeof (ev)); - ev.sigev_notify = SIGEV_THREAD; - ev.sigev_notify_function = fct; - ev.sigev_notify_attributes = &nattr; - ev.sigev_value.sival_ptr = &q; - if (mq_notify (q, &ev) != 0) - { - printf ("mq_notify (q, { SIGEV_THREAD }) failed with: %m\n"); - result = 1; - } - - size_t ps = sysconf (_SC_PAGESIZE); - if (pthread_attr_setguardsize (&nattr, 32 * ps)) - { - puts ("pthread_attr_t setup failed"); - result = 1; - } - - if (mq_notify (q, &ev) == 0) - { - puts ("second mq_notify (q, { SIGEV_NONE }) unexpectedly succeeded"); - result = 1; - } - else if (errno != EBUSY) - { - printf ("second mq_notify (q, { SIGEV_NONE }) failed with: %m\n"); - result = 1; - } - - if (fct_cnt != 0) - { - printf ("fct called too early (%d on %d)\n", fct_cnt, __LINE__); - result = 1; - } - - result |= mqsend (q); - - result |= mqrecv (q); - result |= mqrecv (q); - - if (fct_cnt != 1) - { - printf ("fct not called (%d on %d)\n", fct_cnt, __LINE__); - result = 1; - } - else if (fct_guardsize != 0) - { - printf ("fct_guardsize %zd != 0\n", fct_guardsize); - result = 1; - } - - if (mq_notify (q, &ev) != 0) - { - printf ("third mq_notify (q, { SIGEV_NONE }) failed with: %m\n"); - result = 1; - } - - if (mq_notify (q, NULL) != 0) - { - printf ("mq_notify (q, NULL) failed with: %m\n"); - result = 1; - } - - memset (&ev, 0x11, sizeof (ev)); - ev.sigev_notify = SIGEV_THREAD; - ev.sigev_notify_function = fct; - ev.sigev_notify_attributes = &nattr; - ev.sigev_value.sival_ptr = &q; - if (mq_notify (q, &ev) != 0) - { - printf ("mq_notify (q, { SIGEV_THREAD }) failed with: %m\n"); - result = 1; - } - - if (pthread_attr_setguardsize (&nattr, 0)) - { - puts ("pthread_attr_t setup failed"); - result = 1; - } - - if (mq_notify (q, &ev) == 0) - { - puts ("second mq_notify (q, { SIGEV_NONE }) unexpectedly succeeded"); - result = 1; - } - else if (errno != EBUSY) - { - printf ("second mq_notify (q, { SIGEV_NONE }) failed with: %m\n"); - result = 1; - } - - if (fct_cnt != 1) - { - printf ("fct called too early (%d on %d)\n", fct_cnt, __LINE__); - result = 1; - } - - result |= mqsend (q); - - result |= mqrecv (q); - result |= mqrecv (q); - - if (fct_cnt != 2) - { - printf ("fct not called (%d on %d)\n", fct_cnt, __LINE__); - result = 1; - } - else if (fct_guardsize != 32 * ps) - { - printf ("fct_guardsize %zd != %zd\n", fct_guardsize, 32 * ps); - result = 1; - } - - if (mq_notify (q, &ev) != 0) - { - printf ("third mq_notify (q, { SIGEV_NONE }) failed with: %m\n"); - result = 1; - } - - if (mq_notify (q, NULL) != 0) - { - printf ("mq_notify (q, NULL) failed with: %m\n"); - result = 1; - } - - if (pthread_attr_destroy (&nattr) != 0) - { - puts ("pthread_attr_destroy failed"); - result = 1; - } - - if (mq_unlink (name) != 0) - { - printf ("mq_unlink failed: %m\n"); - result = 1; - } - - if (mq_close (q) != 0) - { - printf ("mq_close failed: %m\n"); - result = 1; - } - - memset (&ev, 0x55, sizeof (ev)); - ev.sigev_notify = SIGEV_THREAD; - ev.sigev_notify_function = fct; - ev.sigev_notify_attributes = NULL; - ev.sigev_value.sival_int = 0; - if (mq_notify (q, &ev) == 0) - { - puts ("mq_notify on closed mqd_t unexpectedly succeeded"); - result = 1; - } - else if (errno != EBADF) - { - printf ("mq_notify on closed mqd_t did not fail with EBADF: %m\n"); - result = 1; - } - - if (fct_err) - result = 1; - return result; -} -#else -# define TEST_FUNCTION 0 -#endif - -#include "../test-skeleton.c" diff --git a/rt/tst-mqueue7.c b/rt/tst-mqueue7.c deleted file mode 100644 index 3680005ee2..0000000000 --- a/rt/tst-mqueue7.c +++ /dev/null @@ -1,108 +0,0 @@ -/* Test all open message queues descriptors are closed during exec*. - Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek <jakub@redhat.com>, 2004. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <fcntl.h> -#include <mqueue.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/wait.h> -#include <time.h> -#include <unistd.h> - -#define OPT_AFTEREXEC 20000 - -static mqd_t after_exec = (mqd_t) -1; - -#define CMDLINE_OPTIONS \ - { "after-exec", required_argument, NULL, OPT_AFTEREXEC }, - -#define CMDLINE_PROCESS \ - case OPT_AFTEREXEC: \ - after_exec = (mqd_t) strtoul (optarg, NULL, 0); \ - break; - -static int -do_after_exec (void) -{ - int result = 0; - - struct mq_attr attr; - if (mq_getattr (after_exec, &attr) == 0) - { - puts ("mq_getattr after exec unexpectedly succeeded"); - result = 1; - } - else if (errno != EBADF) - { - printf ("mq_getattr after exec did not fail with EBADF: %m\n"); - result = 1; - } - - return result; -} - -static int -do_test (int argc, char **argv) -{ - if (after_exec != (mqd_t) -1) - return do_after_exec (); - - char name[sizeof "/tst-mqueue7-" + sizeof (pid_t) * 3]; - snprintf (name, sizeof (name), "/tst-mqueue7-%u", getpid ()); - - struct mq_attr attr = { .mq_maxmsg = 10, .mq_msgsize = 1 }; - mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_WRONLY, 0600, &attr); - - if (q == (mqd_t) -1) - { - printf ("mq_open failed with: %m\n"); - return 0; - } - else if (mq_unlink (name) != 0) - { - printf ("mq_unlink failed with: %m\n"); - return 1; - } - - if (mq_getattr (q, &attr) != 0) - { - printf ("mq_getattr failed: %m\n"); - return 1; - } - - char after_exec_arg[sizeof "--after-exec=0x" + sizeof (long) * 3]; - snprintf (after_exec_arg, sizeof (after_exec_arg), - "--after-exec=0x%lx", (long) q); - - const char *newargv[argc + 2]; - for (int i = 1; i < argc; ++i) - newargv[i - 1] = argv[i]; - newargv[argc - 1] = "--direct"; - newargv[argc] = after_exec_arg; - newargv[argc + 1] = NULL; - - /* Verify that exec* has the effect of mq_close (q). */ - execv (newargv[0], (char * const *) newargv); - printf ("execv failed: %m\n"); - return 1; -} - -#include "../test-skeleton.c" diff --git a/rt/tst-mqueue8.c b/rt/tst-mqueue8.c deleted file mode 100644 index 70a0e87add..0000000000 --- a/rt/tst-mqueue8.c +++ /dev/null @@ -1,265 +0,0 @@ -/* Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek <jakub@redhat.com>, 2004. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <mqueue.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#if _POSIX_THREADS -# include <pthread.h> - -static pthread_barrier_t b; - -/* Cleanup handling test. */ -static int cl_called; - -static void -cl (void *arg) -{ - ++cl_called; -} - -#define TF_MQ_RECEIVE 0L -#define TF_MQ_TIMEDRECEIVE 1L -#define TF_MQ_SEND 2L -#define TF_MQ_TIMEDSEND 3L - -static const char *names[] - = { "mq_receive", "mq_timedreceive", "mq_send", "mq_timedsend" }; - -static mqd_t q; -static struct timespec never; - -static void * -tf (void *arg) -{ - int r = pthread_barrier_wait (&b); - if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - puts ("tf: barrier_wait failed"); - exit (1); - } - - pthread_cleanup_push (cl, NULL); - - char c = ' '; - - switch ((long) arg) - { - case TF_MQ_SEND: - TEMP_FAILURE_RETRY (mq_send (q, &c, 1, 1)); - break; - case TF_MQ_TIMEDSEND: - TEMP_FAILURE_RETRY (mq_timedsend (q, &c, 1, 1, &never)); - break; - case TF_MQ_RECEIVE: - TEMP_FAILURE_RETRY (mq_receive (q, &c, 1, NULL)); - break; - case TF_MQ_TIMEDRECEIVE: - TEMP_FAILURE_RETRY (mq_timedreceive (q, &c, 1, NULL, &never)); - break; - } - - pthread_cleanup_pop (0); - - printf ("tf: %s returned\n", names[(long) arg]); - - exit (1); -} - -#define TEST_FUNCTION do_test () -static int -do_test (void) -{ - char name[sizeof "/tst-mqueue8-" + sizeof (pid_t) * 3]; - snprintf (name, sizeof (name), "/tst-mqueue8-%u", getpid ()); - - struct mq_attr attr = { .mq_maxmsg = 1, .mq_msgsize = 1 }; - q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr); - - if (q == (mqd_t) -1) - { - printf ("mq_open failed with: %m\n"); - return 0; - } - - if (mq_unlink (name) != 0) - { - printf ("mq_unlink failed with: %m\n"); - return 1; - } - - if (pthread_barrier_init (&b, NULL, 2) != 0) - { - puts ("barrier_init failed"); - return 1; - } - - if (clock_gettime (CLOCK_REALTIME, &never) == 0) - never.tv_sec += 100; - else - { - never.tv_sec = time (NULL) + 100; - never.tv_nsec = 0; - } - - int result = 0; - for (long l = TF_MQ_RECEIVE; l <= TF_MQ_TIMEDSEND; ++l) - { - cl_called = 0; - - pthread_t th; - if (pthread_create (&th, NULL, tf, (void *) l) != 0) - { - printf ("1st %s create failed\n", names[l]); - result = 1; - continue; - } - - int r = pthread_barrier_wait (&b); - if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - puts ("barrier_wait failed"); - result = 1; - continue; - } - - struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 }; - while (nanosleep (&ts, &ts) != 0) - continue; - - printf ("going to cancel %s in-time\n", names[l]); - if (pthread_cancel (th) != 0) - { - printf ("1st cancel of %s failed\n", names[l]); - result = 1; - continue; - } - - void *status; - if (pthread_join (th, &status) != 0) - { - printf ("1st join of %s failed\n", names[l]); - result = 1; - continue; - } - if (status != PTHREAD_CANCELED) - { - printf ("1st %s thread not canceled\n", names[l]); - result = 1; - continue; - } - - if (cl_called == 0) - { - printf ("%s cleanup handler not called\n", names[l]); - result = 1; - continue; - } - if (cl_called > 1) - { - printf ("%s cleanup handler called more than once\n", names[l]); - result = 1; - continue; - } - - printf ("in-time %s cancellation succeeded\n", names[l]); - - cl_called = 0; - - if (pthread_create (&th, NULL, tf, (void *) l) != 0) - { - printf ("2nd %s create failed\n", names[l]); - result = 1; - continue; - } - - printf ("going to cancel %s early\n", names[l]); - if (pthread_cancel (th) != 0) - { - printf ("2nd cancel of %s failed\n", names[l]); - result = 1; - continue; - } - - r = pthread_barrier_wait (&b); - if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - puts ("barrier_wait failed"); - result = 1; - continue; - } - - if (pthread_join (th, &status) != 0) - { - printf ("2nd join of %s failed\n", names[l]); - result = 1; - continue; - } - if (status != PTHREAD_CANCELED) - { - printf ("2nd %s thread not canceled\n", names[l]); - result = 1; - continue; - } - - if (cl_called == 0) - { - printf ("%s cleanup handler not called\n", names[l]); - result = 1; - continue; - } - if (cl_called > 1) - { - printf ("%s cleanup handler called more than once\n", names[l]); - result = 1; - continue; - } - - printf ("early %s cancellation succeeded\n", names[l]); - - if (l == TF_MQ_TIMEDRECEIVE) - { - /* mq_receive and mq_timedreceive are tested on empty mq. - For mq_send and mq_timedsend we need to make it full. - If this fails, there is no point in doing further testing. */ - char c = ' '; - if (mq_send (q, &c, 1, 1) != 0) - { - printf ("mq_send failed: %m\n"); - result = 1; - break; - } - } - } - - if (mq_close (q) != 0) - { - printf ("mq_close failed: %m\n"); - result = 1; - } - - return result; -} -#else -# define TEST_FUNCTION 0 -#endif - -#include "../test-skeleton.c" diff --git a/rt/tst-mqueue9.c b/rt/tst-mqueue9.c deleted file mode 100644 index fdafca7a0e..0000000000 --- a/rt/tst-mqueue9.c +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek <jakub@redhat.com>, 2004. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <mqueue.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include "tst-mqueue.h" - -#define TEST_FUNCTION do_test () -static int -do_test (void) -{ - if (geteuid () != 0) - { - puts ("this test requires root"); - return 0; - } - - char name[sizeof "/tst-mqueue9-" + sizeof (pid_t) * 3]; - snprintf (name, sizeof (name), "/tst-mqueue9-%u", getpid ()); - - struct mq_attr attr = { .mq_maxmsg = 1, .mq_msgsize = 1 }; - mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr); - - if (q == (mqd_t) -1) - { - printf ("mq_open failed with: %m\n"); - return 0; - } - else - add_temp_mq (name); - - if (seteuid (1) != 0) - { - printf ("failed to seteuid (1): %m\n"); - mq_unlink (name); - return 0; - } - - int result = 0; - if (mq_unlink (name) == 0) - { - puts ("mq_unlink unexpectedly succeeded"); - result = 1; - } - else if (errno != EACCES) - { - printf ("mq_unlink did not fail with EACCES: %m\n"); - result = 1;; - } - - if (seteuid (0) != 0) - { - printf ("failed to seteuid (0): %m\n"); - result = 1; - } - - if (mq_unlink (name) != 0) - { - printf ("mq_unlink failed with: %m\n"); - result = 1; - } - - if (mq_close (q) != 0) - { - printf ("mq_close failed with: %m\n"); - result = 1; - } - - return result; -} - -#include "../test-skeleton.c" diff --git a/rt/tst-shm-cancel.c b/rt/tst-shm-cancel.c deleted file mode 100644 index ed1d7b8b37..0000000000 --- a/rt/tst-shm-cancel.c +++ /dev/null @@ -1,130 +0,0 @@ -/* Test for shm_open cancellation handling: BZ #18243. - Copyright (C) 2016-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <pthread.h> -#include <sys/mman.h> -#include <semaphore.h> -#include <stdio.h> -#include <fcntl.h> -#include <unistd.h> -#include <errno.h> -#include <stdlib.h> - -static sem_t sem; /* Use to sync with thread start. */ -static const char shm_name[] = "/glibc-shm_open-cancel"; - -static void -remove_shm (int status, void *arg) -{ - shm_unlink (shm_name); -} - -static void * -tf (void *arg) -{ - pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, 0); - - if (sem_wait (&sem) != 0) - { - printf ("error: sem_wait failed: %m"); - exit (1); - } - - if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, 0) != 0) - { - printf ("error: pthread_setcancelstate failed: %m"); - exit (1); - } - - /* Neither sem_unlink or sem_open should act on thread cancellation. */ - shm_unlink (shm_name); - on_exit (remove_shm, NULL); - - int fd = shm_open (shm_name, O_CREAT, 0600); - if (fd == -1) - { - int exit_code; - if (errno == ENOSYS || errno == EACCES) - exit_code = 77; - else - exit_code = 1; - exit (exit_code); - } - - if (pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, 0) != 0) - { - printf ("error: pthread_setcancelstate failed: %m"); - exit (1); - } - - if (close (fd) != 0) - { - printf ("error: pthread_setcancelstate failed: %m"); - exit (1); - } - - return NULL; -} - -static int -do_test (void) -{ - pthread_t td; - - if (sem_init (&sem, 0, 0)) - { - printf ("error: sem_init failed: %m\n"); - exit (1); - } - - if (pthread_create (&td, NULL, tf, NULL) != 0) - { - printf ("error: pthread_create failed: %m\n"); - exit (1); - } - - if (pthread_cancel (td) != 0) - { - printf ("error: pthread_cancel failed: %m\n"); - exit (1); - } - - if (sem_post (&sem) != 0) - { - printf ("error: sem_post failed: %m\n"); - exit (1); - } - - void *r; - if (pthread_join (td, &r) != 0) - { - printf ("error: pthread_join failed: %m\n"); - exit (1); - } - - if (r == PTHREAD_CANCELED) - { - puts ("error: pthread_join returned PTHREAD_CANCELED"); - exit (1); - } - - return 0; -} - -#define TEST_FUNCTION do_test () -#include <test-skeleton.c> diff --git a/rt/tst-shm.c b/rt/tst-shm.c deleted file mode 100644 index 978674837c..0000000000 --- a/rt/tst-shm.c +++ /dev/null @@ -1,211 +0,0 @@ -/* Test program for POSIX shm_* functions. - Copyright (C) 2000-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <error.h> -#include <fcntl.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <unistd.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <sys/wait.h> - - -/* We want to see output immediately. */ -#define STDOUT_UNBUFFERED - -static void -worker (int write_now) -{ - struct timespec ts; - struct stat64 st; - int i; - int fd = shm_open ("/glibc-shm-test", O_RDWR, 0600); - - if (fd == -1) - error (EXIT_FAILURE, 0, "failed to open shared memory object: shm_open"); - - char *mem; - - if (fd == -1) - exit (fd); - - if (fstat64 (fd, &st) == -1) - error (EXIT_FAILURE, 0, "stat failed"); - if (st.st_size != 4000) - error (EXIT_FAILURE, 0, "size incorrect"); - - mem = mmap (NULL, 4000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (mem == MAP_FAILED) - error (EXIT_FAILURE, 0, "mmap failed"); - - ts.tv_sec = 0; - ts.tv_nsec = 500000000; - - if (write_now) - for (i = 0; i <= 4; ++i) - mem[i] = i; - else - /* Wait until the first bytes of the memory region are 0, 1, 2, 3, 4. */ - while (1) - { - for (i = 0; i <= 4; ++i) - if (mem[i] != i) - break; - - if (i > 4) - /* OK, that's done. */ - break; - - nanosleep (&ts, NULL); - } - - if (!write_now) - for (i = 0; i <= 4; ++i) - mem[i] = 4 + i; - else - /* Wait until the first bytes of the memory region are 4, 5, 6, 7, 8. */ - while (1) - { - for (i = 0; i <= 4; ++i) - if (mem[i] != 4 + i) - break; - - if (i > 4) - /* OK, that's done. */ - break; - - nanosleep (&ts, NULL); - } - - if (munmap (mem, 4000) == -1) - error (EXIT_FAILURE, errno, "munmap"); - - close (fd); - - exit (0); -} - - -static int -do_test (void) -{ - int fd; - pid_t pid1; - pid_t pid2; - int status1; - int status2; - struct stat64 st; - - fd = shm_open ("/../escaped", O_RDWR | O_CREAT | O_TRUNC | O_EXCL, 0600); - if (fd != -1) - { - perror ("read file outside of SHMDIR directory"); - return 1; - } - - - /* Create the shared memory object. */ - fd = shm_open ("/glibc-shm-test", O_RDWR | O_CREAT | O_TRUNC | O_EXCL, 0600); - if (fd == -1) - { - /* If shm_open is unimplemented we skip the test. */ - if (errno == ENOSYS) - { - perror ("shm_open unimplemented. Test skipped."); - return 0; - } - else - error (EXIT_FAILURE, 0, "failed to create shared memory object: shm_open"); - } - - /* Size the object. We make it 4000 bytes long. */ - if (ftruncate (fd, 4000) == -1) - { - /* This failed. Must be a bug in the implementation of the - shared memory itself. */ - perror ("failed to size of shared memory object: ftruncate"); - close (fd); - shm_unlink ("/glibc-shm-test"); - return 0; - } - - if (fstat64 (fd, &st) == -1) - { - shm_unlink ("/glibc-shm-test"); - error (EXIT_FAILURE, 0, "initial stat failed"); - } - if (st.st_size != 4000) - { - shm_unlink ("/glibc-shm-test"); - error (EXIT_FAILURE, 0, "initial size not correct"); - } - - /* Spawn to processes which will do the work. */ - pid1 = fork (); - if (pid1 == 0) - worker (0); - else if (pid1 == -1) - { - /* Couldn't create a second process. */ - perror ("fork"); - close (fd); - shm_unlink ("/glibc-shm-test"); - return 0; - } - - pid2 = fork (); - if (pid2 == 0) - worker (1); - else if (pid2 == -1) - { - /* Couldn't create a second process. */ - int ignore; - perror ("fork"); - kill (pid1, SIGTERM); - waitpid (pid1, &ignore, 0); - close (fd); - shm_unlink ("/glibc-shm-test"); - return 0; - } - - /* Wait until the two processes are finished. */ - waitpid (pid1, &status1, 0); - waitpid (pid2, &status2, 0); - - /* Now we can unlink the shared object. */ - shm_unlink ("/glibc-shm-test"); - - return (!WIFEXITED (status1) || WEXITSTATUS (status1) != 0 - || !WIFEXITED (status2) || WEXITSTATUS (status2) != 0); -} - -static void -cleanup_handler (void) -{ - shm_unlink ("/glibc-shm-test"); -} - -#define CLEANUP_HANDLER cleanup_handler - -#include <support/test-driver.c> diff --git a/rt/tst-timer.c b/rt/tst-timer.c deleted file mode 100644 index ee72474f8b..0000000000 --- a/rt/tst-timer.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Tests for POSIX timer implementation. Dummy version. - Copyright (C) 2000-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <unistd.h> - -/* This file is only used if there is no other implementation and it should - means that there is no implementation of POSIX timers. */ -static int -do_test (void) -{ -#ifdef _POSIX_TIMERS - /* There should be a test. */ - return 1; -#else - return 0; -#endif -} - -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" diff --git a/rt/tst-timer2.c b/rt/tst-timer2.c deleted file mode 100644 index b2ce9879ec..0000000000 --- a/rt/tst-timer2.c +++ /dev/null @@ -1,64 +0,0 @@ -/* Test for crashing bugs when trying to create too many timers. */ - -#include <stdio.h> -#include <time.h> -#include <signal.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <unistd.h> - -#if _POSIX_THREADS -# include <pthread.h> - -void -thread (union sigval arg) -{ - puts ("Timeout"); -} - -int -do_test (void) -{ - int i, res; - timer_t timerId; - struct itimerspec itval; - struct sigevent sigev; - - itval.it_interval.tv_sec = 2; - itval.it_interval.tv_nsec = 0; - itval.it_value.tv_sec = 2; - itval.it_value.tv_nsec = 0; - - sigev.sigev_notify = SIGEV_THREAD; - sigev.sigev_notify_function = thread; - sigev.sigev_notify_attributes = NULL; - sigev.sigev_value.sival_ptr = (void *) &timerId; - - for (i = 0; i < 100; i++) - { - printf ("cnt = %d\n", i); - - if (timer_create (CLOCK_REALTIME, &sigev, &timerId) < 0) - { - perror ("timer_create"); - continue; - } - - res = timer_settime (timerId, 0, &itval, NULL); - if (res < 0) - perror ("timer_settime"); - - res = timer_delete (timerId); - if (res < 0) - perror ("timer_delete"); - } - - return 0; -} - -# define TEST_FUNCTION do_test () -#else -# define TEST_FUNCTION 0 -#endif - -#include "../test-skeleton.c" diff --git a/rt/tst-timer3.c b/rt/tst-timer3.c deleted file mode 100644 index 8113f66903..0000000000 --- a/rt/tst-timer3.c +++ /dev/null @@ -1,86 +0,0 @@ -/* Test for bogus per-thread deletion of timers. */ - -#include <stdio.h> -#include <error.h> -#include <time.h> -#include <signal.h> -#include <stdint.h> -#include <string.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <unistd.h> -#if _POSIX_THREADS -# include <pthread.h> - - -/* Creating timers in another thread should work too. */ -static void * -do_timer_create (void *arg) -{ - struct sigevent *const sigev = arg; - timer_t *const timerId = sigev->sigev_value.sival_ptr; - if (timer_create (CLOCK_REALTIME, sigev, timerId) < 0) - { - printf ("timer_create: %m\n"); - return NULL; - } - return timerId; -} - - -static int -do_test (void) -{ - int i, res; - timer_t timerId; - struct itimerspec itval; - struct sigevent sigev; - - itval.it_interval.tv_sec = 2; - itval.it_interval.tv_nsec = 0; - itval.it_value.tv_sec = 2; - itval.it_value.tv_nsec = 0; - - sigev.sigev_notify = SIGEV_SIGNAL; - sigev.sigev_signo = SIGALRM; - sigev.sigev_value.sival_ptr = (void *) &timerId; - - for (i = 0; i < 100; i++) - { - printf ("cnt = %d\n", i); - - pthread_t thr; - res = pthread_create (&thr, NULL, &do_timer_create, &sigev); - if (res) - { - printf ("pthread_create: %s\n", strerror (res)); - continue; - } - void *val; - res = pthread_join (thr, &val); - if (res) - { - printf ("pthread_join: %s\n", strerror (res)); - continue; - } - if (val == NULL) - continue; - - res = timer_settime (timerId, 0, &itval, NULL); - if (res < 0) - printf ("timer_settime: %m\n"); - - res = timer_delete (timerId); - if (res < 0) - printf ("timer_delete: %m\n"); - } - - return 0; -} - -# define TEST_FUNCTION do_test () -#else -# define TEST_FUNCTION 0 -#endif - -#include "../test-skeleton.c" diff --git a/rt/tst-timer4.c b/rt/tst-timer4.c deleted file mode 100644 index 55620d6f2b..0000000000 --- a/rt/tst-timer4.c +++ /dev/null @@ -1,653 +0,0 @@ -/* Tests for POSIX timer implementation. - Copyright (C) 2004-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek <jakub@redhat.com>, 2004 - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; see the file COPYING.LIB. If - not, see <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <signal.h> -#include <stdio.h> -#include <string.h> -#include <time.h> -#include <unistd.h> -#include <stdint.h> -#if _POSIX_THREADS && defined SA_SIGINFO -# include <pthread.h> - -# ifndef TEST_CLOCK -# define TEST_CLOCK CLOCK_REALTIME -# endif - -pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t cond = PTHREAD_COND_INITIALIZER; - -timer_t timer_none, timer_sig1, timer_sig2, timer_thr1, timer_thr2; - -int thr1_cnt, thr1_err; -union sigval thr1_sigval; -struct timespec thr1_ts; - -static void -thr1 (union sigval sigval) -{ - pthread_mutex_lock (&lock); - thr1_err = clock_gettime (TEST_CLOCK, &thr1_ts); - if (thr1_cnt >= 5) - { - struct itimerspec it = { }; - thr1_err |= timer_settime (timer_thr1, 0, &it, NULL); - } - thr1_sigval = sigval; - ++thr1_cnt; - pthread_cond_signal (&cond); - pthread_mutex_unlock (&lock); -} - -int thr2_cnt, thr2_err; -union sigval thr2_sigval; -size_t thr2_guardsize; -struct timespec thr2_ts; - -static void -thr2 (union sigval sigval) -{ - pthread_attr_t nattr; - int err = 0; - size_t guardsize = -1; - int ret = pthread_getattr_np (pthread_self (), &nattr); - if (ret) - { - errno = ret; - printf ("*** pthread_getattr_np failed: %m\n"); - err = 1; - } - else - { - ret = pthread_attr_getguardsize (&nattr, &guardsize); - if (ret) - { - errno = ret; - printf ("*** pthread_attr_getguardsize failed: %m\n"); - err = 1; - } - if (pthread_attr_destroy (&nattr) != 0) - { - puts ("*** pthread_attr_destroy failed"); - err = 1; - } - } - pthread_mutex_lock (&lock); - thr2_err = clock_gettime (TEST_CLOCK, &thr2_ts) | err; - if (thr2_cnt >= 5) - { - struct itimerspec it = { }; - thr2_err |= timer_settime (timer_thr2, 0, &it, NULL); - } - thr2_sigval = sigval; - ++thr2_cnt; - thr2_guardsize = guardsize; - pthread_cond_signal (&cond); - pthread_mutex_unlock (&lock); -} - -volatile int sig1_cnt, sig1_err; -volatile union sigval sig1_sigval; -struct timespec sig1_ts; - -static void -sig1_handler (int sig, siginfo_t *info, void *ctx) -{ - int err = 0; - if (sig != SIGRTMIN) err |= 1 << 0; - if (info->si_signo != SIGRTMIN) err |= 1 << 1; - if (info->si_code != SI_TIMER) err |= 1 << 2; - if (clock_gettime (TEST_CLOCK, &sig1_ts) != 0) - err |= 1 << 3; - if (sig1_cnt >= 5) - { - struct itimerspec it = { }; - if (timer_settime (timer_sig1, 0, &it, NULL)) - err |= 1 << 4; - } - sig1_err |= err; - sig1_sigval = info->si_value; - ++sig1_cnt; -} - -volatile int sig2_cnt, sig2_err; -volatile union sigval sig2_sigval; -struct timespec sig2_ts; - -static void -sig2_handler (int sig, siginfo_t *info, void *ctx) -{ - int err = 0; - if (sig != SIGRTMIN + 1) err |= 1 << 0; - if (info->si_signo != SIGRTMIN + 1) err |= 1 << 1; - if (info->si_code != SI_TIMER) err |= 1 << 2; - if (clock_gettime (TEST_CLOCK, &sig2_ts) != 0) - err |= 1 << 3; - if (sig2_cnt >= 5) - { - struct itimerspec it = { }; - if (timer_settime (timer_sig2, 0, &it, NULL)) - err |= 1 << 4; - } - sig2_err |= err; - sig2_sigval = info->si_value; - ++sig2_cnt; -} - -/* Check if end is later or equal to start + nsec. */ -static int -check_ts (const char *name, const struct timespec *start, - const struct timespec *end, long msec) -{ - struct timespec ts = *start; - - ts.tv_sec += msec / 1000000; - ts.tv_nsec += (msec % 1000000) * 1000; - if (ts.tv_nsec >= 1000000000) - { - ++ts.tv_sec; - ts.tv_nsec -= 1000000000; - } - if (end->tv_sec < ts.tv_sec - || (end->tv_sec == ts.tv_sec && end->tv_nsec < ts.tv_nsec)) - { - printf ("\ -*** timer %s invoked too soon: %ld.%09jd instead of expected %ld.%09jd\n", - name, (long) end->tv_sec, (intmax_t) end->tv_nsec, - (long) ts.tv_sec, (intmax_t) ts.tv_nsec); - return 1; - } - else - return 0; -} - -#define TIMEOUT 15 -#define TEST_FUNCTION do_test () -static int -do_test (void) -{ - int result = 0; - -#ifdef TEST_CLOCK_MISSING - const char *missing = TEST_CLOCK_MISSING (TEST_CLOCK); - if (missing != NULL) - { - printf ("%s missing, skipping test\n", missing); - return 0; - } -#endif - - struct timespec ts; - if (clock_gettime (TEST_CLOCK, &ts) != 0) - { - printf ("*** clock_gettime failed: %m\n"); - result = 1; - } - else - printf ("clock_gettime returned timespec = { %ld, %jd }\n", - (long) ts.tv_sec, (intmax_t) ts.tv_nsec); - - if (clock_getres (TEST_CLOCK, &ts) != 0) - { - printf ("*** clock_getres failed: %m\n"); - result = 1; - } - else - printf ("clock_getres returned timespec = { %ld, %jd }\n", - (long) ts.tv_sec, (intmax_t) ts.tv_nsec); - - struct sigevent ev; - memset (&ev, 0x11, sizeof (ev)); - ev.sigev_notify = SIGEV_NONE; - if (timer_create (TEST_CLOCK, &ev, &timer_none) != 0) - { - printf ("*** timer_create for timer_none failed: %m\n"); - return 1; - } - - struct sigaction sa = { .sa_sigaction = sig1_handler, - .sa_flags = SA_SIGINFO }; - sigemptyset (&sa.sa_mask); - sigaction (SIGRTMIN, &sa, NULL); - sa.sa_sigaction = sig2_handler; - sigaction (SIGRTMIN + 1, &sa, NULL); - - memset (&ev, 0x22, sizeof (ev)); - ev.sigev_notify = SIGEV_SIGNAL; - ev.sigev_signo = SIGRTMIN; - ev.sigev_value.sival_ptr = &ev; - if (timer_create (TEST_CLOCK, &ev, &timer_sig1) != 0) - { - printf ("*** timer_create for timer_sig1 failed: %m\n"); - return 1; - } - - memset (&ev, 0x33, sizeof (ev)); - ev.sigev_notify = SIGEV_SIGNAL; - ev.sigev_signo = SIGRTMIN + 1; - ev.sigev_value.sival_int = 163; - if (timer_create (TEST_CLOCK, &ev, &timer_sig2) != 0) - { - printf ("*** timer_create for timer_sig2 failed: %m\n"); - return 1; - } - - memset (&ev, 0x44, sizeof (ev)); - ev.sigev_notify = SIGEV_THREAD; - ev.sigev_notify_function = thr1; - ev.sigev_notify_attributes = NULL; - ev.sigev_value.sival_ptr = &ev; - if (timer_create (TEST_CLOCK, &ev, &timer_thr1) != 0) - { - printf ("*** timer_create for timer_thr1 failed: %m\n"); - return 1; - } - - pthread_attr_t nattr; - if (pthread_attr_init (&nattr) - || pthread_attr_setguardsize (&nattr, 0)) - { - puts ("*** pthread_attr_t setup failed"); - result = 1; - } - - memset (&ev, 0x55, sizeof (ev)); - ev.sigev_notify = SIGEV_THREAD; - ev.sigev_notify_function = thr2; - ev.sigev_notify_attributes = &nattr; - ev.sigev_value.sival_int = 111; - if (timer_create (TEST_CLOCK, &ev, &timer_thr2) != 0) - { - printf ("*** timer_create for timer_thr2 failed: %m\n"); - return 1; - } - - int ret = timer_getoverrun (timer_thr1); - if (ret != 0) - { - if (ret == -1) - printf ("*** timer_getoverrun failed: %m\n"); - else - printf ("*** timer_getoverrun returned %d != 0\n", ret); - result = 1; - } - - struct itimerspec it; - it.it_value.tv_sec = 0; - it.it_value.tv_nsec = -26; - it.it_interval.tv_sec = 0; - it.it_interval.tv_nsec = 0; - if (timer_settime (timer_sig1, 0, &it, NULL) == 0) - { - puts ("*** timer_settime with negative tv_nsec unexpectedly succeeded"); - result = 1; - } - else if (errno != EINVAL) - { - printf ("*** timer_settime with negative tv_nsec did not fail with " - "EINVAL: %m\n"); - result = 1; - } - - it.it_value.tv_nsec = 100000; - it.it_interval.tv_nsec = 1000000000; - if (timer_settime (timer_sig2, 0, &it, NULL) == 0) - { - puts ("\ -*** timer_settime with tv_nsec 1000000000 unexpectedly succeeded"); - result = 1; - } - else if (errno != EINVAL) - { - printf ("*** timer_settime with tv_nsec 1000000000 did not fail with " - "EINVAL: %m\n"); - result = 1; - } - -#if 0 - it.it_value.tv_nsec = 0; - it.it_interval.tv_nsec = -26; - if (timer_settime (timer_thr1, 0, &it, NULL) != 0) - { - printf ("\ -!!! timer_settime with it_value 0 it_interval invalid failed: %m\n"); - /* FIXME: is this mandated by POSIX? - result = 1; */ - } - - it.it_interval.tv_nsec = 3000000000; - if (timer_settime (timer_thr2, 0, &it, NULL) != 0) - { - printf ("\ -!!! timer_settime with it_value 0 it_interval invalid failed: %m\n"); - /* FIXME: is this mandated by POSIX? - result = 1; */ - } -#endif - - struct timespec startts; - if (clock_gettime (TEST_CLOCK, &startts) != 0) - { - printf ("*** clock_gettime failed: %m\n"); - result = 1; - } - - it.it_value.tv_nsec = 100000000; - it.it_interval.tv_nsec = 0; - if (timer_settime (timer_none, 0, &it, NULL) != 0) - { - printf ("*** timer_settime timer_none failed: %m\n"); - result = 1; - } - - it.it_value.tv_nsec = 200000000; - if (timer_settime (timer_thr1, 0, &it, NULL) != 0) - { - printf ("*** timer_settime timer_thr1 failed: %m\n"); - result = 1; - } - - it.it_value.tv_nsec = 300000000; - if (timer_settime (timer_thr2, 0, &it, NULL) != 0) - { - printf ("*** timer_settime timer_thr2 failed: %m\n"); - result = 1; - } - - it.it_value.tv_nsec = 400000000; - if (timer_settime (timer_sig1, 0, &it, NULL) != 0) - { - printf ("*** timer_settime timer_sig1 failed: %m\n"); - result = 1; - } - - it.it_value.tv_nsec = 500000000; - if (TEMP_FAILURE_RETRY (timer_settime (timer_sig2, 0, &it, NULL)) != 0) - { - printf ("*** timer_settime timer_sig2 failed: %m\n"); - result = 1; - } - - pthread_mutex_lock (&lock); - while (thr1_cnt == 0 || thr2_cnt == 0) - pthread_cond_wait (&cond, &lock); - pthread_mutex_unlock (&lock); - - while (sig1_cnt == 0 || sig2_cnt == 0) - { - ts.tv_sec = 0; - ts.tv_nsec = 100000000; - nanosleep (&ts, NULL); - } - - pthread_mutex_lock (&lock); - - if (thr1_cnt != 1) - { - printf ("*** thr1 not called exactly once, but %d times\n", thr1_cnt); - result = 1; - } - else if (thr1_err) - { - puts ("*** an error occurred in thr1"); - result = 1; - } - else if (thr1_sigval.sival_ptr != &ev) - { - printf ("*** thr1_sigval.sival_ptr %p != %p\n", - thr1_sigval.sival_ptr, &ev); - result = 1; - } - else if (check_ts ("thr1", &startts, &thr1_ts, 200000)) - result = 1; - - if (thr2_cnt != 1) - { - printf ("*** thr2 not called exactly once, but %d times\n", thr2_cnt); - result = 1; - } - else if (thr2_err) - { - puts ("*** an error occurred in thr2"); - result = 1; - } - else if (thr2_sigval.sival_int != 111) - { - printf ("*** thr2_sigval.sival_ptr %d != 111\n", thr2_sigval.sival_int); - result = 1; - } - else if (check_ts ("thr2", &startts, &thr2_ts, 300000)) - result = 1; - else if (thr2_guardsize != 0) - { - printf ("*** thr2 guardsize %zd != 0\n", thr2_guardsize); - result = 1; - } - - pthread_mutex_unlock (&lock); - - if (sig1_cnt != 1) - { - printf ("*** sig1 not called exactly once, but %d times\n", sig1_cnt); - result = 1; - } - else if (sig1_err) - { - printf ("*** errors occurred in sig1 handler %x\n", sig1_err); - result = 1; - } - else if (sig1_sigval.sival_ptr != &ev) - { - printf ("*** sig1_sigval.sival_ptr %p != %p\n", - sig1_sigval.sival_ptr, &ev); - result = 1; - } - else if (check_ts ("sig1", &startts, &sig1_ts, 400000)) - result = 1; - - if (sig2_cnt != 1) - { - printf ("*** sig2 not called exactly once, but %d times\n", sig2_cnt); - result = 1; - } - else if (sig2_err) - { - printf ("*** errors occurred in sig2 handler %x\n", sig2_err); - result = 1; - } - else if (sig2_sigval.sival_int != 163) - { - printf ("*** sig2_sigval.sival_ptr %d != 163\n", sig2_sigval.sival_int); - result = 1; - } - else if (check_ts ("sig2", &startts, &sig2_ts, 500000)) - result = 1; - - if (timer_gettime (timer_none, &it) != 0) - { - printf ("*** timer_gettime timer_none failed: %m\n"); - result = 1; - } - else if (it.it_value.tv_sec || it.it_value.tv_nsec - || it.it_interval.tv_sec || it.it_interval.tv_nsec) - { - printf ("\ -*** timer_gettime timer_none returned { %ld.%09jd, %ld.%09jd }\n", - (long) it.it_value.tv_sec, (intmax_t) it.it_value.tv_nsec, - (long) it.it_interval.tv_sec, (intmax_t) it.it_interval.tv_nsec); - result = 1; - } - - if (clock_gettime (TEST_CLOCK, &startts) != 0) - { - printf ("*** clock_gettime failed: %m\n"); - result = 1; - } - - it.it_value.tv_sec = 1; - it.it_value.tv_nsec = 0; - it.it_interval.tv_sec = 0; - it.it_interval.tv_nsec = 100000000; - if (timer_settime (timer_none, 0, &it, NULL) != 0) - { - printf ("*** timer_settime timer_none failed: %m\n"); - result = 1; - } - - it.it_value.tv_nsec = 100000000; - it.it_interval.tv_nsec = 200000000; - if (timer_settime (timer_thr1, 0, &it, NULL) != 0) - { - printf ("*** timer_settime timer_thr1 failed: %m\n"); - result = 1; - } - - it.it_value.tv_nsec = 200000000; - it.it_interval.tv_nsec = 300000000; - if (timer_settime (timer_thr2, 0, &it, NULL) != 0) - { - printf ("*** timer_settime timer_thr2 failed: %m\n"); - result = 1; - } - - it.it_value.tv_nsec = 300000000; - it.it_interval.tv_nsec = 400000000; - if (timer_settime (timer_sig1, 0, &it, NULL) != 0) - { - printf ("*** timer_settime timer_sig1 failed: %m\n"); - result = 1; - } - - it.it_value.tv_nsec = 400000000; - it.it_interval.tv_nsec = 500000000; - if (TEMP_FAILURE_RETRY (timer_settime (timer_sig2, 0, &it, NULL)) != 0) - { - printf ("*** timer_settime timer_sig2 failed: %m\n"); - result = 1; - } - - pthread_mutex_lock (&lock); - while (thr1_cnt < 6 || thr2_cnt < 6) - pthread_cond_wait (&cond, &lock); - pthread_mutex_unlock (&lock); - - while (sig1_cnt < 6 || sig2_cnt < 6) - { - ts.tv_sec = 0; - ts.tv_nsec = 100000000; - nanosleep (&ts, NULL); - } - - pthread_mutex_lock (&lock); - - if (thr1_err) - { - puts ("*** an error occurred in thr1"); - result = 1; - } - else if (check_ts ("thr1", &startts, &thr1_ts, 1100000 + 4 * 200000)) - result = 1; - - if (thr2_err) - { - puts ("*** an error occurred in thr2"); - result = 1; - } - else if (check_ts ("thr2", &startts, &thr2_ts, 1200000 + 4 * 300000)) - result = 1; - else if (thr2_guardsize != 0) - { - printf ("*** thr2 guardsize %zd != 0\n", thr2_guardsize); - result = 1; - } - - pthread_mutex_unlock (&lock); - - if (sig1_err) - { - printf ("*** errors occurred in sig1 handler %x\n", sig1_err); - result = 1; - } - else if (check_ts ("sig1", &startts, &sig1_ts, 1300000 + 4 * 400000)) - result = 1; - - if (sig2_err) - { - printf ("*** errors occurred in sig2 handler %x\n", sig2_err); - result = 1; - } - else if (check_ts ("sig2", &startts, &sig2_ts, 1400000 + 4 * 500000)) - result = 1; - - if (timer_gettime (timer_none, &it) != 0) - { - printf ("*** timer_gettime timer_none failed: %m\n"); - result = 1; - } - else if (it.it_interval.tv_sec || it.it_interval.tv_nsec != 100000000) - { - printf ("\ -!!! second timer_gettime timer_none returned it_interval %ld.%09jd\n", - (long) it.it_interval.tv_sec, (intmax_t) it.it_interval.tv_nsec); - /* FIXME: For now disabled. - result = 1; */ - } - - if (timer_delete (timer_none) != 0) - { - printf ("*** timer_delete for timer_none failed: %m\n"); - result = 1; - } - - if (timer_delete (timer_sig1) != 0) - { - printf ("*** timer_delete for timer_sig1 failed: %m\n"); - result = 1; - } - - if (timer_delete (timer_sig2) != 0) - { - printf ("*** timer_delete for timer_sig2 failed: %m\n"); - result = 1; - } - - if (timer_delete (timer_thr1) != 0) - { - printf ("*** timer_delete for timer_thr1 failed: %m\n"); - result = 1; - } - - if (timer_delete (timer_thr2) != 0) - { - printf ("*** timer_delete for timer_thr2 failed: %m\n"); - result = 1; - } - return result; -} - -#elif defined TEST_CLOCK_MISSING -/* This just ensures that any functions called in TEST_CLOCK_MISSING - are not diagnosed as unused. */ -# define TEST_FUNCTION (TEST_CLOCK_MISSING (TEST_CLOCK), 0) -#else -# define TEST_FUNCTION 0 -#endif - -#include "../test-skeleton.c" diff --git a/rt/tst-timer5.c b/rt/tst-timer5.c deleted file mode 100644 index 6466c8efc1..0000000000 --- a/rt/tst-timer5.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Timer test using the monotonic clock. */ - -#include <time.h> -#include <unistd.h> - -#if defined CLOCK_MONOTONIC && defined _POSIX_MONOTONIC_CLOCK - -# define TEST_CLOCK CLOCK_MONOTONIC -# define TEST_CLOCK_MISSING(clock) \ - (setup_test () ? "CLOCK_MONOTONIC" : NULL) - -# include <stdio.h> - -static int -setup_test (void) -{ - if (sysconf (_SC_MONOTONIC_CLOCK) <= 0) - return 1; - - /* The user-level timers implementation doesn't support CLOCK_MONOTONIC, - even though sysconf claims it will. */ - timer_t t; - if (timer_create (TEST_CLOCK, NULL, &t) != 0) - { - printf ("timer_create: %m\n"); - return 1; - } - timer_delete (t); - - return 0; -} - -# include "tst-timer4.c" - -#else -# define TEST_FUNCTION 0 -# include "../test-skeleton.c" -#endif |