[MPlayer-dev-eng] unrarlib still broken on 64bit
Peter Cordes
peter at cordes.ca
Sat Jul 28 04:20:45 CEST 2007
On Sun, Jul 01, 2007 at 06:56:26PM -0300, peter wrote:
> Hi mplayer/unrarlib devs,
>
> I'm not subscribe to the mailing list, please CC on replies thanks.
Ok, fine, I caught up with the thread on the archives. I'm replying to
Attila Kinali's message, from Tue Jul 3 18:12:29 CEST 2007, but the
formatting is all weird because I had to paste it into my editor...
Attila Kinali (Tue Jul 3 18:12:29 CEST 2007)
>On Sun, 01 Jul 2007 18:56:26 -0300
>Peter Cordes <peter at cordes.ca> wrote:
>
>> --- unrarlib.h.upstream 2007-06-20 01:15:09.000000000 -0300
>> +++ unrarlib.h 2007-07-01 17:33:55.192251911 -0300
>> @@ -94,17 +94,11 @@
>> #endif
>> #endif
>>
>> -#ifdef _WIN_32
>> -typedef unsigned char UBYTE; /* WIN32 definitions */
>> -typedef unsigned short UWORD;
>> -typedef unsigned long UDWORD;
>> -#endif
>> +#include <stdint.h>
>> +typedef uint8_t UBYTE;
>> +typedef uint16_t UWORD;
>> +typedef uint32_t UDWORD;
>>
>> -#ifdef _UNIX /* LINUX/UNIX definitions*/
>> -typedef unsigned char UBYTE;
>> -typedef unsigned short UWORD;
>> -typedef unsigned long UDWORD;
>> -#endif
>
>The patch like this ins not acceptable, as IIRC
>uint8_t & co are not necessarily defined on cygwin or mingw
>(one of those, don't remember which one uses a horribly
>outdated gcc). But at least the unix defines can be replaced,
>no have to be replaced (they are wrong this way if specific
>sizes are implied in the code).
I checked, and cygwin's stdint.h, which comes with gcc 3.4.4, has uint*_t
types. It looks like mingw has uint*_t types, but not u_int*_t types. e.g.
see http://gnuradio.org/trac/ticket/93.
Also, ubuntu's mingw packages include a stdint.h. I didn't install it to
check, but I think gcc has has uint types for a long time.
In any case, nobody ever fixed this, even just for _UNIX. I think I have a
solution that works everywhere:
#include <stdint.h>
#ifdef UINT32_MAX
typedef uint8_t UBYTE;
typedef uint16_t UWORD;
typedef uint32_t UDWORD;
#else
typedef unsigned char UBYTE;
typedef unsigned short UWORD;
typedef unsigned int UDWORD;
#endif
UINT32_MAX is defined in stdint.h iff it typedefs uint32_t. (wikipedia's
stdint.h page says the fixed-width types are optional, but if an arch has
types of the right width, we can expect to have a uint typedef for them.)
Using int instead of long means it will just work in the common fallback
cases, i.e. AMD64 Windows (P64 ABI, int = long = 32) and GNU (LP64 ABI,
int = 32, long = 64). And of course all 32bit arches.
If anyone wants unrarlib on a 16bit arch, or a 64bit int arch (maybe
Alpha?), they'd better have stdint.h, which gcc has had for ages.
--
#define X(x,y) x##y
Peter Cordes ; e-mail: X(peter at cor , des.ca)
"The gods confound the man who first found out how to distinguish the hours!
Confound him, too, who in this place set up a sundial, to cut and hack
my day so wretchedly into small pieces!" -- Plautus, 200 BC
More information about the MPlayer-dev-eng
mailing list