defs.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. // unique tag to fix pragma once gcc glueing: ./ydb/library/yql/minikql/defs.h
  3. #include <util/system/compiler.h>
  4. #include <util/generic/array_ref.h>
  5. #include <util/generic/yexception.h>
  6. #define THROW ::NKikimr::TThrowable() , __LOCATION__ +
  7. #define MKQL_ENSURE(condition, message) \
  8. do { \
  9. if (Y_UNLIKELY(!(condition))) { \
  10. (THROW yexception() << __FUNCTION__ << "(): requirement " \
  11. << #condition << " failed. " << message); \
  12. } \
  13. } while (0)
  14. #define MKQL_ENSURE_WITH_LOC(location, condition, message) \
  15. do { \
  16. if (Y_UNLIKELY(!(condition))) { \
  17. ThrowException(location + yexception() << message); \
  18. } \
  19. } while (0)
  20. #define MKQL_ENSURE_S(condition, ...) \
  21. do { \
  22. if (Y_UNLIKELY(!(condition))) { \
  23. (THROW yexception() << __FUNCTION__ << "(): requirement " \
  24. << #condition << " failed. " << "" __VA_ARGS__); \
  25. } \
  26. } while (0)
  27. namespace NKikimr {
  28. template <typename T>
  29. [[noreturn]] void ThrowException(T&& e)
  30. {
  31. throw e;
  32. }
  33. struct TThrowable
  34. {
  35. template <typename T>
  36. [[noreturn]] void operator,(T&& e) {
  37. ThrowException(e);
  38. }
  39. };
  40. typedef
  41. #ifdef _win_
  42. struct { ui64 Data, Meta; }
  43. #else
  44. unsigned __int128
  45. #endif
  46. TRawUV;
  47. }