source: abuse/tags/pd/macabuse/imlib/include/system.h @ 49

Last change on this file since 49 was 49, checked in by Sam Hocevar, 15 years ago
  • Imported original public domain release, for future reference.
  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1#ifndef __SYS__
2#define __SYS__
3
4#if defined( __POWERPC__ ) || defined( __MC68K__ )
5#define __MAC__
6#endif
7
8#if !defined( BIG_ENDIANS ) && !defined( LITTLE_ENDIANS)
9  // See if we can detect the byte order
10  #ifdef __WATCOMC__
11    #define LITTLE_ENDIANS
12  #elif defined __linux__
13    #define LITTLE_ENDIANS
14  #elif defined SUN4
15    #define BIG_ENDIANS
16  #elif defined __sgi
17                #define BIG_ENDIANS
18        #elif defined __MAC__
19                #define BIG_ENDIANS
20  #else
21    #error Please define BIG_ENDIANS or LITTLE_ENDIANS
22  #endif
23#endif
24
25
26#if defined( __WATCOMC__ )
27  // they didn't include this def in their math include
28  #ifndef M_PI
29    #define M_PI 3.141592654
30  #endif
31  // so stuff can find proper file ops
32  #include <io.h>
33#elif defined( __MAC__ )
34  // they didn't include this def in their math include
35  #ifndef M_PI
36    #define M_PI 3.141592654
37  #endif
38        #include <unistd.h>
39#else
40  // so apps can find unlink
41  #include <unistd.h>
42#endif
43
44
45#define short_swap(x) (((((unsigned short) (x)))<<8)|((((unsigned short) (x)))>>8))
46#define long_swap(x) \
47   ((( ((unsigned long)(x)) )>>24)|((( ((unsigned long)(x)) )&0x00ff0000)>>8)| \
48   ((( ((unsigned long)(x)) )&0x0000ff00)<<8)|(( ((unsigned long)(x)) )<<24))
49
50#if defined BIG_ENDIANS
51#define LONG int
52#define int_to_intel(x) short_swap(x)
53#define int_to_local(x) int_to_intel(x)
54#define big_long_to_local(x) (x)
55#define big_short_to_local(x) (x)
56#define long_to_intel(x) long_swap(x)
57#define long_to_local(x) long_to_intel(x)
58#else
59#define LONG long
60#define int_to_intel(x) (x)
61#define int_to_local(x) (x)
62#define long_to_local(x) (x)
63#define long_to_intel(x) (x)
64#define big_long_to_local(x) long_swap(x)
65#define big_short_to_local(x) short_swap(x)
66#endif
67
68#define bltl(x) big_long_to_local(x)
69#define bstl(x) big_short_to_local(x)
70#define lltl(x) long_to_intel(x)
71#define lstl(x) int_to_intel(x)
72
73#endif
74
75
76
77
Note: See TracBrowser for help on using the repository browser.