diff options
Diffstat (limited to 'llimits.h')
| -rw-r--r-- | llimits.h | 49 |
1 files changed, 49 insertions, 0 deletions
| @@ -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 |
