[vorbis-dev] Mac OS X/Darwin patch for libvorbis
Timothy J. Wood
tjw at omnigroup.com
Mon Jan 29 17:40:06 PST 2001
This is also pretty simple. Just a small patch to configure.in to set the right compiler flags and changes to os.h to (a) not have deeply nested ifdefs, making the file needlessly hard to read, (b) break up the sections by functionality and (c) don't assume that every non-Win32 has the floating versions of math library functions.
-tim
Index: configure.in
===================================================================
RCS file: /usr/local/cvsroot/vorbis/configure.in,v
retrieving revision 1.34
diff -u -p -r1.34 configure.in
--- configure.in 2001/01/23 17:42:20 1.34
+++ configure.in 2001/01/30 01:37:27
@@ -123,6 +123,10 @@ else
DEBUG="-g -Wall -D__NO_MATH_INLINES -fsigned-char -mv8"
CFLAGS="-O20 -ffast-math -D__NO_MATH_INLINES -fsigned-char -mv8"
PROFILE="-pg -g -O20 -D__NO_MATH_INLINES -fsigned-char -mv8" ;;
+ *-*-darwin*)
+ DEBUG="-DDARWIN -fno-common -force_cpusubtype_ALL -Wall -g -O0 -fsigned-char"
+ CFLAGS="-DDARWIN -fno-common -force_cpusubtype_ALL -Wall -g -O4 -ffast-math -fsigned-char"
+ PROFILE="-DDARWIN -fno-common -force_cpusubtype_ALL -Wall -g -pg -O4 -ffast-math -fsigned-char";;
*)
DEBUG="-g -Wall -D__NO_MATH_INLINES -fsigned-char"
CFLAGS="-O20 -D__NO_MATH_INLINES -fsigned-char"
Index: lib/os.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/os.h,v
retrieving revision 1.19
diff -u -p -r1.19 os.h
--- lib/os.h 2000/12/21 21:04:40 1.19
+++ lib/os.h 2001/01/30 01:37:28
@@ -24,19 +24,31 @@
#ifndef _V_IFDEFJAIL_H_
#define _V_IFDEFJAIL_H_
+#ifdef __GNUC__
+#define STIN static inline
+#elif _WIN32
+#define STIN static __inline
+#else
+#define STIN static
+#endif
+
#ifndef M_PI
#define M_PI (3.1415926536f)
#endif
-#ifndef __GNUC__
+
#ifdef _WIN32
# include <malloc.h>
# define rint(x) (floor((x)+0.5f))
+# define NO_FLOAT_MATH_LIB
+# define FAST_HYPOT(a, b) sqrt((a)*(a) + (b)*(b))
#endif
-#define STIN static
-#else
-#define STIN static inline
+#ifdef DARWIN
+#define NO_FLOAT_MATH_LIB
+#endif
+
+#ifndef NO_FLOAT_MATH_LIB
#define sqrt sqrtf
#define log logf
#define exp expf
@@ -48,9 +60,7 @@
#endif
-#ifdef _WIN32
-# define FAST_HYPOT(a, b) sqrt((a)*(a) + (b)*(b))
-#else /* if not _WIN32 */
+#ifndef FAST_HYPOT
# define FAST_HYPOT hypot
#endif
@@ -72,11 +82,9 @@
# define max(x,y) ((x)<(y)?(y):(x))
#endif
-
-#if defined(__i386__) && defined(__GNUC__)
-#ifndef __BEOS__
-
+#if defined(__i386__) && defined(__GNUC__) && !defined(__BEOS__)
+#define VORBIS_FPU_CONTROL
/* both GCC and MSVC are kinda stupid about rounding/casting to int.
Because of encapsulation constraints (GCC can't see inside the asm
block and so we end up doing stupid things like a store/load that
@@ -109,27 +117,13 @@ static inline int vorbis_ftoi(double f){
__asm__("fistl %0": "=m"(i) : "t"(f));
return(i);
}
-
-#else
-/* this is for beos */
-
-typedef int vorbis_fpu_control;
-static int vorbis_ftoi(double f){
- return (int)(f+.5);
-}
-
-/* We don't have special code for this compiler/arch, so do it the slow way */
-#define vorbis_fpu_setround(vorbis_fpu_control) {}
-#define vorbis_fpu_restore(vorbis_fpu_control) {}
-
#endif
-#else
+#if defined(_WIN32) && !defined(__GNUC__)
+#define VORBIS_FPU_CONTROL
-typedef int vorbis_fpu_control;
-
-#ifdef _WIN32
+typedef ogg_int16_t vorbis_fpu_control;
static __inline int vorbis_ftoi(double f){
int i;
@@ -145,8 +139,13 @@ static __inline void vorbis_fpu_setround
static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){
}
-#else
+#endif
+
+
+#ifndef VORBIS_FPU_CONTROL
+
+typedef int vorbis_fpu_control;
static int vorbis_ftoi(double f){
return (int)(f+.5);
}
@@ -157,6 +156,5 @@ static int vorbis_ftoi(double f){
#endif
-#endif
#endif /* _OS_H */
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Vorbis-dev
mailing list