Version 13 of odyce

Updated 2007-10-01 14:34:16 by suchenwi

Embedded C compiler. Similar to critcl, but without needing a compiler or linker to be installed on target machine. Currently available only as part of eTcl binary distribution.

List of supported architectures:

  • Linux: x86 and arm
  • Win32
  • WinCE (Windows Mobile)
  • Mac OS X: x86

Official home page: http://www.evolane.com/software/odyce/index.html

Partial emulation of Critcl on top of Odyce is also available.


RS 2007-10-01: http://www.evolane.com/software/odyce/index.html says: "This package contains softwares covered by other licenses: TinyCC .. LGPL". Is that tcc? Also, some examples would be very welcome. That pages mentions that no headers are required - not even <stdio.h> and friends? EH System headers, together with Tcl/Tk ones, are embedded into VFS, and system include directory for embedded C compiler is automatically setup to find them there. So you can use #include <stdio.h> and friends in your code without having to care about any header installed on target machine.

wdb 2007-10-01 -- just downloaded etcl, but sadly, no documentation available. Are there any users out there with some example applications? EH 2007-10-01 Odyce announce, together with 1.0-rc23, was a very early announce, to let others know about this previously hidden feature. We are working hard this week on providing samples, documentation, and imrpoving critcl emulation (so that all critcl documentation should be adequate too). This page is good place to keep in sync until our official site gets updated.

RS: Eric Hassold himself posted an example today on fr.comp.lang.tcl:

 # Inutile de charger odyce 
 # package require odyce 
 # Car l'emulation de critcl s'en charge 
 package require critcl 


 # Bug stupide dans la version embarquee 
 # (ai oublie d'initialiser la liste a vide) 
 #::critcl::csources "" 
 set ::critcl::critcl(cfiles) [list] 

 # Un bout de code C a integer 
 critcl::ccode { 
 #include <stdio.h> 
 #include <math.h> 

   static int fib(int n) 
   { 
     if (n <= 2) { 
       return 1; 
     } else { 
       return fib(n-1) + fib(n-2); 
     } 
   } 
 } 
 # Et la definition de la commande Tcl "fib" a partir 
 # du code natif 
 critcl::ccommand fib {dummy interp objc objv} { 
   int n; 

   if (objc!=1) { 
     Tcl_WrongNumArgs(interp,1,objv,"int"); 
   } 
   if (Tcl_GetIntFromObj(interp,objv[1],&n)!=TCL_OK) { 
     return TCL_ERROR; 
   } 
   Tcl_SetObjResult(interp, Tcl_NewIntObj(fib(n))); 
   return TCL_OK; 
 } 


 # Ca va vite, tres vite... 
 puts [fib 30] 

Works by reporting 832040 on stdout - I suppose it's correct :) For comparison, I also did a Tcl version:

 proc fib0 n {
    if {$n <= 2} {return 1}
    expr {[fib0 [expr {$n-1}]] + [fib0 [expr {$n-2}]]}
 }
 puts Odyce:[fib 30],[time {fib 30}]
 puts Tcl:[fib0 30],[time {fib0 30}]

which gives the same result, but takes about 171 times longer:

 Odyce:832040,10578 microseconds per iteration
 Tcl:832040,1808314 microseconds per iteration

Next idea: to wrap a C command into a proc that has it compiled at first call:

 proc Fib x {
    critcl::ccommand Fib {dummy interp objc objv} { 
        int n; 
        if (objc!=1) {Tcl_WrongNumArgs(interp,1,objv,"int");} 
        if (Tcl_GetIntFromObj(interp,objv[1],&n)!=TCL_OK) {return TCL_ERROR;}
        Tcl_SetObjResult(interp, Tcl_NewIntObj(fib(n))); 
        return TCL_OK; 
    }
    uplevel 1 Fib $x
 }
 puts wrapped:[Fib 30],[time {Fib 30}]

which, not surprisingly, fares equally well:

 Odyce:832040,10203 microseconds per iteration
 Tcl:832040,1871121 microseconds per iteration
 wrapped:832040,10511 microseconds per iteration

The difference here is that only if Fib is called (the first time), the C code is compiled. If nobody calls Fib, we save the (not high) time and memory consumption...


Just tested, the examples run on Windows Mobile 5 too, and with an ever bigger gain of 619 (!):

 Odyce:832040,172293 microseconds per iteration
 Tcl:832040,106723982 microseconds per iteration
 wrapped:832040,172042 microseconds per iteration

Re available commands, good old introspection to the rescue:

 21% info commands critcl::*
 ::critcl::init ::critcl::cleanname ::critcl::ccode ::critcl::debug ::critcl::clibraries
 ::critcl::Log ::critcl::ccommand ::critcl::checkname ::critcl::cproc ::critcl::csources
 ::critcl::tk ::critcl::cheaders

Category Package - Category Development