SkSLDefines.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #ifndef SKSL_DEFINES
  8. #define SKSL_DEFINES
  9. #include <cstdint>
  10. #ifdef SKSL_STANDALONE
  11. #if defined(_WIN32) || defined(__SYMBIAN32__)
  12. #define SKSL_BUILD_FOR_WIN
  13. #endif
  14. #else
  15. #ifdef SK_BUILD_FOR_WIN
  16. #define SKSL_BUILD_FOR_WIN
  17. #endif // SK_BUILD_FOR_WIN
  18. #endif // SKSL_STANDALONE
  19. #ifdef SKSL_STANDALONE
  20. #define SkASSERT(x) do { if (!(x)) abort(); } while (false)
  21. #define SkAssertResult(x) do { if (!(x)) abort(); } while (false)
  22. #define SkDEBUGCODE(...) __VA_ARGS__
  23. #define SK_API
  24. #else
  25. #include "include/core/SkTypes.h"
  26. #endif
  27. #if defined(__clang__) || defined(__GNUC__)
  28. #define SKSL_PRINTF_LIKE(A, B) __attribute__((format(printf, (A), (B))))
  29. #define SKSL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
  30. #else
  31. #define SKSL_PRINTF_LIKE(A, B)
  32. #define SKSL_WARN_UNUSED_RESULT
  33. #endif
  34. #define ABORT(...) (printf(__VA_ARGS__), sksl_abort())
  35. #if _MSC_VER
  36. #define NORETURN __declspec(noreturn)
  37. #else
  38. #define NORETURN __attribute__((__noreturn__))
  39. #endif
  40. using SKSL_INT = int32_t;
  41. using SKSL_FLOAT = float;
  42. #endif