new macros 'LUAI_DDEC'/'LUAI_DDEF' to better control declarations and

definitions of non-static variables
This commit is contained in:
Roberto Ierusalimschy
2009-11-19 17:06:52 -02:00
parent b4c1824824
commit 062e809e54
10 changed files with 31 additions and 27 deletions

View File

@@ -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,

View File

@@ -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

View File

@@ -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};
/* /*

View File

@@ -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);

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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);

4
ltm.c
View File

@@ -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"

4
ltm.h
View File

@@ -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);

View File

@@ -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 @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
@* be exported to outside modules. @* 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