Diff

Differences From Artifact [0dd7284c29]:

To Artifact [24c78e2cb7]:


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
...
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <tcl.h>
#include <stdlib.h>
#include "tcc.h"
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
#ifdef HAVE_PSAPI_H
#  ifdef HAVE_WINDOWS_H
#    include <windows.h>
#  endif
#  include <psapi.h>
#endif

struct TclTCCState {
	TCCState *s;
	int relocated;
};

static void Tcc4tclErrorFunc(Tcl_Interp * interp, char * msg) {
................................................................................
	struct TclTCCState *ts;
	TCCState *s;
	Tcl_Obj *sym_addr;
	static CONST char *options[] = {
		"add_include_path", "add_file",  "add_library", 
		"add_library_path", "add_symbol", "command", "compile",
		"define", "get_symbol", "output_file", "undefine",
		"add_runtime_sym",
		(char *) NULL
	};
	enum options {
		TCC4TCL_ADD_INCLUDE, TCC4TCL_ADD_FILE, TCC4TCL_ADD_LIBRARY, 
		TCC4TCL_ADD_LIBRARY_PATH, TCC4TCL_ADD_SYMBOL, TCC4TCL_COMMAND, TCC4TCL_COMPILE,
		TCC4TCL_DEFINE, TCC4TCL_GET_SYMBOL, TCC4TCL_OUTPUT_FILE, TCC4TCL_UNDEFINE,
		TCC4TCL_ADD_RUNTIME_SYM
	};
	char *str;

	ts = (struct TclTCCState *) cdata;
	s = ts->s;

    if (objc < 2) {
................................................................................
        case TCC4TCL_UNDEFINE:
            if (objc != 3) {
                Tcl_WrongNumArgs(interp, 2, objv, "symbol");
                return TCL_ERROR;
            }
            tcc_undefine_symbol(s,Tcl_GetString(objv[2]));
            return TCL_OK;
	case TCC4TCL_ADD_RUNTIME_SYM:
		if (objc != 3) {
			Tcl_WrongNumArgs(interp, 2, objv, "symbol_name");
			return(TCL_ERROR);
		}

		str = Tcl_GetString(objv[2]);
#ifdef HAVE_DLSYM
		val_p = dlsym(NULL, str);
#elif defined(HAVE_ENUMPROCESSMODULES)
		val_p = NULL;
		{
			HANDLE cur_proc;
			HMODULE *modules;
			DWORD needed, i;

			needed = 0;

			cur_proc = GetCurrentProcess();
			EnumProcessModules(cur_proc, NULL, 0, &needed);

			if (needed > 0) {
				modules = (void *) ckalloc(needed);
				if (EnumProcessModules(cur_proc, modules, needed, &needed)) {
					for (i = 0; i < (needed / sizeof(HMODULE)); i++) {
						val_p = (void *) GetProcAddress(modules[i], str);

						if (val_p) {
							break;
						}
					}
				}

				ckfree((void *) modules);
			}
		}
#else
		val_p = NULL;
#endif

		if (val_p == NULL) {
			Tcl_AppendResult(interp, "symbol not found", NULL);

			return(TCL_ERROR);
		}

		tcc_add_symbol(s, Tcl_GetString(objv[2]), val_p); 

		return(TCL_OK);
        default:
            Tcl_Panic("internal error during option lookup");
    }
    return TCL_OK;
} 

static int Tcc4tclCreateCmd( ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[]){







<
<
<
<
<
<
<
<
<







 







<





|
<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







18
19
20
21
22
23
24









25
26
27
28
29
30
31
..
56
57
58
59
60
61
62

63
64
65
66
67
68

69
70
71
72
73
74
75
...
223
224
225
226
227
228
229

















































230
231
232
233
234
235
236
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <tcl.h>
#include <stdlib.h>
#include "tcc.h"










struct TclTCCState {
	TCCState *s;
	int relocated;
};

static void Tcc4tclErrorFunc(Tcl_Interp * interp, char * msg) {
................................................................................
	struct TclTCCState *ts;
	TCCState *s;
	Tcl_Obj *sym_addr;
	static CONST char *options[] = {
		"add_include_path", "add_file",  "add_library", 
		"add_library_path", "add_symbol", "command", "compile",
		"define", "get_symbol", "output_file", "undefine",

		(char *) NULL
	};
	enum options {
		TCC4TCL_ADD_INCLUDE, TCC4TCL_ADD_FILE, TCC4TCL_ADD_LIBRARY, 
		TCC4TCL_ADD_LIBRARY_PATH, TCC4TCL_ADD_SYMBOL, TCC4TCL_COMMAND, TCC4TCL_COMPILE,
		TCC4TCL_DEFINE, TCC4TCL_GET_SYMBOL, TCC4TCL_OUTPUT_FILE, TCC4TCL_UNDEFINE

	};
	char *str;

	ts = (struct TclTCCState *) cdata;
	s = ts->s;

    if (objc < 2) {
................................................................................
        case TCC4TCL_UNDEFINE:
            if (objc != 3) {
                Tcl_WrongNumArgs(interp, 2, objv, "symbol");
                return TCL_ERROR;
            }
            tcc_undefine_symbol(s,Tcl_GetString(objv[2]));
            return TCL_OK;

















































        default:
            Tcl_Panic("internal error during option lookup");
    }
    return TCL_OK;
} 

static int Tcc4tclCreateCmd( ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[]){