yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1#ifndef SLANG_LLVM_H 2#define SLANG_LLVM_H 3 4// TODO(JS): 5// Disable exception declspecs, as not supported on LLVM without some extra options. 6// We could enable with `-fms-extensions` 7#define SLANG_DISABLE_EXCEPTIONS 1 8 9#ifndef SLANG_PRELUDE_ASSERT 10#ifdef SLANG_PRELUDE_ENABLE_ASSERT 11extern "C" void assertFailure (const char * msg ); 12#define SLANG_PRELUDE_EXPECT (VALUE ,MSG ) \ 13 if (VALUE) \ 14 { \ 15 } \ 16 else \ 17 assertFailure("assertion failed: '" MSG "'") 18#define SLANG_PRELUDE_ASSERT (VALUE ) SLANG_PRELUDE_EXPECT(VALUE, #VALUE) 19#else // SLANG_PRELUDE_ENABLE_ASSERT 20#define SLANG_PRELUDE_EXPECT (VALUE ,MSG ) 21#define SLANG_PRELUDE_ASSERT (x ) 22#endif // SLANG_PRELUDE_ENABLE_ASSERT 23#endif 24 25/* 26Taken from stddef.h 27*/ 28 29typedef __PTRDIFF_TYPE__ ptrdiff_t ; 30typedef __SIZE_TYPE__ size_t ; 31typedef __SIZE_TYPE__ rsize_t ; 32 33// typedef __WCHAR_TYPE__ wchar_t; 34 35#if defined(__need_NULL ) 36#undef NULL 37#ifdef __cplusplus 38#if !defined(__MINGW32__ )&& !defined(_MSC_VER ) 39#define NULL __null 40#else 41#define NULL 0 42#endif 43#else 44#define NULL ((void*)0) 45#endif 46#ifdef __cplusplus 47#if defined(_MSC_EXTENSIONS )&& defined(_NATIVE_NULLPTR_SUPPORTED ) 48namespace std 49{ 50typedef decltype (nullptr )nullptr_t ; 51} 52using ::std ::nullptr_t ; 53#endif 54#endif 55#undef __need_NULL 56#endif /* defined(__need_NULL) */ 57 58 59/* 60The following are taken verbatim from stdint.h from Clang in LLVM. Only 8/16/32/64 types are needed. 61*/ 62 63// LLVM/Clang types such that we can use LLVM/Clang without headers for C++ output from Slang 64 65#ifdef __INT64_TYPE__ 66#ifndef __int8_t_defined /* glibc sys/types.h also defines int64_t*/ 67typedef __INT64_TYPE__ int64_t ; 68#endif /* __int8_t_defined */ 69typedef __UINT64_TYPE__ uint64_t ; 70#define __int_least64_t int64_t 71#define __uint_least64_t uint64_t 72#endif /* __INT64_TYPE__ */ 73 74#ifdef __int_least64_t 75typedef __int_least64_t int_least64_t ; 76typedef __uint_least64_t uint_least64_t ; 77typedef __int_least64_t int_fast64_t ; 78typedef __uint_least64_t uint_fast64_t ; 79#endif /* __int_least64_t */ 80 81#ifdef __INT32_TYPE__ 82 83#ifndef __int8_t_defined /* glibc sys/types.h also defines int32_t*/ 84typedef __INT32_TYPE__ int32_t ; 85#endif /* __int8_t_defined */ 86 87#ifndef __uint32_t_defined /* more glibc compatibility */ 88#define __uint32_t_defined 89typedef __UINT32_TYPE__ uint32_t ; 90#endif /* __uint32_t_defined */ 91 92#define __int_least32_t int32_t 93#define __uint_least32_t uint32_t 94#endif /* __INT32_TYPE__ */ 95 96#ifdef __int_least32_t 97typedef __int_least32_t int_least32_t ; 98typedef __uint_least32_t uint_least32_t ; 99typedef __int_least32_t int_fast32_t ; 100typedef __uint_least32_t uint_fast32_t ; 101#endif /* __int_least32_t */ 102 103#ifdef __INT16_TYPE__ 104#ifndef __int8_t_defined /* glibc sys/types.h also defines int16_t*/ 105typedef __INT16_TYPE__ int16_t ; 106#endif /* __int8_t_defined */ 107typedef __UINT16_TYPE__ uint16_t ; 108#define __int_least16_t int16_t 109#define __uint_least16_t uint16_t 110#endif /* __INT16_TYPE__ */ 111 112#ifdef __int_least16_t 113typedef __int_least16_t int_least16_t ; 114typedef __uint_least16_t uint_least16_t ; 115typedef __int_least16_t int_fast16_t ; 116typedef __uint_least16_t uint_fast16_t ; 117#endif /* __int_least16_t */ 118 119#ifdef __INT8_TYPE__ 120#ifndef __int8_t_defined /* glibc sys/types.h also defines int8_t*/ 121typedef __INT8_TYPE__ int8_t ; 122#endif /* __int8_t_defined */ 123typedef __UINT8_TYPE__ uint8_t ; 124#define __int_least8_t int8_t 125#define __uint_least8_t uint8_t 126#endif /* __INT8_TYPE__ */ 127 128#ifdef __int_least8_t 129typedef __int_least8_t int_least8_t ; 130typedef __uint_least8_t uint_least8_t ; 131typedef __int_least8_t int_fast8_t ; 132typedef __uint_least8_t uint_fast8_t ; 133#endif /* __int_least8_t */ 134 135/* prevent glibc sys/types.h from defining conflicting types */ 136#ifndef __int8_t_defined 137#define __int8_t_defined 138#endif /* __int8_t_defined */ 139 140/* C99 7.18.1.4 Integer types capable of holding object pointers. 141*/ 142#define __stdint_join3 (a ,b ,c ) a##b##c 143 144#ifndef _INTPTR_T 145#ifndef __intptr_t_defined 146typedef __INTPTR_TYPE__ intptr_t ; 147#define __intptr_t_defined 148#define _INTPTR_T 149#endif 150#endif 151 152#ifndef _UINTPTR_T 153typedef __UINTPTR_TYPE__ uintptr_t ; 154#define _UINTPTR_T 155#endif 156 157/* C99 7.18.1.5 Greatest-width integer types. 158*/ 159typedef __INTMAX_TYPE__ intmax_t ; 160typedef __UINTMAX_TYPE__ uintmax_t ; 161 162/* C99 7.18.4 Macros for minimum-width integer constants. 163* 164* The standard requires that integer constant macros be defined for all the 165* minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width 166* types are required, the corresponding integer constant macros are defined 167* here. This implementation also defines minimum-width types for every other 168* integer width that the target implements, so corresponding macros are 169* defined below, too. 170* 171* These macros are defined using the same successive-shrinking approach as 172* the type definitions above. It is likewise important that macros are defined 173* in order of decending width. 174* 175* Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the 176* claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). 177*/ 178 179#define __int_c_join (a ,b ) a##b 180#define __int_c (v ,suffix ) __int_c_join(v, suffix) 181#define __uint_c (v ,suffix ) __int_c_join(v##U, suffix) 182 183#ifdef __INT64_TYPE__ 184#ifdef __INT64_C_SUFFIX__ 185#define __int64_c_suffix __INT64_C_SUFFIX__ 186#else 187#undef __int64_c_suffix 188#endif /* __INT64_C_SUFFIX__ */ 189#endif /* __INT64_TYPE__ */ 190 191#ifdef __int_least64_t 192#ifdef __int64_c_suffix 193#define INT64_C (v ) __int_c(v, __int64_c_suffix) 194#define UINT64_C (v ) __uint_c(v, __int64_c_suffix) 195#else 196#define INT64_C (v ) v 197#define UINT64_C (v ) v##U 198#endif /* __int64_c_suffix */ 199#endif /* __int_least64_t */ 200 201 202#ifdef __INT32_TYPE__ 203#ifdef __INT32_C_SUFFIX__ 204#define __int32_c_suffix __INT32_C_SUFFIX__ 205#else 206#undef __int32_c_suffix 207#endif /* __INT32_C_SUFFIX__ */ 208#endif /* __INT32_TYPE__ */ 209 210#ifdef __int_least32_t 211#ifdef __int32_c_suffix 212#define INT32_C (v ) __int_c(v, __int32_c_suffix) 213#define UINT32_C (v ) __uint_c(v, __int32_c_suffix) 214#else 215#define INT32_C (v ) v 216#define UINT32_C (v ) v##U 217#endif /* __int32_c_suffix */ 218#endif /* __int_least32_t */ 219 220#ifdef __INT16_TYPE__ 221#ifdef __INT16_C_SUFFIX__ 222#define __int16_c_suffix __INT16_C_SUFFIX__ 223#else 224#undef __int16_c_suffix 225#endif /* __INT16_C_SUFFIX__ */ 226#endif /* __INT16_TYPE__ */ 227 228#ifdef __int_least16_t 229#ifdef __int16_c_suffix 230#define INT16_C (v ) __int_c(v, __int16_c_suffix) 231#define UINT16_C (v ) __uint_c(v, __int16_c_suffix) 232#else 233#define INT16_C (v ) v 234#define UINT16_C (v ) v##U 235#endif /* __int16_c_suffix */ 236#endif /* __int_least16_t */ 237 238 239#ifdef __INT8_TYPE__ 240#ifdef __INT8_C_SUFFIX__ 241#define __int8_c_suffix __INT8_C_SUFFIX__ 242#else 243#undef __int8_c_suffix 244#endif /* __INT8_C_SUFFIX__ */ 245#endif /* __INT8_TYPE__ */ 246 247#ifdef __int_least8_t 248#ifdef __int8_c_suffix 249#define INT8_C (v ) __int_c(v, __int8_c_suffix) 250#define UINT8_C (v ) __uint_c(v, __int8_c_suffix) 251#else 252#define INT8_C (v ) v 253#define UINT8_C (v ) v##U 254#endif /* __int8_c_suffix */ 255#endif /* __int_least8_t */ 256 257/* C99 7.18.2.1 Limits of exact-width integer types. 258* C99 7.18.2.2 Limits of minimum-width integer types. 259* C99 7.18.2.3 Limits of fastest minimum-width integer types. 260* 261* The presence of limit macros are completely optional in C99. This 262* implementation defines limits for all of the types (exact- and 263* minimum-width) that it defines above, using the limits of the minimum-width 264* type for any types that do not have exact-width representations. 265* 266* As in the type definitions, this section takes an approach of 267* successive-shrinking to determine which limits to use for the standard (8, 268* 16, 32, 64) bit widths when they don't have exact representations. It is 269* therefore important that the definitions be kept in order of decending 270* widths. 271* 272* Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the 273* claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). 274*/ 275 276#ifdef __INT64_TYPE__ 277#define INT64_MAX INT64_C(9223372036854775807) 278#define INT64_MIN (-INT64_C(9223372036854775807) - 1) 279#define UINT64_MAX UINT64_C(18446744073709551615) 280#define __INT_LEAST64_MIN INT64_MIN 281#define __INT_LEAST64_MAX INT64_MAX 282#define __UINT_LEAST64_MAX UINT64_MAX 283#endif /* __INT64_TYPE__ */ 284 285#ifdef __INT_LEAST64_MIN 286#define INT_LEAST64_MIN __INT_LEAST64_MIN 287#define INT_LEAST64_MAX __INT_LEAST64_MAX 288#define UINT_LEAST64_MAX __UINT_LEAST64_MAX 289#define INT_FAST64_MIN __INT_LEAST64_MIN 290#define INT_FAST64_MAX __INT_LEAST64_MAX 291#define UINT_FAST64_MAX __UINT_LEAST64_MAX 292#endif /* __INT_LEAST64_MIN */ 293 294#ifdef __INT32_TYPE__ 295#define INT32_MAX INT32_C(2147483647) 296#define INT32_MIN (-INT32_C(2147483647) - 1) 297#define UINT32_MAX UINT32_C(4294967295) 298#define __INT_LEAST32_MIN INT32_MIN 299#define __INT_LEAST32_MAX INT32_MAX 300#define __UINT_LEAST32_MAX UINT32_MAX 301#endif /* __INT32_TYPE__ */ 302 303#ifdef __INT_LEAST32_MIN 304#define INT_LEAST32_MIN __INT_LEAST32_MIN 305#define INT_LEAST32_MAX __INT_LEAST32_MAX 306#define UINT_LEAST32_MAX __UINT_LEAST32_MAX 307#define INT_FAST32_MIN __INT_LEAST32_MIN 308#define INT_FAST32_MAX __INT_LEAST32_MAX 309#define UINT_FAST32_MAX __UINT_LEAST32_MAX 310#endif /* __INT_LEAST32_MIN */ 311 312#ifdef __INT16_TYPE__ 313#define INT16_MAX INT16_C(32767) 314#define INT16_MIN (-INT16_C(32767) - 1) 315#define UINT16_MAX UINT16_C(65535) 316#define __INT_LEAST16_MIN INT16_MIN 317#define __INT_LEAST16_MAX INT16_MAX 318#define __UINT_LEAST16_MAX UINT16_MAX 319#endif /* __INT16_TYPE__ */ 320 321#ifdef __INT_LEAST16_MIN 322#define INT_LEAST16_MIN __INT_LEAST16_MIN 323#define INT_LEAST16_MAX __INT_LEAST16_MAX 324#define UINT_LEAST16_MAX __UINT_LEAST16_MAX 325#define INT_FAST16_MIN __INT_LEAST16_MIN 326#define INT_FAST16_MAX __INT_LEAST16_MAX 327#define UINT_FAST16_MAX __UINT_LEAST16_MAX 328#endif /* __INT_LEAST16_MIN */ 329 330 331#ifdef __INT8_TYPE__ 332#define INT8_MAX INT8_C(127) 333#define INT8_MIN (-INT8_C(127) - 1) 334#define UINT8_MAX UINT8_C(255) 335#define __INT_LEAST8_MIN INT8_MIN 336#define __INT_LEAST8_MAX INT8_MAX 337#define __UINT_LEAST8_MAX UINT8_MAX 338#endif /* __INT8_TYPE__ */ 339 340#ifdef __INT_LEAST8_MIN 341#define INT_LEAST8_MIN __INT_LEAST8_MIN 342#define INT_LEAST8_MAX __INT_LEAST8_MAX 343#define UINT_LEAST8_MAX __UINT_LEAST8_MAX 344#define INT_FAST8_MIN __INT_LEAST8_MIN 345#define INT_FAST8_MAX __INT_LEAST8_MAX 346#define UINT_FAST8_MAX __UINT_LEAST8_MAX 347#endif /* __INT_LEAST8_MIN */ 348 349/* Some utility macros */ 350#define __INTN_MIN (n ) __stdint_join3(INT, n, _MIN) 351#define __INTN_MAX (n ) __stdint_join3(INT, n, _MAX) 352#define __UINTN_MAX (n ) __stdint_join3(UINT, n, _MAX) 353#define __INTN_C (n ,v ) __stdint_join3(INT, n, _C(v)) 354#define __UINTN_C (n ,v ) __stdint_join3(UINT, n, _C(v)) 355 356/* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */ 357/* C99 7.18.3 Limits of other integer types. */ 358 359#define INTPTR_MIN (-__INTPTR_MAX__ - 1) 360#define INTPTR_MAX __INTPTR_MAX__ 361#define UINTPTR_MAX __UINTPTR_MAX__ 362#define PTRDIFF_MIN (-__PTRDIFF_MAX__ - 1) 363#define PTRDIFF_MAX __PTRDIFF_MAX__ 364#define SIZE_MAX __SIZE_MAX__ 365 366/* ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__ 367* is enabled. */ 368#if defined(__STDC_WANT_LIB_EXT1__ )&& __STDC_WANT_LIB_EXT1__ >=1 369#define RSIZE_MAX (SIZE_MAX >> 1) 370#endif 371 372/* C99 7.18.2.5 Limits of greatest-width integer types. */ 373#define INTMAX_MIN (-__INTMAX_MAX__ - 1) 374#define INTMAX_MAX __INTMAX_MAX__ 375#define UINTMAX_MAX __UINTMAX_MAX__ 376 377/* C99 7.18.3 Limits of other integer types. */ 378#define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__) 379#define SIG_ATOMIC_MAX __INTN_MAX(__SIG_ATOMIC_WIDTH__) 380#ifdef __WINT_UNSIGNED__ 381#define WINT_MIN __UINTN_C(__WINT_WIDTH__, 0) 382#define WINT_MAX __UINTN_MAX(__WINT_WIDTH__) 383#else 384#define WINT_MIN __INTN_MIN(__WINT_WIDTH__) 385#define WINT_MAX __INTN_MAX(__WINT_WIDTH__) 386#endif 387 388#ifndef WCHAR_MAX 389#define WCHAR_MAX __WCHAR_MAX__ 390#endif 391#ifndef WCHAR_MIN 392#if __WCHAR_MAX__ == __INTN_MAX (__WCHAR_WIDTH__ ) 393#define WCHAR_MIN __INTN_MIN(__WCHAR_WIDTH__) 394#else 395#define WCHAR_MIN __UINTN_C(__WCHAR_WIDTH__, 0) 396#endif 397#endif 398 399/* 7.18.4.2 Macros for greatest-width integer constants. */ 400#define INTMAX_C (v ) __int_c(v, __INTMAX_C_SUFFIX__) 401#define UINTMAX_C (v ) __int_c(v, __UINTMAX_C_SUFFIX__) 402 403 404#endif // SLANG_LLVM_H