Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / audio / pulseaudio / patches / patch-aa
bloba9f2edceb67242e8a826f9b89903a7b0db599bcd
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
10 +++ src/utils/padsp.c
11 @@ -49,6 +49,9 @@
12  #ifdef __linux__
13  #include <linux/sockios.h>
14  #endif
15 +#ifdef __NetBSD__
16 +#include <sys/param.h>
17 +#endif
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;
25 +#ifdef __NetBSD__
26 +static int (*_ioctl)(int, u_long, void *) = NULL;
27 +#else
28  static int (*_ioctl)(int, int, void*) = NULL;
29 +#endif
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);
35  }
37 +#ifdef __NetBSD__
38 +#define LOAD_IOCTL_FUNC() \
39 +do { \
40 +    pthread_mutex_lock(&func_mutex); \
41 +    if (!_ioctl)  \
42 +       _ioctl = (int (*)(int, u_long, void*)) dlsym_fn(RTLD_NEXT, "ioctl"); \
43 +    pthread_mutex_unlock(&func_mutex); \
44 +} while(0)
45 +#else
46  #define LOAD_IOCTL_FUNC() \
47  do { \
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); \
52  } while(0)
53 +#endif
55  #define LOAD_OPEN_FUNC() \
56  do { \
57 @@ -199,11 +216,16 @@ do { \
58      pthread_mutex_unlock(&func_mutex); \
59  } while(0)
61 +#ifdef __NetBSD__
62 +#define STAT_FUNC "__stat30"
63 +#else
64 +#define STAT_FUNC "stat"
65 +#endif
66  #define LOAD_STAT_FUNC() \
67  do { \
68      pthread_mutex_lock(&func_mutex); \
69      if (!_stat) \
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); \
73  } while(0)
75 @@ -2264,6 +2286,7 @@ static int dsp_ioctl(fd_info *i, unsigne
76              break;
77          }
79 +#ifndef __sun
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);
85              break;
87 +#endif
88          case SNDCTL_DSP_GETOPTR: {
89              count_info *info;
91 @@ -2357,21 +2381,35 @@ fail:
92      return ret;
93  }
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
99 +#endif
101  #ifdef sun
102  int ioctl(int fd, int request, ...) {
103 +#elif defined(OLD_NETBSD_IOCTL_CALL)
104 +int ioctl(int fd, u_long request, void *_argp) {
105  #else
106  int ioctl(int fd, unsigned long request, ...) {
107  #endif
108      fd_info *i;
109 +#if !defined(OLD_NETBSD_IOCTL_CALL)
110      va_list args;
111 +#endif
112      void *argp;
113      int r, _errno = 0;
115      debug(DEBUG_LEVEL_VERBOSE, __FILE__": ioctl()\n");
117 +#if defined(OLD_NETBSD_IOCTL_CALL)
118 +    argp = _argp;
119 +#else
120      va_start(args, request);
121      argp = va_arg(args, void *);
122      va_end(args);
123 +#endif
125      if (!function_enter()) {
126          LOAD_IOCTL_FUNC();