| @@ -1,84 +1,82 @@ | | | @@ -1,84 +1,82 @@ |
1 | $NetBSD: patch-ab,v 1.5 2004/02/04 13:35:52 markd Exp $ | | 1 | $NetBSD: patch-ab,v 1.6 2012/05/15 13:18:43 abs Exp $ |
2 | | | 2 | |
3 | --- artsc/artsdsp.c.orig 2003-07-17 07:18:09.000000000 +1200 | | 3 | --- artsc/artsdsp.c.orig 2007-10-08 09:47:09.000000000 +0000 |
4 | +++ artsc/artsdsp.c | | 4 | +++ artsc/artsdsp.c |
5 | @@ -133,6 +133,14 @@ int munmap(void *start, size_t length); | | 5 | @@ -133,6 +133,17 @@ int munmap(void *start, size_t length); |
6 | | | 6 | |
7 | static void artsdsp_doinit() | | 7 | static void artsdsp_doinit() |
8 | { | | 8 | { |
9 | +# ifdef RTLD_NEXT | | 9 | +# if defined(__NetBSD__) && !defined(OPEN_SOUND_SYSTEM) |
| | | 10 | +# define OPEN_GLOBAL() handle = dlopen(NULL, DL_LAZY) |
| | | 11 | +# define CLOSE_GLOBAL() (void)dlclose(handle) |
| | | 12 | +# elif defined(RTLD_NEXT) |
10 | +# define OPEN_GLOBAL() handle = RTLD_NEXT; | | 13 | +# define OPEN_GLOBAL() handle = RTLD_NEXT; |
11 | +# define CLOSE_GLOBAL() ; | | 14 | +# define CLOSE_GLOBAL() ; |
12 | +# else | | 15 | +# else |
13 | +# define OPEN_GLOBAL() handle = dlopen(NULL, DL_LAZY); | | 16 | +# define OPEN_GLOBAL() handle = dlopen(NULL, DL_LAZY); |
14 | +# define CLOSE_GLOBAL() dlclose(handle); | | 17 | +# define CLOSE_GLOBAL() dlclose(handle); |
15 | +# endif | | 18 | +# endif |
16 | + void *handle; | | 19 | + void *handle; |
17 | const char *env; | | 20 | const char *env; |
18 | artsdsp_init = 1; | | 21 | artsdsp_init = 1; |
19 | | | 22 | |
20 | @@ -145,15 +153,31 @@ static void artsdsp_doinit() | | 23 | @@ -145,15 +156,17 @@ static void artsdsp_doinit() |
21 | mmapemu = env && !strcmp(env,"1"); | | 24 | mmapemu = env && !strcmp(env,"1"); |
22 | | | 25 | |
23 | /* resolve original symbols */ | | 26 | /* resolve original symbols */ |
24 | - orig_open = (orig_open_ptr)dlsym(RTLD_NEXT,"open"); | | 27 | - orig_open = (orig_open_ptr)dlsym(RTLD_NEXT,"open"); |
25 | - orig_close = (orig_close_ptr)dlsym(RTLD_NEXT,"close"); | | 28 | - orig_close = (orig_close_ptr)dlsym(RTLD_NEXT,"close"); |
26 | - orig_write = (orig_write_ptr)dlsym(RTLD_NEXT,"write"); | | 29 | - orig_write = (orig_write_ptr)dlsym(RTLD_NEXT,"write"); |
27 | - orig_read = (orig_read_ptr)dlsym(RTLD_NEXT,"read"); | | 30 | - orig_read = (orig_read_ptr)dlsym(RTLD_NEXT,"read"); |
28 | - orig_ioctl = (orig_ioctl_ptr)dlsym(RTLD_NEXT,"ioctl"); | | 31 | - orig_ioctl = (orig_ioctl_ptr)dlsym(RTLD_NEXT,"ioctl"); |
29 | - orig_mmap = (orig_mmap_ptr)dlsym(RTLD_NEXT,"mmap"); | | 32 | - orig_mmap = (orig_mmap_ptr)dlsym(RTLD_NEXT,"mmap"); |
30 | - orig_munmap = (orig_munmap_ptr)dlsym(RTLD_NEXT,"munmap"); | | 33 | - orig_munmap = (orig_munmap_ptr)dlsym(RTLD_NEXT,"munmap"); |
31 | - orig_fopen = (orig_fopen_ptr)dlsym(RTLD_NEXT,"fopen"); | | 34 | - orig_fopen = (orig_fopen_ptr)dlsym(RTLD_NEXT,"fopen"); |
32 | - orig_access = (orig_access_ptr)dlsym(RTLD_NEXT,"access"); | | 35 | - orig_access = (orig_access_ptr)dlsym(RTLD_NEXT,"access"); |
33 | +#if defined(__NetBSD__) && !defined(OPEN_SOUND_SYSTEM) | | | |
34 | + handle = dlopen(NULL, DL_LAZY); | | | |
35 | + orig_open = (orig_open_ptr)dlsym(handle,"open"); | | | |
36 | + orig_close = (orig_close_ptr)dlsym(handle,"close"); | | | |
37 | + orig_write = (orig_write_ptr)dlsym(handle,"write"); | | | |
38 | + orig_read = (orig_read_ptr)dlsym(handle,"read"); | | | |
39 | + orig_ioctl = (orig_ioctl_ptr)dlsym(handle,"ioctl"); | | | |
40 | + orig_mmap = (orig_mmap_ptr)dlsym(handle,"mmap"); | | | |
41 | + orig_munmap = (orig_munmap_ptr)dlsym(handle,"munmap"); | | | |
42 | + orig_fopen = (orig_fopen_ptr)dlsym(handle,"fopen"); | | | |
43 | + orig_access = (orig_access_ptr)dlsym(handle,"access"); | | | |
44 | + (void) dlclose(handle); | | | |
45 | +#else | | | |
46 | + OPEN_GLOBAL(); | | 36 | + OPEN_GLOBAL(); |
47 | + orig_open = (orig_open_ptr)dlsym(handle,"open"); | | 37 | + orig_open = (orig_open_ptr)dlsym(handle,"open"); |
48 | + orig_close = (orig_close_ptr)dlsym(handle,"close"); | | 38 | + orig_close = (orig_close_ptr)dlsym(handle,"close"); |
49 | + orig_write = (orig_write_ptr)dlsym(handle,"write"); | | 39 | + orig_write = (orig_write_ptr)dlsym(handle,"write"); |
50 | + orig_read = (orig_read_ptr)dlsym(handle,"read"); | | 40 | + orig_read = (orig_read_ptr)dlsym(handle,"read"); |
51 | + orig_ioctl = (orig_ioctl_ptr)dlsym(handle,"ioctl"); | | 41 | + orig_ioctl = (orig_ioctl_ptr)dlsym(handle,"ioctl"); |
52 | + orig_mmap = (orig_mmap_ptr)dlsym(handle,"mmap"); | | 42 | + orig_mmap = (orig_mmap_ptr)dlsym(handle,"mmap"); |
53 | + orig_munmap = (orig_munmap_ptr)dlsym(handle,"munmap"); | | 43 | + orig_munmap = (orig_munmap_ptr)dlsym(handle,"munmap"); |
54 | + orig_fopen = (orig_fopen_ptr)dlsym(handle,"fopen"); | | 44 | + orig_fopen = (orig_fopen_ptr)dlsym(handle,"fopen"); |
55 | + orig_access = (orig_access_ptr)dlsym(handle,"access"); | | 45 | + orig_access = (orig_access_ptr)dlsym(handle,"access"); |
56 | + CLOSE_GLOBAL(); | | 46 | + CLOSE_GLOBAL(); |
57 | +#endif | | | |
58 | } | | 47 | } |
59 | | | 48 | |
60 | static void | | 49 | static void |
61 | @@ -258,10 +282,15 @@ int open (const char *pathname, int flag | | 50 | @@ -258,10 +271,24 @@ int open (const char *pathname, int flag |
62 | return sndfd; | | 51 | return sndfd; |
63 | } | | 52 | } |
64 | | | 53 | |
65 | +#if defined(__NetBSD__) && !defined(OPEN_SOUND_SYSTEM) | | 54 | +/* NetBSD < 6 and 6.99.0 - 6.99.6 used a different ioctl() definition */ |
| | | 55 | +#if defined(__NetBSD__) |
| | | 56 | +# include <sys/param.h> |
| | | 57 | +# if __NetBSD_Version__ < 600000000 || \ |
| | | 58 | + (__NetBSD_Version__ > 699000000 && __NetBSD_Version__ < 699000700) |
| | | 59 | +# define OLD_NETBSD_IOCTL_CALL |
| | | 60 | +# endif |
| | | 61 | +#endif |
| | | 62 | + |
| | | 63 | +#if defined(OLD_NETBSD_IOCTL_CALL) && !defined(OPEN_SOUND_SYSTEM) |
66 | +int _oss_ioctl (int fd, unsigned long request, void *argp) | | 64 | +int _oss_ioctl (int fd, unsigned long request, void *argp) |
67 | +#else | | 65 | +#else |
68 | int ioctl (int fd, ioctl_request_t request, ...) | | 66 | int ioctl (int fd, ioctl_request_t request, ...) |
69 | +#endif | | 67 | +#endif |
70 | { | | 68 | { |
71 | int space, size, latency, odelay; | | 69 | int space, size, latency, odelay; |
72 | | | 70 | |
73 | +#if !defined(__NetBSD__) || defined(OPEN_SOUND_SYSTEM) | | 71 | +#if !defined(OLD_NETBSD_IOCTL_CALL) || defined(OPEN_SOUND_SYSTEM) |
74 | /* | | 72 | /* |
75 | * FreeBSD needs ioctl with varargs. However I have no idea how to "forward" | | 73 | * FreeBSD needs ioctl with varargs. However I have no idea how to "forward" |
76 | * the variable args ioctl to the orig_ioctl routine. So I expect the ioctl | | 74 | * the variable args ioctl to the orig_ioctl routine. So I expect the ioctl |
77 | @@ -273,6 +302,7 @@ int ioctl (int fd, ioctl_request_t reque | | 75 | @@ -273,6 +300,7 @@ int ioctl (int fd, ioctl_request_t reque |
78 | va_start(args,request); | | 76 | va_start(args,request); |
79 | argp = va_arg(args, void *); | | 77 | argp = va_arg(args, void *); |
80 | va_end(args); | | 78 | va_end(args); |
81 | +#endif | | 79 | +#endif |
82 | | | 80 | |
83 | CHECK_INIT(); | | 81 | CHECK_INIT(); |
84 | | | 82 | |