Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/VM/include/luaconf.h
2725 views
1
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2
// This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
3
#pragma once
4
5
// When debugging complex issues, consider enabling one of these:
6
// This will reallocate the stack very aggressively at every opportunity; use this with asan to catch stale stack pointers
7
// #define HARDSTACKTESTS 1
8
// This will call GC validation very aggressively at every incremental GC step; use this with caution as it's SLOW
9
// #define HARDMEMTESTS 1
10
// This will call GC validation very aggressively at every GC opportunity; use this with caution as it's VERY SLOW
11
// #define HARDMEMTESTS 2
12
13
// To force MSVC2017+ to generate SSE2 code for some stdlib functions we need to locally enable /fp:fast
14
// Note that /fp:fast changes the semantics of floating point comparisons so this is only safe to do for functions without ones
15
#if defined(_MSC_VER) && !defined(__clang__)
16
#define LUAU_FASTMATH_BEGIN __pragma(float_control(precise, off, push))
17
#define LUAU_FASTMATH_END __pragma(float_control(pop))
18
#else
19
#define LUAU_FASTMATH_BEGIN
20
#define LUAU_FASTMATH_END
21
#endif
22
23
// Some functions like floor/ceil have SSE4.1 equivalents but we currently support systems without SSE4.1
24
// Note that we only need to do this when SSE4.1 support is not guaranteed by compiler settings, as otherwise compiler will optimize these for us.
25
#if (defined(__x86_64__) || defined(_M_X64)) && !defined(__SSE4_1__) && !defined(__AVX__)
26
#if defined(_MSC_VER) && !defined(__clang__)
27
#define LUAU_TARGET_SSE41
28
#elif defined(__GNUC__) && defined(__has_attribute)
29
#if __has_attribute(target)
30
#define LUAU_TARGET_SSE41 __attribute__((target("sse4.1")))
31
#endif
32
#endif
33
#endif
34
35
// Used on functions that have a printf-like interface to validate them statically
36
#if defined(__GNUC__)
37
#define LUA_PRINTF_ATTR(fmt, arg) __attribute__((format(printf, fmt, arg)))
38
#else
39
#define LUA_PRINTF_ATTR(fmt, arg)
40
#endif
41
42
#ifdef _MSC_VER
43
#define LUA_NORETURN __declspec(noreturn)
44
#else
45
#define LUA_NORETURN __attribute__((__noreturn__))
46
#endif
47
48
// Can be used to reconfigure visibility/exports for public APIs
49
#ifndef LUA_API
50
#define LUA_API extern
51
#endif
52
53
#define LUALIB_API LUA_API
54
55
// Can be used to reconfigure visibility for internal APIs
56
#if defined(__GNUC__)
57
#define LUAI_FUNC __attribute__((visibility("hidden"))) extern
58
#define LUAI_DATA LUAI_FUNC
59
#else
60
#define LUAI_FUNC extern
61
#define LUAI_DATA extern
62
#endif
63
64
// Can be used to reconfigure internal error handling to use longjmp instead of C++ EH
65
#ifndef LUA_USE_LONGJMP
66
#define LUA_USE_LONGJMP 0
67
#endif
68
69
// LUA_IDSIZE gives the maximum size for the description of the source
70
#ifndef LUA_IDSIZE
71
#define LUA_IDSIZE 256
72
#endif
73
74
// LUA_MINSTACK is the guaranteed number of Lua stack slots available to a C function
75
#ifndef LUA_MINSTACK
76
#define LUA_MINSTACK 20
77
#endif
78
79
// LUAI_MAXCSTACK limits the number of Lua stack slots that a C function can use
80
#ifndef LUAI_MAXCSTACK
81
#define LUAI_MAXCSTACK 8000
82
#endif
83
84
// LUAI_MAXCALLS limits the number of nested calls
85
#ifndef LUAI_MAXCALLS
86
#define LUAI_MAXCALLS 20000
87
#endif
88
89
// LUAI_MAXCCALLS is the maximum depth for nested C calls; this limit depends on native stack size
90
#ifndef LUAI_MAXCCALLS
91
#define LUAI_MAXCCALLS 200
92
#endif
93
94
// buffer size used for on-stack string operations; this limit depends on native stack size
95
#ifndef LUA_BUFFERSIZE
96
#define LUA_BUFFERSIZE 512
97
#endif
98
99
// number of valid Lua userdata tags
100
#ifndef LUA_UTAG_LIMIT
101
#define LUA_UTAG_LIMIT 128
102
#endif
103
104
// number of valid Lua lightuserdata tags
105
#ifndef LUA_LUTAG_LIMIT
106
#define LUA_LUTAG_LIMIT 128
107
#endif
108
109
// upper bound for number of size classes used by page allocator
110
#ifndef LUA_SIZECLASSES
111
#define LUA_SIZECLASSES 40
112
#endif
113
114
// available number of separate memory categories
115
#ifndef LUA_MEMORY_CATEGORIES
116
#define LUA_MEMORY_CATEGORIES 256
117
#endif
118
119
// extra storage for execution callbacks in global state
120
#ifndef LUA_EXECUTION_CALLBACK_STORAGE
121
#define LUA_EXECUTION_CALLBACK_STORAGE 512
122
#endif
123
124
// minimum size for the string table (must be power of 2)
125
#ifndef LUA_MINSTRTABSIZE
126
#define LUA_MINSTRTABSIZE 32
127
#endif
128
129
// maximum number of captures supported by pattern matching
130
#ifndef LUA_MAXCAPTURES
131
#define LUA_MAXCAPTURES 32
132
#endif
133
134
// }==================================================================
135
136
#ifndef LUA_VECTOR_SIZE
137
#define LUA_VECTOR_SIZE 3 // must be 3 or 4
138
#endif
139
140
#define LUA_EXTRA_SIZE (LUA_VECTOR_SIZE - 2)
141
142