Index: .fossil-settings/ignore-glob ================================================================== --- .fossil-settings/ignore-glob +++ .fossil-settings/ignore-glob @@ -30,5 +30,6 @@ profile-bare profile-gperf oprofile_data gmon.out callgrind.out +tclsh-local Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -3,11 +3,13 @@ TCL_CONFIG_SH := $(TCL_CONFIG_SH_DIR)/tclConfig.sh XVFS_ROOT_MOUNTPOINT := //xvfs:/ CPPFLAGS := -DXVFS_ROOT_MOUNTPOINT='"$(XVFS_ROOT_MOUNTPOINT)"' -I. -DUSE_TCL_STUBS=1 -DXVFS_DEBUG $(shell . "${TCL_CONFIG_SH}" && echo "$${TCL_INCLUDE_SPEC}") $(XVFS_ADD_CPPFLAGS) CFLAGS := -fPIC -g3 -ggdb3 -Wall $(XVFS_ADD_CFLAGS) LDFLAGS := $(XVFS_ADD_LDFLAGS) -LIBS := $(shell . "${TCL_CONFIG_SH}" && echo "$${TCL_STUB_LIB_SPEC}") +LIBS := $(XVFS_ADD_LIBS) +TCL_LIB := $(shell . "${TCL_CONFIG_SH}" && echo "$${TCL_LIB_SPEC}") +TCL_STUB_LIB := $(shell . "${TCL_CONFIG_SH}" && echo "$${TCL_STUB_LIB_SPEC}") TCLSH := tclsh LIB_SUFFIX := $(shell . "${TCL_CONFIG_SH}"; echo "$${TCL_SHLIB_SUFFIX:-.so}") all: example-standalone$(LIB_SUFFIX) example-client$(LIB_SUFFIX) example-flexible$(LIB_SUFFIX) xvfs$(LIB_SUFFIX) @@ -21,29 +23,29 @@ example-standalone.o: example.c xvfs-core.h xvfs-core.c Makefile $(CC) $(CPPFLAGS) -DXVFS_MODE_STANDALONE $(CFLAGS) -o example-standalone.o -c example.c example-standalone$(LIB_SUFFIX): example-standalone.o Makefile - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o example-standalone$(LIB_SUFFIX) example-standalone.o $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -shared -o example-standalone$(LIB_SUFFIX) example-standalone.o $(LIBS) $(TCL_STUB_LIB) example-client.o: example.c xvfs-core.h Makefile $(CC) $(CPPFLAGS) -DXVFS_MODE_CLIENT $(CFLAGS) -o example-client.o -c example.c example-client$(LIB_SUFFIX): example-client.o Makefile - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o example-client$(LIB_SUFFIX) example-client.o $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -shared -o example-client$(LIB_SUFFIX) example-client.o $(LIBS) $(TCL_STUB_LIB) example-flexible.o: example.c xvfs-core.h Makefile $(CC) $(CPPFLAGS) -DXVFS_MODE_FLEXIBLE $(CFLAGS) -o example-flexible.o -c example.c example-flexible$(LIB_SUFFIX): example-flexible.o Makefile - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o example-flexible$(LIB_SUFFIX) example-flexible.o $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -shared -o example-flexible$(LIB_SUFFIX) example-flexible.o $(LIBS) $(TCL_STUB_LIB) xvfs.o: xvfs-core.h xvfs-core.c Makefile $(CC) $(CPPFLAGS) -DXVFS_MODE_SERVER $(CFLAGS) -o xvfs.o -c xvfs-core.c xvfs$(LIB_SUFFIX): xvfs.o Makefile - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o xvfs$(LIB_SUFFIX) xvfs.o $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -shared -o xvfs$(LIB_SUFFIX) xvfs.o $(LIBS) $(TCL_STUB_LIB) # xvfs-create-standalone is a standalone (i.e., no external dependencies # like lib/minirivet, xvfs-core.c, etc) version of "xvfs-create" xvfs-create-standalone: $(shell find lib -type f) xvfs-create xvfs-core.c xvfs-core.h lib/xvfs/xvfs.c.rvt Makefile rm -f xvfs-create-standalone.new xvfs-create-standalone @@ -107,10 +109,24 @@ ./profile-gperf gprof ./profile-gperf valgrind --tool=callgrind --callgrind-out-file=callgrind.out ./profile-bare 10 2 callgrind_annotate callgrind.out +do-valgrind: Makefile + $(MAKE) test XVFS_TEST_EXIT_ON_FAILURE=0 GDB='valgrind --tool=memcheck --track-origins=yes --leak-check=full' + +tclsh-local: tclsh-local.c + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -UUSE_TCL_STUBS -o tclsh-local tclsh-local.c $(LIBS) $(TCL_LIB) + +do-asan: Makefile + rm -f tclsh-local + $(MAKE) tclsh-local test XVFS_TEST_EXIT_ON_FAILURE=0 CC='clang -fsanitize=address' XVFS_ADD_CFLAGS='-Wno-string-plus-int' TCLSH=./tclsh-local + +do-msan: Makefile + rm -f tclsh-local + $(MAKE) tclsh-local test XVFS_TEST_EXIT_ON_FAILURE=0 CC='clang -fsanitize=memory' XVFS_ADD_CFLAGS='-Wno-string-plus-int' TCLSH=./tclsh-local + clean: rm -f xvfs-create-standalone.new xvfs-create-standalone rm -f xvfs-create-c.o xvfs-create-c rm -f example.c example.c.new example.c.new.1 example.c.new.2 rm -f example-standalone$(LIB_SUFFIX) example-standalone.o @@ -128,9 +144,10 @@ rm -f gmon.out rm -f callgrind.out rm -rf oprofile_data rm -f xvfs-test-coverage.info rm -rf xvfs-test-coverage + rm -f tclsh-local distclean: clean -.PHONY: all clean distclean test do-test do-coverage do-benchmark do-profile +.PHONY: all clean distclean test do-test do-coverage do-benchmark do-profile do-valgrind do-asan do-msan ADDED tclsh-local.c Index: tclsh-local.c ================================================================== --- /dev/null +++ tclsh-local.c @@ -0,0 +1,53 @@ +#include + +/* + * tclAppInit.c -- + * + * Provides a default version of the main program and Tcl_AppInit + * function for Tcl applications (without Tk). + * + * Copyright (c) 1993 The Regents of the University of California. + * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright (c) 1998-1999 by Scriptics Corporation. + * + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. + */ + +/* + *---------------------------------------------------------------------- + * + * Tcl_AppInit -- + * + * This function performs application-specific initialization. Most + * applications, especially those that incorporate additional packages, + * will have their own version of this function. + * + * Results: + * Returns a standard Tcl completion code, and leaves an error message in + * the interp's result if an error occurs. + * + * Side effects: + * Depends on the startup script. + * + *---------------------------------------------------------------------- + */ + +int Tcl_AppInit(Tcl_Interp *interp) { + if (Tcl_Init(interp) == TCL_ERROR) { + return TCL_ERROR; + } + +#ifdef DJGPP + Tcl_SetVar(interp, "tcl_rcFileName", "~/tclsh.rc", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY); +#endif + + return TCL_OK; +} + +int main(int argc, char **argv) { + Tcl_Main(argc, argv, Tcl_AppInit); + return(1); +}