The Build Engine
Main Page
Classes
Files
File List
File Members
platform.h
1
#ifndef _INCLUDE_PLATFORM_H_
2
#define _INCLUDE_PLATFORM_H_
3
4
#if (defined PLATFORM_WIN32)
5
#include "win32_compat.h"
6
#elif (defined PLATFORM_MACOSX)
7
#include "unix_compat.h"
8
#include <machine/endian.h>
9
#elif (defined PLATFORM_FREEBSD)
10
#include "unix_compat.h"
11
#include <sys/endian.h>
12
#elif (defined PLATFORM_UNIX)
13
#include "unix_compat.h"
14
#if !defined(__SUNPRO_C)
15
#include <endian.h>
16
#endif
17
#elif (defined PLATFORM_DOS)
18
#include "doscmpat.h"
19
#else
20
#error Define your platform!
21
#endif
22
23
#ifdef PLATFORM_MACOSX
24
/* may be an x86 Mac, so turn off PowerPC ASM and Altivec if needed... */
25
#if __POWERPC__
26
#define HAVE_POWERPC 1
27
#endif
28
#endif
29
30
#ifdef PLATFORM_LINUXPPC
31
#define HAVE_POWERPC 1
32
#endif
33
34
#if (!defined __EXPORT__)
35
#define __EXPORT__
36
#endif
37
38
#if ((defined PLATFORM_SUPPORTS_SDL) && (!defined PLATFORM_TIMER_HZ))
39
#define PLATFORM_TIMER_HZ 100
40
#endif
41
42
#if (!defined PLATFORM_TIMER_HZ)
43
#error You need to define PLATFORM_TIMER_HZ for your platform.
44
#endif
45
46
#if (defined __WATCOMC__)
47
#define snprintf _snprintf
48
#endif
49
50
#if (defined __SUNPRO_C)
51
#define __inline inline
52
#endif
53
54
static
__inline
unsigned
short
_swap16(
unsigned
short
D)
55
{
56
#if HAVE_POWERPC
57
register
unsigned
short
returnValue;
58
__asm__
volatile
(
"lhbrx %0,0,%1"
59
:
"=r"
(returnValue)
60
:
"r"
(&D)
61
);
62
return
returnValue;
63
#else
64
return
((D<<8)|(D>>8));
65
#endif
66
}
67
68
static
__inline
unsigned
int
_swap32(
unsigned
int
D)
69
{
70
#if HAVE_POWERPC
71
register
unsigned
int
returnValue;
72
__asm__
volatile
(
"lwbrx %0,0,%1"
73
:
"=r"
(returnValue)
74
:
"r"
(&D)
75
);
76
return
returnValue;
77
#else
78
return
((D<<24)|((D<<8)&0x00FF0000)|((D>>8)&0x0000FF00)|(D>>24));
79
#endif
80
}
81
82
#if HAVE_POWERPC
83
#define PLATFORM_BIGENDIAN 1
84
#define BUILDSWAP_INTEL16(x) _swap16(x)
85
#define BUILDSWAP_INTEL32(x) _swap32(x)
86
#else
87
#if __BYTE_ORDER == __LITTLE_ENDIAN
88
#define PLATFORM_LITTLEENDIAN 1
89
#define BUILDSWAP_INTEL16(x) (x)
90
#define BUILDSWAP_INTEL32(x) (x)
91
#else
92
#define PLATFORM_BIGENDIAN 1
93
#define BUILDSWAP_INTEL16(x) _swap16(x)
94
#define BUILDSWAP_INTEL32(x) _swap32(x)
95
#endif
96
#endif
97
98
extern
int
has_altivec;
/* PowerPC-specific. */
99
100
#endif
/* !defined _INCLUDE_PLATFORM_H_ */
101
102
/* end of platform.h ... */
103
104
Generated on Thu Mar 21 2013 22:36:57 for The Build Engine by
1.8.3.1