Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -7,24 +7,20 @@ example.c: $(shell find example -type f) $(shell find lib -type f) xvfs.c.rvt xvfs-create Makefile ./xvfs-create --directory example --name example > example.c.new mv example.c.new example.c -example.o: example.c xvfs-core.h Makefile +example.o: example.c xvfs-core.h xvfs-core.c Makefile $(CC) $(CPPFLAGS) $(CFLAGS) -o example.o -c example.c -xvfs-core.o: xvfs-core.c xvfs-core.h Makefile - $(CC) $(CPPFLAGS) $(CFLAGS) -o xvfs-core.o -c xvfs-core.c - -example.so: example.o xvfs-core.o Makefile - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o example.so example.o xvfs-core.o $(LIBS) +example.so: example.o Makefile + $(CC) $(CFLAGS) $(LDFLAGS) -shared -o example.so example.o $(LIBS) test: example.so echo 'if {[catch { load ./example.so Xvfs_example; source //xvfs:/example/main.tcl }]} { puts stderr $$::errorInfo; exit 1 }; exit 0' | tclsh clean: rm -f example.so example.o example.c - rm -f xvfs-core.o distclean: clean .PHONY: all clean distclean test Index: xvfs-core.c ================================================================== --- xvfs-core.c +++ xvfs-core.c @@ -125,11 +125,11 @@ * process at runtime, if found do #2, otherwise * fallback to #1 * */ static Tcl_Filesystem xvfs_tclfs_standalone_fs; -int xvfs_standalone_register(Tcl_Interp *interp, struct Xvfs_FSInfo *fsInfo) { +static int xvfs_standalone_register(Tcl_Interp *interp, struct Xvfs_FSInfo *fsInfo) { int tcl_ret; static int registered = 0; /* * Ensure this instance is not already registered @@ -198,11 +198,11 @@ return(TCL_OK); } #endif /* XVFS_MODE_STANDALONE || XVFS_MODE_FLEXIBLE */ #if defined(XVFS_MODE_FLEXIBLE) -int xvfs_flexible_register(Tcl_Interp *interp, struct Xvfs_FSInfo *fsInfo) { +static int xvfs_flexible_register(Tcl_Interp *interp, struct Xvfs_FSInfo *fsInfo) { ClientData fsHandlerDataRaw; struct xvfs_tclfs_server_info *fsHandlerData; const Tcl_Filesystem *fsHandler; int (*xvfs_register)(Tcl_Interp *interp, struct Xvfs_FSInfo *fsInfo); Tcl_Obj *rootPathObj; Index: xvfs-core.h ================================================================== --- xvfs-core.h +++ xvfs-core.h @@ -24,22 +24,22 @@ * In standalone mode, we just redefine calls to * Xvfs_Register() to go to the xvfs_standalone_register() * function */ # define Xvfs_Register xvfs_standalone_register -XVFS_REGISTER_INTERFACE(Xvfs_Register) +static XVFS_REGISTER_INTERFACE(Xvfs_Register) #elif defined(XVFS_MODE_FLEXIBLE) /* - * In flexible mode we declare an external symbol named - * Xvfs_Register(), as well as an internal symbol called - * xvfs_flexible_register(), which we redefine future - * calls to Xvfs_Register() to invoke + * In flexible mode, we just redefine calls to + * Xvfs_Register() to go to the xvfs_flexible_register() + * function which will either dispatch to a common + * core XVFS or use the xvfs_standalone_register() + * function as a standalone would. */ -extern XVFS_REGISTER_INTERFACE(Xvfs_Register) # define Xvfs_Register xvfs_flexible_register -XVFS_REGISTER_INTERFACE(Xvfs_Register) +static XVFS_REGISTER_INTERFACE(Xvfs_Register) #elif defined(XVFS_MODE_CLIENT) /* * In client mode we declare an external symbol named * Xvfs_Register() that must be provided by the environment @@ -56,7 +56,15 @@ #else # error Unsupported XVFS_MODE #endif +/* + * In flexible or standalone mode, directly include what + * would otherwise be a separate translation unit, to + * avoid symbols leaking + */ +#if defined(XVFS_MODE_FLEXIBLE) || defined(XVFS_MODE_STANDALONE) +#include +#endif #endif Index: xvfs-create ================================================================== --- xvfs-create +++ xvfs-create @@ -20,11 +20,14 @@ "dump-tcl" { set xvfs_tcl [file join $sourceDirectory lib xvfs xvfs.tcl] set xvfs_core_h [file join $sourceDirectory xvfs-core.h] set xvfs_core_c [file join $sourceDirectory xvfs-core.c] - set cleanup [list "#include " ""] + set cleanup { + "#include " "" + "#include " "" + } set core_header_data "" append core_header_data [string map $cleanup [read [open $xvfs_core_h]]] "\n" append core_header_data [string map $cleanup [read [open $xvfs_core_c]]] "\n"