From 220389758c547d667d397221c3c51605d4723c36 Mon Sep 17 00:00:00 2001 From: chsieh Date: Fri, 17 Dec 2010 16:52:13 -0800 Subject: [PATCH] Added preprocessor token definitions. Also added corresponding ARM asm instructions for existing macros/functions. --- Classes/Foundation/Common/GlobalDefines.h | 35 ++++++++++++++++++++-------- Littlest.xcodeproj/project.pbxproj | 10 +++++++- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Classes/Foundation/Common/GlobalDefines.h b/Classes/Foundation/Common/GlobalDefines.h index 58323d7..94b70ba 100755 --- a/Classes/Foundation/Common/GlobalDefines.h +++ b/Classes/Foundation/Common/GlobalDefines.h @@ -3,38 +3,40 @@ #include "Foundation/Common/GlobalTypes.h" #ifdef _WINDOWS -#define __WINDOWS__ + #define __WINDOWS__ +#ifdef __iOS__ + #define __ARM__ #endif #ifdef _DEBUG -#define DEBUG + #define DEBUG #endif #ifdef _NDEBUG -#define RELEASE + #define RELEASE #endif #ifndef NULL -#define NULL 0 + #define NULL 0 #endif #ifndef FALSE -#define FALSE 0 + #define FALSE 0 #endif #ifndef TRUE -#define TRUE 1 + #define TRUE 1 #endif //---------------------------------------------------------------------------------------- // cache information #ifndef CACHE_LINE_SIZE -#define CACHE_LINE_SIZE 128 //equal to 2 line for intel normally +#define CACHE_LINE_SIZE 128 // normally equals to 2 lines for intel #endif //---------------------------------------------------------------------------------------- //force inline on non-debug, might make code explode -#ifdef _DEBUG +#ifdef DEBUG #define slInline inline #else #define slInline __forceinline @@ -49,6 +51,8 @@ // alignment macros #if defined(__WINDOWS__) #define ALIGN(N) __declspec(align(N)) +#elif defined(__iOS__) +#define ALIGN(N) __atribute__((aligned (N))) #endif #define IS_POWER_OF_TWO(x) ( ((x) & -(x)) == (x) ) @@ -66,7 +70,7 @@ #if defined(__WINDOWS__) // uhh, nothing? #elif defined(__ARM__) -#define DCBT(x) __asm__("pld" #(x)) +#define DCBT(x) __asm__("pld %0" : : "r"((x))) #else #error Not implemented yet! #endif @@ -95,6 +99,7 @@ //---------------------------------------------------------------------------------------- #if defined(__WINDOWS__) + slInline uint8_t LZCount(uint64_t x) { uint8_t leading_zero_count = 0; @@ -112,8 +117,18 @@ slInline uint8_t LZCount(uint64_t x) return leading_zero_count; } + +#elif defined(__ARM__) + +slInline uint8_t LZCount(uint64_t x) +{ + uint8_t result; + __asm__("clz %1 %0" : "=r" (result) : "r"(x)); + return result; +} + #else -#error // use lzcnt! +#error use lzcnt! #endif //---------------------------------------------------------------------------------------- diff --git a/Littlest.xcodeproj/project.pbxproj b/Littlest.xcodeproj/project.pbxproj index d49746c..81661ef 100755 --- a/Littlest.xcodeproj/project.pbxproj +++ b/Littlest.xcodeproj/project.pbxproj @@ -385,9 +385,14 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; GCC_CHAR_IS_UNSIGNED_CHAR = YES; GCC_C_LANGUAGE_STANDARD = c99; + GCC_ENABLE_CPP_EXCEPTIONS = NO; + GCC_ENABLE_CPP_RTTI = NO; GCC_FAST_MATH = YES; GCC_ONE_BYTE_BOOL = NO; - GCC_PREPROCESSOR_DEFINITIONS = DEBUG; + GCC_PREPROCESSOR_DEFINITIONS = ( + __iOS__, + DEBUG, + ); GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; @@ -402,8 +407,11 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; GCC_CHAR_IS_UNSIGNED_CHAR = YES; GCC_C_LANGUAGE_STANDARD = c99; + GCC_ENABLE_CPP_EXCEPTIONS = NO; + GCC_ENABLE_CPP_RTTI = NO; GCC_FAST_MATH = YES; GCC_ONE_BYTE_BOOL = NO; + GCC_PREPROCESSOR_DEFINITIONS = __iOS__; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; -- 1.7.0.4