Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / audio / rio / patches / patch-ab
blob0359c782edd1a43381bb4f374bc86f3536f4170f
1 $NetBSD: patch-ab,v 1.3 2000/01/11 11:31:19 agc Exp $
3 Add NetBSD and Solaris platforms
4 Add inb() and outb() from XFree86 sources.
5 Add NetBSD/x86_64 support.
7 --- rio.cpp.orig        1999-06-11 12:26:46.000000000 -0400
8 +++ rio.cpp     2008-08-02 14:16:07.000000000 -0400
9 @@ -109,11 +109,101 @@
10         #define         CLOCK_SECOND                    ((int)CLOCKS_PER_SEC)
11         #define         DELETEARRAY                             delete
13 +#elif defined(__NetBSD__)
14 +       // NetBSD/i386,amd64 g++
15 +       #include        <fcntl.h>
16 +       #include        <unistd.h>
17 +       #include        <machine/sysarch.h>
18 +       //#include      <machine/cpufunc.h>
19 +       #define         OUTPORT(p,v)                    outb( p, v )
20 +       #define         INPORT(p)                               inb( p )
21 +       #define         CLOCK_SECOND                    CLOCKS_PER_SEC
22 +       #define         DELETEARRAY                             delete[]
24 +#elif defined(__sun__) && defined(__svr4__)
25 +       // Solaris/i386 g++
26 +       #include        <fcntl.h>
27 +       #include        <unistd.h>
28 +       #include        <sys/cpupart.h>
29 +       #include        <sys/cpuvar.h>
30 +       #include        <sys/ddi.h>
31 +       #include        <sys/sunddi.h>
32 +       #define         OUTPORT(p,v)                    outb( p, v )
33 +       #define         INPORT(p)                               inb( p )
34 +       #define         CLOCK_SECOND                    CLOCKS_PER_SEC
35 +       #define         DELETEARRAY                             delete[]
37  #else
38         // not supported
39         #error ! ! compiler/platform not supported ! !
40  #endif
42 +#if defined(__NetBSD__)
43 +/* copied from the XFree86 sources */
44 +/* xc/programs/Xserver/hw/xfree86/common/compiler.h */
45 +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.24.2.4 1998/10/18 20:42:10 hohndel Exp $ */
46 +/*
47 + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
48 + *
49 + * Permission to use, copy, modify, distribute, and sell this software and its
50 + * documentation for any purpose is hereby granted without fee, provided that
51 + * the above copyright notice appear in all copies and that both that
52 + * copyright notice and this permission notice appear in supporting
53 + * documentation, and that the name of Thomas Roell not be used in
54 + * advertising or publicity pertaining to distribution of the software without
55 + * specific, written prior permission.  Thomas Roell makes no representations
56 + * about the suitability of this software for any purpose.  It is provided
57 + * "as is" without express or implied warranty.
58 + *
59 + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
60 + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
61 + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
62 + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
63 + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
64 + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
65 + * PERFORMANCE OF THIS SOFTWARE.
66 + *
67 + */
68 +/* $XConsortium: compiler.h /main/16 1996/10/25 15:38:34 kaleb $ */
69 +/* also hacked by agc to do i386_iopl, and by dholland for x86_64_iopl */
70 +static int ports_enabled;
72 +static __inline__ unsigned int
73 +inb(unsigned short int port)
75 +       unsigned char   ret;
77 +       if (!ports_enabled) {
78 +#ifdef __i386__
79 +               i386_iopl(1);
80 +#endif
81 +#ifdef __x86_64__
82 +               x86_64_iopl(1);
83 +#endif
84 +               ports_enabled = 1;
85 +       }
86 +       __asm__ __volatile__("inb %1,%0" :
87 +               "=a" (ret) :
88 +               "d" (port));
89 +       return ret;
92 +static __inline__ void
93 +outb(unsigned short int port, unsigned char val)
95 +       if (!ports_enabled) {
96 +#ifdef __i386__
97 +               i386_iopl(1);
98 +#endif
99 +#ifdef __x86_64__
100 +               x86_64_iopl(1);
101 +#endif
102 +               ports_enabled = 1;
103 +       }
104 +       __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
106 +#endif
108  // port offset constants
109  #define                OFFSET_PORT_DATA                0
110  #define                OFFSET_PORT_STATUS              1