Check-in [e4de9a2934]
Overview
Comment:Updated to create loadable filesystem by including C-Tcl interface when creating C version of directory tree (dir2c)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e4de9a293440484a5584e278931ab310186149a5
User & Date: rkeene on 2010-09-26 04:51:35
Other Links: manifest | tags
Context
2010-09-26
04:51
Added patch from "Schelte Bron" <s...@wanadoo.nl> to fix build issue on Mac OS X check-in: d57968a24a user: rkeene tags: trunk
04:51
Updated to create loadable filesystem by including C-Tcl interface when creating C version of directory tree (dir2c) check-in: e4de9a2934 user: rkeene tags: trunk
04:51
Removed Tcl implementation of getData check-in: 2e1961564b user: rkeene tags: trunk
Changes

Modified kitdll/buildsrc/kitdll-0.0/Makefile from [08cd3293c4] to [ed7666f1a7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
CC = gcc
CFLAGS = -Wall -O3
CPPFLAGS = -DUSE_TCL_STUBS
LIBS = -ltclstub8.5

all: vfs_kitdll_data.so

vfs_kitdll_data.h: dir2c.tcl starpack.vfs
	./dir2c.tcl vfs_kitdll_data starpack.vfs > vfs_kitdll_data.h

vfs_kitdll.tcl.h: vfs_kitdll.tcl
	./stringify.tcl vfs_kitdll.tcl > vfs_kitdll.tcl.h

vfs_kitdll_data.o: vfs_kitdll_data.c vfs_kitdll_data.h vfs_kitdll.tcl.h

vfs_kitdll_data.so: vfs_kitdll_data.o
	$(CC) $(CPPFLAGS) $(CFLAGS) -rdynamic -shared $(LDFLAGS) -o vfs_kitdll_data.so vfs_kitdll_data.o $(LIBS)

clean:
	rm -f vfs_kitdll_data.so vfs_kitdll_data.o
	rm -f vfs_kitdll.tcl.h vfs_kitdll_data.h

.PHONY: clean


|


|

|
|




|

|
|


|
|


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
CC = gcc
CFLAGS = -Wall -O3
CPPFLAGS = -DUSE_TCL_STUBS -DKITDLL_MAKE_LOADABLE=1 -DHAVE_STDC=1
LIBS = -ltclstub8.5

all: vfs_kitdll_data_tcl.so

vfs_kitdll_data_tcl.c: dir2c.tcl starpack.vfs vfs_kitdll_data.c
	./dir2c.tcl tcl starpack.vfs > vfs_kitdll_data_tcl.c

vfs_kitdll.tcl.h: vfs_kitdll.tcl
	./stringify.tcl vfs_kitdll.tcl > vfs_kitdll.tcl.h

vfs_kitdll_data_tcl.o: vfs_kitdll_data_tcl.c

vfs_kitdll_data_tcl.so: vfs_kitdll_data_tcl.o
	$(CC) $(CPPFLAGS) $(CFLAGS) -rdynamic -shared $(LDFLAGS) -o vfs_kitdll_data_tcl.so vfs_kitdll_data_tcl.o $(LIBS)

clean:
	rm -f vfs_kitdll_data_tcl.so vfs_kitdll_data_tcl.o
	rm -f vfs_kitdll_data_tcl.c

.PHONY: clean

Modified kitdll/buildsrc/kitdll-0.0/dir2c.tcl from [4a88bcbca8] to [28f9b94a91].

101
102
103
104
105
106
107

108
109
110
111
112
113
114

# Insert dummy entry cooresponding to C dummy entry
set files [linsert $files 0 "__DUMMY__"]

# Produce C89 compatible header
set cpp_tag "KITDLL_[string toupper $hashkey]"
set code_tag "kitdll_[string tolower $hashkey]"


puts "#ifndef $cpp_tag"
puts "#  define $cpp_tag 1"
puts {
#  ifdef HAVE_STDC
#    ifndef HAVE_UNISTD_H
#      define HAVE_UNISTD_H 1







>







101
102
103
104
105
106
107
108
109
110
111
112
113
114
115

# Insert dummy entry cooresponding to C dummy entry
set files [linsert $files 0 "__DUMMY__"]

# Produce C89 compatible header
set cpp_tag "KITDLL_[string toupper $hashkey]"
set code_tag "kitdll_[string tolower $hashkey]"
set hashkey [string tolower $hashkey]

puts "#ifndef $cpp_tag"
puts "#  define $cpp_tag 1"
puts {
#  ifdef HAVE_STDC
#    ifndef HAVE_UNISTD_H
#      define HAVE_UNISTD_H 1
346
347
348
349
350
351
352









































353

puts "\t}"
puts ""
puts "\treturn(num_children);"
puts "}"
puts ""










































puts "#endif /* !$cpp_tag */"







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395

puts "\t}"
puts ""
puts "\treturn(num_children);"
puts "}"
puts ""

puts "#  ifdef KITDLL_MAKE_LOADABLE"

set fd [open "vfs_kitdll_data.c"]
puts [read $fd]
close $fd


puts "static cmd_getData_t *getCmdData(const char *hashkey) {"
puts "\treturn(${code_tag}_getData);"
puts "}"
puts ""
puts "static cmd_getChildren_t *getCmdChildren(const char *hashkey) {"
puts "\treturn(${code_tag}_getChildren);"
puts "}"
puts ""

puts "int Vfs_kitdll_data_${hashkey}_Init(Tcl_Interp *interp) {"
puts "\tTcl_Command tclCreatComm_ret;"
puts "\tint tclPkgProv_ret;"
puts ""
puts "\ttclCreatComm_ret = Tcl_CreateObjCommand(interp, \"::vfs::kitdll::data::${hashkey}::getMetadata\", getMetadata, NULL, NULL);"
puts "\tif (!tclCreatComm_ret) {"
puts "\t\treturn(TCL_ERROR);"
puts "\t}"
puts ""
puts "\ttclCreatComm_ret = Tcl_CreateObjCommand(interp, \"::vfs::kitdll::data::${hashkey}::getData\", getData, NULL, NULL);"
puts "\tif (!tclCreatComm_ret) {"
puts "\t\treturn(TCL_ERROR);"
puts "\t}"
puts ""
puts "\ttclCreatComm_ret = Tcl_CreateObjCommand(interp, \"::vfs::kitdll::data::${hashkey}::getChildren\", getChildren, NULL, NULL);"
puts "\tif (!tclCreatComm_ret) {"
puts "\t\treturn(TCL_ERROR);"
puts "\t}"
puts ""
puts "\ttclPkgProv_ret = Tcl_PkgProvide(interp, \"vfs::kitdll::data::${hashkey}\", \"1.0\");"
puts ""
puts "\treturn(tclPkgProv_ret);"
puts "\t}"
puts "#  endif /* KITDLL_MAKE_LOADABLE */"

puts "#endif /* !$cpp_tag */"

Modified kitdll/buildsrc/kitdll-0.0/vfs_kitdll.tcl from [7fbf4669d3] to [34b10d5483].

12
13
14
15
16
17
18





























19
20
21
22
23
24
25
}

proc ::vfs::kitdll::Unmount {local} {
	vfs::filesystem unmount $local
}

# Implementation





























## VFS and Chan I/O
### Dispatchers
proc ::vfs::kitdll::vfshandler {hashkey subcmd args} {
	set cmd $args
	set cmd [linsert $cmd 0 "::vfs::kitdll::vfsop_${subcmd}" $hashkey]

	return [eval $cmd]







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







12
13
14
15
16
17
18
19
20
21
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
}

proc ::vfs::kitdll::Unmount {local} {
	vfs::filesystem unmount $local
}

# Implementation
## I/O Handlers (pass to appropriate hashkey)
namespace eval ::vfs::kitdll::data {}
proc ::vfs::kitdll::data::getChildren args {
	set hashkey [lindex $args 0]

	set cmd "::vfs::kitdll::data::${hashkey}::getChildren"
	set cmd [linsert $args 0 $cmd]

	eval $cmd
}

proc ::vfs::kitdll::data::getMetadata args {
	set hashkey [lindex $args 0]

	set cmd "::vfs::kitdll::data::${hashkey}::getMetadata"
	set cmd [linsert $args 0 $cmd]

	eval $cmd
}

proc ::vfs::kitdll::data::getData args {
	set hashkey [lindex $args 0]

	set cmd "::vfs::kitdll::data::${hashkey}::getData"
	set cmd [linsert $args 0 $cmd]

	eval $cmd
}

## VFS and Chan I/O
### Dispatchers
proc ::vfs::kitdll::vfshandler {hashkey subcmd args} {
	set cmd $args
	set cmd [linsert $cmd 0 "::vfs::kitdll::vfsop_${subcmd}" $hashkey]

	return [eval $cmd]
299
300
301
302
303
304
305
306
}
proc ::vfs::kitdll::vfsop_utime {} {
	vfs::filesystem posixerror $::vfs::posix(EROFS)
}

package provide vfs::kitdll 1.0

::vfs::kitdll::Mount vfs_kitdll_data /tmp







|
328
329
330
331
332
333
334
335
}
proc ::vfs::kitdll::vfsop_utime {} {
	vfs::filesystem posixerror $::vfs::posix(EROFS)
}

package provide vfs::kitdll 1.0

::vfs::kitdll::Mount tcl /tmp

Modified kitdll/buildsrc/kitdll-0.0/vfs_kitdll_data.c from [7be7436122] to [78ff5be79c].

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
31
32
33
34
35
36
#define HAVE_STDC 1

#include <tcl.h>
#include <stdio.h>
#include <stdlib.h>

#include "vfs_kitdll_data.h"

typedef struct kitdll_data *(cmd_getData_t)(const char *, unsigned long);
typedef unsigned long (cmd_getChildren_t)(const char *, unsigned long *, unsigned long);


static cmd_getData_t *getCmdData(const char *hashkey) {
	/* XXX: TODO: Look up symbol using dlsym() */
	if (strcmp(hashkey, "vfs_kitdll_data") == 0) {
		return(kitdll_vfs_kitdll_data_getData);
	}

	return(NULL);
}

static cmd_getChildren_t *getCmdChildren(const char *hashkey) {
	/* XXX: TODO: Look up symbol using dlsym() */
	if (strcmp(hashkey, "vfs_kitdll_data") == 0) {
		return(kitdll_vfs_kitdll_data_getChildren);
	}

	return(NULL);
}

static int getMetadata(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
	cmd_getData_t *cmd_getData;
	cmd_getChildren_t *cmd_getChildren;
	struct kitdll_data *finfo = NULL;
	Tcl_Obj *ret_list, *ret_list_items[20];
	unsigned long num_children;
	const char *hashkey;
<
<

<


<
<



>
|
<
<
<
<
<
<
<
<
|
<
<
<
|
|
<
<
<









1

2
3


4
5
6
7
8








9



10
11



12
13
14
15
16
17
18


#include <tcl.h>

#include <stdlib.h>



typedef struct kitdll_data *(cmd_getData_t)(const char *, unsigned long);
typedef unsigned long (cmd_getChildren_t)(const char *, unsigned long *, unsigned long);

/* Your implementation must provide these */
static cmd_getData_t *getCmdData(const char *hashkey);








static cmd_getChildren_t *getCmdChildren(const char *hashkey);




/* Tcl Commands */



static int getMetadata(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
	cmd_getData_t *cmd_getData;
	cmd_getChildren_t *cmd_getChildren;
	struct kitdll_data *finfo = NULL;
	Tcl_Obj *ret_list, *ret_list_items[20];
	unsigned long num_children;
	const char *hashkey;
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309

	free(children);

	Tcl_SetObjResult(interp, ret_list);

	return(TCL_OK);
}

int Vfs_kitdll_data_Init(Tcl_Interp *interp) {   
	Tcl_Command tclCreatComm_ret;
	int tclPkgProv_ret;

	tclCreatComm_ret = Tcl_CreateObjCommand(interp, "::vfs::kitdll::data::getMetadata", getMetadata, NULL, NULL);
	if (!tclCreatComm_ret) {
		return(TCL_ERROR);
	}

	tclCreatComm_ret = Tcl_CreateObjCommand(interp, "::vfs::kitdll::data::getData", getData, NULL, NULL);
	if (!tclCreatComm_ret) {
		return(TCL_ERROR);
	}

	tclCreatComm_ret = Tcl_CreateObjCommand(interp, "::vfs::kitdll::data::getChildren", getChildren, NULL, NULL);
	if (!tclCreatComm_ret) {
		return(TCL_ERROR);
	}

	tclPkgProv_ret = Tcl_PkgProvide(interp, "vfs::kitdll::data", "1.0");

	return(tclPkgProv_ret);
}







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
261
262
263
264
265
266
267

























	free(children);

	Tcl_SetObjResult(interp, ret_list);

	return(TCL_OK);
}