Subject: Re: No endian.h on HP-UX
From: Tomas Frydrych (tomas@frydrych.uklinux.net)
Date: Sat Feb 10 2001 - 02:49:29 CST
> abi/src/af/gr/unix/gr_UnixGraphics.cpp contains this:
> #ifndef __FreeBSD__
> #include <endian.h>
> #else
> #include <machine/endian.h>
> #endif
> Since HP-UX doesn't have endian.h anywhere, I just wrapped this
> up in "#ifndef __hpux" / "#endif". Which is fine by me, but I
> bet there's a prettier place for this kind of logic, more in
> keeping with the abiword build model. Any suggestions?
This is my doing; you cannot just #ifndef it though. I suggest that
we create /af/util/xp/ut_endian.h with the contents below, and that
each platform defines in there either UT_BIG_ENDIAN or
UT_LITTLE_ENDIAN. We can then include this file if we need to
decide on ediannes.
Tomas
----------------------------------------- ut_endian.h -------------------------------------
#ifndef UT_ENDIAN_H
#define UT_ENDIAN_H
#ifdef __hpux
#elif __FreeBSD__
#include <machine/endian.h>
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define UT_LITTLE_ENDIAN
#else
#define UT_BIG_ENDIAN
#endif
#else
#include <endian.h>
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define UT_LITTLE_ENDIAN
#else
#define UT_BIG_ENDIAN
#endif
#endif
//XP macros
// convert single UCS character
// x,y are pointers to UT_UCSChar
// we will use a temporary variable, so that x and y
// can be the same
#ifdef UT_LITTLE_ENDIAN
#define LE2BE16(x,y) \
char * lb1; \
UT_UCSChar tucs; \
tucs = * ((UT_UCSChar *)(x)); lb1 = (char*) (&tucs); \
*((char*)(y)) = *(lb1+1); *(((char*)(y)+1)) = *lb1;
#else
#define LE2BE16(x,y)
#endif
#endif //UT_ENDIAN_H
*********************************************
tomas@frydrych.net / www.frydrych.net
PGP keys: http://www.frydrych.net/contact.html
This archive was generated by hypermail 2b25 : Sat Feb 10 2001 - 02:55:55 CST