xref: /netbsd/sys/compat/linux/common/linux_sched.h (revision 5390d158)
1*5390d158Sthorpej /*	$NetBSD: linux_sched.h,v 1.10 2021/09/19 23:51:37 thorpej Exp $	*/
2e2c674e2Sthorpej 
3e2c674e2Sthorpej /*-
4e2c674e2Sthorpej  * Copyright (c) 1999 The NetBSD Foundation, Inc.
5e2c674e2Sthorpej  * All rights reserved.
6e2c674e2Sthorpej  *
7e2c674e2Sthorpej  * This code is derived from software contributed to The NetBSD Foundation
8e2c674e2Sthorpej  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9e2c674e2Sthorpej  * NASA Ames Research Center.
10e2c674e2Sthorpej  *
11e2c674e2Sthorpej  * Redistribution and use in source and binary forms, with or without
12e2c674e2Sthorpej  * modification, are permitted provided that the following conditions
13e2c674e2Sthorpej  * are met:
14e2c674e2Sthorpej  * 1. Redistributions of source code must retain the above copyright
15e2c674e2Sthorpej  *    notice, this list of conditions and the following disclaimer.
16e2c674e2Sthorpej  * 2. Redistributions in binary form must reproduce the above copyright
17e2c674e2Sthorpej  *    notice, this list of conditions and the following disclaimer in the
18e2c674e2Sthorpej  *    documentation and/or other materials provided with the distribution.
19e2c674e2Sthorpej  *
20e2c674e2Sthorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21e2c674e2Sthorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22e2c674e2Sthorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23e2c674e2Sthorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24e2c674e2Sthorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25e2c674e2Sthorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26e2c674e2Sthorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27e2c674e2Sthorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28e2c674e2Sthorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29e2c674e2Sthorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30e2c674e2Sthorpej  * POSSIBILITY OF SUCH DAMAGE.
31e2c674e2Sthorpej  */
32e2c674e2Sthorpej 
33e2c674e2Sthorpej #ifndef _LINUX_SCHED_H
34e2c674e2Sthorpej #define	_LINUX_SCHED_H
35e2c674e2Sthorpej 
36e2c674e2Sthorpej /*
37e2c674e2Sthorpej  * Flags passed to the Linux __clone(2) system call.
38e2c674e2Sthorpej  */
39e2c674e2Sthorpej #define	LINUX_CLONE_CSIGNAL	0x000000ff	/* signal to be sent at exit */
40e2c674e2Sthorpej #define	LINUX_CLONE_VM		0x00000100	/* share address space */
41e2c674e2Sthorpej #define	LINUX_CLONE_FS		0x00000200	/* share "file system" info */
42e2c674e2Sthorpej #define	LINUX_CLONE_FILES	0x00000400	/* share file descriptors */
43e2c674e2Sthorpej #define	LINUX_CLONE_SIGHAND	0x00000800	/* share signal actions */
44e2c674e2Sthorpej #define	LINUX_CLONE_PID		0x00001000	/* share process ID */
45e2c674e2Sthorpej #define	LINUX_CLONE_PTRACE	0x00002000	/* ptrace(2) continues on
46e2c674e2Sthorpej 						   child */
47e2c674e2Sthorpej #define	LINUX_CLONE_VFORK	0x00004000	/* parent blocks until child
48e2c674e2Sthorpej 						   exits */
49bae3c8fbSjdolecek #define LINUX_CLONE_PARENT	0x00008000	/* want same parent as cloner */
50bae3c8fbSjdolecek #define LINUX_CLONE_THREAD	0x00010000	/* same thread group */
51bae3c8fbSjdolecek #define LINUX_CLONE_NEWNS	0x00020000	/* new namespace group */
52bae3c8fbSjdolecek #define LINUX_CLONE_SYSVSEM	0x00040000	/* share SysV SEM_UNDO */
53bae3c8fbSjdolecek #define LINUX_CLONE_SETTLS	0x00080000	/* create new TLS for child */
54bae3c8fbSjdolecek #define LINUX_CLONE_PARENT_SETTID \
55bae3c8fbSjdolecek 				0x00100000	/* set TID in the parent */
56bae3c8fbSjdolecek #define LINUX_CLONE_CHILD_CLEARTID \
57bae3c8fbSjdolecek 				0x00200000	/* clear TID in the child */
58bae3c8fbSjdolecek #define LINUX_CLONE_DETACHED	0x00400000	/* unused */
59bae3c8fbSjdolecek #define LINUX_CLONE_UNTRACED	0x00800000	/* set if parent cannot force CLONE_PTRACE */
60bae3c8fbSjdolecek #define LINUX_CLONE_CHILD_SETTID \
61bae3c8fbSjdolecek 				0x01000000	/* set TID in the child */
62bae3c8fbSjdolecek #define LINUX_CLONE_STOPPED	0x02000000	/* start in stopped state */
63e2c674e2Sthorpej 
649b451861Stron struct linux_sched_param {
659b451861Stron 	int	sched_priority;
669b451861Stron };
679b451861Stron 
689b451861Stron #define LINUX_SCHED_OTHER	0
699b451861Stron #define LINUX_SCHED_FIFO	1
709b451861Stron #define LINUX_SCHED_RR		2
719b451861Stron 
729b451861Stron struct linux_timespec {
739b451861Stron 	linux_time_t	tv_sec;		/* seconds */
749b451861Stron 	long		tv_nsec;	/* nanoseconds */
759b451861Stron };
769b451861Stron 
77a987d85cSthorpej struct linux_itimerspec {
78a987d85cSthorpej 	struct linux_timespec it_interval;
79a987d85cSthorpej 	struct linux_timespec it_value;
80a987d85cSthorpej };
81a987d85cSthorpej 
82046b9a57Sfvdl #define LINUX_CLOCK_REALTIME		0
83046b9a57Sfvdl #define LINUX_CLOCK_MONOTONIC		1
84046b9a57Sfvdl #define LINUX_CLOCK_PROCESS_CPUTIME_ID	2
85046b9a57Sfvdl #define LINUX_CLOCK_THREAD_CPUTIME_ID	3
86a987d85cSthorpej #define LINUX_CLOCK_MONOTONIC_RAW	4
87a987d85cSthorpej #define	LINUX_CLOCK_REALTIME_COARSE	5
88a987d85cSthorpej #define	LINUX_CLOCK_MONOTONIC_COARSE	6
89a987d85cSthorpej #define	LINUX_CLOCK_BOOTTIME		7
90a987d85cSthorpej #define	LINUX_CLOCK_BOOTTIME_ALARM	8
91a987d85cSthorpej #define	LINUX_CLOCK_REALTIME_ALARM	9
92a987d85cSthorpej 
93a987d85cSthorpej #define LINUX_TIMER_ABSTIME		0x01
94046b9a57Sfvdl 
95c007e33aSnjoly int	linux_to_native_clockid(clockid_t *, clockid_t);
96a987d85cSthorpej 
97a987d85cSthorpej void	native_to_linux_timespec(struct linux_timespec *,
98a987d85cSthorpej 	    const struct timespec *);
99a987d85cSthorpej void	linux_to_native_timespec(struct timespec *,
100a987d85cSthorpej 	    const struct linux_timespec *);
101a987d85cSthorpej 
102a987d85cSthorpej void	native_to_linux_itimerspec(struct linux_itimerspec *,
103a987d85cSthorpej 	    const struct itimerspec *);
104a987d85cSthorpej void	linux_to_native_itimerspec(struct itimerspec *,
105a987d85cSthorpej 	    const struct linux_itimerspec *);
106a987d85cSthorpej 
107a987d85cSthorpej int	linux_to_native_timer_create_clockid(clockid_t *, clockid_t);
108c007e33aSnjoly 
109*5390d158Sthorpej int	linux_to_native_timerfd_settime_flags(int *, int);
110*5390d158Sthorpej 
111e2c674e2Sthorpej #endif /* _LINUX_SCHED_H */
112