180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/* 380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2006 The Android Open Source Project 480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * 580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be 680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file. 780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SkPostConfig_DEFINED 1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SkPostConfig_DEFINED 1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_WINCE) 1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_BUILD_FOR_WIN 1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if defined(SK_DEBUG) && defined(SK_RELEASE) 1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #error "cannot define both SK_DEBUG and SK_RELEASE" 1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#elif !defined(SK_DEBUG) && !defined(SK_RELEASE) 2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #error "must define either SK_DEBUG or SK_RELEASE" 2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if defined SK_SUPPORT_UNITTEST && !defined(SK_DEBUG) 2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #error "can't have unittests without debug" 2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if defined(SK_SCALAR_IS_FIXED) && defined(SK_SCALAR_IS_FLOAT) 2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #error "cannot define both SK_SCALAR_IS_FIXED and SK_SCALAR_IS_FLOAT" 2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#elif !defined(SK_SCALAR_IS_FIXED) && !defined(SK_SCALAR_IS_FLOAT) 3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_SCALAR_IS_FLOAT 3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 33363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger#if defined(SK_MSCALAR_IS_DOUBLE) && defined(SK_MSCALAR_IS_FLOAT) 34363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger #error "cannot define both SK_MSCALAR_IS_DOUBLE and SK_MSCALAR_IS_FLOAT" 35363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger#elif !defined(SK_MSCALAR_IS_DOUBLE) && !defined(SK_MSCALAR_IS_FLOAT) 36363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger // default is double, as that is faster given our impl uses doubles 37363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger // for intermediate calculations. 38363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger #define SK_MSCALAR_IS_DOUBLE 39363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger#endif 40363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger 4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if defined(SK_CPU_LENDIAN) && defined(SK_CPU_BENDIAN) 4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #error "cannot define both SK_CPU_LENDIAN and SK_CPU_BENDIAN" 4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#elif !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN) 4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #error "must define either SK_CPU_LENDIAN or SK_CPU_BENDIAN" 4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// ensure the port has defined all of these, or none of them 4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef SK_A32_SHIFT 4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #if !defined(SK_R32_SHIFT) || !defined(SK_G32_SHIFT) || !defined(SK_B32_SHIFT) 5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #error "all or none of the 32bit SHIFT amounts must be defined" 5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#else 5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #if defined(SK_R32_SHIFT) || defined(SK_G32_SHIFT) || defined(SK_B32_SHIFT) 5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #error "all or none of the 32bit SHIFT amounts must be defined" 5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 5680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if !defined(SK_HAS_COMPILER_FEATURE) 5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #if defined(__has_feature) 6080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_HAS_COMPILER_FEATURE(x) __has_feature(x) 6180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #else 6280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_HAS_COMPILER_FEATURE(x) 0 6380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 6480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 6580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 6680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if !defined(SK_SUPPORT_GPU) 6780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_SUPPORT_GPU 1 6880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 6980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 7080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/** 7180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * The clang static analyzer likes to know that when the program is not 7280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * expected to continue (crash, assertion failure, etc). It will notice that 7380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * some combination of parameters lead to a function call that does not return. 7480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * It can then make appropriate assumptions about the parameters in code 7580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * executed only if the non-returning function was *not* called. 7680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 7780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if !defined(SkNO_RETURN_HINT) 7880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #if SK_HAS_COMPILER_FEATURE(attribute_analyzer_noreturn) 79d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger static inline void SkNO_RETURN_HINT() __attribute__((analyzer_noreturn)); 80d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger static inline void SkNO_RETURN_HINT() {} 8180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #else 8280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SkNO_RETURN_HINT() do {} while (false) 8380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 8480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 8580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 8680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if defined(SK_ZLIB_INCLUDE) && defined(SK_SYSTEM_ZLIB) 8780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #error "cannot define both SK_ZLIB_INCLUDE and SK_SYSTEM_ZLIB" 8880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#elif defined(SK_ZLIB_INCLUDE) || defined(SK_SYSTEM_ZLIB) 8980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_HAS_ZLIB 9080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 9180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 9280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/////////////////////////////////////////////////////////////////////////////// 9380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 9480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SkNEW 95d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger #define SkNEW(type_name) (new type_name) 96d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger #define SkNEW_ARGS(type_name, args) (new type_name args) 97d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger #define SkNEW_ARRAY(type_name, count) (new type_name[(count)]) 98d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger #define SkNEW_PLACEMENT(buf, type_name) (new (buf) type_name) 9980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SkNEW_PLACEMENT_ARGS(buf, type_name, args) \ 100d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger (new (buf) type_name args) 101d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger #define SkDELETE(obj) (delete (obj)) 102d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger #define SkDELETE_ARRAY(array) (delete[] (array)) 10380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 10480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 10580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SK_CRASH 10680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if 1 // set to 0 for infinite loop, which can help connecting gdb 10780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_CRASH() do { SkNO_RETURN_HINT(); *(int *)(uintptr_t)0xbbadbeef = 0; } while (false) 10880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#else 10980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_CRASH() do { SkNO_RETURN_HINT(); } while (true) 11080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 11180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 11280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 11380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/////////////////////////////////////////////////////////////////////////////// 11480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 115d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger// SK_ENABLE_INST_COUNT defaults to 1 in DEBUG and 0 in RELEASE 116d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger#ifndef SK_ENABLE_INST_COUNT 117d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger #ifdef SK_DEBUG 118d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger #define SK_ENABLE_INST_COUNT 1 119d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger #else 120d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger #define SK_ENABLE_INST_COUNT 0 121d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger #endif 122d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger#endif 123d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger 124d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger/////////////////////////////////////////////////////////////////////////////// 125d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger 12680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if defined(SK_SOFTWARE_FLOAT) && defined(SK_SCALAR_IS_FLOAT) 12780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // if this is defined, we convert floats to 2scompliment ints for compares 12880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #ifndef SK_SCALAR_SLOW_COMPARES 12980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_SCALAR_SLOW_COMPARES 13080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 13180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #ifndef SK_USE_FLOATBITS 13280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_USE_FLOATBITS 13380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 13480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 13580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 13680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef SK_BUILD_FOR_WIN 13780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // we want lean_and_mean when we include windows.h 13880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #ifndef WIN32_LEAN_AND_MEAN 13980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define WIN32_LEAN_AND_MEAN 14080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define WIN32_IS_MEAN_WAS_LOCALLY_DEFINED 14180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 14280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 14380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #include <windows.h> 14480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 14580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #ifdef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED 14680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #undef WIN32_LEAN_AND_MEAN 14780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 14880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 14980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #ifndef SK_DEBUGBREAK 15080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_DEBUGBREAK(cond) do { if (!(cond)) { SkNO_RETURN_HINT(); __debugbreak(); }} while (false) 15180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 15280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 15380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #ifndef SK_A32_SHIFT 15480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_A32_SHIFT 24 15580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_R32_SHIFT 16 15680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_G32_SHIFT 8 15780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_B32_SHIFT 0 15880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 15980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 16080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#elif defined(SK_BUILD_FOR_MAC) 16180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #ifndef SK_DEBUGBREAK 16280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_DEBUGBREAK(cond) do { if (!(cond)) SK_CRASH(); } while (false) 16380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 16480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#else 16580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #ifdef SK_DEBUG 16680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #include <stdio.h> 16780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #ifndef SK_DEBUGBREAK 16880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_DEBUGBREAK(cond) do { if (cond) break; \ 16980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkDebugf("%s:%d: failed assertion \"%s\"\n", \ 17080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru __FILE__, __LINE__, #cond); SK_CRASH(); } while (false) 17180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 17280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 17380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 17480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 17580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/* 17680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * We check to see if the SHIFT value has already been defined. 17780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * if not, we define it ourself to some default values. We default to OpenGL 17880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * order (in memory: r,g,b,a) 17980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 18080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SK_A32_SHIFT 18180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #ifdef SK_CPU_BENDIAN 18280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_R32_SHIFT 24 18380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_G32_SHIFT 16 18480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_B32_SHIFT 8 18580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_A32_SHIFT 0 18680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #else 18780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_R32_SHIFT 0 18880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_G32_SHIFT 8 18980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_B32_SHIFT 16 19080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_A32_SHIFT 24 19180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 19280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 19380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 19480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// stdlib macros 19580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 19680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if 0 19780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if !defined(strlen) && defined(SK_DEBUG) 19880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru extern size_t sk_strlen(const char*); 19980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define strlen(s) sk_strlen(s) 20080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 20180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef sk_strcpy 20280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define sk_strcpy(dst, src) strcpy(dst, src) 20380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 20480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef sk_strchr 20580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define sk_strchr(s, c) strchr(s, c) 20680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 20780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef sk_strrchr 20880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define sk_strrchr(s, c) strrchr(s, c) 20980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 21080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef sk_strcmp 21180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define sk_strcmp(s, t) strcmp(s, t) 21280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 21380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef sk_strncmp 21480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define sk_strncmp(s, t, n) strncmp(s, t, n) 21580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 21680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef sk_memcpy 21780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define sk_memcpy(dst, src, n) memcpy(dst, src, n) 21880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 21980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef memmove 22080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define memmove(dst, src, n) memmove(dst, src, n) 22180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 22280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef sk_memset 22380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define sk_memset(dst, val, n) memset(dst, val, n) 22480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 22580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef sk_memcmp 22680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define sk_memcmp(s, t, n) memcmp(s, t, n) 22780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 22880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 22980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define sk_strequal(s, t) (!sk_strcmp(s, t)) 23080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define sk_strnequal(s, t, n) (!sk_strncmp(s, t, n)) 23180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 23280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 23380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru////////////////////////////////////////////////////////////////////// 23480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 23580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_MAC) 23680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #ifndef SkLONGLONG 23780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #ifdef SK_BUILD_FOR_WIN32 23880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SkLONGLONG __int64 23980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #else 24080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SkLONGLONG long long 24180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 24280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 24380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 24480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 24580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru////////////////////////////////////////////////////////////////////////////////////////////// 24680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SK_BUILD_FOR_WINCE 24780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include <string.h> 24880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include <stdlib.h> 24980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#else 25080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define _CMNINTRIN_DECLARE_ONLY 25180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "cmnintrin.h" 25280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 25380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 25480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if defined SK_DEBUG && defined SK_BUILD_FOR_WIN32 25580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru//#define _CRTDBG_MAP_ALLOC 25680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef free 25780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#undef free 25880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 25980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include <crtdbg.h> 26080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#undef free 26180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 26280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef SK_DEBUGx 26380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if defined(SK_SIMULATE_FAILED_MALLOC) && defined(__cplusplus) 26480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void * operator new( 26580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru size_t cb, 26680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru int nBlockUse, 26780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const char * szFileName, 26880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru int nLine, 26980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru int foo 27080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru ); 27180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void * operator new[]( 27280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru size_t cb, 27380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru int nBlockUse, 27480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const char * szFileName, 27580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru int nLine, 27680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru int foo 27780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru ); 27880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void operator delete( 27980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void *pUserData, 28080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru int, const char*, int, int 28180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru ); 28280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void operator delete( 28380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void *pUserData 28480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru ); 28580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void operator delete[]( void * p ); 28680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__, 0) 28780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#else 28880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__) 28980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 29080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define new DEBUG_CLIENTBLOCK 29180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#else 29280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define DEBUG_CLIENTBLOCK 29380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif // _DEBUG 29480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 29580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 29680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 29780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 29880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 29980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 30080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru////////////////////////////////////////////////////////////////////// 30180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 30280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SK_OVERRIDE 30380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #if defined(_MSC_VER) 30480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_OVERRIDE override 30580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #elif defined(__clang__) && !defined(SK_BUILD_FOR_IOS) 30680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #if __has_feature(cxx_override_control) 30780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // Some documentation suggests we should be using __attribute__((override)), 30880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // but it doesn't work. 30980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_OVERRIDE override 31080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #elif defined(__has_extension) 31180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #if __has_extension(cxx_override_control) 31280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_OVERRIDE override 31380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 31480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 31580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #else 31680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // Linux GCC ignores "__attribute__((override))" and rejects "override". 31780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SK_OVERRIDE 31880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #endif 31980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 32080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 32180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru////////////////////////////////////////////////////////////////////// 32280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 32380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SK_PRINTF_LIKE 32480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if defined(__clang__) || defined(__GNUC__) 32580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SK_PRINTF_LIKE(A, B) __attribute__((format(printf, (A), (B)))) 32680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#else 32780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SK_PRINTF_LIKE(A, B) 32880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 32980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 33080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 33180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru////////////////////////////////////////////////////////////////////// 33280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 33380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SK_SIZE_T_SPECIFIER 33480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if defined(_MSC_VER) 33580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SK_SIZE_T_SPECIFIER "%Iu" 33680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#else 33780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SK_SIZE_T_SPECIFIER "%zu" 33880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 33980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 34080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 34180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru////////////////////////////////////////////////////////////////////// 34280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 34380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 34480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 1 34580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 346