xref: /netbsd-src/lib/libc/compat/sys/compat__lwp_park.c (revision 85e843ca8392aa79901026ae66eb557e4cb50741)
1*85e843caSthorpej /*	$NetBSD: compat__lwp_park.c,v 1.3 2024/06/01 13:33:46 thorpej Exp $ */
2461a86f9Schristos 
3461a86f9Schristos /*-
4461a86f9Schristos  * Copyright (c) 2008 The NetBSD Foundation, Inc.
5461a86f9Schristos  * All rights reserved.
6461a86f9Schristos  *
7461a86f9Schristos  * This code is derived from software contributed to The NetBSD Foundation
8461a86f9Schristos  * by Christos Zoulas.
9461a86f9Schristos  *
10461a86f9Schristos  * Redistribution and use in source and binary forms, with or without
11461a86f9Schristos  * modification, are permitted provided that the following conditions
12461a86f9Schristos  * are met:
13461a86f9Schristos  * 1. Redistributions of source code must retain the above copyright
14461a86f9Schristos  *    notice, this list of conditions and the following disclaimer.
15461a86f9Schristos  * 2. Redistributions in binary form must reproduce the above copyright
16461a86f9Schristos  *    notice, this list of conditions and the following disclaimer in the
17461a86f9Schristos  *    documentation and/or other materials provided with the distribution.
18461a86f9Schristos  * 3. All advertising materials mentioning features or use of this software
19461a86f9Schristos  *    must display the following acknowledgement:
20461a86f9Schristos  *        This product includes software developed by the NetBSD
21461a86f9Schristos  *        Foundation, Inc. and its contributors.
22461a86f9Schristos  * 4. Neither the name of The NetBSD Foundation nor the names of its
23461a86f9Schristos  *    contributors may be used to endorse or promote products derived
24461a86f9Schristos  *    from this software without specific prior written permission.
25461a86f9Schristos  *
26461a86f9Schristos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27461a86f9Schristos  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28461a86f9Schristos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29461a86f9Schristos  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30461a86f9Schristos  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31461a86f9Schristos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32461a86f9Schristos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33461a86f9Schristos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34461a86f9Schristos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35461a86f9Schristos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36461a86f9Schristos  * POSSIBILITY OF SUCH DAMAGE.
37461a86f9Schristos  */
38461a86f9Schristos #include <sys/cdefs.h>
39461a86f9Schristos #if defined(LIBC_SCCS) && !defined(lint)
40*85e843caSthorpej __RCSID("$NetBSD: compat__lwp_park.c,v 1.3 2024/06/01 13:33:46 thorpej Exp $");
41461a86f9Schristos #endif /* LIBC_SCCS and not lint */
42461a86f9Schristos 
43461a86f9Schristos #include "namespace.h"
44461a86f9Schristos #define __LIBC12_SOURCE__
45461a86f9Schristos #include <sys/time.h>
46461a86f9Schristos #include <compat/sys/time.h>
47461a86f9Schristos #include <compat/include/lwp.h>
48461a86f9Schristos 
49461a86f9Schristos __warn_references(_lwp_park,
50461a86f9Schristos     "warning: reference to compatibility _lwp_park(); include <lwp.h> to generate correct reference")
51461a86f9Schristos 
52461a86f9Schristos /*
53461a86f9Schristos  * Copy timeout to local variable and call the syscall.
54461a86f9Schristos  */
55461a86f9Schristos int
_lwp_park(const struct timespec50 * ts50,lwpid_t unpark,const void * hint,const void * unparkhint)56461a86f9Schristos _lwp_park(const struct timespec50 *ts50, lwpid_t unpark,
57461a86f9Schristos     const void *hint, const void *unparkhint)
58461a86f9Schristos {
59461a86f9Schristos 	struct timespec ts, *tsp;
60461a86f9Schristos 
61461a86f9Schristos 	if (ts50)
62461a86f9Schristos 		timespec50_to_timespec(ts50, tsp = &ts);
63461a86f9Schristos 	else
64461a86f9Schristos 		tsp = NULL;
65461a86f9Schristos 	return ___lwp_park50(tsp, unpark, hint, unparkhint);
66461a86f9Schristos }
67