2021-10-30 04:25:12 +08:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
// This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// When debugging complex issues, consider enabling one of these:
|
|
|
|
// This will reallocate the stack very aggressively at every opportunity; use this with asan to catch stale stack pointers
|
|
|
|
// #define HARDSTACKTESTS 1
|
|
|
|
// This will call GC validation very aggressively at every incremental GC step; use this with caution as it's SLOW
|
|
|
|
// #define HARDMEMTESTS 1
|
|
|
|
// This will call GC validation very aggressively at every GC opportunity; use this with caution as it's VERY SLOW
|
|
|
|
// #define HARDMEMTESTS 2
|
|
|
|
|
|
|
|
// To force MSVC2017+ to generate SSE2 code for some stdlib functions we need to locally enable /fp:fast
|
|
|
|
// Note that /fp:fast changes the semantics of floating point comparisons so this is only safe to do for functions without ones
|
|
|
|
#if defined(_MSC_VER) && !defined(__clang__)
|
|
|
|
#define LUAU_FASTMATH_BEGIN __pragma(float_control(precise, off, push))
|
|
|
|
#define LUAU_FASTMATH_END __pragma(float_control(pop))
|
|
|
|
#else
|
|
|
|
#define LUAU_FASTMATH_BEGIN
|
|
|
|
#define LUAU_FASTMATH_END
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Used on functions that have a printf-like interface to validate them statically
|
|
|
|
#if defined(__GNUC__)
|
|
|
|
#define LUA_PRINTF_ATTR(fmt, arg) __attribute__((format(printf, fmt, arg)))
|
|
|
|
#else
|
|
|
|
#define LUA_PRINTF_ATTR(fmt, arg)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define LUA_NORETURN __declspec(noreturn)
|
|
|
|
#else
|
|
|
|
#define LUA_NORETURN __attribute__((__noreturn__))
|
|
|
|
#endif
|
|
|
|
|
2022-08-05 06:35:33 +08:00
|
|
|
// Can be used to reconfigure visibility/exports for public APIs
|
2021-12-01 09:03:18 +08:00
|
|
|
#ifndef LUA_API
|
2021-10-30 04:25:12 +08:00
|
|
|
#define LUA_API extern
|
2021-12-01 09:03:18 +08:00
|
|
|
#endif
|
|
|
|
|
2021-10-30 04:25:12 +08:00
|
|
|
#define LUALIB_API LUA_API
|
|
|
|
|
2022-08-05 06:35:33 +08:00
|
|
|
// Can be used to reconfigure visibility for internal APIs
|
2021-10-30 04:25:12 +08:00
|
|
|
#if defined(__GNUC__)
|
|
|
|
#define LUAI_FUNC __attribute__((visibility("hidden"))) extern
|
|
|
|
#define LUAI_DATA LUAI_FUNC
|
|
|
|
#else
|
|
|
|
#define LUAI_FUNC extern
|
|
|
|
#define LUAI_DATA extern
|
|
|
|
#endif
|
|
|
|
|
2022-08-05 06:35:33 +08:00
|
|
|
// Can be used to reconfigure internal error handling to use longjmp instead of C++ EH
|
2021-12-01 09:03:18 +08:00
|
|
|
#ifndef LUA_USE_LONGJMP
|
2021-10-30 04:25:12 +08:00
|
|
|
#define LUA_USE_LONGJMP 0
|
2021-12-01 09:03:18 +08:00
|
|
|
#endif
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2022-08-05 06:35:33 +08:00
|
|
|
// LUA_IDSIZE gives the maximum size for the description of the source
|
2021-12-01 09:03:18 +08:00
|
|
|
#ifndef LUA_IDSIZE
|
2021-10-30 04:25:12 +08:00
|
|
|
#define LUA_IDSIZE 256
|
2021-12-01 09:03:18 +08:00
|
|
|
#endif
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2022-08-05 06:35:33 +08:00
|
|
|
// LUA_MINSTACK is the guaranteed number of Lua stack slots available to a C function
|
2021-12-01 09:03:18 +08:00
|
|
|
#ifndef LUA_MINSTACK
|
2021-10-30 04:25:12 +08:00
|
|
|
#define LUA_MINSTACK 20
|
2021-12-01 09:03:18 +08:00
|
|
|
#endif
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2022-08-05 06:35:33 +08:00
|
|
|
// LUAI_MAXCSTACK limits the number of Lua stack slots that a C function can use
|
2021-12-01 09:03:18 +08:00
|
|
|
#ifndef LUAI_MAXCSTACK
|
2021-10-30 04:25:12 +08:00
|
|
|
#define LUAI_MAXCSTACK 8000
|
2021-12-01 09:03:18 +08:00
|
|
|
#endif
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2022-08-05 06:35:33 +08:00
|
|
|
// LUAI_MAXCALLS limits the number of nested calls
|
2021-12-01 09:03:18 +08:00
|
|
|
#ifndef LUAI_MAXCALLS
|
2021-10-30 04:25:12 +08:00
|
|
|
#define LUAI_MAXCALLS 20000
|
2021-12-01 09:03:18 +08:00
|
|
|
#endif
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2022-08-05 06:35:33 +08:00
|
|
|
// LUAI_MAXCCALLS is the maximum depth for nested C calls; this limit depends on native stack size
|
2021-12-01 09:03:18 +08:00
|
|
|
#ifndef LUAI_MAXCCALLS
|
2021-10-30 04:25:12 +08:00
|
|
|
#define LUAI_MAXCCALLS 200
|
2021-12-01 09:03:18 +08:00
|
|
|
#endif
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2022-08-05 06:35:33 +08:00
|
|
|
// buffer size used for on-stack string operations; this limit depends on native stack size
|
2021-12-01 09:03:18 +08:00
|
|
|
#ifndef LUA_BUFFERSIZE
|
2021-10-30 04:25:12 +08:00
|
|
|
#define LUA_BUFFERSIZE 512
|
2021-12-01 09:03:18 +08:00
|
|
|
#endif
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2022-08-05 06:35:33 +08:00
|
|
|
// number of valid Lua userdata tags
|
2021-12-01 09:03:18 +08:00
|
|
|
#ifndef LUA_UTAG_LIMIT
|
2021-10-30 04:25:12 +08:00
|
|
|
#define LUA_UTAG_LIMIT 128
|
2021-12-01 09:03:18 +08:00
|
|
|
#endif
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2022-08-05 06:35:33 +08:00
|
|
|
// upper bound for number of size classes used by page allocator
|
2021-12-01 09:03:18 +08:00
|
|
|
#ifndef LUA_SIZECLASSES
|
2021-10-30 04:25:12 +08:00
|
|
|
#define LUA_SIZECLASSES 32
|
2021-12-01 09:03:18 +08:00
|
|
|
#endif
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2022-08-05 06:35:33 +08:00
|
|
|
// available number of separate memory categories
|
2021-12-01 09:03:18 +08:00
|
|
|
#ifndef LUA_MEMORY_CATEGORIES
|
2021-10-30 04:25:12 +08:00
|
|
|
#define LUA_MEMORY_CATEGORIES 256
|
2021-12-01 09:03:18 +08:00
|
|
|
#endif
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2022-08-05 06:35:33 +08:00
|
|
|
// minimum size for the string table (must be power of 2)
|
2021-12-01 09:03:18 +08:00
|
|
|
#ifndef LUA_MINSTRTABSIZE
|
2021-10-30 04:25:12 +08:00
|
|
|
#define LUA_MINSTRTABSIZE 32
|
2021-12-01 09:03:18 +08:00
|
|
|
#endif
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2022-08-05 06:35:33 +08:00
|
|
|
// maximum number of captures supported by pattern matching
|
2021-12-01 09:03:18 +08:00
|
|
|
#ifndef LUA_MAXCAPTURES
|
2021-10-30 04:25:12 +08:00
|
|
|
#define LUA_MAXCAPTURES 32
|
2021-12-01 09:03:18 +08:00
|
|
|
#endif
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2022-09-24 03:17:25 +08:00
|
|
|
// enables callbacks to redirect code execution from Luau VM to a custom implementation
|
|
|
|
#ifndef LUA_CUSTOM_EXECUTION
|
|
|
|
#define LUA_CUSTOM_EXECUTION 0
|
|
|
|
#endif
|
|
|
|
|
2022-08-05 06:35:33 +08:00
|
|
|
// }==================================================================
|
2021-10-30 04:25:12 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
|
|
|
|
** CHANGE it if your system requires alignments larger than double. (For
|
|
|
|
** instance, if your system supports long doubles and they must be
|
|
|
|
** aligned in 16-byte boundaries, then you should add long double in the
|
|
|
|
** union.) Probably you do not need to change this.
|
|
|
|
*/
|
|
|
|
#define LUAI_USER_ALIGNMENT_T \
|
|
|
|
union \
|
|
|
|
{ \
|
|
|
|
double u; \
|
|
|
|
void* s; \
|
|
|
|
long l; \
|
|
|
|
}
|
2021-11-22 23:42:33 +08:00
|
|
|
|
2022-08-05 06:35:33 +08:00
|
|
|
#define LUA_VECTOR_SIZE 3 // must be 3 or 4
|
2021-11-22 23:42:33 +08:00
|
|
|
|
|
|
|
#define LUA_EXTRA_SIZE LUA_VECTOR_SIZE - 2
|