1 $NetBSD: patch-aa,v 1.12 2012/05/30 23:47:49 obache Exp $
3 ioctl() takes u_long argument on NetBSD.
4 On NetBSD<6 and 6.99.0-6.99.7, use third parameter in ioctl instead of varargs.
5 stat() system call has been versioned, use latest version when dlopen()ing.
6 Try more typical device names.
7 SOUND_PCM_* is not available on SunOS.
9 --- src/utils/padsp.c.orig 2012-07-16 11:37:55.000000000 +0000
13 #include <linux/sockios.h>
16 +#include <sys/param.h>
19 #include <pulse/pulseaudio.h>
20 #include <pulse/gccmacro.h>
21 @@ -115,7 +118,11 @@ static pthread_mutex_t func_mutex = PTHR
23 static PA_LLIST_HEAD(fd_info, fd_infos) = NULL;
26 +static int (*_ioctl)(int, u_long, void *) = NULL;
28 static int (*_ioctl)(int, int, void*) = NULL;
30 static int (*_close)(int) = NULL;
31 static int (*_open)(const char *, int, mode_t) = NULL;
32 static int (*___open_2)(const char *, int) = NULL;
33 @@ -143,6 +150,15 @@ static inline fnptr dlsym_fn(void *handl
34 return (fnptr) (long) dlsym(handle, symbol);
38 +#define LOAD_IOCTL_FUNC() \
40 + pthread_mutex_lock(&func_mutex); \
42 + _ioctl = (int (*)(int, u_long, void*)) dlsym_fn(RTLD_NEXT, "ioctl"); \
43 + pthread_mutex_unlock(&func_mutex); \
46 #define LOAD_IOCTL_FUNC() \
48 pthread_mutex_lock(&func_mutex); \
49 @@ -150,6 +166,7 @@ do { \
50 _ioctl = (int (*)(int, int, void*)) dlsym_fn(RTLD_NEXT, "ioctl"); \
51 pthread_mutex_unlock(&func_mutex); \
55 #define LOAD_OPEN_FUNC() \
57 @@ -199,11 +216,16 @@ do { \
58 pthread_mutex_unlock(&func_mutex); \
62 +#define STAT_FUNC "__stat30"
64 +#define STAT_FUNC "stat"
66 #define LOAD_STAT_FUNC() \
68 pthread_mutex_lock(&func_mutex); \
70 - _stat = (int (*)(const char *, struct stat *)) dlsym_fn(RTLD_NEXT, "stat"); \
71 + _stat = (int (*)(const char *, struct stat *)) dlsym_fn(RTLD_NEXT, STAT_FUNC); \
72 pthread_mutex_unlock(&func_mutex); \
75 @@ -2264,6 +2286,7 @@ static int dsp_ioctl(fd_info *i, unsigne
80 case SOUND_PCM_READ_RATE:
81 debug(DEBUG_LEVEL_NORMAL, __FILE__": SOUND_PCM_READ_RATE\n");
83 @@ -2288,6 +2311,7 @@ static int dsp_ioctl(fd_info *i, unsigne
84 pa_threaded_mainloop_unlock(i->mainloop);
88 case SNDCTL_DSP_GETOPTR: {
91 @@ -2357,21 +2381,35 @@ fail:
95 +/* NetBSD < 6 and 6.99.0 - 6.99.6 used a different ioctl() definition */
96 +#if defined(__NetBSD__) && (__NetBSD_Version__ < 600000000 || \
97 + (__NetBSD_Version__ > 699000000 && __NetBSD_Version__ < 699000700) )
98 +# define OLD_NETBSD_IOCTL_CALL
102 int ioctl(int fd, int request, ...) {
103 +#elif defined(OLD_NETBSD_IOCTL_CALL)
104 +int ioctl(int fd, u_long request, void *_argp) {
106 int ioctl(int fd, unsigned long request, ...) {
109 +#if !defined(OLD_NETBSD_IOCTL_CALL)
115 debug(DEBUG_LEVEL_VERBOSE, __FILE__": ioctl()\n");
117 +#if defined(OLD_NETBSD_IOCTL_CALL)
120 va_start(args, request);
121 argp = va_arg(args, void *);
125 if (!function_enter()) {