SkPostConfig.h revision 04423805455de868b1b468cfe4057cb77f74b6b0
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/*
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project
48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file.
78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */
88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkPostConfig_DEFINED
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkPostConfig_DEFINED
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_WINCE)
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define SK_BUILD_FOR_WIN
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if defined(SK_DEBUG) && defined(SK_RELEASE)
188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #error "cannot define both SK_DEBUG and SK_RELEASE"
198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#elif !defined(SK_DEBUG) && !defined(SK_RELEASE)
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #error "must define either SK_DEBUG or SK_RELEASE"
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if defined SK_SUPPORT_UNITTEST && !defined(SK_DEBUG)
248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #error "can't have unittests without debug"
258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if defined(SK_SCALAR_IS_FIXED) && defined(SK_SCALAR_IS_FLOAT)
288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #error "cannot define both SK_SCALAR_IS_FIXED and SK_SCALAR_IS_FLOAT"
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#elif !defined(SK_SCALAR_IS_FIXED) && !defined(SK_SCALAR_IS_FLOAT)
308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #ifdef SK_CAN_USE_FLOAT
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        #define SK_SCALAR_IS_FLOAT
328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #else
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        #define SK_SCALAR_IS_FIXED
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #endif
358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if defined(SK_SCALAR_IS_FLOAT) && !defined(SK_CAN_USE_FLOAT)
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define SK_CAN_USE_FLOAT
398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    // we do nothing in the else case: fixed-scalars can have floats or not
408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if defined(SK_CPU_LENDIAN) && defined(SK_CPU_BENDIAN)
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #error "cannot define both SK_CPU_LENDIAN and SK_CPU_BENDIAN"
448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#elif !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN)
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #error "must define either SK_CPU_LENDIAN or SK_CPU_BENDIAN"
468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// ensure the port has defined all of these, or none of them
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifdef SK_A32_SHIFT
508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #if !defined(SK_R32_SHIFT) || !defined(SK_G32_SHIFT) || !defined(SK_B32_SHIFT)
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        #error "all or none of the 32bit SHIFT amounts must be defined"
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #endif
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#else
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #if defined(SK_R32_SHIFT) || defined(SK_G32_SHIFT) || defined(SK_B32_SHIFT)
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        #error "all or none of the 32bit SHIFT amounts must be defined"
568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #endif
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5904423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com#if !defined(SK_HAS_COMPILER_FEATURE)
6004423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com    #if defined(__has_feature)
6104423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com        #define SK_HAS_COMPILER_FEATURE(x) __has_feature(x)
6204423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com    #else
6304423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com        #define SK_HAS_COMPILER_FEATURE(x) 0
6404423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com    #endif
6504423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com#endif
6604423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com
6704423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com/**
6804423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com * The clang static analyzer likes to know that when the program is not
6904423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com * expected to continue (crash, assertion failure, etc). It will notice that
7004423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com * some combination of parameters lead to a function call that does not return.
7104423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com * It can then make appropriate assumptions about the parameters in code
7204423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com * executed only if the non-returning function was *not* called.
7304423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com */
7404423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com#if !defined(SkNO_RETURN_HINT)
7504423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com    #if SK_HAS_COMPILER_FEATURE(attribute_analyzer_noreturn)
7604423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com        namespace {
7704423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com            inline void SkNO_RETURN_HINT() __attribute__((analyzer_noreturn));
7804423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com            void SkNO_RETURN_HINT() {}
7904423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com        }
8004423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com    #else
8104423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com        #define SkNO_RETURN_HINT() do {} while (false)
8204423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com    #endif
8304423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com#endif
8404423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com
858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com///////////////////////////////////////////////////////////////////////////////
868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkNEW
888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define SkNEW(type_name)                new type_name
898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define SkNEW_ARGS(type_name, args)     new type_name args
908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define SkNEW_ARRAY(type_name, count)   new type_name[count]
918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define SkDELETE(obj)                   delete obj
928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define SkDELETE_ARRAY(array)           delete[] array
938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SK_CRASH
968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if 1   // set to 0 for infinite loop, which can help connecting gdb
9704423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com    #define SK_CRASH() SkNO_RETURN_HINT(); *(int *)(uintptr_t)0xbbadbeef = 0
988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#else
9904423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com    #define SK_CRASH() SkNO_RETURN_HINT(); do {} while (true)
1008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
1018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
1028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com///////////////////////////////////////////////////////////////////////////////
1048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if defined(SK_SOFTWARE_FLOAT) && defined(SK_SCALAR_IS_FLOAT)
1068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    // if this is defined, we convert floats to 2scompliment ints for compares
1078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #ifndef SK_SCALAR_SLOW_COMPARES
1088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        #define SK_SCALAR_SLOW_COMPARES
1098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #endif
1105c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com    #ifndef SK_USE_FLOATBITS
1115c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com        #define SK_USE_FLOATBITS
1125c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com    #endif
1138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
1148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifdef SK_BUILD_FOR_WIN
11616690af1c21dead3eedb25ebd0a4b9a091684ed4reed@android.com    // we want lean_and_mean when we include windows.h
11716690af1c21dead3eedb25ebd0a4b9a091684ed4reed@android.com    #ifndef WIN32_LEAN_AND_MEAN
11816690af1c21dead3eedb25ebd0a4b9a091684ed4reed@android.com        #define WIN32_LEAN_AND_MEAN
11916690af1c21dead3eedb25ebd0a4b9a091684ed4reed@android.com        #define WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
12016690af1c21dead3eedb25ebd0a4b9a091684ed4reed@android.com    #endif
12116690af1c21dead3eedb25ebd0a4b9a091684ed4reed@android.com
1228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #include <windows.h>
12316690af1c21dead3eedb25ebd0a4b9a091684ed4reed@android.com
12416690af1c21dead3eedb25ebd0a4b9a091684ed4reed@android.com    #ifdef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
12516690af1c21dead3eedb25ebd0a4b9a091684ed4reed@android.com        #undef WIN32_LEAN_AND_MEAN
12616690af1c21dead3eedb25ebd0a4b9a091684ed4reed@android.com    #endif
1278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #ifndef SK_DEBUGBREAK
12904423805455de868b1b468cfe4057cb77f74b6b0bsalomon@google.com        #define SK_DEBUGBREAK(cond)     do { if (!(cond)) { SkNO_RETURN_HINT(); __debugbreak(); }} while (false)
1308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #endif
131f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com
132f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com    #ifndef SK_A32_SHIFT
133f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com        #define SK_A32_SHIFT 24
134f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com        #define SK_R32_SHIFT 16
135f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com        #define SK_G32_SHIFT 8
136f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com        #define SK_B32_SHIFT 0
137f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com    #endif
138f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com
1398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#elif defined(SK_BUILD_FOR_MAC)
1408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #ifndef SK_DEBUGBREAK
1418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        #define SK_DEBUGBREAK(cond)     do { if (!(cond)) SK_CRASH(); } while (false)
1428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #endif
1438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#else
1448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #ifdef SK_DEBUG
1458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        #include <stdio.h>
1468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        #ifndef SK_DEBUGBREAK
1478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            #define SK_DEBUGBREAK(cond) do { if (cond) break; \
1488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                SkDebugf("%s:%d: failed assertion \"%s\"\n", \
1498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                __FILE__, __LINE__, #cond); SK_CRASH(); } while (false)
1508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        #endif
1518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #endif
1528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
1538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
15427661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com/*
15527661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com *  We check to see if the SHIFT value has already been defined.
15627661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com *  if not, we define it ourself to some default values. We default to OpenGL
15727661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com *  order (in memory: r,g,b,a)
15827661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com */
15927661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com#ifndef SK_A32_SHIFT
16027661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com    #ifdef SK_CPU_BENDIAN
16127661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com        #define SK_R32_SHIFT    24
16227661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com        #define SK_G32_SHIFT    16
16327661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com        #define SK_B32_SHIFT    8
16427661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com        #define SK_A32_SHIFT    0
16527661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com    #else
16627661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com        #define SK_R32_SHIFT    0
16727661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com        #define SK_G32_SHIFT    8
16827661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com        #define SK_B32_SHIFT    16
16927661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com        #define SK_A32_SHIFT    24
17027661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com    #endif
17127661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com#endif
17227661181d757145d98f2dc3e02b88ee3fffce9e5bsalomon@google.com
1738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//  stdlib macros
1748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if 0
1768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if !defined(strlen) && defined(SK_DEBUG)
1778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    extern size_t sk_strlen(const char*);
1788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define strlen(s)   sk_strlen(s)
1798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
1808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef sk_strcpy
1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define sk_strcpy(dst, src)     strcpy(dst, src)
1828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
1838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef sk_strchr
1848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define sk_strchr(s, c)         strchr(s, c)
1858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
1868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef sk_strrchr
1878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define sk_strrchr(s, c)        strrchr(s, c)
1888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
1898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef sk_strcmp
1908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define sk_strcmp(s, t)         strcmp(s, t)
1918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
1928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef sk_strncmp
1938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define sk_strncmp(s, t, n)     strncmp(s, t, n)
1948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
1958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef sk_memcpy
1968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define sk_memcpy(dst, src, n)  memcpy(dst, src, n)
1978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
1988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef memmove
1998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define memmove(dst, src, n)    memmove(dst, src, n)
2008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
2018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef sk_memset
2028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define sk_memset(dst, val, n)  memset(dst, val, n)
2038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
2048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef sk_memcmp
2058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define sk_memcmp(s, t, n)      memcmp(s, t, n)
2068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
2078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define sk_strequal(s, t)           (!sk_strcmp(s, t))
2098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define sk_strnequal(s, t, n)       (!sk_strncmp(s, t, n))
2108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
2118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2125c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com//////////////////////////////////////////////////////////////////////
2135c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com
2145c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com#if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_MAC)
2155c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com    #ifndef SkLONGLONG
2165c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com        #ifdef SK_BUILD_FOR_WIN32
2175c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com            #define SkLONGLONG  __int64
2185c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com        #else
2195c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com            #define SkLONGLONG  long long
2205c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com        #endif
2215c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com    #endif
2225c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com#endif
2235c80ea17d4e4a795bfaeb260fc27e952ba471f1dreed@android.com
2248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//////////////////////////////////////////////////////////////////////////////////////////////
2258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SK_BUILD_FOR_WINCE
2268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include <string.h>
2278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include <stdlib.h>
2288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#else
2298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define _CMNINTRIN_DECLARE_ONLY
2308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "cmnintrin.h"
2318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
2328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if defined SK_DEBUG && defined SK_BUILD_FOR_WIN32
2348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//#define _CRTDBG_MAP_ALLOC
2358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifdef free
2368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#undef free
2378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
2388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include <crtdbg.h>
2398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#undef free
2408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifdef SK_DEBUGx
2428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if defined(SK_SIMULATE_FAILED_MALLOC) && defined(__cplusplus)
2438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void * operator new(
2448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        size_t cb,
2458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        int nBlockUse,
2468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        const char * szFileName,
2478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        int nLine,
2488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        int foo
2498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        );
2508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void * operator new[](
2518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        size_t cb,
2528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        int nBlockUse,
2538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        const char * szFileName,
2548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        int nLine,
2558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        int foo
2568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        );
2578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void operator delete(
2588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        void *pUserData,
2598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        int, const char*, int, int
2608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        );
2618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void operator delete(
2628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        void *pUserData
2638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        );
2648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void operator delete[]( void * p );
2658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define DEBUG_CLIENTBLOCK   new( _CLIENT_BLOCK, __FILE__, __LINE__, 0)
2668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#else
2678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define DEBUG_CLIENTBLOCK   new( _CLIENT_BLOCK, __FILE__, __LINE__)
2688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
2698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define new DEBUG_CLIENTBLOCK
2708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#else
2718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DEBUG_CLIENTBLOCK
2728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif // _DEBUG
2738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2741341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com
2751341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com#endif
2761341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com
2778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
2788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2791341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com//////////////////////////////////////////////////////////////////////
2801341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com
2811341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com#ifndef SK_OVERRIDE
2821341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com#if defined(SK_BUILD_FOR_WIN)
2831341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com#define SK_OVERRIDE override
2841341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com#elif defined(__clang__)
2851341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com// Some documentation suggests we should be using __attribute__((override)),
2861341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com// but it doesn't work.
2871341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com#define SK_OVERRIDE override
2881341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com#else
2891341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com// Linux GCC ignores "__attribute__((override))" and rejects "override".
2901341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com#define SK_OVERRIDE
2911341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com#endif
2928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
2938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
294