>Win95. Unfortunately, the encoder_example segfaults. I get the same >results from Cygwin as well.Problem solved! (Or rather, worked around...) The problem with the segfault appears to have indeed been with alloca. There is a function _alloca in libgcc.a that comes with the mingw32 distribution of gcc-2.95.2. After examining the generated assembly code from envelope.c (and others), I found that when I left the #define alloca(x) (_alloca(x)) in os.h, it would link to this function. If you #ifdef the define out, it would simply subtract the required number of bytes off of the stack pointer. I haven't had a chance to look at what the _alloca() function is doing in mingw32, but removing the #define does the trick. After adding an additional #ifdef to os.h (plus typedefs for int64_t, u_int32_t, and int16_t), the library and examples build. A quick test with the examples produced acceptable output. If anyone is interested, I modified decoder_example.c to write to a WAV file instead of just a raw sample. To get rid of the segfaults, in os.h I replaced #ifndef alloca #ifdef _WIN32 #define alloca(x) (_alloca(x)) #endif #endif with #ifndef alloca #if defined(_WIN32) && !defined(__GNUC__) #define alloca(x) (_alloca(x)) #endif #endif regards, Andy ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/
> Problem solved! (Or rather, worked around...) The problem with the segfault > appears to have indeed been with alloca. There is a function _alloca in > libgcc.a that comes with the mingw32 distribution of gcc-2.95.2. After > examining the generated assembly code from envelope.c (and others), I found > that when I left the #define alloca(x) (_alloca(x)) in os.h, it would link > to this function. If you #ifdef the define out, it would simply subtract > the required number of bytes off of the stack pointer. I haven't had a > chance to look at what the _alloca() function is doing in mingw32, but > removing the #define does the trick.Ah. MSVC requires _alloca() as a synonym for *NIX alloca(). This must be an internal function in mingw32 that I shouldn't use. The obvious fault is me using #ifdef _WIN32 in os.h. Is, perhaps, _MSVC_ or somethign like that a better idea?> #ifndef alloca > #if defined(_WIN32) && !defined(__GNUC__) > #define alloca(x) (_alloca(x)) > #endif > #endifSince we're trying to fix it right, it seems like that could trip us up eventually too... what do other developers who code for both WIN32/GNU and their unholy union do? Monty --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/
>Ah. MSVC requires _alloca() as a synonym for *NIX alloca(). This must be >an >internal function in mingw32 that I shouldn't use.I think it's more a bug in mingw32. Without the prototype, it just subtracts x bytes from the stack pointer to allocate space. The function version seems to do so as well -- the stack pointer has changed upon return from _alloca() -- but something's not quite right in all cases. If I have some more time, I'll probably look at it. In any case, why the function doesn't work is irrelevant. :-)>The obvious fault is me using #ifdef _WIN32 in os.h. Is, perhaps, _MSVC_ >or >somethign like that a better idea?Perhaps a configuration option, like config.h: #define NEED_UNDERSCORE_ALLOCA 0 os.h: #if NEED_UNDERSCORE_ALLOCA # define alloca(x) (_alloca(x)) #endif Each OS/compiler could have its own config.h -- it would be easier than trying to find what symbols have to be #define'd by different compilers. ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/