Add a thunk_atexit() so ucontext() ends can be dealt with as they shoulddiff -r1.17 -r1.18 src/sys/arch/usermode/include/thunk.h
(reinoud)
--- src/sys/arch/usermode/include/thunk.h 2011/08/25 11:06:29 1.17
+++ src/sys/arch/usermode/include/thunk.h 2011/08/27 21:14:15 1.18
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: thunk.h,v 1.17 2011/08/25 11:06:29 jmcneill Exp $ */ | 1 | /* $NetBSD: thunk.h,v 1.18 2011/08/27 21:14:15 reinoud Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca> | 4 | * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca> | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -67,26 +67,27 @@ void thunk_putchar(int); | @@ -67,26 +67,27 @@ void thunk_putchar(int); | |||
67 | 67 | |||
68 | int thunk_execv(const char *, char * const []); | 68 | int thunk_execv(const char *, char * const []); | |
69 | 69 | |||
70 | int thunk_open(const char *, int, mode_t); | 70 | int thunk_open(const char *, int, mode_t); | |
71 | int thunk_fstat_getsize(int, ssize_t *, ssize_t *); | 71 | int thunk_fstat_getsize(int, ssize_t *, ssize_t *); | |
72 | ssize_t thunk_pread(int, void *, size_t, off_t); | 72 | ssize_t thunk_pread(int, void *, size_t, off_t); | |
73 | ssize_t thunk_pwrite(int, const void *, size_t, off_t); | 73 | ssize_t thunk_pwrite(int, const void *, size_t, off_t); | |
74 | int thunk_fsync(int); | 74 | int thunk_fsync(int); | |
75 | int thunk_mkstemp(char *); | 75 | int thunk_mkstemp(char *); | |
76 | int thunk_unlink(const char *); | 76 | int thunk_unlink(const char *); | |
77 | 77 | |||
78 | int thunk_sigaction(int, const struct sigaction *, struct sigaction *); | 78 | int thunk_sigaction(int, const struct sigaction *, struct sigaction *); | |
79 | void thunk_signal(int, void (*)(int)); | 79 | void thunk_signal(int, void (*)(int)); | |
80 | int thunk_atexit(void (*function)(void)); | |||
80 | 81 | |||
81 | int thunk_aio_read(struct aiocb *); | 82 | int thunk_aio_read(struct aiocb *); | |
82 | int thunk_aio_write(struct aiocb *); | 83 | int thunk_aio_write(struct aiocb *); | |
83 | int thunk_aio_error(const struct aiocb *); | 84 | int thunk_aio_error(const struct aiocb *); | |
84 | int thunk_aio_return(struct aiocb *); | 85 | int thunk_aio_return(struct aiocb *); | |
85 | 86 | |||
86 | void * thunk_malloc(size_t len); | 87 | void * thunk_malloc(size_t len); | |
87 | void thunk_free(void *addr); | 88 | void thunk_free(void *addr); | |
88 | void * thunk_sbrk(intptr_t len); | 89 | void * thunk_sbrk(intptr_t len); | |
89 | void * thunk_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset); | 90 | void * thunk_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset); | |
90 | int thunk_munmap(void *addr, size_t len); | 91 | int thunk_munmap(void *addr, size_t len); | |
91 | int thunk_mprotect(void *addr, size_t len, int prot); | 92 | int thunk_mprotect(void *addr, size_t len, int prot); | |
92 | 93 |
--- src/sys/arch/usermode/usermode/thunk.c 2011/08/25 11:06:29 1.19
+++ src/sys/arch/usermode/usermode/thunk.c 2011/08/27 21:14:15 1.20
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: thunk.c,v 1.19 2011/08/25 11:06:29 jmcneill Exp $ */ | 1 | /* $NetBSD: thunk.c,v 1.20 2011/08/27 21:14:15 reinoud Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca> | 4 | * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca> | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -17,27 +17,27 @@ | @@ -17,27 +17,27 @@ | |||
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __RCSID("$NetBSD: thunk.c,v 1.19 2011/08/25 11:06:29 jmcneill Exp $"); | 30 | __RCSID("$NetBSD: thunk.c,v 1.20 2011/08/27 21:14:15 reinoud Exp $"); | |
31 | 31 | |||
32 | #include <sys/types.h> | 32 | #include <sys/types.h> | |
33 | #include <sys/ansi.h> | 33 | #include <sys/ansi.h> | |
34 | 34 | |||
35 | #include <aio.h> | 35 | #include <aio.h> | |
36 | #include <assert.h> | 36 | #include <assert.h> | |
37 | #include <fcntl.h> | 37 | #include <fcntl.h> | |
38 | #include <stdarg.h> | 38 | #include <stdarg.h> | |
39 | #include <stdint.h> | 39 | #include <stdint.h> | |
40 | #include <stdio.h> | 40 | #include <stdio.h> | |
41 | #include <stdlib.h> | 41 | #include <stdlib.h> | |
42 | #include <signal.h> | 42 | #include <signal.h> | |
43 | #include <time.h> | 43 | #include <time.h> | |
@@ -255,26 +255,32 @@ thunk_unlink(const char *path) | @@ -255,26 +255,32 @@ thunk_unlink(const char *path) | |||
255 | int | 255 | int | |
256 | thunk_sigaction(int sig, const struct sigaction *act, struct sigaction *oact) | 256 | thunk_sigaction(int sig, const struct sigaction *act, struct sigaction *oact) | |
257 | { | 257 | { | |
258 | return sigaction(sig, act, oact); | 258 | return sigaction(sig, act, oact); | |
259 | } | 259 | } | |
260 | 260 | |||
261 | void | 261 | void | |
262 | thunk_signal(int sig, void (*func)(int)) | 262 | thunk_signal(int sig, void (*func)(int)) | |
263 | { | 263 | { | |
264 | signal(sig, func); | 264 | signal(sig, func); | |
265 | } | 265 | } | |
266 | 266 | |||
267 | int | 267 | int | |
268 | thunk_atexit(void (*function)(void)) | |||
269 | { | |||
270 | return atexit(function); | |||
271 | } | |||
272 | ||||
273 | int | |||
268 | thunk_aio_read(struct aiocb *aiocbp) | 274 | thunk_aio_read(struct aiocb *aiocbp) | |
269 | { | 275 | { | |
270 | return aio_read(aiocbp); | 276 | return aio_read(aiocbp); | |
271 | } | 277 | } | |
272 | 278 | |||
273 | int | 279 | int | |
274 | thunk_aio_write(struct aiocb *aiocbp) | 280 | thunk_aio_write(struct aiocb *aiocbp) | |
275 | { | 281 | { | |
276 | return aio_write(aiocbp); | 282 | return aio_write(aiocbp); | |
277 | } | 283 | } | |
278 | 284 | |||
279 | int | 285 | int | |
280 | thunk_aio_error(const struct aiocb *aiocbp) | 286 | thunk_aio_error(const struct aiocb *aiocbp) |