1 /* $NetBSD: rumpuser_pth_dummy.c,v 1.7 2009/11/19 14:44:58 pooka Exp $ */
4 * Copyright (c) 2009 Antti Kantee. All Rights Reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/cdefs.h>
30 __RCSID("$NetBSD: rumpuser_pth_dummy.c,v 1.7 2009/11/19 14:44:58 pooka Exp $");
42 #include <rump/rumpuser.h>
44 #include "rumpuser_int.h"
46 struct rumpuser_cv
{};
56 struct rumpuser_mtx rumpuser_aio_mtx
;
57 struct rumpuser_cv rumpuser_aio_cv
;
58 int rumpuser_aio_head
, rumpuser_aio_tail
;
59 struct rumpuser_aio rumpuser_aios
[N_AIOS
];
63 void donada(int arg
) {}
64 void dounnada(int, int *);
66 void dounnada(int arg
, int *ap
) {}
67 kernel_lockfn rumpuser__klock
= donada
;
68 kernel_unlockfn rumpuser__kunlock
= dounnada
;
72 rumpuser_thrinit(kernel_lockfn lockfn
, kernel_unlockfn unlockfn
, int threads
)
79 rumpuser_biothread(void *arg
)
82 fprintf(stderr
, "rumpuser: threads not available\n");
88 rumpuser_thread_create(void *(*f
)(void *), void *arg
, const char *thrname
)
91 fprintf(stderr
, "rumpuser: threads not available\n");
97 rumpuser_thread_exit(void)
103 rumpuser_mutex_init(struct rumpuser_mtx
**mtx
)
106 *mtx
= calloc(1, sizeof(struct rumpuser_mtx
));
110 rumpuser_mutex_recursive_init(struct rumpuser_mtx
**mtx
)
113 rumpuser_mutex_init(mtx
);
117 rumpuser_mutex_enter(struct rumpuser_mtx
*mtx
)
124 rumpuser_mutex_tryenter(struct rumpuser_mtx
*mtx
)
132 rumpuser_mutex_exit(struct rumpuser_mtx
*mtx
)
139 rumpuser_mutex_destroy(struct rumpuser_mtx
*mtx
)
146 rumpuser_mutex_held(struct rumpuser_mtx
*mtx
)
153 rumpuser_rw_init(struct rumpuser_rw
**rw
)
156 *rw
= calloc(1, sizeof(struct rumpuser_rw
));
160 rumpuser_rw_enter(struct rumpuser_rw
*rw
, int write
)
173 rumpuser_rw_tryenter(struct rumpuser_rw
*rw
, int write
)
176 rumpuser_rw_enter(rw
, write
);
181 rumpuser_rw_exit(struct rumpuser_rw
*rw
)
193 rumpuser_rw_destroy(struct rumpuser_rw
*rw
)
200 rumpuser_rw_held(struct rumpuser_rw
*rw
)
207 rumpuser_rw_rdheld(struct rumpuser_rw
*rw
)
214 rumpuser_rw_wrheld(struct rumpuser_rw
*rw
)
222 rumpuser_cv_init(struct rumpuser_cv
**cv
)
229 rumpuser_cv_destroy(struct rumpuser_cv
*cv
)
236 rumpuser_cv_wait(struct rumpuser_cv
*cv
, struct rumpuser_mtx
*mtx
)
243 rumpuser_cv_timedwait(struct rumpuser_cv
*cv
, struct rumpuser_mtx
*mtx
,
244 int64_t sec
, int64_t nsec
)
253 nanosleep(&ts
, NULL
);
259 rumpuser_cv_signal(struct rumpuser_cv
*cv
)
266 rumpuser_cv_broadcast(struct rumpuser_cv
*cv
)
273 rumpuser_cv_has_waiters(struct rumpuser_cv
*cv
)
283 static struct lwp
*curlwp
;
285 rumpuser_set_curlwp(struct lwp
*l
)
292 rumpuser_get_curlwp(void)