summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-04-12 11:51:53 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-04-12 11:51:53 -0300
commitab964ad7c64d0ff355b061ec045a27126b34aa29 (patch)
treeac2a66188c18d23ea7ef4f781d21e29a8045094c
parentef789d4161b6f2b6c28c28c71268a591e9ec6d42 (diff)
downloadlua-ab964ad7c64d0ff355b061ec045a27126b34aa29.tar.gz
lua-ab964ad7c64d0ff355b061ec045a27126b34aa29.tar.bz2
lua-ab964ad7c64d0ff355b061ec045a27126b34aa29.zip
new macro LUA_MAXUNSIGNED + support for 'short' integers (for tests only)
-rw-r--r--luaconf.h48
1 files changed, 36 insertions, 12 deletions
diff --git a/luaconf.h b/luaconf.h
index 68a02fc4..de12366e 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luaconf.h,v 1.195 2014/04/09 17:05:11 roberto Exp roberto $ 2** $Id: luaconf.h,v 1.196 2014/04/11 19:53:45 roberto Exp roberto $
3** Configuration file for Lua 3** Configuration file for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -536,9 +536,32 @@
536@@ LUA_INTEGER_FMT is the format for writing integers. 536@@ LUA_INTEGER_FMT is the format for writing integers.
537@@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. 537@@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER.
538@@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. 538@@ LUA_MININTEGER is the minimum value for a LUA_INTEGER.
539@@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED.
539@@ lua_integer2str converts an integer to a string. 540@@ lua_integer2str converts an integer to a string.
540*/ 541*/
541 542
543
544/* The following definitions are good for most cases here */
545
546#define LUA_INTEGER_SCAN "%" LUA_INTEGER_FRMLEN "d"
547#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d"
548#define lua_integer2str(s,n) sprintf((s), LUA_INTEGER_FMT, (n))
549
550#define LUA_MAXUNSIGNED (~(LUA_UNSIGNED)0)
551#define LUA_MAXINTEGER ((LUA_INTEGER)(LUA_MAXUNSIGNED >> 1))
552#define LUA_MININTEGER ((LUA_INTEGER)~(LUA_MAXUNSIGNED >> 1))
553
554#define LUAI_UACINT LUA_INTEGER
555
556/*
557** use LUAI_UACINT here to avoid problems with promotions (which can change
558** an unsigned back to a signed type)
559*/
560#define LUA_UNSIGNED unsigned LUAI_UACINT
561
562
563/* now the variable definitions */
564
542#if defined(LUA_INT_INT) /* { int */ 565#if defined(LUA_INT_INT) /* { int */
543 566
544#define LUA_INTEGER int 567#define LUA_INTEGER int
@@ -559,23 +582,24 @@
559#define LUA_INTEGER_FRMLEN "ll" 582#define LUA_INTEGER_FRMLEN "ll"
560#endif 583#endif
561 584
562#else /* }{ */ 585#elif defined(LUA_INT_SHORT) /* }{ short int; for tests */
563 586
564#error "numeric integer type not defined" 587#define LUA_INTEGER short int
588#define LUA_INTEGER_FRMLEN ""
565 589
566#endif /* } */ 590#undef LUA_MAXUNSIGNED
591#undef LUAI_UACINT
592#undef LUA_INTEGER_SCAN
567 593
594#define LUA_MAXUNSIGNED 0xffffu
595#define LUAI_UACINT int
596#define LUA_INTEGER_SCAN "%hd"
568 597
569#define LUA_INTEGER_SCAN "%" LUA_INTEGER_FRMLEN "d" 598#else /* }{ */
570#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d"
571#define lua_integer2str(s,n) sprintf((s), LUA_INTEGER_FMT, (n))
572
573#define LUA_UNSIGNED unsigned LUA_INTEGER
574 599
575#define LUA_MAXINTEGER ((LUA_INTEGER)(~(LUA_UNSIGNED)0 >> 1)) 600#error "numeric integer type not defined"
576#define LUA_MININTEGER ((LUA_INTEGER)~(~(LUA_UNSIGNED)0 >> 1))
577 601
578#define LUAI_UACINT LUA_INTEGER 602#endif /* } */
579 603
580/* }================================================================== */ 604/* }================================================================== */
581 605