| 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 | #define SkASSERT(x) do { if (!(x)) abort(); } while (false) |
| 15 | #define SkASSERTF(x, __VA_ARGS__) do { if (!(x)) { printf(__VA_ARGS__); abort(); } } while (false) |
| 16 | #define SkDEBUGFAIL(x) do { printf("%s", x); abort(); } while (false) |
| 17 | #define SkDEBUGFAILF(fmt, ...) do { printf(fmt, __VA_ARGS__); abort(); } while (false) |
| 18 | #define SkAssertResult(x) do { if (!(x)) abort(); } while (false) |
| 19 | #define SkDEBUGCODE(...) __VA_ARGS__ |
| 20 | #define SK_API |
| 21 | #if !defined(SkUNREACHABLE) |
| 22 | # if defined(_MSC_VER) && !defined(__clang__) |
| 23 | # define SkUNREACHABLE __assume(false) |
| 24 | # else |
| 25 | # define SkUNREACHABLE __builtin_unreachable() |
| 26 | # endif |
| 27 | #endif |
| 28 | #else |
| 29 | #include "include/core/SkTypes.h" |
| 30 | #endif |
| 31 | |
| 32 | #if defined(__clang__) || defined(__GNUC__) |
| 33 | #define SKSL_PRINTF_LIKE(A, B) __attribute__((format(printf, (A), (B)))) |
| 34 | #define SKSL_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
| 35 | #else |
| 36 | #define SKSL_PRINTF_LIKE(A, B) |
| 37 | #define SKSL_WARN_UNUSED_RESULT |
| 38 | #endif |
| 39 | |
| 40 | #define ABORT(...) (printf(__VA_ARGS__), sksl_abort()) |
| 41 | |
| 42 | #if _MSC_VER |
| 43 | #define NORETURN __declspec(noreturn) |
| 44 | #else |
| 45 | #define NORETURN __attribute__((__noreturn__)) |
| 46 | #endif |
| 47 | |
| 48 | using SKSL_INT = int32_t; |
| 49 | using SKSL_FLOAT = float; |
| 50 | |
| 51 | #endif |
| 52 | |