1*461a86f9Schristos /* $NetBSD: sigtimedwait.c,v 1.3 2009/01/11 02:46:30 christos Exp $ */
2af3d346aSjdolecek
3af3d346aSjdolecek /*-
4af3d346aSjdolecek * Copyright (c) 2003 The NetBSD Foundation, Inc.
5af3d346aSjdolecek * All rights reserved.
6af3d346aSjdolecek *
7af3d346aSjdolecek * This code is derived from software contributed to The NetBSD Foundation
8af3d346aSjdolecek * by Jaromir Dolecek.
9af3d346aSjdolecek *
10af3d346aSjdolecek * Redistribution and use in source and binary forms, with or without
11af3d346aSjdolecek * modification, are permitted provided that the following conditions
12af3d346aSjdolecek * are met:
13af3d346aSjdolecek * 1. Redistributions of source code must retain the above copyright
14af3d346aSjdolecek * notice, this list of conditions and the following disclaimer.
15af3d346aSjdolecek * 2. Redistributions in binary form must reproduce the above copyright
16af3d346aSjdolecek * notice, this list of conditions and the following disclaimer in the
17af3d346aSjdolecek * documentation and/or other materials provided with the distribution.
18af3d346aSjdolecek *
19af3d346aSjdolecek * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20af3d346aSjdolecek * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21af3d346aSjdolecek * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22af3d346aSjdolecek * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23af3d346aSjdolecek * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24af3d346aSjdolecek * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25af3d346aSjdolecek * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26af3d346aSjdolecek * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27af3d346aSjdolecek * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28af3d346aSjdolecek * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29af3d346aSjdolecek * POSSIBILITY OF SUCH DAMAGE.
30af3d346aSjdolecek */
31af3d346aSjdolecek
32af3d346aSjdolecek #include <sys/cdefs.h>
33af3d346aSjdolecek #if defined(LIBC_SCCS) && !defined(lint)
34*461a86f9Schristos __RCSID("$NetBSD: sigtimedwait.c,v 1.3 2009/01/11 02:46:30 christos Exp $");
35af3d346aSjdolecek #endif /* LIBC_SCCS and not lint */
36af3d346aSjdolecek
37af3d346aSjdolecek #include "namespace.h"
38af3d346aSjdolecek #include <sys/types.h>
39af3d346aSjdolecek #include <sys/syscall.h>
40af3d346aSjdolecek #include <unistd.h>
41af3d346aSjdolecek #include <signal.h>
42af3d346aSjdolecek #include <time.h>
43af3d346aSjdolecek
44af3d346aSjdolecek /*
45af3d346aSjdolecek * Copy timeout to local variable and call the syscall.
46af3d346aSjdolecek */
47af3d346aSjdolecek int
sigtimedwait(const sigset_t * __restrict set,siginfo_t * __restrict info,const struct timespec * __restrict timeout)48*461a86f9Schristos sigtimedwait(const sigset_t * __restrict set, siginfo_t * __restrict info,
49af3d346aSjdolecek const struct timespec * __restrict timeout)
50af3d346aSjdolecek {
51af3d346aSjdolecek struct timespec ts;
52af3d346aSjdolecek
53af3d346aSjdolecek if (timeout) {
54af3d346aSjdolecek ts = *timeout;
55*461a86f9Schristos return __sigtimedwait(set, info, &ts);
56af3d346aSjdolecek } else
57*461a86f9Schristos return __sigtimedwait(set, info, NULL);
58af3d346aSjdolecek }
59