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      1   CC = gcc
     2      2   CFLAGS = -Wall -O3
     3         -CPPFLAGS = -DUSE_TCL_STUBS
            3  +CPPFLAGS = -DUSE_TCL_STUBS -DKITDLL_MAKE_LOADABLE=1 -DHAVE_STDC=1
     4      4   LIBS = -ltclstub8.5
     5      5   
     6         -all: vfs_kitdll_data.so
            6  +all: vfs_kitdll_data_tcl.so
     7      7   
     8         -vfs_kitdll_data.h: dir2c.tcl starpack.vfs
     9         -	./dir2c.tcl vfs_kitdll_data starpack.vfs > vfs_kitdll_data.h
            8  +vfs_kitdll_data_tcl.c: dir2c.tcl starpack.vfs vfs_kitdll_data.c
            9  +	./dir2c.tcl tcl starpack.vfs > vfs_kitdll_data_tcl.c
    10     10   
    11     11   vfs_kitdll.tcl.h: vfs_kitdll.tcl
    12     12   	./stringify.tcl vfs_kitdll.tcl > vfs_kitdll.tcl.h
    13     13   
    14         -vfs_kitdll_data.o: vfs_kitdll_data.c vfs_kitdll_data.h vfs_kitdll.tcl.h
           14  +vfs_kitdll_data_tcl.o: vfs_kitdll_data_tcl.c
    15     15   
    16         -vfs_kitdll_data.so: vfs_kitdll_data.o
    17         -	$(CC) $(CPPFLAGS) $(CFLAGS) -rdynamic -shared $(LDFLAGS) -o vfs_kitdll_data.so vfs_kitdll_data.o $(LIBS)
           16  +vfs_kitdll_data_tcl.so: vfs_kitdll_data_tcl.o
           17  +	$(CC) $(CPPFLAGS) $(CFLAGS) -rdynamic -shared $(LDFLAGS) -o vfs_kitdll_data_tcl.so vfs_kitdll_data_tcl.o $(LIBS)
    18     18   
    19     19   clean:
    20         -	rm -f vfs_kitdll_data.so vfs_kitdll_data.o
    21         -	rm -f vfs_kitdll.tcl.h vfs_kitdll_data.h
           20  +	rm -f vfs_kitdll_data_tcl.so vfs_kitdll_data_tcl.o
           21  +	rm -f vfs_kitdll_data_tcl.c
    22     22   
    23     23   .PHONY: clean

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

   101    101   
   102    102   # Insert dummy entry cooresponding to C dummy entry
   103    103   set files [linsert $files 0 "__DUMMY__"]
   104    104   
   105    105   # Produce C89 compatible header
   106    106   set cpp_tag "KITDLL_[string toupper $hashkey]"
   107    107   set code_tag "kitdll_[string tolower $hashkey]"
          108  +set hashkey [string tolower $hashkey]
   108    109   
   109    110   puts "#ifndef $cpp_tag"
   110    111   puts "#  define $cpp_tag 1"
   111    112   puts {
   112    113   #  ifdef HAVE_STDC
   113    114   #    ifndef HAVE_UNISTD_H
   114    115   #      define HAVE_UNISTD_H 1
................................................................................
   346    347   
   347    348   puts "\t}"
   348    349   puts ""
   349    350   puts "\treturn(num_children);"
   350    351   puts "}"
   351    352   puts ""
   352    353   
          354  +puts "#  ifdef KITDLL_MAKE_LOADABLE"
          355  +
          356  +set fd [open "vfs_kitdll_data.c"]
          357  +puts [read $fd]
          358  +close $fd
          359  +
          360  +
          361  +puts "static cmd_getData_t *getCmdData(const char *hashkey) {"
          362  +puts "\treturn(${code_tag}_getData);"
          363  +puts "}"
          364  +puts ""
          365  +puts "static cmd_getChildren_t *getCmdChildren(const char *hashkey) {"
          366  +puts "\treturn(${code_tag}_getChildren);"
          367  +puts "}"
          368  +puts ""
          369  +
          370  +puts "int Vfs_kitdll_data_${hashkey}_Init(Tcl_Interp *interp) {"
          371  +puts "\tTcl_Command tclCreatComm_ret;"
          372  +puts "\tint tclPkgProv_ret;"
          373  +puts ""
          374  +puts "\ttclCreatComm_ret = Tcl_CreateObjCommand(interp, \"::vfs::kitdll::data::${hashkey}::getMetadata\", getMetadata, NULL, NULL);"
          375  +puts "\tif (!tclCreatComm_ret) {"
          376  +puts "\t\treturn(TCL_ERROR);"
          377  +puts "\t}"
          378  +puts ""
          379  +puts "\ttclCreatComm_ret = Tcl_CreateObjCommand(interp, \"::vfs::kitdll::data::${hashkey}::getData\", getData, NULL, NULL);"
          380  +puts "\tif (!tclCreatComm_ret) {"
          381  +puts "\t\treturn(TCL_ERROR);"
          382  +puts "\t}"
          383  +puts ""
          384  +puts "\ttclCreatComm_ret = Tcl_CreateObjCommand(interp, \"::vfs::kitdll::data::${hashkey}::getChildren\", getChildren, NULL, NULL);"
          385  +puts "\tif (!tclCreatComm_ret) {"
          386  +puts "\t\treturn(TCL_ERROR);"
          387  +puts "\t}"
          388  +puts ""
          389  +puts "\ttclPkgProv_ret = Tcl_PkgProvide(interp, \"vfs::kitdll::data::${hashkey}\", \"1.0\");"
          390  +puts ""
          391  +puts "\treturn(tclPkgProv_ret);"
          392  +puts "\t}"
          393  +puts "#  endif /* KITDLL_MAKE_LOADABLE */"
          394  +
   353    395   puts "#endif /* !$cpp_tag */"

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

    12     12   }
    13     13   
    14     14   proc ::vfs::kitdll::Unmount {local} {
    15     15   	vfs::filesystem unmount $local
    16     16   }
    17     17   
    18     18   # Implementation
           19  +## I/O Handlers (pass to appropriate hashkey)
           20  +namespace eval ::vfs::kitdll::data {}
           21  +proc ::vfs::kitdll::data::getChildren args {
           22  +	set hashkey [lindex $args 0]
           23  +
           24  +	set cmd "::vfs::kitdll::data::${hashkey}::getChildren"
           25  +	set cmd [linsert $args 0 $cmd]
           26  +
           27  +	eval $cmd
           28  +}
           29  +
           30  +proc ::vfs::kitdll::data::getMetadata args {
           31  +	set hashkey [lindex $args 0]
           32  +
           33  +	set cmd "::vfs::kitdll::data::${hashkey}::getMetadata"
           34  +	set cmd [linsert $args 0 $cmd]
           35  +
           36  +	eval $cmd
           37  +}
           38  +
           39  +proc ::vfs::kitdll::data::getData args {
           40  +	set hashkey [lindex $args 0]
           41  +
           42  +	set cmd "::vfs::kitdll::data::${hashkey}::getData"
           43  +	set cmd [linsert $args 0 $cmd]
           44  +
           45  +	eval $cmd
           46  +}
           47  +
    19     48   ## VFS and Chan I/O
    20     49   ### Dispatchers
    21     50   proc ::vfs::kitdll::vfshandler {hashkey subcmd args} {
    22     51   	set cmd $args
    23     52   	set cmd [linsert $cmd 0 "::vfs::kitdll::vfsop_${subcmd}" $hashkey]
    24     53   
    25     54   	return [eval $cmd]
................................................................................
   299    328   }
   300    329   proc ::vfs::kitdll::vfsop_utime {} {
   301    330   	vfs::filesystem posixerror $::vfs::posix(EROFS)
   302    331   }
   303    332   
   304    333   package provide vfs::kitdll 1.0
   305    334   
   306         -::vfs::kitdll::Mount vfs_kitdll_data /tmp
          335  +::vfs::kitdll::Mount tcl /tmp

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

     1         -#define HAVE_STDC 1
     2         -
     3      1   #include <tcl.h>
     4         -#include <stdio.h>
     5      2   #include <stdlib.h>
     6      3   
     7         -#include "vfs_kitdll_data.h"
     8         -
     9      4   typedef struct kitdll_data *(cmd_getData_t)(const char *, unsigned long);
    10      5   typedef unsigned long (cmd_getChildren_t)(const char *, unsigned long *, unsigned long);
    11      6   
    12         -static cmd_getData_t *getCmdData(const char *hashkey) {
    13         -	/* XXX: TODO: Look up symbol using dlsym() */
    14         -	if (strcmp(hashkey, "vfs_kitdll_data") == 0) {
    15         -		return(kitdll_vfs_kitdll_data_getData);
    16         -	}
            7  +/* Your implementation must provide these */
            8  +static cmd_getData_t *getCmdData(const char *hashkey);
            9  +static cmd_getChildren_t *getCmdChildren(const char *hashkey);
    17     10   
    18         -	return(NULL);
    19         -}
    20         -
    21         -static cmd_getChildren_t *getCmdChildren(const char *hashkey) {
    22         -	/* XXX: TODO: Look up symbol using dlsym() */
    23         -	if (strcmp(hashkey, "vfs_kitdll_data") == 0) {
    24         -		return(kitdll_vfs_kitdll_data_getChildren);
    25         -	}
    26         -
    27         -	return(NULL);
    28         -}
    29         -
           11  +/* Tcl Commands */
    30     12   static int getMetadata(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
    31     13   	cmd_getData_t *cmd_getData;
    32     14   	cmd_getChildren_t *cmd_getChildren;
    33     15   	struct kitdll_data *finfo = NULL;
    34     16   	Tcl_Obj *ret_list, *ret_list_items[20];
    35     17   	unsigned long num_children;
    36     18   	const char *hashkey;
................................................................................
   279    261   
   280    262   	free(children);
   281    263   
   282    264   	Tcl_SetObjResult(interp, ret_list);
   283    265   
   284    266   	return(TCL_OK);
   285    267   }
   286         -
   287         -int Vfs_kitdll_data_Init(Tcl_Interp *interp) {   
   288         -	Tcl_Command tclCreatComm_ret;
   289         -	int tclPkgProv_ret;
   290         -
   291         -	tclCreatComm_ret = Tcl_CreateObjCommand(interp, "::vfs::kitdll::data::getMetadata", getMetadata, NULL, NULL);
   292         -	if (!tclCreatComm_ret) {
   293         -		return(TCL_ERROR);
   294         -	}
   295         -
   296         -	tclCreatComm_ret = Tcl_CreateObjCommand(interp, "::vfs::kitdll::data::getData", getData, NULL, NULL);
   297         -	if (!tclCreatComm_ret) {
   298         -		return(TCL_ERROR);
   299         -	}
   300         -
   301         -	tclCreatComm_ret = Tcl_CreateObjCommand(interp, "::vfs::kitdll::data::getChildren", getChildren, NULL, NULL);
   302         -	if (!tclCreatComm_ret) {
   303         -		return(TCL_ERROR);
   304         -	}
   305         -
   306         -	tclPkgProv_ret = Tcl_PkgProvide(interp, "vfs::kitdll::data", "1.0");
   307         -
   308         -	return(tclPkgProv_ret);
   309         -}