aboutsummaryrefslogtreecommitdiff
path: root/llimits.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-08-21 10:51:17 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-08-21 10:51:17 -0300
commit13d2326a23a6cde050c17c5b856f962e93e06f3d (patch)
treeffda9b12b83cb92cb861a9d3f6dfc87d1cb9265e /llimits.h
parent06c5d3825f03eafc90b56d43f70f70048b785bc8 (diff)
downloadlua-13d2326a23a6cde050c17c5b856f962e93e06f3d.tar.gz
lua-13d2326a23a6cde050c17c5b856f962e93e06f3d.tar.bz2
lua-13d2326a23a6cde050c17c5b856f962e93e06f3d.zip
Some definitions moved from luaconf.h to llimits.h
These definitions were in luaconf.h only because the standard libraries need them. Now that llimits.h is included by the libraries, it offers a more private place for these definitions.
Diffstat (limited to 'llimits.h')
-rw-r--r--llimits.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/llimits.h b/llimits.h
index c4719a15..d115496f 100644
--- a/llimits.h
+++ b/llimits.h
@@ -287,6 +287,55 @@ typedef unsigned long l_uint32;
287#endif 287#endif
288 288
289 289
290
291/*
292** lua_numbertointeger converts a float number with an integral value
293** to an integer, or returns 0 if the float is not within the range of
294** a lua_Integer. (The range comparisons are tricky because of
295** rounding. The tests here assume a two-complement representation,
296** where MININTEGER always has an exact representation as a float;
297** MAXINTEGER may not have one, and therefore its conversion to float
298** may have an ill-defined value.)
299*/
300#define lua_numbertointeger(n,p) \
301 ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \
302 (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \
303 (*(p) = (LUA_INTEGER)(n), 1))
304
305
306
307/*
308** LUAI_FUNC is a mark for all extern functions that are not to be
309** exported to outside modules.
310** LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables,
311** none of which to be exported to outside modules (LUAI_DDEF for
312** definitions and LUAI_DDEC for declarations).
313** Elf/gcc (versions 3.2 and later) mark them as "hidden" to optimize
314** access when Lua is compiled as a shared library. Not all elf targets
315** support this attribute. Unfortunately, gcc does not offer a way to
316** check whether the target offers that support, and those without
317** support give a warning about it. To avoid these warnings, change to
318** the default definition.
319*/
320#if !defined(LUAI_FUNC)
321
322#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
323 defined(__ELF__) /* { */
324#define LUAI_FUNC __attribute__((visibility("internal"))) extern
325#else /* }{ */
326#define LUAI_FUNC extern
327#endif /* } */
328
329#define LUAI_DDEC(dec) LUAI_FUNC dec
330#define LUAI_DDEF /* empty */
331
332#endif
333
334
335/* Give these macros simpler names for internal use */
336#define l_likely(x) luai_likely(x)
337#define l_unlikely(x) luai_unlikely(x)
338
290/* 339/*
291** {================================================================== 340** {==================================================================
292** "Abstraction Layer" for basic report of messages and errors 341** "Abstraction Layer" for basic report of messages and errors