1
//============================================================================
3
// BBBBB SSSS PPPPP FFFFFF
4
// BB BB SS SS PP PP FF
6
// BBBBB SSSS PPPPP FFFF -- "Brad's Simple Portability Framework"
11
// Copyright (c) 1995-2010 by Bradford W. Mott, Stephen Anthony
12
// and the Stella Team
14
// See the file "License.txt" for information on usage and redistribution of
15
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
17
// $Id: bspf.hxx 2001 2010-04-10 21:37:23Z stephena $
18
//============================================================================
24
This file defines various basic data types and preprocessor variables
25
that need to be defined for different operating systems.
27
@author Bradford W. Mott
28
@version $Id: bspf.hxx 2001 2010-04-10 21:37:23Z stephena $
34
// Types for 8-bit signed and unsigned integers
36
typedef uint8_t uInt8;
37
// Types for 16-bit signed and unsigned integers
38
typedef int16_t Int16;
39
typedef uint16_t uInt16;
40
// Types for 32-bit signed and unsigned integers
41
typedef int32_t Int32;
42
typedef uint32_t uInt32;
43
// Types for 64-bit signed and unsigned integers
44
typedef int64_t Int64;
45
typedef uint64_t uInt64;
46
#elif defined BSPF_WIN32
47
// Types for 8-bit signed and unsigned integers
48
typedef signed char Int8;
49
typedef unsigned char uInt8;
50
// Types for 16-bit signed and unsigned integers
51
typedef signed short Int16;
52
typedef unsigned short uInt16;
53
// Types for 32-bit signed and unsigned integers
54
typedef signed int Int32;
55
typedef unsigned int uInt32;
56
// Types for 64-bit signed and unsigned integers
57
typedef __int64 Int64;
58
typedef unsigned __int64 uInt64;
60
#error Update BSPF.hxx for datatypes
64
// The following code should provide access to the standard C++ objects and
65
// types: cout, cerr, string, ostream, istream, etc.
73
// Defines to help with path handling
75
#define BSPF_PATH_SEPARATOR "/"
76
#elif (defined(BSPF_DOS) || defined(BSPF_WIN32) || defined(BSPF_OS2))
77
#define BSPF_PATH_SEPARATOR "\\"
78
#elif defined BSPF_MAC_OSX
79
#define BSPF_PATH_SEPARATOR "/"
80
#elif defined BSPF_GP2X
81
#define BSPF_PATH_SEPARATOR "/"
84
// I wish Windows had a complete POSIX layer
85
#if defined BSPF_WIN32 && !defined __GNUG__
86
#define BSPF_strcasecmp stricmp
87
#define BSPF_strncasecmp strnicmp
88
#define BSPF_isblank(c) ((c == ' ') || (c == '\t'))
89
#define BSPF_snprintf _snprintf
90
#define BSPF_vsnprintf _vsnprintf
93
#define BSPF_strcasecmp strcasecmp
94
#define BSPF_strncasecmp strncasecmp
95
#define BSPF_isblank(c) isblank(c)
96
#define BSPF_snprintf snprintf
97
#define BSPF_vsnprintf vsnprintf
100
// CPU architecture type
101
// This isn't complete yet, but takes care of all the major platforms
102
#if defined(__i386__) || defined(_M_IX86)
103
#define BSPF_ARCH "i386"
104
#elif defined(__x86_64__) || defined(_WIN64)
105
#define BSPF_ARCH "x86_64"
106
#elif defined(__powerpc__) || defined(__ppc__)
107
#define BSPF_ARCH "ppc"
109
#define BSPF_ARCH "NOARCH"
112
// Some convenience functions
113
template<typename T> inline void BSPF_swap(T &a, T &b) { T tmp = a; a = b; b = tmp; }
114
template<typename T> inline T BSPF_abs (T x) { return (x>=0) ? x : -x; }
115
template<typename T> inline T BSPF_min (T a, T b) { return (a<b) ? a : b; }
116
template<typename T> inline T BSPF_max (T a, T b) { return (a>b) ? a : b; }
117
inline string BSPF_tolower(const string& s)
120
transform(t.begin(), t.end(), t.begin(), (int(*)(int)) tolower);
124
static const string EmptyString("");