pthread_compat.c revision 1.1 1 1.1 ad /* $NetBSD: pthread_compat.c,v 1.1 2008/09/29 08:48:15 ad Exp $ */
2 1.1 ad
3 1.1 ad /*-
4 1.1 ad * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 1.1 ad * All rights reserved.
6 1.1 ad *
7 1.1 ad * This code is derived from software developed for The NetBSD Foundation
8 1.1 ad * by Andrew Doran.
9 1.1 ad *
10 1.1 ad * Redistribution and use in source and binary forms, with or without
11 1.1 ad * modification, are permitted provided that the following conditions
12 1.1 ad * are met:
13 1.1 ad * 1. Redistributions of source code must retain the above copyright
14 1.1 ad * notice, this list of conditions and the following disclaimer.
15 1.1 ad * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 ad * notice, this list of conditions and the following disclaimer in the
17 1.1 ad * documentation and/or other materials provided with the distribution.
18 1.1 ad *
19 1.1 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 ad * POSSIBILITY OF SUCH DAMAGE.
30 1.1 ad */
31 1.1 ad
32 1.1 ad #include <sys/cdefs.h>
33 1.1 ad __RCSID("$NetBSD: pthread_compat.c,v 1.1 2008/09/29 08:48:15 ad Exp $");
34 1.1 ad
35 1.1 ad #include <sys/param.h>
36 1.1 ad #include <sys/syscall.h>
37 1.1 ad
38 1.1 ad #include <lwp.h>
39 1.1 ad #include <unistd.h>
40 1.1 ad #include <sched.h>
41 1.1 ad
42 1.1 ad #include "pthread.h"
43 1.1 ad #include "pthread_int.h"
44 1.1 ad
45 1.1 ad static void __pthread_init(void) __attribute__((__constructor__, __used__));
46 1.1 ad
47 1.1 ad void __libc_thr_init(void);
48 1.1 ad void __libc_atomic_init(void);
49 1.1 ad int _sys_sched_yield(void);
50 1.1 ad
51 1.1 ad static void
52 1.1 ad __pthread_init(void)
53 1.1 ad {
54 1.1 ad
55 1.1 ad __libc_thr_init();
56 1.1 ad __libc_atomic_init();
57 1.1 ad }
58 1.1 ad
59 1.1 ad int
60 1.1 ad _lwp_kill(lwpid_t a, int b)
61 1.1 ad {
62 1.1 ad
63 1.1 ad return syscall(SYS__lwp_kill, a, b);
64 1.1 ad }
65 1.1 ad
66 1.1 ad int
67 1.1 ad _lwp_detach(lwpid_t a)
68 1.1 ad {
69 1.1 ad
70 1.1 ad return syscall(SYS__lwp_detach, a);
71 1.1 ad }
72 1.1 ad
73 1.1 ad int
74 1.1 ad _lwp_park(const struct timespec *a, lwpid_t b, const void *c, const void *d)
75 1.1 ad {
76 1.1 ad
77 1.1 ad return syscall(SYS__lwp_park, a, b, c, d);
78 1.1 ad }
79 1.1 ad
80 1.1 ad int
81 1.1 ad _lwp_unpark(lwpid_t a, const void *b)
82 1.1 ad {
83 1.1 ad
84 1.1 ad return syscall(SYS__lwp_unpark, a, b);
85 1.1 ad }
86 1.1 ad
87 1.1 ad ssize_t
88 1.1 ad _lwp_unpark_all(const lwpid_t *a, size_t b, const void *c)
89 1.1 ad {
90 1.1 ad
91 1.1 ad return syscall(SYS__lwp_unpark_all, a, b, c);
92 1.1 ad }
93 1.1 ad
94 1.1 ad int
95 1.1 ad _lwp_setname(lwpid_t a, const char *b)
96 1.1 ad {
97 1.1 ad
98 1.1 ad return syscall(SYS__lwp_setname, a, b);
99 1.1 ad }
100 1.1 ad
101 1.1 ad int
102 1.1 ad _lwp_getname(lwpid_t a, char *b, size_t c)
103 1.1 ad {
104 1.1 ad
105 1.1 ad return syscall(SYS__lwp_getname, a, b, c);
106 1.1 ad }
107 1.1 ad
108 1.1 ad int
109 1.1 ad _lwp_ctl(int a, struct lwpctl **b)
110 1.1 ad {
111 1.1 ad
112 1.1 ad return syscall(SYS__lwp_ctl, a, b);
113 1.1 ad }
114 1.1 ad
115 1.1 ad int
116 1.1 ad _sys_sched_yield(void)
117 1.1 ad {
118 1.1 ad
119 1.1 ad return syscall(SYS_sched_yield);
120 1.1 ad }
121 1.1 ad
122 1.1 ad int
123 1.1 ad sched_yield(void)
124 1.1 ad {
125 1.1 ad
126 1.1 ad return syscall(SYS_sched_yield);
127 1.1 ad }
128 1.1 ad
129 1.1 ad int
130 1.1 ad _sched_setaffinity(pid_t a, lwpid_t b, size_t c, const cpuset_t *d)
131 1.1 ad {
132 1.1 ad
133 1.1 ad return syscall(SYS__sched_setaffinity, a, b, c, d);
134 1.1 ad }
135 1.1 ad
136 1.1 ad int
137 1.1 ad _sched_getaffinity(pid_t a, lwpid_t b, size_t c, cpuset_t *d)
138 1.1 ad {
139 1.1 ad
140 1.1 ad return syscall(SYS__sched_getaffinity, a, b, c, d);
141 1.1 ad }
142 1.1 ad
143 1.1 ad int
144 1.1 ad _sched_setparam(pid_t a, lwpid_t b, int c, const struct sched_param *d)
145 1.1 ad {
146 1.1 ad
147 1.1 ad return syscall(SYS__sched_setparam, a, b, c, d);
148 1.1 ad }
149 1.1 ad
150 1.1 ad int
151 1.1 ad _sched_getparam(pid_t a, lwpid_t b, int *c, struct sched_param *d)
152 1.1 ad {
153 1.1 ad
154 1.1 ad return syscall(SYS__sched_getparam, a, b, c, d);
155 1.1 ad }
156