Check-in [b8cca3a6b4]
Overview
Comment:In flexible/standalone mode include the core functionality as a header to avoid duplicate symbols
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b8cca3a6b42d9aedb2d9134b30ef668fc3e0d868bce2896511308c48de3bd547
User & Date: rkeene on 2019-05-08 19:42:23
Other Links: manifest | tags
Context
2019-05-22
14:28
Improved minirivet to use lists check-in: 9b0190676f user: rkeene tags: trunk
2019-05-08
19:42
In flexible/standalone mode include the core functionality as a header to avoid duplicate symbols check-in: b8cca3a6b4 user: rkeene tags: trunk
17:25
For --dump-tcl mode dump all dependency C files as well check-in: 7664854ef9 user: rkeene tags: trunk
Changes

Modified Makefile from [1a2e05ec17] to [beb49ead95].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
CPPFLAGS := -I. -DUSE_TCL_STUBS=1 -DXVFS_MODE_FLEXIBLE
CFLAGS   := -fPIC -g3 -ggdb3 -Wall
LDFLAGS  :=
LIBS     := -ltclstub8.6

all: example.so

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
	$(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)

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











|


<
<
<
|
|






<




1
2
3
4
5
6
7
8
9
10
11
12
13
14



15
16
17
18
19
20
21
22

23
24
25
26
CPPFLAGS := -I. -DUSE_TCL_STUBS=1 -DXVFS_MODE_FLEXIBLE
CFLAGS   := -fPIC -g3 -ggdb3 -Wall
LDFLAGS  :=
LIBS     := -ltclstub8.6

all: example.so

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 xvfs-core.c Makefile
	$(CC) $(CPPFLAGS) $(CFLAGS) -o example.o -c example.c




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


distclean: clean

.PHONY: all clean distclean test

Modified xvfs-core.c from [a09ee5d8ff] to [1dde3041c8].

123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
 *                 handler
 *    3. flexible -- Attempts to find a core Xvfs instance for the
 *                   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) {
	int tcl_ret;
	static int registered = 0;
	
	/*
	 * Ensure this instance is not already registered
	 */
	if (registered) {







|







123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
 *                 handler
 *    3. flexible -- Attempts to find a core Xvfs instance for the
 *                   process at runtime, if found do #2, otherwise
 *                   fallback to #1
 *
 */
static Tcl_Filesystem xvfs_tclfs_standalone_fs;
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
	 */
	if (registered) {
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
	}
	
	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) {
	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;

	xvfs_register = &xvfs_standalone_register;







|







196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
	}
	
	return(TCL_OK);
}
#endif /* XVFS_MODE_STANDALONE || XVFS_MODE_FLEXIBLE */

#if defined(XVFS_MODE_FLEXIBLE)
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;

	xvfs_register = &xvfs_standalone_register;

Modified xvfs-core.h from [490b145452] to [689f90a830].

22
23
24
25
26
27
28
29
30
31
32
33
34
35

36

37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60








61
62
#if defined(XVFS_MODE_STANDALONE)
/*
 * 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)

#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

 */
extern XVFS_REGISTER_INTERFACE(Xvfs_Register)
#  define Xvfs_Register xvfs_flexible_register
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
 * we are loaded into
 */
extern XVFS_REGISTER_INTERFACE(Xvfs_Register)

#elif defined(XVFS_MODE_SERVER)
/*
 * In server mode we are going to implementing Xvfs_Register()
 * for flexible/client modes, just forward declare it
 */
XVFS_REGISTER_INTERFACE(Xvfs_Register)

#else
#  error Unsupported XVFS_MODE
#endif










#endif







|



|
<
|
>
|
>

<

|




















>
>
>
>
>
>
>
>


22
23
24
25
26
27
28
29
30
31
32
33

34
35
36
37
38

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#if defined(XVFS_MODE_STANDALONE)
/*
 * In standalone mode, we just redefine calls to
 * Xvfs_Register() to go to the xvfs_standalone_register()
 * function
 */
#  define Xvfs_Register xvfs_standalone_register
static XVFS_REGISTER_INTERFACE(Xvfs_Register)

#elif defined(XVFS_MODE_FLEXIBLE)
/*
 * 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.
 */

#  define Xvfs_Register xvfs_flexible_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
 * we are loaded into
 */
extern XVFS_REGISTER_INTERFACE(Xvfs_Register)

#elif defined(XVFS_MODE_SERVER)
/*
 * In server mode we are going to implementing Xvfs_Register()
 * for flexible/client modes, just forward declare it
 */
XVFS_REGISTER_INTERFACE(Xvfs_Register)

#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 <xvfs-core.c>
#endif

#endif

Modified xvfs-create from [1c8fe7fbaa] to [58057edf98].

18
19
20
21
22
23
24

25


26
27
28
29
30
31
32
		::minirivet::parse $template
	}
	"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 <xvfs-core.h>" ""]



		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"

		puts "#! /usr/bin/env tclsh"
		puts ""







>
|
>
>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
		::minirivet::parse $template
	}
	"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 {
			"#include <xvfs-core.h>" ""
			"#include <xvfs-core.c>" ""
		}

		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"

		puts "#! /usr/bin/env tclsh"
		puts ""