diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2007-03-07 15:53:27 -0500 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2007-03-07 16:02:09 -0500 |
commit | 2cc1c73705d70f834b43996f70080860ac66e57d (patch) | |
tree | 72bc628d6cb08854dc7fbc96748f78fc5518b4ab /src/cairoint.h | |
parent | 62e864e73cd1136b3c0e889dca43a1c0cc648b21 (diff) |
[cairoint] Move endian-conversion routines into cairoint.h
Diffstat (limited to 'src/cairoint.h')
-rwxr-xr-x | src/cairoint.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/cairoint.h b/src/cairoint.h index 19897ff9..3e548575 100755 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -272,6 +272,41 @@ typedef cairo_fixed_16_16_t cairo_fixed_t; #define CAIRO_BITSWAP8_IF_LITTLE_ENDIAN(c) CAIRO_BITSWAP8(c) #endif +#ifdef WORDS_BIGENDIAN + +#define cpu_to_be16(v) (v) +#define be16_to_cpu(v) (v) +#define cpu_to_be32(v) (v) +#define be32_to_cpu(v) (v) + +#else + +static inline uint16_t +cpu_to_be16(uint16_t v) +{ + return (v << 8) | (v >> 8); +} + +static inline uint16_t +be16_to_cpu(uint16_t v) +{ + return cpu_to_be16 (v); +} + +static inline uint32_t +cpu_to_be32(uint32_t v) +{ + return (cpu_to_be16 (v) << 16) | cpu_to_be16 (v >> 16); +} + +static inline uint32_t +be32_to_cpu(uint32_t v) +{ + return cpu_to_be32 (v); +} + +#endif + #include "cairo-hash-private.h" #include "cairo-cache-private.h" |