Browse Source

new macros 'LUAI_DDEC'/'LUAI_DDEF' to better control declarations and
definitions of non-static variables

Roberto Ierusalimschy 15 years ago
parent
commit
062e809e54
10 changed files with 31 additions and 27 deletions
  1. 2 2
      lctype.c
  2. 2 2
      lctype.h
  3. 2 2
      lobject.c
  4. 2 2
      lobject.h
  5. 3 3
      lopcodes.c
  6. 3 3
      lopcodes.h
  7. 3 3
      ltests.h
  8. 2 2
      ltm.c
  9. 2 2
      ltm.h
  10. 10 6
      luaconf.h

+ 2 - 2
lctype.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lctype.c,v 1.6 2009/05/18 17:15:14 roberto Exp roberto $
+** $Id: lctype.c,v 1.7 2009/05/27 16:51:15 roberto Exp roberto $
 ** 'ctype' functions for Lua
 ** 'ctype' functions for Lua
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -8,7 +8,7 @@
 
 
 #include "lctype.h"
 #include "lctype.h"
 
 
-const lu_byte luai_ctype_[UCHAR_MAX + 2] = {
+LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = {
   0x00,  /* EOZ */
   0x00,  /* EOZ */
   0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
   0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
   0x00,  0x08,  0x08,  0x08,  0x08,  0x08,  0x00,  0x00,
   0x00,  0x08,  0x08,  0x08,  0x08,  0x08,  0x00,  0x00,

+ 2 - 2
lctype.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lctype.h,v 1.6 2009/05/18 17:15:14 roberto Exp roberto $
+** $Id: lctype.h,v 1.7 2009/05/27 16:51:15 roberto Exp roberto $
 ** 'ctype' functions for Lua
 ** 'ctype' functions for Lua
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -44,7 +44,7 @@
 
 
 
 
 /* one more entry for 0 and one more for -1 (EOZ) */
 /* one more entry for 0 and one more for -1 (EOZ) */
-LUAI_DATA const lu_byte luai_ctype_[UCHAR_MAX + 2];
+LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2];
 
 
 #endif
 #endif
 
 

+ 2 - 2
lobject.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lobject.c,v 2.31 2009/06/17 17:48:34 roberto Exp roberto $
+** $Id: lobject.c,v 2.32 2009/11/06 17:07:12 roberto Exp roberto $
 ** Some generic functions over Lua objects
 ** Some generic functions over Lua objects
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -25,7 +25,7 @@
 
 
 
 
 
 
-const TValue luaO_nilobject_ = {NILCONSTANT};
+LUAI_DDEF const TValue luaO_nilobject_ = {NILCONSTANT};
 
 
 
 
 /*
 /*

+ 2 - 2
lobject.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lobject.h,v 2.31 2009/11/05 17:43:54 roberto Exp roberto $
+** $Id: lobject.h,v 2.32 2009/11/06 17:09:27 roberto Exp roberto $
 ** Type definitions for Lua objects
 ** Type definitions for Lua objects
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -370,7 +370,7 @@ typedef struct Table {
 
 
 #define luaO_nilobject		(&luaO_nilobject_)
 #define luaO_nilobject		(&luaO_nilobject_)
 
 
-LUAI_DATA const TValue luaO_nilobject_;
+LUAI_DDEC const TValue luaO_nilobject_;
 
 
 LUAI_FUNC int luaO_int2fb (unsigned int x);
 LUAI_FUNC int luaO_int2fb (unsigned int x);
 LUAI_FUNC int luaO_fb2int (int x);
 LUAI_FUNC int luaO_fb2int (int x);

+ 3 - 3
lopcodes.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lopcodes.c,v 1.39 2008/04/02 16:16:06 roberto Exp roberto $
+** $Id: lopcodes.c,v 1.40 2008/10/30 15:39:30 roberto Exp roberto $
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
 
 
@@ -13,7 +13,7 @@
 
 
 /* ORDER OP */
 /* ORDER OP */
 
 
-const char *const luaP_opnames[NUM_OPCODES+1] = {
+LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
   "MOVE",
   "MOVE",
   "LOADK",
   "LOADK",
   "LOADBOOL",
   "LOADBOOL",
@@ -60,7 +60,7 @@ const char *const luaP_opnames[NUM_OPCODES+1] = {
 
 
 #define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m))
 #define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m))
 
 
-const lu_byte luaP_opmodes[NUM_OPCODES] = {
+LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
 /*       T  A    B       C     mode		   opcode	*/
 /*       T  A    B       C     mode		   opcode	*/
   opmode(0, 1, OpArgR, OpArgN, iABC)		/* OP_MOVE */
   opmode(0, 1, OpArgR, OpArgN, iABC)		/* OP_MOVE */
  ,opmode(0, 1, OpArgK, OpArgN, iABx)		/* OP_LOADK */
  ,opmode(0, 1, OpArgK, OpArgN, iABx)		/* OP_LOADK */

+ 3 - 3
lopcodes.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lopcodes.h,v 1.131 2009/09/28 16:32:50 roberto Exp roberto $
+** $Id: lopcodes.h,v 1.132 2009/10/28 12:20:07 roberto Exp roberto $
 ** Opcodes for Lua virtual machine
 ** Opcodes for Lua virtual machine
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -270,7 +270,7 @@ enum OpArgMask {
   OpArgK   /* argument is a constant or register/constant */
   OpArgK   /* argument is a constant or register/constant */
 };
 };
 
 
-LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES];
+LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES];
 
 
 #define getOpMode(m)	(cast(enum OpMode, luaP_opmodes[m] & 3))
 #define getOpMode(m)	(cast(enum OpMode, luaP_opmodes[m] & 3))
 #define getBMode(m)	(cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
 #define getBMode(m)	(cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
@@ -279,7 +279,7 @@ LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES];
 #define testTMode(m)	(luaP_opmodes[m] & (1 << 7))
 #define testTMode(m)	(luaP_opmodes[m] & (1 << 7))
 
 
 
 
-LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1];  /* opcode names */
+LUAI_DDEC const char *const luaP_opnames[NUM_OPCODES+1];  /* opcode names */
 
 
 
 
 /* number of list items to accumulate before a SETLIST instruction */
 /* number of list items to accumulate before a SETLIST instruction */

+ 3 - 3
ltests.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltests.h,v 2.24 2008/08/05 19:24:46 roberto Exp roberto $
+** $Id: ltests.h,v 2.25 2009/04/17 22:00:01 roberto Exp roberto $
 ** Internal Header for Debugging of the Lua Implementation
 ** Internal Header for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -32,13 +32,13 @@ typedef struct Memcontrol {
   unsigned long memlimit;
   unsigned long memlimit;
 } Memcontrol;
 } Memcontrol;
 
 
-LUAI_DATA Memcontrol l_memcontrol;
+Memcontrol l_memcontrol;
 
 
 
 
 /*
 /*
 ** generic variable for debug tricks
 ** generic variable for debug tricks
 */
 */
-LUAI_DATA void *l_Trick;
+void *l_Trick;
 
 
 
 
 void *debug_realloc (void *ud, void *block, size_t osize, size_t nsize);
 void *debug_realloc (void *ud, void *block, size_t osize, size_t nsize);

+ 2 - 2
ltm.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltm.c,v 2.8 2006/01/10 12:50:00 roberto Exp roberto $
+** $Id: ltm.c,v 2.9 2007/09/10 17:59:32 roberto Exp roberto $
 ** Tag methods
 ** Tag methods
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -20,7 +20,7 @@
 
 
 
 
 
 
-const char *const luaT_typenames[] = {
+LUAI_DDEF const char *const luaT_typenames[] = {
   "nil", "boolean", "userdata", "number",
   "nil", "boolean", "userdata", "number",
   "string", "table", "function", "userdata", "thread",
   "string", "table", "function", "userdata", "thread",
   "proto", "upval"
   "proto", "upval"

+ 2 - 2
ltm.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltm.h,v 2.6 2005/06/06 13:30:25 roberto Exp roberto $
+** $Id: ltm.h,v 2.7 2007/09/10 17:59:32 roberto Exp roberto $
 ** Tag methods
 ** Tag methods
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -43,7 +43,7 @@ typedef enum {
 
 
 #define fasttm(l,et,e)	gfasttm(G(l), et, e)
 #define fasttm(l,et,e)	gfasttm(G(l), et, e)
 
 
-LUAI_DATA const char *const luaT_typenames[];
+LUAI_DDEC const char *const luaT_typenames[];
 
 
 
 
 LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
 LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);

+ 10 - 6
luaconf.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: luaconf.h,v 1.113 2009/11/16 15:51:03 roberto Exp roberto $
+** $Id: luaconf.h,v 1.114 2009/11/19 16:26:52 roberto Exp roberto $
 ** Configuration file for Lua
 ** Configuration file for Lua
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -170,8 +170,9 @@
 /*
 /*
 @@ LUAI_FUNC is a mark for all extern functions that are not to be
 @@ LUAI_FUNC is a mark for all extern functions that are not to be
 @* exported to outside modules.
 @* exported to outside modules.
-@@ LUAI_DATA is a mark for all extern (const) variables that are not to
-@* be exported to outside modules.
+@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
+@* that are not to be exported to outside modules (LUAI_DDEF for
+@* definitions and LUAI_DDEC for declarations).
 ** CHANGE them if you need to mark them in some special way. Elf/gcc
 ** CHANGE them if you need to mark them in some special way. Elf/gcc
 ** (versions 3.2 and later) mark them as "hidden" to optimize access
 ** (versions 3.2 and later) mark them as "hidden" to optimize access
 ** when Lua is compiled as a shared library. Not all elf targets support
 ** when Lua is compiled as a shared library. Not all elf targets support
@@ -182,16 +183,19 @@
 */
 */
 #if defined(luaall_c)
 #if defined(luaall_c)
 #define LUAI_FUNC	static
 #define LUAI_FUNC	static
-#define LUAI_DATA	extern
+#define LUAI_DDEC	static
+#define LUAI_DDEF	static
 
 
 #elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
 #elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
       defined(__ELF__)
       defined(__ELF__)
 #define LUAI_FUNC	__attribute__((visibility("hidden"))) extern
 #define LUAI_FUNC	__attribute__((visibility("hidden"))) extern
-#define LUAI_DATA	LUAI_FUNC
+#define LUAI_DDEC	LUAI_FUNC
+#define LUAI_DDEF	/* empty */
 
 
 #else
 #else
 #define LUAI_FUNC	extern
 #define LUAI_FUNC	extern
-#define LUAI_DATA	extern
+#define LUAI_DDEC	extern
+#define LUAI_DDEF	/* empty */
 #endif
 #endif