1 /* 2 * Copyright 2019 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SKSL_DEFINES 9 #define SKSL_DEFINES 10 11 #include <cstdint> 12 13 #ifdef SKSL_STANDALONE 14 #if defined(_WIN32) || defined(__SYMBIAN32__) 15 #define SKSL_BUILD_FOR_WIN 16 #endif 17 #else 18 #ifdef SK_BUILD_FOR_WIN 19 #define SKSL_BUILD_FOR_WIN 20 #endif // SK_BUILD_FOR_WIN 21 #endif // SKSL_STANDALONE 22 23 #ifdef SKSL_STANDALONE 24 #define SkASSERT(x) do { if (!(x)) abort(); } while (false) 25 #define SkAssertResult(x) do { if (!(x)) abort(); } while (false) 26 #define SkDEBUGCODE(...) __VA_ARGS__ 27 #define SK_API 28 #if !defined(SkUNREACHABLE) 29 # if defined(_MSC_VER) && !defined(__clang__) 30 # define SkUNREACHABLE __assume(false) 31 # else 32 # define SkUNREACHABLE __builtin_unreachable() 33 # endif 34 #endif 35 #else 36 #include "include/core/SkTypes.h" 37 #endif 38 39 #if defined(__clang__) || defined(__GNUC__) 40 #define SKSL_PRINTF_LIKE(A, B) __attribute__((format(printf, (A), (B)))) 41 #define SKSL_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) 42 #else 43 #define SKSL_PRINTF_LIKE(A, B) 44 #define SKSL_WARN_UNUSED_RESULT 45 #endif 46 47 #define ABORT(...) (printf(__VA_ARGS__), sksl_abort()) 48 49 #if _MSC_VER 50 #define NORETURN __declspec(noreturn) 51 #else 52 #define NORETURN __attribute__((__noreturn__)) 53 #endif 54 55 using SKSL_INT = int32_t; 56 using SKSL_FLOAT = float; 57 58 #endif 59