├── CVSROOT ├── checkoutlist ├── commitinfo ├── config ├── cvswrappers ├── loginfo ├── modules ├── notify ├── rcsinfo ├── taginfo └── verifymsg └── lua-tcc ├── Makefile ├── lua_tcc.c └── test.lua /CVSROOT/checkoutlist: -------------------------------------------------------------------------------- 1 | # The "checkoutlist" file is used to support additional version controlled 2 | # administrative files in $CVSROOT/CVSROOT, such as template files. 3 | # 4 | # The first entry on a line is a filename which will be checked out from 5 | # the corresponding RCS file in the $CVSROOT/CVSROOT directory. 6 | # The remainder of the line is an error message to use if the file cannot 7 | # be checked out. 8 | # 9 | # File format: 10 | # 11 | # [][] 12 | # 13 | # comment lines begin with '#' 14 | -------------------------------------------------------------------------------- /CVSROOT/commitinfo: -------------------------------------------------------------------------------- 1 | # The "commitinfo" file is used to control pre-commit checks. 2 | # The filter on the right is invoked with the repository and a list 3 | # of files to check. A non-zero exit of the filter program will 4 | # cause the commit to be aborted. 5 | # 6 | # The first entry on a line is a regular expression which is tested 7 | # against the directory that the change is being committed to, relative 8 | # to the $CVSROOT. For the first match that is found, then the remainder 9 | # of the line is the name of the filter to run. 10 | # 11 | # Format strings present in the filter will be replaced as follows: 12 | # %p = path relative to repository 13 | # %r = repository (path portion of $CVSROOT) 14 | # %{s} = file name, file name, ... 15 | # 16 | # If no format strings are present in the filter string, a default of 17 | # " %r %s" will be appended to the filter string, but this usage is 18 | # deprecated. 19 | # 20 | # If the repository name does not match any of the regular expressions in this 21 | # file, the "DEFAULT" line is used, if it is specified. 22 | # 23 | # If the name "ALL" appears as a regular expression it is always used 24 | # in addition to the first matching regex or "DEFAULT". 25 | -------------------------------------------------------------------------------- /CVSROOT/config: -------------------------------------------------------------------------------- 1 | # Set this to "no" if pserver shouldn't check system users/passwords 2 | #SystemAuth=no 3 | 4 | # Put CVS lock files in this directory rather than directly in the repository. 5 | #LockDir=/var/lock/cvs 6 | 7 | # Set `TopLevelAdmin' to `yes' to create a CVS directory at the top 8 | # level of the new working directory when using the `cvs checkout' 9 | # command. 10 | #TopLevelAdmin=no 11 | 12 | # Set `LogHistory' to `all' or `TOEFWUPCGMAR' to log all transactions to the 13 | # history file, or a subset as needed (ie `TMAR' logs all write operations) 14 | #LogHistory=TOEFWUPCGMAR 15 | 16 | # Set `RereadLogAfterVerify' to `always' (the default) to allow the verifymsg 17 | # script to change the log message. Set it to `stat' to force CVS to verify 18 | # that the file has changed before reading it (this can take up to an extra 19 | # second per directory being committed, so it is not recommended for large 20 | # repositories. Set it to `never' (the previous CVS behavior) to prevent 21 | # verifymsg scripts from changing the log message. 22 | #RereadLogAfterVerify=always 23 | 24 | # Set `UserAdminOptions' to the list of `cvs admin' commands (options) 25 | # that users not in the `cvsadmin' group are allowed to run. This 26 | # defaults to `k', or only allowing the changing of the default 27 | # keyword expansion mode for files for users not in the `cvsadmin' group. 28 | # This value is ignored if the `cvsadmin' group does not exist. 29 | # 30 | # The following string would enable all `cvs admin' commands for all 31 | # users: 32 | #UserAdminOptions=aAbceIklLmnNostuU 33 | 34 | # Set `UseNewInfoFmtStrings' to `no' if you must support a legacy system by 35 | # enabling the deprecated old style info file command line format strings. 36 | # Be warned that these strings could be disabled in any new version of CVS. 37 | UseNewInfoFmtStrings=yes 38 | -------------------------------------------------------------------------------- /CVSROOT/cvswrappers: -------------------------------------------------------------------------------- 1 | # This file affects handling of files based on their names. 2 | # 3 | # The -m option specifies whether CVS attempts to merge files. 4 | # 5 | # The -k option specifies keyword expansion (e.g. -kb for binary). 6 | # 7 | # Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers) 8 | # 9 | # wildcard [option value][option value]... 10 | # 11 | # where option is one of 12 | # -f from cvs filter value: path to filter 13 | # -t to cvs filter value: path to filter 14 | # -m update methodology value: MERGE or COPY 15 | # -k expansion mode value: b, o, kkv, &c 16 | # 17 | # and value is a single-quote delimited value. 18 | # For example: 19 | #*.gif -k 'b' 20 | -------------------------------------------------------------------------------- /CVSROOT/loginfo: -------------------------------------------------------------------------------- 1 | # The "loginfo" file controls where "cvs commit" log information 2 | # is sent. The first entry on a line is a regular expression which must match 3 | # the directory that the change is being made to, relative to the 4 | # $CVSROOT. If a match is found, then the remainder of the line is a filter 5 | # program that should expect log information on its standard input. 6 | # 7 | # If the repository name does not match any of the regular expressions in this 8 | # file, the "DEFAULT" line is used, if it is specified. 9 | # 10 | # If the name ALL appears as a regular expression it is always used 11 | # in addition to the first matching regex or DEFAULT. 12 | # 13 | # If any format strings are present in the filter, they will be replaced as follows: 14 | # %p = path relative to repository 15 | # %r = repository (path portion of $CVSROOT) 16 | # %{sVv} = attribute list = file name, old version number (pre-checkin), 17 | # new version number (post-checkin). When either old or new revision is 18 | # unknown, doesn't exist, or isn't applicable, the string "NONE" will be 19 | # placed on the command line instead. 20 | # 21 | # Note that %{sVv} is a list operator and not all elements are necessary. Thus %{sv} is 22 | # a legal format string, but will only be replaced with file name and new revision. 23 | # it also generates multiple arguments for each file being operated upon. i.e. if two 24 | # files, file1 & file2, are being commited from 1.1 to version 1.1.2.1 and from 1.1.2.2 25 | # to 1.1.2.3, respectively, %{sVv} will generate the following six arguments in this 26 | # order: file1, 1.1, 1.1.2.1, file2, 1.1.2.2, 1.1.2.3. 27 | # 28 | # For example: 29 | #DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog 30 | # or 31 | #DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog 32 | -------------------------------------------------------------------------------- /CVSROOT/modules: -------------------------------------------------------------------------------- 1 | # Three different line formats are valid: 2 | # key -a aliases... 3 | # key [options] directory 4 | # key [options] directory files... 5 | # 6 | # Where "options" are composed of: 7 | # -i prog Run "prog" on "cvs commit" from top-level of module. 8 | # -o prog Run "prog" on "cvs checkout" of module. 9 | # -e prog Run "prog" on "cvs export" of module. 10 | # -t prog Run "prog" on "cvs rtag" of module. 11 | # -u prog Run "prog" on "cvs update" of module. 12 | # -d dir Place module in directory "dir" instead of module name. 13 | # -l Top-level directory only -- do not recurse. 14 | # 15 | # NOTE: If you change any of the "Run" options above, you'll have to 16 | # release and re-checkout any working directories of these modules. 17 | # 18 | # And "directory" is a path to a directory relative to $CVSROOT. 19 | # 20 | # The "-a" option specifies an alias. An alias is interpreted as if 21 | # everything on the right of the "-a" had been typed on the command line. 22 | # 23 | # You can encode a module within a module by using the special '&' 24 | # character to interpose another module into the current module. This 25 | # can be useful for creating a module that consists of many directories 26 | # spread out over the entire source repository. 27 | -------------------------------------------------------------------------------- /CVSROOT/notify: -------------------------------------------------------------------------------- 1 | # The "notify" file controls where notifications from watches set by 2 | # "cvs watch add" or "cvs edit" are sent. The first entry on a line is 3 | # a regular expression which is tested against the directory that the 4 | # change is being made to, relative to the $CVSROOT. If it matches, 5 | # then the remainder of the line is a filter program that should contain 6 | # one occurrence of %s for the user to notify, and information on its 7 | # standard input. 8 | # 9 | # "ALL" or "DEFAULT" can be used in place of the regular expression. 10 | # 11 | # format strings are replaceed as follows: 12 | # %p = path relative to repository 13 | # %r = repository (path portion of $CVSROOT) 14 | # %s = user to notify 15 | # 16 | # For example: 17 | #ALL (echo Committed to %r/%p; cat) |mail %s -s "CVS notification" 18 | -------------------------------------------------------------------------------- /CVSROOT/rcsinfo: -------------------------------------------------------------------------------- 1 | # The "rcsinfo" file is used to control templates with which the editor 2 | # is invoked on commit and import. 3 | # 4 | # The first entry on a line is a regular expression which is tested 5 | # against the directory that the change is being made to, relative to the 6 | # $CVSROOT. For the first match that is found, then the remainder of the 7 | # line is the name of the file that contains the template. 8 | # 9 | # If the repository name does not match any of the regular expressions in this 10 | # file, the "DEFAULT" line is used, if it is specified. 11 | # 12 | # If the name "ALL" appears as a regular expression it is always used 13 | # in addition to the first matching regex or "DEFAULT". 14 | -------------------------------------------------------------------------------- /CVSROOT/taginfo: -------------------------------------------------------------------------------- 1 | # The "taginfo" file is used to control pre-tag checks. 2 | # The filter on the right is invoked with the following arguments if no format strings are present: 3 | # 4 | # $1 -- tagname 5 | # $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d 6 | # $3 -- tagtype "?" on delete, "T" for branch, "N" for static 7 | # $4 -- repository 8 | # $5-> file revision [file revision ...] 9 | # 10 | # If any format strings are present in the filter, they will be replaced as follows: 11 | # %b = branch mode = "?" (delete ops - unknown) | "T" (branch) | "N" (not branch) 12 | # %o = operation = "add" | "mov" | "del" 13 | # %p = path relative to repository 14 | # %r = repository (path portion of $CVSROOT) 15 | # %t = tagname 16 | # %{sVv} = attribute list = file name, old version tag will be deleted from, 17 | # new version tag will be added to (or deleted from, but this feature is 18 | # deprecated. When either old or new revision is unknown, doesn't exist, 19 | # or isn't applicable, the string "NONE" will be placed on the command 20 | # line. 21 | # 22 | # Note that %{sVv} is a list operator and not all elements are necessary. Thus %{sV} is 23 | # a legal format string, but will only be replaced with file name and old revision. 24 | # it also generates multiple arguments for each file being operated upon. i.e. if two 25 | # files, file1 & file2, are having a tag moved from version 1.1 to versoin 1.1.2.9, %{sVv} 26 | # will generate the following six arguments in this order: file1, 1.1, 1.1.2.9, file2, 1.1, 27 | # 1.1.2.9. 28 | # 29 | # A non-zero exit of the filter program will cause the tag to be aborted. 30 | # 31 | # The first entry on a line is a regular expression which is tested 32 | # against the directory that the change is being committed to, relative 33 | # to the $CVSROOT. For the first match that is found, then the remainder 34 | # of the line is the name of the filter to run. 35 | # 36 | # If the repository name does not match any of the regular expressions in this 37 | # file, the "DEFAULT" line is used, if it is specified. 38 | # 39 | # If the name "ALL" appears as a regular expression it is always used 40 | # in addition to the first matching regex or "DEFAULT". 41 | -------------------------------------------------------------------------------- /CVSROOT/verifymsg: -------------------------------------------------------------------------------- 1 | # The "verifymsg" file is used to allow verification of logging 2 | # information. It works best when a template (as specified in the 3 | # rcsinfo file) is provided for the logging procedure. Given a 4 | # template with locations for, a bug-id number, a list of people who 5 | # reviewed the code before it can be checked in, and an external 6 | # process to catalog the differences that were code reviewed, the 7 | # following test can be applied to the code: 8 | # 9 | # Making sure that the entered bug-id number is correct. 10 | # Validating that the code that was reviewed is indeed the code being 11 | # checked in (using the bug-id number or a seperate review 12 | # number to identify this particular code set.). 13 | # 14 | # If any of the above test failed, then the commit would be aborted. 15 | # 16 | # Format strings present in the filter will be replaced as follows: 17 | # %p = path relative to repository 18 | # %r = repository (path portion of $CVSROOT) 19 | # %l = name of log file to be verified. 20 | # 21 | # If no format strings are present in the filter, a default " %l" will 22 | # be appended to the filter, but this usage is deprecated. 23 | # 24 | # Actions such as mailing a copy of the report to each reviewer are 25 | # better handled by an entry in the loginfo file. 26 | # 27 | # One thing that should be noted is the the ALL keyword is not 28 | # supported. There can be only one entry that matches a given 29 | # repository. 30 | -------------------------------------------------------------------------------- /lua-tcc/Makefile: -------------------------------------------------------------------------------- 1 | # Compilation parameters 2 | CC = gcc 3 | CWARNS = -Wall -pedantic \ 4 | -Waggregate-return \ 5 | -Wcast-align \ 6 | -Wmissing-prototypes \ 7 | -Wstrict-prototypes \ 8 | -Wnested-externs \ 9 | -Wpointer-arith \ 10 | -Wshadow \ 11 | -Wwrite-strings 12 | 13 | 14 | CFLAGS = $(CONFIG) $(CWARNS) -ansi -g -O2 -I/usr/local/include/lua5 15 | 16 | 17 | lua_tcc.so : lua_tcc.o 18 | ld -o lua_tcc.so -shared lua_tcc.o -ltcc 19 | 20 | 21 | -------------------------------------------------------------------------------- /lua-tcc/lua_tcc.c: -------------------------------------------------------------------------------- 1 | #include "lua.h" 2 | #include "lauxlib.h" 3 | #include "libtcc.h" 4 | 5 | #define RELEASE_MEM 0 /* there's a bug somewhere */ 6 | 7 | static const char TCCStateType[] = "__TCCStateType__"; 8 | 9 | typedef struct { 10 | TCCState *s; 11 | } tcc_userdata; 12 | 13 | static tcc_userdata *check_tcc (lua_State *L, int index) { 14 | tcc_userdata *tcc; 15 | int top = lua_gettop (L); 16 | 17 | if (index < 0 && -index <= top) 18 | index = top+index+1; 19 | 20 | tcc = (tcc_userdata *)luaL_checkudata(L, index, TCCStateType); 21 | luaL_argcheck(L, tcc, index, "TCC state expected"); 22 | return tcc; 23 | } 24 | 25 | 26 | /* 27 | * tcc.new () 28 | */ 29 | static tcc_userdata * tccnew (lua_State *L) 30 | { 31 | tcc_userdata *tcc = (tcc_userdata *)lua_newuserdata (L, sizeof (tcc_userdata)); 32 | /*printf ("allocated tcc=%X\n", tcc);*/ 33 | 34 | tcc->s = tcc_new (); 35 | if (!tcc->s) 36 | luaL_error (L, "Can't create tcc state"); 37 | 38 | /*printf ("allocated tcc->s=%X\n", tcc->s);*/ 39 | 40 | tcc_set_output_type (tcc->s, TCC_OUTPUT_MEMORY); 41 | 42 | luaL_getmetatable (L, TCCStateType); 43 | lua_setmetatable (L, -2); 44 | return tcc; 45 | } 46 | 47 | static void add_library (lua_State *L, TCCState *s, int index) 48 | { 49 | const char *libname = luaL_checkstring (L, index); 50 | if (tcc_add_library (s, libname)) 51 | luaL_error (L, "can't load library %s", libname); 52 | } 53 | 54 | static void push_symbol (lua_State *L, int tccindex, int nameindex) 55 | { 56 | unsigned long sym; 57 | lua_CFunction f; 58 | tcc_userdata *tcc = check_tcc (L, tccindex); 59 | const char *funcname = luaL_checkstring (L, nameindex); 60 | 61 | if (tcc_get_symbol (tcc->s, &sym, funcname) < 0) 62 | luaL_error (L, "can't get symbol %s", funcname); 63 | f = (lua_CFunction)sym; 64 | 65 | lua_pushvalue (L, tccindex); 66 | lua_pushcclosure (L, f, 1); 67 | } 68 | 69 | /* 70 | * tcc.compile (code, funcname [, libs]) 71 | */ 72 | static int compile (lua_State *L) 73 | { 74 | const char *code = luaL_checkstring (L, 1); 75 | tcc_userdata *tcc; 76 | 77 | /* check params */ 78 | if (!lua_isstring (L, 2) && !lua_istable (L, 2)) 79 | luaL_error (L, "arg 2: string or table expected, got %s", lua_typename (L, lua_type (L,2))); 80 | 81 | if (lua_gettop (L) > 2 && !lua_isstring (L, 3) && !lua_istable (L, 3)) 82 | luaL_error (L, "arg 3: optional string or table expected, got %s", lua_typename (L, lua_type (L,3))); 83 | 84 | /* TCC state is at top of stack */ 85 | tcc = tccnew (L); 86 | 87 | /* add libs */ 88 | if (lua_istable (L, 3)) { 89 | lua_pushnil (L); 90 | while (lua_next (L, 3)) { 91 | add_library (L, tcc->s, -1); 92 | lua_pop (L, 1); 93 | } 94 | } else if (lua_isstring (L, 3)) { 95 | add_library (L, tcc->s, 3); 96 | } 97 | 98 | /* compile & link */ 99 | if (tcc_compile_string (tcc->s, code)) 100 | luaL_error (L, "can't compile %s", code); 101 | 102 | if (tcc_relocate (tcc->s)) 103 | luaL_error (L, "bad tcc_relocate"); 104 | 105 | /* get named symbol(s) as cfunction (s) */ 106 | if (lua_istable (L, 2)) { 107 | lua_newtable (L); 108 | lua_pushnil (L); 109 | while (lua_next (L, 2)) { 110 | push_symbol (L, -4, -1); 111 | lua_settable (L, -4); 112 | } 113 | 114 | } else if (lua_isstring (L, 2)) { 115 | push_symbol (L, -1, 2); 116 | 117 | } else { 118 | luaL_error (L, "arg 2: string or table expected, got %s", lua_typename (L, lua_type (L,2))); 119 | } 120 | 121 | return 1; 122 | } 123 | 124 | 125 | 126 | /* 127 | * __gc 128 | */ 129 | static int gc (lua_State *L) 130 | { 131 | #if RELEASE_MEM 132 | tcc_userdata *tcc = check_tcc (L, 1); 133 | printf ("gcc (tcc=%X)\n", tcc); 134 | if (tcc && tcc->s) { 135 | printf ("deleting tcc->s=%X\n", tcc->s); 136 | tcc_delete (tcc->s); 137 | tcc->s = NULL; 138 | } 139 | printf ("fin\n"); 140 | #endif 141 | 142 | return 0; 143 | } 144 | 145 | static const struct luaL_reg tcc_meths [] = { 146 | {"__gc", gc}, 147 | {NULL, NULL} 148 | }; 149 | 150 | static const struct luaL_reg tcc_funcs[] = { 151 | {"compile", compile}, 152 | {NULL, NULL} 153 | }; 154 | 155 | /* 156 | ** Assumes the table is on top of the stack. 157 | */ 158 | static void set_info (lua_State *L) { 159 | lua_pushliteral (L, "_COPYRIGHT"); 160 | lua_pushliteral (L, "Copyright (C) 2006 Javier Guerra"); 161 | lua_settable (L, -3); 162 | lua_pushliteral (L, "_DESCRIPTION"); 163 | lua_pushliteral (L, "TCC runtime C compiler"); 164 | lua_settable (L, -3); 165 | lua_pushliteral (L, "_NAME"); 166 | lua_pushliteral (L, "lua_tcc"); 167 | lua_settable (L, -3); 168 | lua_pushliteral (L, "_VERSION"); 169 | lua_pushliteral (L, "0.1"); 170 | lua_settable (L, -3); 171 | } 172 | 173 | int luaopen_lua_tcc (lua_State *L); 174 | int luaopen_lua_tcc (lua_State *L) 175 | { 176 | luaL_newmetatable(L, TCCStateType); 177 | lua_pushliteral(L, "__index"); 178 | lua_pushvalue(L, -2); 179 | lua_rawset(L, -3); 180 | luaL_openlib (L, NULL, tcc_meths, 0); 181 | luaL_openlib (L, "tcc", tcc_funcs, 0); 182 | set_info (L); 183 | 184 | return 1; 185 | } 186 | -------------------------------------------------------------------------------- /lua-tcc/test.lua: -------------------------------------------------------------------------------- 1 | require "lua_tcc" 2 | 3 | m = tcc.compile ([[ 4 | 5 | #include "lua.h" 6 | 7 | typedef struct { 8 | void *s; 9 | } tcc_userdata; 10 | 11 | void hi (void) { 12 | printf ("hi!\n"); 13 | } 14 | 15 | void bye (void) { 16 | printf ("bye..!\n"); 17 | } 18 | 19 | int count (lua_State *L) { 20 | printf ("hay %d parametros\n", lua_gettop (L)); 21 | lua_pushnumber (L, lua_gettop (L)); 22 | return 1; 23 | } 24 | 25 | int tell (lua_State *L) { 26 | tcc_userdata *p = lua_touserdata (L, lua_upvalueindex(1)); 27 | lua_pushnumber (L, lua_upvalueindex(1)); 28 | lua_pushlightuserdata (L, p); 29 | lua_pushlightuserdata (L, p->s); 30 | return 3; 31 | } 32 | 33 | ]], {"hi", "bye", "count", "tell"}) 34 | 35 | x = tcc.compile ([[ 36 | #include 37 | #include 38 | 39 | #include "lua.h" 40 | 41 | int main(int argc, char **argv) 42 | { 43 | Display *display; 44 | Screen *screen; 45 | 46 | raptor_init (); 47 | 48 | display = XOpenDisplay(""); 49 | if (!display) { 50 | fprintf(stderr, "Could not open X11 display\n"); 51 | exit(1); 52 | } 53 | printf("X11 display opened.\n"); 54 | screen = XScreenOfDisplay(display, 0); 55 | printf("width = %d\nheight = %d\ndepth = %d\n", 56 | screen->width, 57 | screen->height, 58 | screen->root_depth); 59 | XCloseDisplay(display); 60 | return 0; 61 | } 62 | 63 | typedef struct { 64 | void *s; 65 | } tcc_userdata; 66 | 67 | int tell (lua_State *L) { 68 | tcc_userdata *p = lua_touserdata (L, lua_upvalueindex(1)); 69 | lua_pushnumber (L, lua_upvalueindex(1)); 70 | lua_pushlightuserdata (L, p); 71 | lua_pushlightuserdata (L, p->s); 72 | return 3; 73 | } 74 | 75 | ]], {"main", "tell"}, {"X11", "raptor"}) 76 | 77 | y = tcc.compile ([[ 78 | #include "lua.h" 79 | 80 | typedef struct { 81 | void *s; 82 | } tcc_userdata; 83 | 84 | int tell (lua_State *L) { 85 | tcc_userdata *p = lua_touserdata (L, lua_upvalueindex(1)); 86 | lua_pushnumber (L, lua_upvalueindex(1)); 87 | lua_pushlightuserdata (L, p); 88 | lua_pushlightuserdata (L, p->s); 89 | return 3; 90 | } 91 | ]], "tell") --------------------------------------------------------------------------------