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