l4-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Patch for idl4


From: ness
Subject: Re: Patch for idl4
Date: Mon, 15 Aug 2005 12:05:29 +0200
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050813)

First of all, thanks a lot for your great work, antrik. With your patches it was easy for me to correct small bugs. patch.idl4.v2 is antriks patch.idl4 with a bugfix related to idl4. You only have to run autoreconfig -fis before building. patch.hurd-l4 is the global patch for the hurd. The build process works now, for further information see README.idl4 and the ChangeLog. patch.ruth-example the example patch for ruth. The code is not yet indented in the GNU-style, but I didn't want to make it largen then necessary.

ChangeLog:
2005-08-15  Tom Bachmann  <address@hidden>
        * configure.ac: Add support for idl4
        * test.idl: create, used by configure.ac
        * README.idl4 created
        * MAKEFILE.idl4 created

part of README.idl4:
PLEASE HAVE A LOOK AT CONFIGURE.AC, I MARKED A
LINE.
There are several steps if you want to implement
a new interface. First of all, you have to write
the .idl-file(s) for idl4. After that, edit the
Makefile.am of your server in the following way:
-add the .idl-file(s) to the SOURCES of your
 server
-add the implementation file(s) for the new
 interface(s) if necessary
-for every .idl-file, add the _server.h and
 _client.h to the BUILT_SOURCES variable
-include $(top_srcdir)/Makefile.idl4
idl4 can create you a template implementation
file for every .idl-file. It's recommended
that you let idl4 create one and edit this
instead of writing an own one, if you don't
have a very good reason for not doing so.
Unfortunately, creating a template is a little
tricky: remove a created _client.h or _server.h
(e.g. ruth/test_server.h), type make and look
for the call of idl4. Copy this and replace -s
(or -c, if you removed a _client.h) with -t.
Usually you don't want to directly include
the _client.h but wrap it. Do so

ruth/ChangeLog:
2005-08-15 Tom Bachmann  <address@hidden>

        * ruth.c: edited for example use of an idl4-generated interface
        * test.idl4: created
        * ruth-class.c: created by idl4 as a template edited
        (ruth_class_test_implementation): output for testing purpose
        * Makefile.am: included $(top_srcdir)/Makefile.idl4
        (ruth_SOURCES): added ruth-class.c and test.idl
        (BUILT_SOURCES) [added] set to test_client.h test_server.h

-ness-
diff -Naur hurd-l4/Makefile.idl4 hurd-l4-new/Makefile.idl4
--- hurd-l4/Makefile.idl4       1970-01-01 01:00:00.000000000 +0100
+++ hurd-l4-new/Makefile.idl4   2005-07-13 18:30:52.379788376 +0200
@@ -0,0 +1,8 @@
+%_client.h: %.idl
+       $(IDL4) $(IDL4FLAGS) -c $<
+
+%_server.h: %.idl
+       $(IDL4) $(IDL4FLAGS) -s $<
+
+clean-local:
+       rm -f *_server.h *_client.h


--- hurd-l4-old/test.idl        1970-01-01 01:00:00.000000000 +0100
+++ hurd-l4-idl4/test.idl       2005-08-14 11:18:03.368176664 +0200
@@ -0,0 +1,4 @@
+interface foo
+{
+       int bar(in long a);
+};
--- hurd-l4-old/configure.ac    2005-08-13 17:23:01.287952984 +0200
+++ hurd-l4-idl4/configure.ac   2005-08-15 11:24:22.367592000 +0200
@@ -1,6 +1,7 @@
 # configure.ac - Configure script for the GNU Hurd.
 # Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
 # Written by Marcus Brinkmann.
+# Edited by Tom Bachmann
 #
 # This file is part of the GNU Hurd.
 # 
@@ -34,13 +35,46 @@
 # Checks for programs.
 AC_PROG_CC
 
+#Find idl4-config. We need this here, since it gives
+#us some CFLAGS
+if test "x$IDL4CONFIG" = "x" ;then
+  AC_PATH_TOOL([IDL4CONFIG], [idl4-config], no)
+fi
+if test "x$IDL4CONFIG" = "xno"; then
+  exit 1
+fi
 # FIXME: We should support setting the CFLAGS by the user.  But
 # -std=gnu99 and -O2 are required.
-CFLAGS="-std=gnu99 -Wall -g -O3"
+CFLAGS="-std=gnu99 -Wall -g -O3 `$IDL4CONFIG --cflags`"
+
 AM_PROG_AS
 AC_PROG_RANLIB
 AC_CHECK_TOOL([AR], [ar], :)
 AC_CHECK_TOOL([NM], [nm], :)
+
+#idl4 stuff (check, --help, ...)
+AC_ARG_VAR(IDL4,idl4 code generator command)
+AC_ARG_VAR(IDL4FLAGS, idl4 code generator flags)
+AC_ARG_VAR(IDL4CONFIG, idl4 path configuration tool)
+IDL4FLAGS="$IDL4FLAGS -i V4_GNU -p generic -T -fctypes"
+if test "x$IDL4" = "x";then
+  AC_PATH_TOOL([IDL4], [idl4], no)
+fi
+if test "x$IDL4" = xno; then
+  exit 1
+fi
+echo -n "checking for idl4 -l -i V4_GNU -T... "
+$IDL4 $IDL4FLAGS -l -c -C "$CC $CFLAGS" test.idl
+if test -e test_client.h;then
+  echo yes
+  rm test_client.h
+else
+  echo 'Your version of idl4 is outdated, see README.idl4!'
+  exit 1
+fi
+IDL4FLAGS="$IDL4FLAGS -C \"\$(COMPILE) \$(\$(subdir)_CPPFLAGS)\""
+# > > > > > > SEE ABOVE < < < < < < < < 
+# Have a better idea? -> edit
 AC_PATH_PROG([SED], [sed], :)
 AC_PATH_PROG([SORT], [sort], :)
 
--- hurd-l4-old/ChangeLog       2005-08-13 17:23:01.272955264 +0200
+++ hurd-l4-idl4/ChangeLog      2005-08-15 11:36:31.719713624 +0200
@@ -1,3 +1,9 @@
+2005-08-15  Tom Bachmann  <address@hidden>
+        * configure.ac: Add support for idl4
+        * test.idl: create, used by configure.ac
+        * README.idl4 created
+        * MAKEFILE.idl4 created
+
 2005-04-08  Neal H. Walfield  <address@hidden>
 
        * configure.ac: Add include for physmem/headers.m4.
--- hurd-l4-old/README.idl4     1970-01-01 01:00:00.000000000 +0100
+++ hurd-l4-idl4/README.idl4    2005-08-15 11:23:00.543031224 +0200
@@ -0,0 +1,35 @@
+If configure failes and attemps you to read this,
+read the first next clause. If you want developer
+information about how to use the patched idl4 here,
+read the third  clause.
+
+You use the official version of idl4 that has some
+issues. To correct this, see the mailing list for
+a patch (patch.idl4.vX).
+
+PLEASE HAVE A LOOK AT CONFIGURE.AC, I MARKED A
+LINE.
+There are several steps if you want to implement
+a new interface. First of all, you have to write
+the .idl-file(s) for idl4. After that, edit the
+Makefile.am of your server in the following way:
+-add the .idl-file(s) to the SOURCES of your
+ server
+-add the implementation file(s) for the new
+ interface(s) if necessary
+-for every .idl-file, add the _server.h and
+ _client.h to the BUILT_SOURCES variable
+-include $(top_srcdir)/Makefile.idl4
+idl4 can create you a template implementation
+file for every .idl-file. It's recommended
+that you let idl4 create one and edit this
+instead of writing an own one, if you don't
+have a very good reason for not doing so.
+Unfortunately, creating a template is a little
+tricky: remove a created _client.h or _server.h
+(e.g. ruth/test_server.h), type make and look
+for the call of idl4. Copy this and replace -s
+(or -c, if you removed a _client.h) with -t.
+Usually you don't want to directly include
+the _client.h but wrap it. Do so.
+
--- idl4-1.0.2/src/be/types/pointer.cc       2003-04-08 15:57:01.000000000 
+0200
+++ idl4/src/be/types/pointer.cc        2005-08-15 10:23:03.474383560 +0200
@@ -22,8 +22,9 @@
       addTo(specifiers, new CASTTypeSpecifier(buildIdentifier()));
       return new CASTDeclaration(specifiers, decl, compound);
     }
- 
   CASTDeclaration *subdecl = getType(aoi->ref)->buildDeclaration(decl, 
compound);
+  if(!subdecl->declarators)
+    subdecl->declarators=new CASTDeclarator((CASTIdentifier*)0);
   subdecl->declarators->addIndir(1);
   return subdecl;
 }
diff -Naur idl4-1.0.2/AUTHORS idl4/AUTHORS
--- idl4-1.0.2/AUTHORS  2002-05-21 10:07:38.000000000 +0200
+++ idl4/AUTHORS        2005-07-12 21:50:14.341594080 +0200
@@ -1,3 +1,6 @@
 Andreas Haeberlen originally designed and implemented IDL4.
 
 Espen Skoglund added the autoconf-based build process.
+
+Tom Bachmann did some bugfix and added V4_GNU backend aswell
+as the options -M -C and -T.
diff -Naur idl4-1.0.2/ChangeLog idl4/ChangeLog
--- idl4-1.0.2/ChangeLog        2002-05-17 14:58:14.000000000 +0200
+++ idl4/ChangeLog      2005-07-12 21:57:06.405950776 +0200
@@ -0,0 +1,57 @@
+15/08/05,by Tom Bachmann aka ness <address@hidden>
+  be/types/pointer.cc
+     Slight misstake corrected (related to declaratorless calls
+     of buildDeclaration
+12/07/05, by Tom Bachmann aka ness <address@hidden>
+  base/tools.cc
+     Small bug fixed (related to errors while compiling the
+     temporary file resulting in incomplete/no output)
+10/07/2005, by Tom Bachmann aka ness <address@hidden>
+  base/main.cc
+    - implemented -M and -C to create make compliant
+      dependencies
+      NOTE: I used printf, since I got errors if I included
+      iostream
+
+  lots, e.g. base/main.cc, base/tools.cc, fe/idl/parser.yy,
+  ...
+    - implemented options -T to use the compiler to determine
+      the size of userdefined types. The main problem for me
+      was, that the C/C++ parser reported errors where the
+      compiler couldn't find any. Second, the C/C++ parser will
+      never be perfect, since the standard gives some freedom
+      to the compilers (e.g. padding, non standardized
+      extensions, ...) and because of that it would be extremely
+      much work to emulate all the differences of different gcc
+      branches (who says we only want to support gcc?). But only
+      making (and keeping) the parser standard compliant would be
+      hard. I added new CAoiUserType and CBEUserType classes
+      and extended the visitors to support them. There are also
+      significant extensions for global_t.
+      NOTE: There is still a lot of work needed, e.g. extend
+            parser.yy to accept user defined structs. This
+            (and all my other code, but especially this)
+            has to be tested!!!
+
+09/07/2005, by Tom Bachmann aka ness <address@hidden>
+  lots of files, mostly arch/v4_gnu/* include/arch/v4_gnu,
+  base/main.cc
+    - new virtual functions in base classes, some functiones
+      changed to virtual
+    - some *_gnu classes
+    -> a new interface called V4_GNU for use with the GNU
+       Hurd/L4 and the optional argument
+       -l (SMALL L) to build cap_class stubs
+
+
+03/07/2005, by Tom Bachmann aka ness <address@hidden>
+  base/version.cc, arch/v4/ia32/ms.cc, cast/cast.cc,
+  be/scope.cc, include/user/idl4/glue/v4-ia32/runtime.h
+    - repaired broken ia32 optimization on V4
+    - changed the order of printing stuff in
+      CASTDeclarator::write (to make gcc understand
+      attributes in function definitions).
+    - changed CBERootScope::buildServerTemplate to
+      add a better default include (more or less bad
+      hack)
+    - changed extern inline directives into always inline,
+      so that it compiles even if there's no optimization
+      enabled
+
+

diff -Naur idl4-1.0.2/configure.in idl4/configure.in
--- idl4-1.0.2/configure.in     2003-11-03 22:31:05.000000000 +0100
+++ idl4/configure.in   2005-07-10 08:05:39.417865712 +0200
@@ -176,6 +176,7 @@
 src/arch/v4/Makefile
 src/arch/v4/ia32/Makefile
 src/arch/v4/ia64/Makefile
+src/arch/v4_gnu/Makefile
 src/arch/x0/Makefile
 src/arch/x0/ia32/Makefile
 src/base/Makefile
diff -Naur idl4-1.0.2/NEWS idl4/NEWS
--- idl4-1.0.2/NEWS     2002-07-31 15:54:12.000000000 +0200
+++ idl4/NEWS   2005-07-12 21:45:10.361806032 +0200
@@ -1,3 +1,48 @@
+patch by ness
+  - BE    : new CBEInterface_gnu and CBEOperation_gnu
+            with some overwritten virtual functions,
+            a new cross visitor (everything needed for
+            V4_GNU)
+  - V4_GNU: new interface (for use with GNU Hurd/L4)
+            This is very rudimentary. No exceptions are
+            supported, no data larger then 32 bit (shouldn't
+            be hard to change), no strings, no fpages, no ...
+            I skipped the implicit _env parameter, since
+            the implementation doesn't use it.
+            I added a new implicit parameter _cap, because of
+            every IPC uses capabilities in hurd.
+  - command line options:
+    --make-depend [-M]: create make compliant dependencies
+                        using the compiler (this creates a
+                        temporary file including all imported
+                        files and calls the compiler -MM,
+                        afterwards the temporary file is
+                        deleted)
+    --compiler [-C]   : allws to specify the compiler command
+                        (standard is gcc if mapping is C, g++
+                        if mapping is C++). All include options
+                        given to idl4 are given to the compiler
+                        call (as -I...), too (anything else
+                        wouldn't make sense, IMHO)
+    --user-types [-T] : in principle this an other way to handle
+                        import directives in the .idl files. See
+                        the CHangeLog for longer explination of
+                        why I implemented that. Here I'll list
+                        the issues:
+                          - all types are assumed to be trans-
+                            fered by copying them
+                          - parser.yy is not yet hacked to accept
+                            imported structures (shouldn't be hard
+                            to change [only enlarge the point
+                            structures [struct ...] are parsed to
+                            let them look up (see scoped_name, or
+                            so)], but I'm not a yacc/bison geek)
+                        This creates a temporary file that includes
+                        all imported files and (as compiled binary)
+                        prints size an alignment of the unknown
+                        types. This file is compiled and executed
+                        and it's output is parsed.
+
 0.9.1
   - BE: Visual debugging
   - V4: New backend
diff -Naur idl4-1.0.2/src/aoi/aoi.cc idl4/src/aoi/aoi.cc
--- idl4-1.0.2/src/aoi/aoi.cc   2003-04-08 15:54:09.000000000 +0200
+++ idl4/src/aoi/aoi.cc 2005-07-10 14:27:58.477161584 +0200
@@ -2,6 +2,7 @@
 #include <string.h>
 
 #include "aoi.h"
+#include <ms.h>
 
 int semanticErrors = 0;
 
@@ -157,7 +158,6 @@
   tmp = localLookup(identifier, symbolType);
   if ((!tmp) && parent)
     tmp = ((CAoiScope*)parent)->lookupSymbol(identifier, symbolType);
-    
   return tmp;  
 }
 
@@ -199,7 +199,7 @@
     
   switch (symbolType)
     {
-      case SYM_TYPE      : return types->getByName(identifier);
+      case SYM_TYPE:   return types->getByName(identifier);
       case SYM_CONSTANT  : return constants->getByName(identifier);
       case SYM_OPERATION : return operations->getByName(identifier);
       case SYM_ATTRIBUTE : return attributes->getByName(identifier);
diff -Naur idl4-1.0.2/src/aoi/check.cc idl4/src/aoi/check.cc
--- idl4-1.0.2/src/aoi/check.cc 2003-02-14 16:01:41.000000000 +0100
+++ idl4/src/aoi/check.cc       2005-07-10 14:57:37.123766200 +0200
@@ -407,3 +407,11 @@
   assert(peer->lineNo>=0);
   assert(peer->pos>=0);
 }
+
+void CAoiCheckVisitor::visit(CAoiUserType *peer)
+{
+       //printf("%s\n",peer->name);
+       assert(peer->name);
+       assert(globals.types[peer->name]->getSize()!=0);
+       assert(globals.types[peer->name]->getAlign()!=0);
+}
diff -Naur idl4-1.0.2/src/aoi/dump.cc idl4/src/aoi/dump.cc
--- idl4-1.0.2/src/aoi/dump.cc  2003-02-14 16:01:41.000000000 +0100
+++ idl4/src/aoi/dump.cc        2005-07-10 14:57:49.950816192 +0200
@@ -408,3 +408,8 @@
 {
   println("CAoiCustomType: %s", peer->name);
 }
+
+void CAoiDumpVisitor::visit(CAoiUserType *peer)
+{
+  println("CAoiUserType: %s,%i", 
peer->name,globals.types[peer->name]->getSize());
+}
diff -Naur idl4-1.0.2/src/aoi/visitor.cc idl4/src/aoi/visitor.cc
--- idl4-1.0.2/src/aoi/visitor.cc       2002-10-30 12:25:23.000000000 +0100
+++ idl4/src/aoi/visitor.cc     2005-07-10 13:47:21.105629224 +0200
@@ -83,7 +83,13 @@
 {
   worker->visit(this);
 }
+
+void CAoiUserType::accept(CAoiVisitor *worker)
+{
+  worker->visit(this);
+}
   
+
 void CAoiUnionType::accept(CAoiVisitor *worker)
 
 {
diff -Naur idl4-1.0.2/src/arch/Makefile.am idl4/src/arch/Makefile.am
--- idl4-1.0.2/src/arch/Makefile.am     2002-07-22 15:58:21.000000000 +0200
+++ idl4/src/arch/Makefile.am   2005-07-10 08:05:39.431863584 +0200
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS=               v2 v4 x0
+SUBDIRS=               v2 v4 x0 v4_gnu
 
 noinst_LIBRARIES=      libarch.a
 libarch_a_SOURCES=     dummy.cc list.cc tools.cc
diff -Naur idl4-1.0.2/src/arch/v4/ia32/ms.cc idl4/src/arch/v4/ia32/ms.cc
--- idl4-1.0.2/src/arch/v4/ia32/ms.cc   2003-11-07 01:00:49.000000000 +0100
+++ idl4/src/arch/v4/ia32/ms.cc 2005-07-10 08:05:39.435862976 +0200
@@ -376,3 +376,16 @@
   
   return result;
 }
+
+//change by ness
+CASTBase *CMSConnectionI4::buildServerWrapper(CASTIdentifier *key, 
CASTCompoundStatement *compound)
+{
+  CASTIdentifier *wrapperIdentifier = key->clone();
+  wrapperIdentifier->addPrefix("service_");
+  
+  return getWrapperReturnType()->buildDeclaration( 
+    new CASTDeclarator(wrapperIdentifier, 
+      buildWrapperParams(key), NULL, NULL, NULL, buildWrapperAttributes()),
+    compound
+  );
+};
diff -Naur idl4-1.0.2/src/arch/v4_gnu/be.cc idl4/src/arch/v4_gnu/be.cc
--- idl4-1.0.2/src/arch/v4_gnu/be.cc    1970-01-01 01:00:00.000000000 +0100
+++ idl4/src/arch/v4_gnu/be.cc  2005-07-13 17:08:43.008546472 +0200
@@ -0,0 +1,880 @@
+#include <arch/v4_gnu.h>
+
+#include "be.h"
+#include "ops.h"
+#define dprintln(a...) do { if (debug_mode&DEBUG_GENERATOR) println(a); } 
while (0)
+#define prependStatement(a, b) do { CASTStatement *pre = (b); addTo(pre, (a)); 
(a) = (pre); } while (0)
+
+static char contractBuffer[20000];
+
+CASTStatement *CBEInterface_gnu::buildReferenceDefinition()
+{    
+  return NULL;
+}
+
+//################################################################################
+//################################################################################
+//################################################################################
+CASTStatement *CBEOperation_gnu::buildClientHeader()
+{
+       dprintln("*** Building client header for %s", aoi->name);
+
+       assert(connection);
+
+       forAll(aoi->exceptions,
+               warning("Not implemented: Exceptions")
+       );
+
+       /* Build a list of all parameters, including the implicit ones */
+       
+       CASTDeclaration *parameters = NULL;
+       
+       bool hasImplicitHandle = false;
+       forAll(aoi->parameters, 
+       if (getParameter(item)->getFirstMemberWithProperty("handle")) 
+               hasImplicitHandle = true
+       );
+       
+       if (!hasImplicitHandle)
+       addTo(parameters, new CASTDeclaration(
+               new CASTTypeSpecifier(new CASTIdentifier("idl4_thread_id_t")),
+               knitDeclarator("_server"))
+       );
+    
+       addTo(parameters,new CASTDeclaration(
+               new CASTTypeSpecifier(new CASTIdentifier("idl4_cap_handle_t")),
+                       knitDeclarator("_cap"))
+       );
+       
+       forAll(aoi->parameters, addTo(parameters, 
getParameter(item)->buildDeclaration()));
+       
+       dprintln(" +  Declaring transfer buffer");
+
+       /* Declare local variables and the transfer buffer */
+
+       CASTStatement *declStatements = NULL;
+
+       CBEVarSource *varSource = new CBEVarSource();
+       forAllOps(marshalOps, item->buildClientDeclarations(varSource));
+       if (returnOp)
+               returnOp->buildClientDeclarations(varSource);
+       addTo(declStatements, varSource->declareAll());
+
+       dprintln(" +  Declaring client variables");
+  
+       addTo(declStatements, 
connection->buildClientLocalVars(buildIdentifier()));
+       if (!aoi->returnType->isVoid())
+       {
+               CASTDeclarator *rv = new CASTDeclarator(new 
CASTIdentifier("__retval"));
+               
rv->addIndir(getType(aoi->returnType)->getArgIndirLevel(RETVAL));
+               CASTDeclaration *dclr = 
getType(aoi->returnType)->buildDeclaration(rv);
+               addTo(declStatements, new CASTDeclarationStatement(dclr));
+       }
+
+       /* Translate all marshal operations (they were collected during 
+        the marshal phase) */
+       
+       dprintln(" +  Translating marshal operartions");
+
+       CASTStatement *marshalStatements = NULL;  
+       forAllOps(marshalOps, addTo(marshalStatements, 
item->buildClientMarshal()));
+       prependStatement(marshalStatements, connection->buildClientInit());
+       if (marshalStatements)
+               prependStatement(marshalStatements, new 
CASTBlockComment("marshal"));
+
+       /* Translate all unmarshal operations (see above) */
+       
+       dprintln(" +  Translating unmarshal operations");
+       
+       /*CASTStatement *setExceptionStatements = new CASTIfStatement(
+               new CASTBinaryOp("!=",
+                       new CASTIdentifier("_env"),
+                       new CASTIntegerConstant(0)),
+               connection->buildClientResultAssignment(
+                       new CASTIdentifier("_env"),
+         (aoi->flags&FLAG_ONEWAY) ? (CASTExpression*)new 
CASTIntegerConstant(0) : (CASTExpression*)new CASTIdentifier("_exception"))
+       );*/
+
+       CASTStatement *unmarshalStatements = NULL;  
+       forAllOps(marshalOps, addTo(unmarshalStatements, 
item->buildClientUnmarshal()));
+       addTo(unmarshalStatements, connection->buildClientFinish());
+  
+       CASTStatement *getStatusStatements = NULL;
+       /*if (!(aoi->flags&FLAG_ONEWAY))
+               addTo(getStatusStatements, 
connection->assignFCCDataFromBuffer(CHANNEL_OUT, 0, new 
CASTIdentifier("_exception")));*/
+
+       if (unmarshalStatements)
+       {
+               prependStatement(unmarshalStatements, new 
CASTBlockComment("unmarshal"));
+               unmarshalStatements = new CASTIfStatement(
+                       new CASTFunctionOp(
+                               new CASTIdentifier("IDL4_EXPECT_TRUE"),
+                               connection->buildClientCallSucceeded()),
+                       new CASTCompoundStatement(
+                               unmarshalStatements)
+               );
+       }   
+
+  /* Return normally */
+
+       CASTStatement *returnStatements = NULL;
+       if (returnOp)
+       {
+               //addTo(returnStatements, returnOp->buildClientUnmarshal());    
                //we transfer the retval in the label
+               addTo(returnStatements,new CASTExpressionStatement(new 
CASTBinaryOp("=",
+                       new CASTIdentifier("__retval"),
+                       connection->buildLabelExpr())));
+               addTo(returnStatements, new CASTReturnStatement(new 
CASTIdentifier("__retval")));
+       }
+
+  if (returnStatements)
+    prependStatement(returnStatements, new CASTBlockComment("return 
normally"));
+
+  /* Construct the IPC invocation. Note that both marshal and unmarshal
+     operations have to be constructed before this point, because the
+     CMSConnection needs to know what will go into the registers! */
+
+  CAoiInterface *parent = (CAoiInterface*)aoi->parent;
+  int fid = getID();
+  
+  assert(fid!=UNKNOWN);
+  assert(parent);
+  assert(parent->iid!=UNKNOWN);
+  
+  CASTExpression *pathToHandle = new CASTIdentifier("_service");
+  forAll(aoi->parameters, 
+    {
+      CBEParameter *param = getParameter(item);
+      if (param->getFirstMemberWithProperty("handle"))
+        {
+          pathToHandle = param->buildIdentifier();
+          for (int i=0;i<param->getArgIndirLevel();i++)
+            pathToHandle = new CASTUnaryOp("*", pathToHandle);
+            
+          while (param!=param->getFirstMemberWithProperty("handle"))
+            {
+              param = param->getFirstMemberWithProperty("handle");
+              pathToHandle = new CASTBinaryOp(".", pathToHandle, 
param->buildIdentifier());
+            }
+        }
+    }
+  );
+  
+  CASTStatement *invocationStatements = connection->buildClientCall(
+    pathToHandle,
+    new CASTIdentifier("_env")
+  );
+  
+  if (globals.pre_call_code)
+    prependStatement(invocationStatements, new CASTExpressionStatement(
+      new CASTIdentifier(globals.pre_call_code))
+    );
+  if (globals.post_call_code)
+    addTo(invocationStatements, new CASTExpressionStatement(
+      new CASTIdentifier(globals.post_call_code))
+    );
+  
+  prependStatement(invocationStatements, new CASTBlockComment("invoke IPC"));
+
+  /* Insert all those statements into the stub */
+
+  CASTStatement *statements = NULL;
+  addWithTrailingSpacerTo(statements, declStatements);
+  addWithTrailingSpacerTo(statements, marshalStatements);
+  addTo(statements, invocationStatements);
+  addWithLeadingSpacerTo(statements, getStatusStatements);
+  addWithLeadingSpacerTo(statements, unmarshalStatements);
+  //addWithLeadingSpacerTo(statements, setExceptionStatements);
+  addWithLeadingSpacerTo(statements, returnStatements);
+
+  /* From the pieces collected above, build the stub declaration */
+
+  CASTCompoundStatement *compound = new CASTCompoundStatement(statements);
+
+  CASTDeclarator *declarator = new CASTDeclarator(buildIdentifier(), 
parameters);
+  declarator->addIndir(getType(aoi->returnType)->getArgIndirLevel(RETVAL));
+  CASTDeclaration *declaration = 
getType(aoi->returnType)->buildDeclaration(declarator, compound);
+  
+  declaration->addSpecifier(new CASTStorageClassSpecifier("inline"));
+  declaration->addSpecifier(new CASTStorageClassSpecifier("static"));
+
+  /* Build a comment with the transfer contract */
+  
+  enableStringMode(contractBuffer, sizeof(contractBuffer)-1);
+  connection->dump();
+  disableStringMode();
+ 
+  /* Return the whole thing */
+  
+  CASTIdentifier *defName = buildIdentifier();
+  defName->addPrefix("_funcdef___");
+  
+  CASTStatement *funcDef = NULL;
+  addTo(funcDef, new CASTPreprocDefine(defName, ANONYMOUS));
+  addTo(funcDef, new CASTDeclarationStatement(declaration));
+  
+  CASTStatement *result = NULL;
+  if (contractBuffer[0])
+    addTo(result, new CASTComment(mprintf(contractBuffer)));
+  
+  addTo(result, new CASTPreprocConditional(
+    new CASTUnaryOp("!", new CASTFunctionOp(new CASTIdentifier("defined"), 
defName->clone())), funcDef)
+  );
+
+  addTo(result, new CASTSpacer());
+
+  dprintln("Completed client header for %s", aoi->name);
+ 
+  return result;
+}
+
+//################################################################################
+//################################################################################
+//################################################################################
+CASTStatement *CBEOperation_gnu::buildServerHeader()
+{
+       if(aoi->flags&FLAG_ONEWAY)
+               panic("Oneway functions aren't supported yet!");
+       CASTStatement *result = NULL;
+
+       assert(connection);
+
+       /* Declare the necessary types */
+
+       addWithTrailingSpacerTo(result, 
+               connection->buildServerDeclarations(buildIdentifier())
+       );
+
+       /* Generate a forward declaration for the implementation function */
+       
+       CASTDeclaration *parameters = NULL;
+       addTo(parameters, new CASTDeclaration(
+               new CASTTypeSpecifier(new 
CASTIdentifier("idl4_cap_rpc_context_t")),
+               knitDeclarator("_ctx"))
+       );
+    
+       forAll(aoi->parameters, addTo(parameters, 
getParameter(item)->buildDeclaration()));
+       
+       //We dont' need..
+       /*addTo(parameters, new CASTDeclaration(
+       new CASTTypeSpecifier(new CASTIdentifier("idl4_server_environment")),
+       new CASTDeclarator(new CASTIdentifier("_env"), new CASTPointer(1)))
+       );*/
+
+       CASTIdentifier *implementationName = buildIdentifier();
+       implementationName->addPostfix("_implementation");
+       
+       CASTDeclarator *declarator = new CASTDeclarator(implementationName, 
parameters);
+       
declarator->addIndir(getType(aoi->returnType)->getArgIndirLevel(RETVAL));
+       
+       CASTDeclaration *declaration = 
getType(aoi->returnType)->buildDeclaration(declarator);
+       declaration->addSpecifier(new CASTStorageClassSpecifier("inline"));
+       
+       addWithTrailingSpacerTo(result, new 
CASTDeclarationStatement(declaration));
+
+       /* Add a description of the buffer layout to the header file */
+       
+       enableStringMode(contractBuffer, sizeof(contractBuffer)-1);
+       connection->dump();
+       disableStringMode();
+       addTo(result, new CASTComment(mprintf(contractBuffer)));
+  
+  /* Create the declaration macro */
+  
+  addTo(result, new CASTPreprocDefine(
+    new CASTFunctionOp(
+      buildWrapperName(true),
+      new CASTIdentifier("_func")),
+    connection->buildServerWrapper(buildIdentifier(), buildServerStub()))
+  );  
+  
+  /* Better support for CPP magic (the Neal macro) */
+  
+  addWithLeadingSpacerTo(result, new CASTPreprocDefine(
+    buildWrapperName(false),
+    buildWrapperName(true))
+  );
+     
+  return result;
+}  
+
+//################################################################################
+//################################################################################
+//################################################################################
+CASTCompoundStatement *CBEOperation_gnu::buildServerStub()
+{
+       /* Translate all marshal operations (they were collected during 
+        the marshal phase) */
+       
+       assert(connection);
+       
+       dprintln("Building server stub for %s", aoi->name);
+       
+       CASTStatement *declStatements = NULL;
+       CASTStatement *unmarshalStatements = NULL;  
+       CBEVarSource *varSource = new CBEVarSource();
+  
+       forAllOps(marshalOps, 
+       {
+         item->buildServerDeclarations(varSource);
+         addTo(unmarshalStatements, item->buildServerUnmarshal());
+       });
+       
+       if (!aoi->returnType->isVoid())
+       {
+               CASTDeclarator *rv = new CASTDeclarator(new 
CASTIdentifier("__retval"));
+               
rv->addIndir(getType(aoi->returnType)->getArgIndirLevel(RETVAL));
+               CASTDeclaration *dclr = 
getType(aoi->returnType)->buildDeclaration(rv);
+               addTo(declStatements, new CASTDeclarationStatement(dclr));
+       }
+       //if (returnOp)                                                         
                                                                        //we 
don't need that
+       //  returnOp->buildServerDeclarations(varSource);
+       
+       if (unmarshalStatements)
+               prependStatement(unmarshalStatements, new 
CASTBlockComment("unmarshal"));
+
+  /************************************************************************/
+
+  CASTStatement *positionCheckStatements = NULL;
+
+  if (debug_mode & DEBUG_TESTSUITE)
+    {
+      positionCheckStatements = connection->buildServerTestStructural();
+      if (positionCheckStatements)
+        prependStatement(positionCheckStatements, new 
CASTBlockComment("position check"));
+    }
+
+  /************************************************************************/
+
+  /*CASTStatement *envInitStatements = NULL;
+  
+  addTo(envInitStatements, new CASTExpressionStatement(
+    new CASTBinaryOp("=",
+      new CASTBinaryOp(".",
+        new CASTIdentifier("_env"),
+        new CASTIdentifier("_action")),
+      new CASTIntegerConstant(0)))
+  );  */
+
+  /************************************************************************/
+  
+  CASTStatement *invocationStatements = NULL;
+  CASTStatement *debugOutStatements = NULL;
+  CASTStatement *debugInStatements = NULL;
+  CASTStatement *itransStatements = NULL;
+  CASTStatement *otransStatements = NULL;
+  CASTExpression *arguments = NULL;
+  bool transUsed = false;
+  
+  addTo(arguments, connection->buildServerCallerID());
+  forAll(aoi->parameters,
+    {
+      CAoiParameter *thisParam = (CAoiParameter*)item;
+      CBEMarshalOp *thisOp = marshalOps;
+      bool found = false;
+      
+      assert(thisOp); // we seem to have parameters, after all
+      do {
+           if (thisOp->isResponsibleFor(getParameter(thisParam)))
+             { 
+               found = true;
+               break;
+             }
+           thisOp = thisOp->next;
+         } while (thisOp!=marshalOps);
+      if (!found)
+        panic("Marshal operation not found for parameter: %s", 
thisParam->name);
+      
+      CASTExpression *thisArg = 
thisOp->buildServerArg(getParameter(thisParam));
+      assert(thisArg);
+      
+      if ((debug_mode & DEBUG_VISUAL) && (thisParam->flags & FLAG_IN))
+        addTo(debugInStatements,
+          getParameter(thisParam)->buildTestDisplayStmt(buildTestKeyPrefix(), 
varSource, thisArg->clone())
+        );
+        
+      if ((debug_mode & DEBUG_VISUAL) && (thisParam->flags & FLAG_OUT))
+        addTo(debugOutStatements,
+          getParameter(thisParam)->buildTestDisplayStmt(buildTestKeyPrefix(), 
varSource, thisArg->clone())
+        );
+          
+      for (int i=0;i<getParameter(thisParam)->getArgIndirLevel();i++)
+        thisArg = new CASTUnaryOp("&", thisArg);
+        
+      addTo(arguments, thisArg);
+      
+      CAoiProperty *itrans = thisParam->getProperty("itrans");
+      CAoiProperty *otrans = thisParam->getProperty("otrans");
+
+      if (itrans)
+        {
+          assert(itrans->refValue);
+          CASTStatement *itransInvocation = new CASTExpressionStatement(
+            new CASTFunctionOp(
+              new CASTIdentifier(itrans->refValue),
+              knitExprList(
+                connection->buildServerCallerID(),
+                thisArg->clone(),
+                new CASTUnaryOp("&",
+                  new CASTIdentifier("_env"))
+                ))
+          );
+          
+          if (transUsed)
+            itransInvocation = new CASTIfStatement(
+              new CASTFunctionOp(
+                new CASTIdentifier("IDL4_EXPECT_TRUE"),
+                new CASTBinaryOp("==",
+                  new CASTBinaryOp(".",
+                    new CASTIdentifier("_env"),
+                    new CASTIdentifier("_action")),
+                  new CASTIntegerConstant(0))),
+              itransInvocation
+            );
+            
+          addTo(itransStatements, itransInvocation);
+          transUsed = true;
+        }  
+
+      if (otrans)
+        {
+          assert(otrans->refValue);
+          CASTStatement *otransInvocation = new CASTExpressionStatement(
+            new CASTFunctionOp(
+              new CASTIdentifier(otrans->refValue),
+              knitExprList(
+                connection->buildServerCallerID(),
+                thisArg->clone(),
+                new CASTUnaryOp("&",
+                  new CASTIdentifier("_env"))
+                ))
+          );
+          
+          otransInvocation = new CASTIfStatement(
+            new CASTFunctionOp(
+              new CASTIdentifier("IDL4_EXPECT_TRUE"),
+              new CASTBinaryOp("==",
+                new CASTBinaryOp(".",
+                  new CASTIdentifier("_env"),
+                  new CASTIdentifier("_action")),
+                new CASTIntegerConstant(0))),
+            otransInvocation
+          );
+            
+          addTo(otransStatements, otransInvocation);
+        }  
+    }
+  );
+  //addTo(arguments, new CASTUnaryOp("&", new CASTIdentifier("_env")));
+
+  if (itransStatements)
+    prependStatement(itransStatements, new CASTBlockComment("apply input 
translations"));
+    
+  if (otransStatements)
+    prependStatement(otransStatements, new CASTBlockComment("apply output 
translations"));
+
+  if (globals.pre_call_code)
+    addTo(itransStatements, new CASTExpressionStatement(
+      new CASTIdentifier(globals.pre_call_code))
+    );
+  if (globals.post_call_code)
+    prependStatement(otransStatements, new CASTExpressionStatement(
+      new CASTIdentifier(globals.post_call_code))
+    );
+
+  CASTExpression *invocation = new CASTFunctionOp(new CASTIdentifier("_func"), 
arguments);
+  if (!aoi->returnType->isVoid())
+    {
+      invocation = new CASTBinaryOp("=",
+        new CASTIdentifier("__retval"),
+        invocation
+      );
+      
+      char nameStr[100];
+      enableStringMode(nameStr, sizeof(nameStr));
+      getType(aoi->returnType)->buildDeclaration(new CASTDeclarator(new 
CASTIdentifier("__retval")))->write();
+      disableStringMode();
+      
+      addTo(debugOutStatements,
+        new CASTExpressionStatement(
+          new CASTFunctionOp(
+            new CASTIdentifier("printf"),
+            new CASTStringConstant(false, mprintf("out %s = ", nameStr))))
+      );
+      
+      /*addTo(debugOutStatements,
+        getType(aoi->returnType)->buildTestDisplayStmt(
+          new CASTIdentifier("__retval"),
+          new CASTIdentifier("__retval"),
+          varSource, RETVAL, 
+          returnOp->buildServerArg(NULL))
+      );*/
+
+      addTo(debugOutStatements,
+        new CASTExpressionStatement(
+          new CASTFunctionOp(
+            new CASTIdentifier("printf"),
+            new CASTStringConstant(false, "\\n")))
+      );
+    }
+
+  addTo(invocationStatements, new CASTBlockComment(mprintf("invoke 
service")));  
+  addTo(declStatements, varSource->declareAll());
+  
+  if (debug_mode&DEBUG_VISUAL)
+    {
+      addTo(invocationStatements, new CASTExpressionStatement(
+        new CASTFunctionOp(
+          new CASTIdentifier("printf"),
+          knitExprList(
+            new CASTStringConstant(false, mprintf("*** Servicing call from %%X 
to %s::%s\\n", ((CAoiScope*)aoi->parent)->scopedName, aoi->name)),
+            new CASTFunctionOp(
+              new CASTIdentifier("idl4_raw_fpage"),
+              connection->buildServerCallerID()
+            ))))
+      );
+      addTo(invocationStatements, debugInStatements);
+      addTo(invocationStatements, new CASTSpacer());
+    }
+
+  CASTStatement *invocationTemp = new CASTExpressionStatement(invocation);
+  if (transUsed)
+    invocationTemp = new CASTIfStatement(
+      new CASTFunctionOp(
+        new CASTIdentifier("IDL4_EXPECT_TRUE"),
+          new CASTBinaryOp("==",
+          new CASTBinaryOp(".",
+            new CASTIdentifier("_env"),
+            new CASTIdentifier("_action")),
+          new CASTIntegerConstant(0))),
+      invocationTemp
+    );
+  
+  addTo(invocationStatements, invocationTemp);
+  
+  if (debug_mode&DEBUG_VISUAL)
+    {
+      addTo(invocationStatements, new CASTSpacer());
+      addTo(invocationStatements, new CASTExpressionStatement(
+        new CASTFunctionOp(
+          new CASTIdentifier("printf"),
+          knitExprList(
+            new CASTStringConstant(false, "--- Return code is %d\\n"),
+              new CASTBinaryOp(".",
+                new CASTIdentifier("_env"),
+                new CASTIdentifier("_action"))
+            )))
+      );
+      addTo(invocationStatements, debugOutStatements);
+    }
+  
+  addTo(invocationStatements, connection->buildServerMarshalInit());
+
+  /************************************************************************/
+
+  CASTStatement *marshalStatements = NULL;
+  if (!(aoi->flags & FLAG_ONEWAY))
+    {
+      //forAllOps(marshalOps, addTo(marshalStatements, 
item->buildServerMarshal()));
+      //if (!aoi->returnType->isVoid())
+      //  addTo(marshalStatements, returnOp->buildServerMarshal());
+      if (marshalStatements)
+        prependStatement(marshalStatements, new CASTBlockComment("marshal"));
+    
+      //addWithLeadingSpacerTo(marshalStatements, new CASTBlockComment("jump 
back"));
+      //addTo(marshalStatements, connection->buildServerBackjump(CHANNEL_OUT, 
new CASTIdentifier("_env")));
+  
+      /*marshalStatements = new CASTIfStatement(
+        new CASTFunctionOp(
+          new CASTIdentifier("IDL4_EXPECT_TRUE"),
+          new CASTBinaryOp("==",
+            new CASTBinaryOp(".",
+              new CASTIdentifier("_env"),
+              new CASTIdentifier("_action")),
+            new CASTIntegerConstant(0))),
+        new CASTCompoundStatement(
+          marshalStatements)
+      );*/
+    }
+
+  /************************************************************************/
+
+  CASTStatement *exceptionStatements = NULL;
+  int channelID = CHANNEL_OUT + 1;
+  
+  forAll(aoi->exceptions,
+    {
+      CBEExceptionType *bExc = getException(((CAoiRef*)item)->ref);
+      CASTStatement *backjump;
+
+      connection->reset();
+      backjump = connection->buildServerBackjump(channelID++, new 
CASTIdentifier("_env"));
+      if (backjump->next != backjump)
+        backjump = new CASTCompoundStatement(backjump);
+      
+      CASTStatement *newBackjump = new CASTIfStatement(
+        new CASTBinaryOp("==",
+          new CASTBinaryOp(".",
+            new CASTIdentifier("_env"),
+            new CASTIdentifier("_action")),
+          new CASTBinaryOp("+",
+            new CASTIdentifier("CORBA_USER_EXCEPTION"),
+            new CASTBinaryOp("<<",
+              bExc->buildID(),
+              new CASTIntegerConstant(8)))),
+        backjump
+      );
+      addWithLeadingSpacerTo(exceptionStatements, newBackjump);
+    }
+  );
+
+  if (exceptionStatements)
+    prependStatement(exceptionStatements, new CASTBlockComment("handle 
exceptions"));
+
+  /************************************************************************/
+
+  /* This must be done last, because the backend might need to allocate
+     additional buffers during marshalling */
+     
+  addTo(declStatements, connection->buildServerLocalVars(buildIdentifier()));
+
+  /************************************************************************/
+
+  
+  CASTStatement *stub = NULL;
+  addWithTrailingSpacerTo(stub, declStatements);
+  //addWithTrailingSpacerTo(stub, envInitStatements);
+  addWithTrailingSpacerTo(stub,connection->buildServerStoreData("_ctx->msg"));
+  addWithTrailingSpacerTo(stub, positionCheckStatements);
+  addWithTrailingSpacerTo(stub, unmarshalStatements);
+  addWithTrailingSpacerTo(stub, itransStatements);
+  addTo(stub, invocationStatements);
+  addWithLeadingSpacerTo(stub, otransStatements);
+  if(!aoi->returnType->isVoid())
+       
addWithLeadingSpacerTo(stub,connection->buildServerAppendData("_ctx->msg","__retval"));
+  else
+       
addWithLeadingSpacerTo(stub,connection->buildServerAppendData("_ctx->msg",0));
+  addWithLeadingSpacerTo(stub, marshalStatements);
+  //addWithLeadingSpacerTo(stub, exceptionStatements);
+  //addWithLeadingSpacerTo(stub, connection->buildServerAbort());              
//we don't abort, if we're here, everything is OK
+  
+  return new CASTCompoundStatement(stub);
+}
+
+//################################################################################
+//################################################################################
+//################################################################################
+CASTStatement *CBEInterface_gnu::buildServerDefinitions()
+{
+  CAoiScope *definitionScope = NULL;
+  CASTStatement *subtree = NULL;
+
+  CASTDeclarator *serverLoopDeclarator = new CASTDeclarator(
+    buildServerFuncName(),
+       new CASTDeclaration(
+               new CASTTypeSpecifier(new CASTIdentifier("idl4_cap_bucket_t")),
+               knitDeclarator("_bucket"))
+  );
+
+  /* We should not assume that server loops can _never_ return */
+  if (debug_mode & DEBUG_TESTSUITE)
+    serverLoopDeclarator->setAttributes(
+      new CASTAttributeSpecifier(
+        new CASTIdentifier("noreturn"))
+    );
+
+  addTo(subtree, new CASTDeclarationStatement(
+    getType(aoiRoot->lookupSymbol("#void", SYM_TYPE))->buildDeclaration(
+      serverLoopDeclarator))
+  );
+    
+  CASTIdentifier *discardFuncName = buildIdentifier();
+  discardFuncName->addPostfix("_discard");
+
+  addTo(subtree, 
+    new CASTDeclarationStatement(
+      getType(aoiRoot->lookupSymbol("#void", SYM_TYPE))->buildDeclaration(
+        new CASTDeclarator(
+          discardFuncName,
+          new CASTDeclaration(
+                       new CASTTypeSpecifier(new 
CASTIdentifier("idl4_cap_rpc_context_t")),
+                       knitDeclarator("_ctx"))
+        )))
+  );        
+  
+  CASTDeclarator *serverDemDeclarator = new CASTDeclarator(
+    buildServerDemuxerName(),
+       new CASTDeclaration(
+               new CASTTypeSpecifier(new 
CASTIdentifier("idl4_cap_rpc_context_t")),
+               knitDeclarator("_ctx"))
+  );
+  
+  addTo(subtree, new CASTDeclarationStatement(
+    (new CBEOpaqueType("error_t",globals.word_size, globals.word_size, 
true))->buildDeclaration(
+      serverDemDeclarator))
+  );
+  /***************************************************************************/
+    if(globals.with_cap_class)
+       {
+               CASTIdentifier *class_init= buildIdentifier();
+               class_init->addPostfix("_init");
+               addTo(subtree, new CASTDeclarationStatement(
+                       new CASTDeclaration(
+                               new CASTTypeSpecifier(new 
CASTIdentifier("error_t")),
+                               new CASTDeclarator(
+                                       class_init,
+                                       new CASTEmptyDeclaration())))
+               );
+         
+               CASTIdentifier *class_alloc= buildIdentifier();
+               class_alloc->addPostfix("_alloc");
+               CASTStatement* class_alloc_statement=NULL;
+               addTo(class_alloc_statement,new CASTBlockComment("do necessary 
changes"));
+               addTo(class_alloc_statement,new CASTReturnStatement(new 
CASTFunctionOp(
+                       new CASTIdentifier("idl4_cap_class_alloc"),
+                       knitExprList(
+                               new CASTUnaryOp("&",buildIdentifier()),
+                               new CASTIdentifier("_r_obj")))
+               ));
+               CASTDeclaration *class_alloc_parameters = NULL;
+               addTo(class_alloc_parameters,new CASTDeclaration(
+                       new CASTTypeSpecifier(new 
CASTIdentifier("idl4_cap_obj_t*")),
+                               knitDeclarator("_r_obj"))
+               );
+       
+  addTo(subtree, new CASTDeclarationStatement(
+               new CASTDeclaration(
+                       new CASTTypeSpecifier(new CASTIdentifier("error_t")),
+                       new CASTDeclarator(
+                               class_alloc,
+                               class_alloc_parameters)))
+       );
+       };      
+  /***************************************************************************/
+  addTo(subtree, new CASTSpacer());  
+
+  /* Collect the function pointers. For each ID, we ask the superclasses 
+     for a pointer; it nothing is returned, we insert the discard function */
+  
+  int numVtableElements, iidMin, iidMax, fidMin, fidMax, kidMin, kidMax;
+  numVtableElements = getVtableSize();
+  getIDRange(&iidMin, &iidMax, &fidMin, &fidMax, &kidMin, &kidMax);
+
+  for (int iid=iidMin;iid<=iidMax;iid++)
+    {
+      bool foundFuncWithThisIID = false;
+      definitionScope = NULL;
+      
+      for (int fid=fidMin;fid<=fidMax;fid++)
+        if (getFunctionForID(fid, iid, &definitionScope))
+          foundFuncWithThisIID = true;
+
+      if (foundFuncWithThisIID || (iidMin==iidMax))
+        {
+          CASTExpression *functionPointers = NULL;
+          for (int fid=0;fid<numVtableElements;fid++)
+            {
+              CAoiOperation *thisFunc;
+              CASTExpression *newElement;
+              
+              definitionScope = NULL;
+              thisFunc = getFunctionForID(fid, iid, &definitionScope);
+              if (thisFunc != NULL)
+                {
+                  CASTIdentifier *funcName = buildIdentifier();
+                  funcName->addPrefix("service_");
+                  funcName->addPostfix("_");
+                  funcName->addPostfix(thisFunc->name);
+                  newElement = funcName;
+                } else newElement = discardFuncName->clone();
+                
+              if (globals.mapping == MAPPING_CXX)
+                newElement = new CASTUnaryOp("(void*)&", newElement);
+              
+              addTo(functionPointers, newElement);
+            }
+            
+         addTo(subtree, new CASTPreprocDefine(
+           (iidMin==iidMax) ? buildDefaultVtableName() : buildVtableName(iid), 
+           new CASTArrayInitializer(functionPointers))
+         );  
+        }
+    }
+    
+  if (iidMin!=iidMax)
+    {
+      CASTExpression *functionPointers = NULL;
+      for (int fid=0;fid<numVtableElements;fid++)
+        addTo(functionPointers, new CASTUnaryOp("(void*)&", 
discardFuncName->clone()));
+        
+      addTo(subtree, new CASTPreprocDefine(
+        buildVtableName(UNKNOWN),
+        new CASTArrayInitializer(functionPointers))
+      );
+    }
+    
+  CASTIdentifier *vtableSizeMacro = buildIdentifier();
+  vtableSizeMacro->capitalize();
+  vtableSizeMacro->addPostfix("_DEFAULT_VTABLE_SIZE");
+  addTo(subtree, new CASTPreprocDefine(
+    vtableSizeMacro,
+    new CASTIntegerConstant(getVtableSize()))
+  );
+
+  CASTIdentifier *maxFidMacro = buildIdentifier();
+  maxFidMacro->capitalize();
+  maxFidMacro->addPostfix("_MAX_FID");
+  addTo(subtree, new CASTPreprocDefine(
+    maxFidMacro,
+    new CASTIntegerConstant(fidMax))
+  );
+
+  if ((kidMin!=kidMax) || getFunctionForID(kidMin, IID_KERNEL, 
&definitionScope))
+    {
+      CASTExpression *functionPointers = NULL;
+      int maxKid = getKtableSize();
+      
+      for (int kid=0;kid<maxKid;kid++)
+        {
+          CASTExpression *newElement;
+          CAoiOperation *thisFunc;
+          thisFunc = getFunctionForID(kid, IID_KERNEL, &definitionScope);
+          if (thisFunc != NULL)
+            {
+              CASTIdentifier *funcName = buildIdentifier();
+              funcName->addPrefix("service_");
+              funcName->addPostfix("_");
+              funcName->addPostfix(thisFunc->name);
+              newElement = funcName;
+            } else newElement = discardFuncName->clone();
+            
+          if (globals.mapping == MAPPING_CXX)
+            newElement = new CASTUnaryOp("(void*)&", newElement);
+            
+          addTo(functionPointers, newElement);
+        }
+            
+      addTo(subtree, new CASTPreprocDefine(
+        buildKtableName(), 
+        new CASTArrayInitializer(functionPointers))
+      );  
+
+      CASTIdentifier *ktableSizeMacro = buildIdentifier();
+      ktableSizeMacro->capitalize();
+      ktableSizeMacro->addPostfix("_DEFAULT_KTABLE_SIZE");
+      addTo(subtree, new CASTPreprocDefine(
+        ktableSizeMacro,
+        new CASTIntegerConstant(getKtableSize()))
+      );
+    }
+
+  return subtree;      
+}
+
+CASTIdentifier *CBEInterface_gnu::buildServerDemuxerName()
+{
+  CASTIdentifier *serverFuncName = buildIdentifier();
+  serverFuncName->addPostfix("_demuxer");
+  
+  return serverFuncName;
+}
diff -Naur idl4-1.0.2/src/arch/v4_gnu/client.cc idl4/src/arch/v4_gnu/client.cc
--- idl4-1.0.2/src/arch/v4_gnu/client.cc        1970-01-01 01:00:00.000000000 
+0100
+++ idl4/src/arch/v4_gnu/client.cc      2005-07-13 14:37:29.312134272 +0200
@@ -0,0 +1,133 @@
+#include <arch/v4_gnu.h>
+CASTStatement *CMSConnection4_gnu::buildClientLocalVars(CASTIdentifier *key)
+{
+       CASTDeclarationStatement *result = buildClientStandardVars();
+       
+       addTo(result, new CASTDeclarationStatement(
+       new CASTDeclaration(
+         new CASTTypeSpecifier(
+               new CASTIdentifier("l4_msg_tag_t")),
+         new CASTDeclarator(
+               new CASTIdentifier("_tag"))))
+       );
+       
+       addTo(result, new CASTDeclarationStatement(
+       new CASTDeclaration(
+         new CASTTypeSpecifier(
+               new CASTIdentifier("l4_msg_t")),
+         new CASTDeclarator(
+               new CASTIdentifier("_msg"))))
+       );
+       CASTDeclarationSpecifier* p=buildClientMsgBuf();
+       if(p)
+               addTo(result, new CASTDeclarationStatement(
+               new CASTDeclaration(
+                 p,
+                 new CASTDeclarator(
+                       new CASTIdentifier("_pack"))))
+               );
+       
+       return result;
+}
+
+CASTStatement *CMSConnection4_gnu::buildClientCall(CASTExpression *target, 
CASTExpression *env)
+{
+       if(options & OPTION_ONEWAY)
+               panic("Oneway functions aren't supported yet!");
+       CASTStatement *result = NULL;
+
+       /*addTo(result, buildMemMsgSetup(CHANNEL_IN));
+       addTo(result, new CASTExpressionStatement(
+       new CASTBinaryOp("=",
+         new CASTBinaryOp(".",
+               buildSourceBufferRvalue(CHANNEL_IN),
+               new CASTIdentifier("_msgtag")),
+         buildMsgTag(CHANNEL_IN)))
+       );*/
+       
+       addTo(result,new 
GNU_CALL_FN_NAME("l4_accept","L4_UNTYPED_WORDS_ACCEPTOR"));
+       addTo(result,new GNU_CALL_FN_NAME("l4_msg_clear","_msg"));
+       addTo(result,new GNU_CALL_FN(new 
CASTIdentifier("l4_set_msg_label"),knitExprList(
+               new CASTIdentifier("_msg"),buildMsgTag(CHANNEL_IN)))
+       );
+       
+       //add data to message
+       
+       addTo(result,new GNU_CALL_FN(new CASTIdentifier("l4_msg_append_word"),
+               knitExprList(new CASTIdentifier("_msg"),new CASTCastOp(new 
CASTDeclaration(
+                                       new CASTTypeSpecifier("l4_word_t"),
+                                       NULL),
+                               new CASTIdentifier("_cap"),
+                               CASTStandardCast)))
+       );
+       
+       
if(!mem_fixed[CHANNEL_IN]->isEmpty()||!mem_variable[CHANNEL_IN]->isEmpty()||!strings[CHANNEL_IN]->isEmpty()||
+               
!fpages[CHANNEL_IN]->isEmpty()||!special[CHANNEL_IN]->isEmpty()||!reg_variable[CHANNEL_IN]->isEmpty())
+               panic("Unsupported datatypes: strings,fpages");         //WHAT 
ARE THE OTHERS?
+               forAllMS(reg_fixed[CHANNEL_IN],
+               {
+                       CMSChunk4* chunk=(CMSChunk4*)item;
+                       if(strcasecmp(chunk->name,"_msgtag"))           //HOW 
TO DO THIS CLEARLY?
+                               
addTo(result,appendRegFixedToMsg(CHANNEL_IN,chunk,"_msg"));
+               };);
+       
+       addTo(result, new CASTExpressionStatement(
+               new CASTFunctionOp(
+                       new CASTIdentifier("l4_msg_load"),
+                       new CASTIdentifier("_msg")))
+       );
+       
+  //fpages aren't supported yet
+  /*bool hasOutFpages = false;
+  for (int i=1;i<numChannels;i++)
+    if (!fpages[i]->isEmpty())
+      hasOutFpages = true;
+  
+  if (hasOutFpages)
+    addTo(result, new CASTExpressionStatement(
+      new CASTFunctionOp(
+        new CASTIdentifier("L4_Accept"),
+        new CASTBinaryOp("->",
+          env->clone(),
+          new CASTIdentifier("_rcv_window"))))
+    );*/
+
+       addTo(result, new CASTExpressionStatement(
+               new CASTBinaryOp("=",
+                       new CASTIdentifier("_tag"),
+                       new CASTFunctionOp(
+                               new CASTIdentifier("l4_call"),
+                               new CASTIdentifier("_server"))))
+       );
+       if (!(options & OPTION_ONEWAY))
+               addTo(result, new CASTExpressionStatement(
+                       new CASTFunctionOp(
+                               new CASTIdentifier("l4_msg_store"),
+                               knitExprList(
+                                       new CASTIdentifier("_tag"),
+                                       new CASTIdentifier("_msg"))))
+               );
+       unsigned i=1;           //first (0) is the cap
+       //store data in message
+       
if(!mem_fixed[CHANNEL_OUT]->isEmpty()||!mem_variable[CHANNEL_OUT]->isEmpty()||!strings[CHANNEL_OUT]->isEmpty()||
+               
!fpages[CHANNEL_OUT]->isEmpty()||!special[CHANNEL_OUT]->isEmpty()||!reg_variable[CHANNEL_OUT]->isEmpty())
+               panic("Unsupported datatypes: strings,fpages");         //WHAT 
ARE THE OTHERS?
+               forAllMS(reg_fixed[CHANNEL_OUT],
+               {
+                       CMSChunk4* chunk=(CMSChunk4*)item;
+                       
if(strcasecmp(chunk->name,"_msgtag")&&strcasecmp(chunk->name,"__retval"))       
        //HOW TO DO THIS CLEARLY?
+                               
addTo(result,storeRegFixedFromMsg(CHANNEL_OUT,chunk,i++,"_msg"));
+               };);
+       
+  addTo(result, buildClientUnmarshalStart());
+  
+  return result;    
+}
+
+CASTExpression* CMSConnection4_gnu::buildClientCallSucceeded()
+{
+       return new CASTFunctionOp(
+               new CASTIdentifier("l4_ipc_succeeded"),
+               new CASTIdentifier("_tag")
+       );
+};
diff -Naur idl4-1.0.2/src/arch/v4_gnu/cross.cc idl4/src/arch/v4_gnu/cross.cc
--- idl4-1.0.2/src/arch/v4_gnu/cross.cc 1970-01-01 01:00:00.000000000 +0100
+++ idl4/src/arch/v4_gnu/cross.cc       2005-07-10 08:05:39.439862368 +0200
@@ -0,0 +1,64 @@
+#include <arch/v4_gnu.h>
+void CAoiCrossVisitor_gnu::visit(CAoiInterface *aoi)
+{
+  if (!aoi->peer)
+    {
+      CAoiList *singleSuperclasses = aoi->getAllSuperclasses();
+      CBEList *inheritedOps = new CBEList();
+      
+      forAll(singleSuperclasses, 
+        {
+          CAoiInterface *superclass = (CAoiInterface*)((CAoiRef*)item)->ref;
+          CAoiOperation *op = 
(CAoiOperation*)superclass->operations->getFirstElement();
+          
+          if (superclass != aoi)
+            while (!op->isEndOfList())
+              {
+                inheritedOps->add(new CBEInheritedOperation(op, aoi));
+                op = (CAoiOperation*)op->next;
+              }
+        }
+      );
+
+      aoi->peer = new CBEInterface_gnu(aoi, inheritedOps);
+    }  
+
+  aoi->constants->accept(this);
+  aoi->types->accept(this);
+  aoi->attributes->accept(this);
+  aoi->exceptions->accept(this);
+  aoi->operations->accept(this);
+  aoi->submodules->accept(this);
+  aoi->interfaces->accept(this);
+  aoi->superclasses->accept(this);
+}
+
+void CAoiCrossVisitor_gnu::visit(CAoiOperation *aoi)
+{
+  if (!aoi->peer)
+    {
+      aoi->peer = new CBEOperation_gnu(aoi);
+      aoi->returnType->accept(this);
+      aoi->parameters->accept(this);
+      aoi->exceptions->accept(this);
+      
+      CBEDependencyList *depList = new CBEDependencyList();
+      forAll(aoi->parameters, 
getParameter(item)->registerDependencies(depList));
+      if (!depList->commit())
+        semanticError(aoi->context, "circular dependency between parameters");
+        
+      int maxPrio = 0;
+      forAll(aoi->parameters, 
+        if (getParameter(item)->priority>maxPrio)
+          maxPrio = getParameter(item)->priority;
+      );
+      
+      CBEList *sortedParams = getOperation(aoi)->sortedParams;
+      assert(sortedParams->isEmpty());
+      for (int i=0;i<=maxPrio;i++)
+        forAll(aoi->parameters,
+          if (getParameter(item)->priority == i)
+            sortedParams->add(getParameter(item));
+        );  
+    }  
+}
diff -Naur idl4-1.0.2/src/arch/v4_gnu/Makefile.am 
idl4/src/arch/v4_gnu/Makefile.am
--- idl4-1.0.2/src/arch/v4_gnu/Makefile.am      1970-01-01 01:00:00.000000000 
+0100
+++ idl4/src/arch/v4_gnu/Makefile.am    2005-07-10 08:05:39.439862368 +0200
@@ -0,0 +1,6 @@
+## Process this file with automake to produce Makefile.in
+
+SUBDIRS=
+
+noinst_LIBRARIES=      libv4_gnu.a
+libv4_gnu_a_SOURCES=   template.cc server.cc client.cc stuff.cc be.cc cross.cc
diff -Naur idl4-1.0.2/src/arch/v4_gnu/server.cc idl4/src/arch/v4_gnu/server.cc
--- idl4-1.0.2/src/arch/v4_gnu/server.cc        1970-01-01 01:00:00.000000000 
+0100
+++ idl4/src/arch/v4_gnu/server.cc      2005-07-13 17:20:35.763191296 +0200
@@ -0,0 +1,97 @@
+#include <arch/v4_gnu.h>
+CASTStatement *CMSConnection4_gnu::buildServerDeclarations(CASTIdentifier *key)
+{
+  CASTStatement *result=NULL; //= buildServerStandardDecls(key);               
//We don't want those
+  
+  CASTIdentifier *wrapperIdentifier = key->clone();
+  wrapperIdentifier->addPrefix("service_");
+  
+  CASTDeclarationStatement *wrapperDecl = new CASTDeclarationStatement(
+    getWrapperReturnType()->buildDeclaration( 
+      new CASTDeclarator(
+        wrapperIdentifier,
+        buildWrapperParams(key),
+        NULL, 
+        NULL, 
+        NULL, 
+        buildWrapperAttributes()))
+  );
+  
+  addWithLeadingSpacerTo(result, wrapperDecl);
+
+  return result;  
+}
+
+CASTDeclaration *CMSConnection4_gnu::buildWrapperParams(CASTIdentifier *key)
+{
+       CASTDeclaration *wrapperParams = NULL;
+       
+       addTo(wrapperParams,new CASTDeclaration(
+               new CASTTypeSpecifier(new 
CASTIdentifier("idl4_cap_rpc_context_t")),
+                       knitDeclarator("_ctx"))
+       );
+       
+       return wrapperParams;
+}
+
+CASTStatement *CMSConnection4_gnu::buildServerLocalVars(CASTIdentifier *key)
+
+{
+       CASTDeclarationStatement *result = NULL;
+       
+       CASTDeclarationSpecifier* p=buildClientMsgBuf();
+       if(p)
+               addTo(result, new CASTDeclarationStatement(
+               new CASTDeclaration(
+                 p,
+                 new CASTDeclarator(
+                       new CASTIdentifier("_pack"))))
+               );
+       
+       return result;
+}
+
+CBEType *CMSConnection4_gnu::getWrapperReturnType()
+{
+  return new CBEOpaqueType("void", globals.word_size, globals.word_size);
+}
+
+CASTStatement* CMSConnection4_gnu::buildServerStoreData(const char* msg)
+{
+       CASTStatement* result=NULL;
+       unsigned i=1;
+       
if(!mem_fixed[CHANNEL_IN]->isEmpty()||!mem_variable[CHANNEL_IN]->isEmpty()||!strings[CHANNEL_IN]->isEmpty()||
+               
!fpages[CHANNEL_IN]->isEmpty()||!special[CHANNEL_IN]->isEmpty()||!reg_variable[CHANNEL_IN]->isEmpty())
+               panic("Unsupported datatypes: strings,fpages");         //WHAT 
ARE THE OTHERS?
+       forAllMS(reg_fixed[CHANNEL_IN],
+       {
+               CMSChunk4* chunk=(CMSChunk4*)item;
+                       if(strcasecmp(chunk->name,"_msgtag"))           //HOW 
TO DO THIS CLEARLY?
+                               
addTo(result,storeRegFixedFromMsg(CHANNEL_IN,chunk,i++,msg));
+       };);
+       return result;
+};
+
+CASTStatement* CMSConnection4_gnu::buildServerAppendData(const char* msg,const 
char* ret)
+{
+       CASTStatement* result=NULL;
+       if(ret)
+               addTo(result,new GNU_CALL_FN(
+                       new CASTIdentifier("l4_set_msg_label"),knitExprList(new 
CASTIdentifier(msg),new CASTIdentifier(ret)))
+               );
+       
if(!mem_fixed[CHANNEL_OUT]->isEmpty()||!mem_variable[CHANNEL_OUT]->isEmpty()||!strings[CHANNEL_OUT]->isEmpty()||
+               
!fpages[CHANNEL_OUT]->isEmpty()||!special[CHANNEL_OUT]->isEmpty()||!reg_variable[CHANNEL_OUT]->isEmpty())
+               panic("Unsupported datatypes: strings,fpages");         //WHAT 
ARE THE OTHERS?
+               forAllMS(reg_fixed[CHANNEL_OUT],
+               {
+                       CMSChunk4* chunk=(CMSChunk4*)item;
+                       
if(strcasecmp(chunk->name,"_msgtag")&&strcasecmp(chunk->name,"__retval"))       
        //HOW TO DO THIS CLEARLY?
+                               
addTo(result,appendRegFixedToMsg(CHANNEL_OUT,chunk,msg));
+               };);
+       return result;
+};
+
+CASTExpression *CMSConnection4_gnu::buildServerCallerID()
+{
+  return new CASTIdentifier("_ctx");
+}
diff -Naur idl4-1.0.2/src/arch/v4_gnu/stuff.cc idl4/src/arch/v4_gnu/stuff.cc
--- idl4-1.0.2/src/arch/v4_gnu/stuff.cc 1970-01-01 01:00:00.000000000 +0100
+++ idl4/src/arch/v4_gnu/stuff.cc       2005-07-10 08:05:39.441862064 +0200
@@ -0,0 +1,161 @@
+#include <arch/v4_gnu.h>
+void CMSFactory4_gnu::initRootScope(CAoiRootScope *rootScope)
+{
+  CAoiModule *idl4 = getBuiltinScope(rootScope, "idl4");
+  rootScope->submodules->add(idl4);
+  idl4->constants->add(getBuiltinConstant(rootScope, idl4, "startup", 0));
+  idl4->constants->add(getBuiltinConstant(rootScope, idl4, "interrupt", 1));
+  idl4->constants->add(getBuiltinConstant(rootScope, idl4, "pagefault", 2));
+  idl4->constants->add(getBuiltinConstant(rootScope, idl4, "preemption", 3));
+  idl4->constants->add(getBuiltinConstant(rootScope, idl4, "sysexc", 4));
+  idl4->constants->add(getBuiltinConstant(rootScope, idl4, "archexc", 5));
+  idl4->constants->add(getBuiltinConstant(rootScope, idl4, "sigma0rpc", 6));
+}
+
+CASTDeclarationStatement *CMSConnection4_gnu::buildMessageMembers(int channel)
+{
+       CASTDeclarationStatement *members = NULL;
+       
+       forAllMS(reg_fixed[channel], 
+       {
+               CMSChunk4 *chunk = (CMSChunk4*)item;
+               
if(strcasecmp(chunk->name,"_msgtag")&&strcasecmp(chunk->name,"__retval"))       
        //HOW TO DO THIS CLEARLY?
+                       addTo(members, chunk->buildDeclarationStatement());
+       }    
+       );
+  
+  if (!mem_fixed[channel]->isEmpty() || !mem_variable[channel]->isEmpty())
+    addTo(members, new CASTDeclarationStatement(
+      new CASTDeclaration(
+        new CASTTypeSpecifier(
+          new CASTIdentifier("idl4_stringitem")),
+        new CASTDeclarator(
+          new CASTIdentifier("_memmsg"))))
+    );
+    
+  forAllMS(strings[channel], 
+    if (((CMSChunk4*)item)->flags & CHUNK_XFER_COPY)
+      addTo(members, new CASTDeclarationStatement(
+        new CASTDeclaration(
+          new CASTTypeSpecifier(
+            new CASTIdentifier("idl4_stringitem")),
+          new CASTDeclarator(
+            new CASTIdentifier(item->name))))
+      )
+  );
+    
+  forAllMS(fpages[channel], 
+    addTo(members, new CASTDeclarationStatement(
+      new CASTDeclaration(
+        new CASTTypeSpecifier(
+          new CASTIdentifier("idl4_mapitem")),
+        new CASTDeclarator(
+          new CASTIdentifier(item->name))))
+    )
+  );
+    
+  return members;  
+}
+
+CASTExpression *CMSConnection4_gnu::buildLabelExpr()
+{
+  return new CASTFunctionOp(
+    new CASTIdentifier("l4_label"),
+    new CASTIdentifier("_tag")
+  );
+}
+
+CASTExpression *CMSConnection4_gnu::buildSourceBufferRvalue(int channel)
+{
+       CASTIdentifier *bufferName;
+       
+       bufferName = new CASTIdentifier("_pack");
+       
+       return new CASTBinaryOp(".",
+               bufferName,
+               buildChannelIdentifier(channel));
+}
+
+CASTExpression *CMSConnection4_gnu::buildTargetBufferRvalue(int channel)
+{
+       return buildSourceBufferRvalue(channel);
+}
+
+CASTExpression *CMSConnection4_gnu::buildFCCDataSourceExpr(int channel, 
ChunkID chunkID)
+{
+  CMSChunk4 *chunk;
+
+  chunk = findChunk(reg_fixed[channel], chunkID);
+  if (chunk)
+    {
+      return new CASTBinaryOp(".",
+        new CASTBinaryOp(".",
+          new CASTIdentifier("_pack"), 
+          buildChannelIdentifier(channel)),
+        new CASTIdentifier(chunk->name)
+      );    
+    }
+
+  chunk = findChunk(mem_fixed[channel], chunkID);
+  if (chunk)
+    {
+      return new CASTBinaryOp(".",
+        new CASTBinaryOp("->",
+          new CASTIdentifier("_memmsg"), 
+          buildChannelIdentifier(channel)),
+        new CASTIdentifier(chunk->name)
+      );    
+    }
+
+  chunk = findChunk(strings[channel], chunkID);
+  if (chunk)
+    {
+      return new CASTUnaryOp("*",
+        chunk->contentType->buildTypeCast(1, 
+          new CASTBinaryOp(".",
+            new CASTBinaryOp(".",
+              new CASTBinaryOp(".",
+                new CASTIdentifier("_pack"),
+                new CASTIdentifier("_buf")),
+              new CASTIndexOp(
+                new CASTIdentifier("_str"),
+                new CASTIntegerConstant(15 - chunk->bufferIndex))),
+              new CASTIdentifier("ptr")))
+      );    
+    }
+    
+  panic("Cannot build FCC source expression (chunk %d in channel %d)", 
chunkID, channel);
+  return NULL;
+}
+
+CASTStatement* CMSConnection4_gnu::appendRegFixedToMsg(int channel,CMSChunk4* 
chunk,const char* msg)
+{
+       m_assert(chunk->size<=globals.word_size,"So big data isn't supported 
yet!");
+       return new GNU_CALL_FN(
+               new CASTIdentifier("l4_msg_append_word"),
+               knitExprList(
+                       new CASTIdentifier(msg),
+                       new CASTCastOp(
+                               new CASTDeclaration(
+                                       new CASTTypeSpecifier("l4_word_t"),
+                                       NULL),
+                               new CASTBinaryOp(".",
+                                       buildSourceBufferRvalue(channel),
+                                       new CASTIdentifier(chunk->name)),
+                               CASTStandardCast)));
+};
+
+CASTStatement* CMSConnection4_gnu::storeRegFixedFromMsg(int channel,CMSChunk4* 
chunk,unsigned nr,const char* msg)
+{
+       m_assert(chunk->size<=globals.word_size,"So big data isn't supported 
yet!");
+       return new CASTExpressionStatement(new CASTBinaryOp("=",
+               new CASTBinaryOp(".",
+                       buildTargetBufferRvalue(channel),
+                       new CASTIdentifier(chunk->name)),
+               chunk->contentType->buildTypeCast(0,
+                       new CASTFunctionOp(
+                               new CASTIdentifier("l4_msg_word"),
+                               knitExprList(
+                                       new CASTIdentifier(msg),
+                                       new 
CASTIdentifier(mprintf("%i",nr)))))));      //WHAT IS WITH THE DEALLOCATION OF 
THIS STRINGS?
+};
diff -Naur idl4-1.0.2/src/arch/v4_gnu/template.cc 
idl4/src/arch/v4_gnu/template.cc
--- idl4-1.0.2/src/arch/v4_gnu/template.cc      1970-01-01 01:00:00.000000000 
+0100
+++ idl4/src/arch/v4_gnu/template.cc    2005-07-10 08:05:39.441862064 +0200
@@ -0,0 +1,269 @@
+#include <arch/v4_gnu.h>
+
+#include "be.h"
+#include "ops.h"
+#define dprintln(a...) do { if (debug_mode&DEBUG_GENERATOR) println(a); } 
while (0)
+#define prependStatement(a, b) do { CASTStatement *pre = (b); addTo(pre, (a)); 
(a) = (pre); } while (0)
+
+static char contractBuffer[20000];
+CASTStatement *CMSService4_gnu::buildServerLoop(CASTIdentifier *prefix, 
CASTExpression *utableRef, CASTExpression *ktableRef, bool useItable, bool 
hasKernelMessages)
+{
+         return new 
GNU_CALL_FN_NAME("hurd_cap_bucket_manage_mt","_bucket,NULL,0,0");
+}
+
+CASTStatement *CBEInterface_gnu::buildServerTemplate()
+{
+  CASTStatement *subtree = NULL;
+
+  if ((globals.flags & FLAG_MODULESONLY) && ((aoi->parent)->parent == 0))
+    return NULL;
+
+  int iidMin, iidMax, fidMin, fidMax, kidMin, kidMax;
+  getIDRange(&iidMin, &iidMax, &fidMin, &fidMax, &kidMin, &kidMax);
+
+  if (!(globals.flags & FLAG_LOOPONLY))
+    {
+      addTo(subtree, buildTitleComment());
+      forAll(aoi->operations, 
+        {
+          addTo(subtree, getOperation(item)->buildServerTemplate());
+          if (debug_mode&DEBUG_TESTSUITE)
+            addTo(subtree, getOperation(item)->buildTestFunction());
+        }
+      );    
+      forAllBE(inheritedOps, 
+        addTo(subtree, ((CBEInheritedOperation*)item)->buildServerTemplate())
+      );
+      forAll(aoi->interfaces, 
+        addTo(subtree, getInterface(item)->buildServerTemplate())
+      );
+    }
+
+  addTo(subtree, buildVtableDeclaration());
+
+  /* As a special optimization, we do not use uTables when only kernel
+     messages need to be dispatched */
+
+  CASTIdentifier *utableRef = NULL;
+  if (containsUserMessages() || !containsKernelMessages())
+    {
+      utableRef = buildIdentifier();
+      utableRef->addPostfix((iidMin==iidMax) ? "_vtable" : "_itable");
+    }  
+
+  CASTIdentifier *ktableRef = NULL;
+  if (containsKernelMessages())
+    {
+      ktableRef = buildIdentifier();
+      ktableRef->addPostfix("_ktable");
+    }  
+
+  CASTIdentifier *prefix = buildIdentifier();
+  prefix->capitalize();  
+  addTo(subtree, new CASTDeclarationStatement(
+    new CASTDeclaration(
+      new CASTTypeSpecifier(new CASTIdentifier("void")),
+      new CASTDeclarator(
+        buildServerFuncName(),
+        new CASTDeclaration(
+                       new CASTTypeSpecifier(new 
CASTIdentifier("idl4_cap_bucket_t")),
+                       
knitDeclarator(service->getServerTemplateBucketName()))),
+      new CASTCompoundStatement(service->buildServerLoop(prefix, utableRef, 
ktableRef, (iidMin!=iidMax), containsKernelMessages()))))
+  );
+  addTo(subtree, new CASTSpacer());
+  
+  /***************************************************************************/
+
+  if (!(globals.flags & FLAG_LOOPONLY))  
+    {
+      CASTIdentifier *discardFuncName = buildIdentifier();
+      discardFuncName->addPostfix("_discard");
+
+      CASTStatement *discardFunction = NULL;
+      if (debug_mode&DEBUG_TESTSUITE)
+        addTo(discardFunction, new CASTExpressionStatement(
+          new CASTFunctionOp(
+            new CASTIdentifier("enter_kdebug"),
+            new CASTStringConstant(false, mprintf("Discarding request for 
interface %s", aoi->scopedName))))
+        );
+      addWithTrailingSpacerTo(subtree, new CASTDeclarationStatement(
+        new CASTDeclaration(
+          new CASTTypeSpecifier(mprintf("void")),
+          new CASTDeclarator(
+            discardFuncName,
+            new CASTDeclaration(
+                               new CASTTypeSpecifier(new 
CASTIdentifier("idl4_cap_rpc_context_t")),
+                               knitDeclarator("_ctx"))),
+          new CASTCompoundStatement(discardFunction)))
+      );
+    }
+  
+  /***************************************************************************/
+       
+       CASTIdentifier *demuxer= buildIdentifier();
+       demuxer->addPostfix("_demuxer");
+       
+       addWithTrailingSpacerTo(subtree, new CASTDeclarationStatement(
+               new CASTDeclaration(
+                       new CASTTypeSpecifier(mprintf("error_t")),
+                       new CASTDeclarator(
+                               demuxer,
+                               new CASTDeclaration(
+                                       new CASTTypeSpecifier(new 
CASTIdentifier("idl4_cap_rpc_context_t")),
+                                       knitDeclarator("_ctx"))),
+               new 
CASTCompoundStatement(service->buildServerDemuxer("_ctx",prefix, utableRef, 
ktableRef, (iidMin!=iidMax), containsKernelMessages()))))
+       );
+         
+  /***************************************************************************/
+       if(globals.with_cap_class)
+       {
+               addWithTrailingSpacerTo(subtree,new CASTDeclarationStatement(
+                       new CASTDeclaration(
+                               new CASTTypeSpecifier(new 
CASTIdentifier("static idl4_cap_class")),                     //FIXME
+                               new CASTDeclarator(
+                                       buildIdentifier())))
+               );
+               
+               CASTIdentifier *class_init= buildIdentifier();
+               CASTStatement* class_init_statement=NULL;
+               addTo(class_init_statement,new CASTBlockComment("do necessary 
changes"));
+               addTo(class_init_statement,new CASTReturnStatement(new 
CASTFunctionOp(
+                       new CASTIdentifier("idl4_cap_class_init"),
+                       knitExprList(
+                               new CASTUnaryOp("&",buildIdentifier()),
+                               new CASTIdentifier("int*"),
+                               knitExprList(
+                                       new CASTIdentifier("NULL"),new 
CASTIdentifier("NULL"),
+                                       new CASTIdentifier("NULL"),new 
CASTIdentifier("NULL"),
+                                       demuxer->clone())))
+               ));
+               class_init->addPostfix("_init");
+               addWithTrailingSpacerTo(subtree, new CASTDeclarationStatement(
+                       new CASTDeclaration(
+                               new CASTTypeSpecifier(new 
CASTIdentifier("error_t")),
+                               new CASTDeclarator(
+                                       class_init,
+                                       new CASTEmptyDeclaration()),
+                               new 
CASTCompoundStatement(class_init_statement)))
+               );
+               
+               CASTIdentifier *class_alloc= buildIdentifier();
+               class_alloc->addPostfix("_alloc");
+               CASTStatement* class_alloc_statement=NULL;
+               addTo(class_alloc_statement,new CASTBlockComment("do necessary 
changes"));
+               addTo(class_alloc_statement,new CASTReturnStatement(new 
CASTFunctionOp(
+                       new CASTIdentifier("idl4_cap_class_alloc"),
+                       knitExprList(
+                               new CASTUnaryOp("&",buildIdentifier()),
+                               new CASTIdentifier("_r_obj")))
+               ));
+               CASTDeclaration *class_alloc_parameters = NULL;
+               addTo(class_alloc_parameters,new CASTDeclaration(
+                       new CASTTypeSpecifier(new 
CASTIdentifier("idl4_cap_obj_t*")),
+                               knitDeclarator("_r_obj"))
+               );
+               addWithTrailingSpacerTo(subtree, new CASTDeclarationStatement(
+                       new CASTDeclaration(
+                               new CASTTypeSpecifier(new 
CASTIdentifier("error_t")),
+                               new CASTDeclarator(
+                                       class_alloc,
+                                       class_alloc_parameters),
+                               new 
CASTCompoundStatement(class_alloc_statement)))
+               );
+       };
+       
+  return subtree;
+}
+
+CASTStatement *CBEOperation_gnu::buildServerTemplate()
+{
+  CASTStatement *result = NULL;
+  CASTDeclaration *parameters = NULL;
+  
+  assert(connection);
+  
+  dprintln("*** Building server template for %s", aoi->name);
+
+  addTo(parameters, new CASTDeclaration(
+    new CASTTypeSpecifier(new CASTIdentifier("idl4_cap_rpc_context_t")),
+    knitDeclarator("_ctx"))
+  );
+    
+  forAll(aoi->parameters, addTo(parameters, 
getParameter(item)->buildDeclaration()));
+
+  CASTIdentifier *implementationName = buildIdentifier();
+  implementationName->addPostfix("_implementation");
+
+  CBEVarSource *varSource = new CBEVarSource();
+  CASTStatement *localVars = NULL;
+  CASTStatement *statements = NULL;
+
+  if (debug_mode&DEBUG_TESTSUITE)
+    addTo(statements, buildTestClientCode(varSource));
+    else addTo(statements, new CASTBlockComment(mprintf("implementation of 
%s::%s", ((CAoiInterface*)aoi->parent)->scopedName, aoi->name)));
+
+  dprintln(" +  Marshalling return value");
+  
+  addTo(localVars, varSource->declareAll());
+  if (!aoi->returnType->isVoid())
+    {
+      CASTDeclarator *rv = new CASTDeclarator(new CASTIdentifier("__retval"), 
NULL, NULL, getType(aoi->returnType)->buildDefaultValue());
+      rv->addIndir(getType(aoi->returnType)->getArgIndirLevel(RETVAL));
+      addTo(localVars, new CASTDeclarationStatement(
+        getType(aoi->returnType)->buildDeclaration(rv))
+      );
+
+      addTo(statements, new CASTReturnStatement(
+        new CASTIdentifier("__retval")));
+    } else addTo(statements, new CASTReturnStatement());
+
+  CASTStatement *compound = NULL;
+  addWithTrailingSpacerTo(compound, localVars);
+  addTo(compound, statements);
+  
+  CASTDeclarator *declarator = new CASTDeclarator(implementationName, 
parameters);
+  declarator->addIndir(getType(aoi->returnType)->getArgIndirLevel(RETVAL));
+  CASTDeclaration *declaration = 
getType(aoi->returnType)->buildDeclaration(declarator, new 
CASTCompoundStatement(compound));
+  declaration->addSpecifier(new 
CASTStorageClassSpecifier(mprintf("IDL4_INLINE")));
+  
+  addWithTrailingSpacerTo(result, new CASTDeclarationStatement(declaration));
+
+  addWithTrailingSpacerTo(result, new CASTExpressionStatement(
+    new CASTFunctionOp(
+      buildWrapperName(true),
+      implementationName->clone()))
+  );
+  
+  return result;
+}
+
+CASTStatement* CMSService4_gnu::buildServerDemuxer(const char* 
ctx,CASTIdentifier *prefix, CASTExpression *utableRef,
+                                                                               
                                                                        
CASTExpression *ktableRef, bool useItable, bool hasKernelMessages)
+{
+       CASTIdentifier *fidMask = prefix->clone();      
+       fidMask->addPostfix("_FID_MASK");
+       
+       CASTStatement* r=NULL;
+       
+
+       if(hasKernelMessages)
+               panic("Kernel messages not implemented!");
+       if(useItable)
+               panic("Multiple interfaces not implemented!");
+  
+       addTo(r,new GNU_CALL_FN(new CASTFunctionOp(new CASTIdentifier(""),
+               new CASTUnaryOp("*",
+                       new CASTFunctionOp(
+                               new 
CASTIdentifier("(void(*)(idl4_cap_rpc_context_t))"),
+                               new CASTIndexOp(
+                                       utableRef,
+                                       new CASTBinaryOp("&",
+                                         new CASTFunctionOp(
+                                               new 
CASTIdentifier("idl4_get_function_id"),
+                                               new 
CASTIdentifier("idl4_msg_label(_ctx->msg)")),
+                                         fidMask))))),
+               new CASTIdentifier("_ctx")));
+       addTo(r,new CASTReturnStatement(new CASTIntegerConstant(0)));
+  
+  return r;
+};
diff -Naur idl4-1.0.2/src/base/main.cc idl4/src/base/main.cc
--- idl4-1.0.2/src/base/main.cc 2003-08-25 06:34:52.000000000 +0200
+++ idl4/src/base/main.cc       2005-07-13 16:36:21.083113600 +0200
@@ -8,6 +8,9 @@
 #include <stdlib.h>
 #include <time.h>
 
+#include <fstream>
+#include <vector>
+
 #ifdef HAVE_GETOPT_LONG
 #include <getopt.h>
 #else
@@ -29,6 +32,7 @@
 #include "arch/dummy.h"
 #include "arch/v2.h"
 #include "arch/v4.h"
+#include "arch/v4_gnu.h"
 
 #define dprintln(fmt...) do { if 
(debug_mode&(~(DEBUG_TESTSUITE+DEBUG_PARANOID))) printf(fmt); } while (0)
 #define OPTION(sopt, lopt, arg, expl) printf("  -%c%-21s%s\n", sopt, (lopt[0]) 
? mprintf(", --%s%s%s", lopt, (arg[0] ? "=" : " "), arg) : "", expl)
@@ -59,6 +63,11 @@
   OPTION('p',"platform" ,"SPEC","specify platform (ia32, arm)");
   OPTION('i',"interface","SPEC","choose kernel interface (V2, X0, V4)");
   OPTION('m',"mapping"  ,"SPEC","use specific mapping (C)");
+  OPTION('l',"class"  ,"","add cap-class stubs (very rudimentary, better use 
wrapping for headers)");
+  OPTION('M',"make-depend"  ,"","build make compliant dependencies");
+  OPTION('C',"compiler"  ,"","specifiy the compiler (and the flags) to use 
[gcc/g++]");
+  OPTION('T',"user-types"  ,"","use the compiler to find out align and size of 
unknown types");
+  OPTION('N',"no-erase"  ,"","don't erase temporary files");
   printf("\n");
   exit(1);
 }
@@ -74,7 +83,7 @@
 
 {
   char optch;
-  static char stropts[] = "stco:h:d::vp:i:m:f:D:I:W:w:";
+  static char stropts[] = "NMTC:lstco:h:d::vp:i:m:f:D:I:W:w:";
   int optidx;
   static struct option longopts[] = 
     { { "debug",     optional_argument, 0, 'd' },
@@ -90,6 +99,11 @@
       { "pre-call",  required_argument, 0, 4   },
       { "post-call", required_argument, 0, 5   },
       { "help",      no_argument,       0, 1   },
+         { "class",     optional_argument, 0, 'l' },
+         { "compiler",     optional_argument, 0, 'C' },
+         { "make-depend",     optional_argument, 0, 'M' },
+         { "user-types",     optional_argument, 0, 'T' },
+         { "no-erase",     optional_argument, 0, 'N' },
       { 0,           0,                 0, 0   } };
 
   for (int i=0;i<MAX_OPTIONS;i++)
@@ -100,16 +114,21 @@
 
   for (int i=0;i<MAX_OPTIONS;i++)
     globals.preproc_defines[i] = getBuiltinMacro(i);
-
+  globals.no_erase=false;
   while ((optch=getopt_long(argc, argv, stropts, longopts, &optidx))!=EOF)
     switch (optch)
       {
         case 's' : globals.output_type = OUTPUT_SERVER; break;
+               case 'N' : globals.no_erase=true;break;
         case 't' : globals.output_type = OUTPUT_TEMPLATE; break;
         case 'c' : globals.output_type = OUTPUT_CLIENT; break;
         case 'o' : strncpy(globals.outfile_name, optarg, FILENAME_MAX);break;
         case 'h' : strncpy(globals.header_name, optarg, FILENAME_MAX);break;
+        case 'l' : globals.with_cap_class=true;break;
         case 'v' : version();break;
+        case 'M' : globals.make_depend=true;break;
+        case 'T' : globals.user_types=true;break;
+        case 'C' : if(optarg)globals.cc=optarg;else panic("said to give 
compiler but no compiler given");break;
         case 'd' : if (optarg)
                      { 
                        if (!strcasecmp(optarg, "test"))
@@ -219,6 +238,7 @@
         case 'i' : if (!strcasecmp(optarg,"V2")) globals.interface = 
INTERFACE_V2; else
                    if (!strcasecmp(optarg,"X0")) globals.interface = 
INTERFACE_X0; else
                    if (!strcasecmp(optarg,"V4")) globals.interface = 
INTERFACE_V4; else
+                   if (!strcasecmp(optarg,"V4_GNU")) globals.interface = 
INTERFACE_V4_GNU; else
                      {
                        printf("Unknown kernel interface: %s\n", optarg);
                        exit(1);
@@ -265,7 +285,20 @@
 
   if (argc==optind)
     help();
-
+  
+  if(globals.user_types&&globals.cc=="")
+         switch (globals.mapping)
+         {
+                 case MAPPING_CXX:
+                               globals.cc="g++";
+                               break;
+                 case MAPPING_C:
+                               globals.cc="gcc";
+                               break;
+                 default:
+                               panic("can't guess the compiler - unknown 
mapping");
+         };
+  
   dprintln("Debug mode set to %d\n", debug_mode);
     
   strncpy(globals.infile_name, argv[optind], FILENAME_MAX);
@@ -291,11 +324,124 @@
     } else strcpy(globals.prefix_path, "");
 }
 
+int make_depend()
+{
+       std::ifstream in(globals.infile_name);
+       if(!in)
+       {
+               panic("inputfile doesn't exist");
+               return 1;
+       };
+       std::string s;
+       std::string::iterator i;
+       std::string::size_type c;
+       std::vector<std::string> v;
+       while(getline(in,s))
+       {
+               if((c=s.find("import"))==std::string::npos)
+                       continue;
+               const unsigned skip=6;
+               if((c==0||(s[c-1]==' 
'||s[c-1]=='\t'))&&(s.size()>(c+skip))&&(s[c+skip]==' '||s[c+skip]=='\t'))      
           //make sure it's really a keyword (and not within an identifier)
+               {
+                       std::string::iterator j=s.begin()+c+skip;
+                       for(;*j!='\"'&&j!=s.end();++j);
+                       if(j==s.end())
+                               panic("malformed import directive");
+                       ++j;
+                       std::string::iterator k=j;
+                       for(;*k!='\"'&&k!=s.end();++k);
+                       if(k==s.end())
+                               panic("malformed import directive");
+                       std::string::iterator l=k;
+                       for(;*l!=';'&&l!=s.end();++l);
+                       if(l==s.end())
+                               panic("malformed import directive");
+                       //printf("%s\n",std::string(j,k).c_str());
+                       v.push_back(std::string(j,k));
+               };
+       };
+       
+       printf("%s: %s ",globals.header_name,globals.infile_name);
+       if(v.size())
+       {
+               std::string ccopt;
+               char buffer[MAX_PATH];
+               getcwd(buffer,MAX_OPTIONS);
+               ccopt+=std::string("-I")+buffer+" ";
+               for(const char** 
cpp=globals.preproc_includes;*cpp&&cpp<(globals.preproc_includes+MAX_OPTIONS+1);++cpp)
+                       ccopt+=(std::string("-I")+*cpp)+" ";
+               for(const char** 
cpp=globals.preproc_options;*cpp&&cpp<(globals.preproc_options+MAX_OPTIONS+1);++cpp)
+                       ccopt+=(std::string("-")+*cpp)+" ";
+               for(const char** 
cpp=globals.preproc_defines;*cpp&&cpp<(globals.preproc_defines+MAX_OPTIONS+1);++cpp)
+                       ccopt+=(std::string("-D")+*cpp)+" ";
+               
+               std::string r("/tmp/");
+               for(unsigned i=0;i<15;++i)
+                       r+=(rand()%26+'a');
+               if(globals.mapping==MAPPING_C)
+                       r+=".c";
+               else if(globals.mapping==MAPPING_CXX)
+                       r+="cc";
+               else
+                       panic("unsupported mapping");
+               //printf("%s\n",r.c_str());
+               std::string r2("/tmp/");
+               for(unsigned i=0;i<15;++i)
+                       r2+=(rand()%26+'a');
+               //printf("%s\n",r2.c_str());
+               
+               std::ofstream f(r.c_str());
+               for(unsigned i=0;i<v.size();++i)
+               {
+                       f<<"#include <"<<v[i]<<'>'<<std::endl;
+               };
+               f.close();
+               system((globals.cc+" -MM "+ccopt+r+" > "+r2).c_str());
+               
+               std::ifstream f2(r2.c_str());
+               if(f2)
+               {
+                       getline(f2,s);
+                       if(f2)
+                       {
+                               i=s.begin();
+                               for(;*i!=':'&&i!=s.end();++i);
+                               for(;*i!='.'&&i!=s.end();++i);
+                               for(;*i!=' '&&*i!='\t'&&i!=s.end();++i);
+                               for(;(*i==' '||*i=='\t')&&i!=s.end();++i);
+                               for(;i!=s.end();++i)
+                                       printf("%c",*i);
+                               printf("\n");
+                               while(getline(f2,s))
+                                       printf("%s\n",s.c_str());
+                       }
+                       else
+                       {
+                               f2.close();
+                               remove(r.c_str());
+                               remove(r2.c_str());
+                               panic("confused (by compiler errors?)");
+                       };
+               }
+               f2.close();
+               remove(r.c_str());
+               remove(r2.c_str());
+       }
+       else
+               printf("\n");
+       
+       return 0;
+};
+
 int main(int argc, char *argv[])
 
 {
+  srand(time(0));
   parse_args(argc, argv);
-
+  
+  if(globals.make_depend)
+         return make_depend();
+       
   if (globals.interface == INTERFACE_X0)
     {
       switch (globals.platform)
@@ -326,7 +472,16 @@
           case PLATFORM_DUMMY   : msFactory = new CMSFactoryDummy();break;
           default               : panic("V4 platforms: generic, ia32, dummy");
         }
-    } else panic("Unsupported interface");
+    } else 
+  if (globals.interface == INTERFACE_V4_GNU)
+    {
+      switch (globals.platform)
+        {
+          case PLATFORM_GENERIC : msFactory = new CMSFactory4_gnu();break;
+          case PLATFORM_DUMMY   : msFactory = new CMSFactoryDummy();break;
+          default               : panic("V4_GNU platforms: generic, dummy");
+        }
+    }else panic("Unsupported interface");
 
   if (globals.mapping == MAPPING_CXX)
     CASTBase::setCXXMode(true);
@@ -349,6 +504,9 @@
     panic("%s: %i Error(s) and %i Warning(s)", globals.infile_name,
           mainFile->getErrorCount(), mainFile->getWarningCount());
 
+  if(globals.user_types)
+         make_user_types();
+  
   if (debug_mode & DEBUG_AOI)
     aoiRoot->accept(new CAoiDumpVisitor());  
 
@@ -358,7 +516,10 @@
   if ((globals.mapping == MAPPING_C) || (globals.mapping == MAPPING_CXX))
     {
       dprintln("transforming...\n");
-      aoiRoot->accept(new CAoiCrossVisitor());
+      if(globals.interface==INTERFACE_V4_GNU)
+        aoiRoot->accept(new CAoiCrossVisitor_gnu());
+      else
+        aoiRoot->accept(new CAoiCrossVisitor());
 
       CBERootScope *beRoot = (CBERootScope*)aoiRoot->peer;
       CBEIDSource *idSource = new CBEIDSource();
diff -Naur idl4-1.0.2/src/base/tools.cc idl4/src/base/tools.cc
--- idl4-1.0.2/src/base/tools.cc        2003-03-12 14:05:44.000000000 +0100
+++ idl4/src/base/tools.cc      2005-07-13 16:42:11.630822248 +0200
@@ -2,9 +2,13 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <fstream>
+#include <unistd.h>
+#include <string>
+
 #include "globals.h"
 #include "base.h"
-
+#include <aoi.h>
 char *getDefaultFilename(int number, int mode)
 
 {
@@ -62,3 +66,103 @@
 
   return version_string;
 }
+
+void make_user_types()
+{
+       std::string ccopt;
+       char buffer[MAX_PATH];
+       getcwd(buffer,MAX_PATH);
+       ccopt+=std::string("-I")+buffer+" ";
+       for(const char** 
cpp=globals.preproc_includes;*cpp&&cpp<(globals.preproc_includes+MAX_OPTIONS+1);++cpp)
+               ccopt+=(std::string("-I")+*cpp)+" ";
+       for(const char** 
cpp=globals.preproc_options;*cpp&&cpp<(globals.preproc_options+MAX_OPTIONS+1);++cpp)
+               ccopt+=(std::string("-")+*cpp)+" ";
+       for(const char** 
cpp=globals.preproc_defines;*cpp&&cpp<(globals.preproc_defines+MAX_OPTIONS+1);++cpp)
+               ccopt+=(std::string("-D")+*cpp)+" ";
+       
+       std::string r1("/tmp/");        
+       for(unsigned i=0;i<15;++i)
+               r1+=(rand()%26+'a');
+       std::string r2=r1;
+       if(globals.mapping==MAPPING_C)
+               r1+=".c";
+       else if(globals.mapping==MAPPING_CXX)
+               r1+="cc";
+       else
+               panic("unsupported mapping");
+       std::string r3("/tmp/");
+       for(unsigned i=0;i<15;++i)
+               r3+=(rand()%26+'a');
+       //printf("%s\n",r1.c_str());
+       //printf("%s\n",r2.c_str());    
+       //printf("%s\n",r3.c_str());    
+       std::ofstream cfile(r1.c_str());
+       assert(cfile);
+       
+       cfile<<"#if HAVE_CONFIG_H\n#include <config.h>\n#endif"<<std::endl;
+       forAll(aoiRoot->includes,
+       {
+               cfile<<"#include 
<"<<((CAoiConstString*)item)->value<<'>'<<std::endl;
+       };);
+       cfile<<"#include <stdlib.h>"<<std::endl;
+       cfile<<"#include <stdio.h>"<<std::endl;
+       cfile<<"int main()"<<std::endl<<'{'<<std::endl; 
+       for(std::map<std::string,CAoiUserType*>::iterator 
i=globals.types.begin();i!=globals.types.end();++i)
+               cfile<<"printf(\"%i 
%i"<<'\\'<<'n'<<"\",sizeof("<<i->first<<"),__alignof("<<i->first<<"));"<<std::endl;
+       cfile<<"exit(0);"<<std::endl<<'}'<<std::endl;
+       
+       system((globals.cc+" "+ccopt+"-o "+r2+" "+r1).c_str());
+       system((r2+" > "+r3).c_str());  
+       
+       std::ifstream ifile(r3.c_str());
+       if(!ifile)
+               if(!globals.no_erase)
+               {
+                       cfile.close();
+                       ifile.close();
+                       remove(r1.c_str());
+                       remove(r2.c_str());
+                       remove(r3.c_str());
+                       assert(false);
+               };
+       
+       unsigned tmp;
+       for(std::map<std::string,CAoiUserType*>::iterator 
i=globals.types.begin();i!=globals.types.end();++i)
+       {
+               ifile>>tmp;
+               if(!ifile)
+                       if(!globals.no_erase)
+                       {
+                               cfile.close();
+                               ifile.close();
+                               remove(r1.c_str());
+                               remove(r2.c_str());
+                               remove(r3.c_str());
+                               assert(false);
+                       };
+               i->second->setSize(tmp);
+               if(!ifile)
+                       if(!globals.no_erase)
+                       {
+                               cfile.close();
+                               ifile.close();
+                               remove(r1.c_str());
+                               remove(r2.c_str());
+                               remove(r3.c_str());
+                               assert(false);
+                       };
+               i->second->setAlign(tmp);
+       };
+       
+       //for(std::map<std::string,CAoiUserType*>::iterator 
i=globals.types.begin();i!=globals.types.end();++i)
+       //      printf("%s: 
%i,%i\n",i->first.c_str(),i->second->getSize(),i->second->getAlign());
+               
+       if(!globals.no_erase)
+       {
+               cfile.close();
+               ifile.close();
+               remove(r1.c_str());
+               remove(r2.c_str());
+               remove(r3.c_str());
+       };
+};
diff -Naur idl4-1.0.2/src/base/version.cc idl4/src/base/version.cc
--- idl4-1.0.2/src/base/version.cc      2003-03-29 20:40:46.000000000 +0100
+++ idl4/src/base/version.cc    2005-07-10 08:05:39.445861456 +0200
@@ -1,6 +1,6 @@
 #include <config.h>
 
-const char* idl4_version = VERSION " (roadrunner)";
+const char* idl4_version = VERSION " (patch by ness <address@hidden>)";
 const char* idl4_build   = __DATE__ " " __TIME__;
 const char* idl4_user    = __USER__;
 const char* idl4_gcc     = __GCCVERSION__;
diff -Naur idl4-1.0.2/src/be/cross.cc idl4/src/be/cross.cc
--- idl4-1.0.2/src/be/cross.cc  2002-10-30 17:08:55.000000000 +0100
+++ idl4/src/be/cross.cc        2005-07-10 18:37:42.497045664 +0200
@@ -307,3 +307,10 @@
         } else panic("Unknown custom type: %s", aoi->identifier);
     }  
 }
+
+void CAoiCrossVisitor::visit(CAoiUserType *aoi)
+{
+       assert(globals.user_types);
+       if(!aoi->peer)
+               aoi->peer=new CBEUserType(aoi);
+};
diff -Naur idl4-1.0.2/src/be/scope.cc idl4/src/be/scope.cc
--- idl4-1.0.2/src/be/scope.cc  2003-02-26 15:51:00.000000000 +0100
+++ idl4/src/be/scope.cc        2005-07-10 08:05:39.447861152 +0200
@@ -259,8 +259,17 @@
       addWithTrailingSpacerTo(result, msFactory->buildTestIncludes());
       addTo(result, new CASTPreprocInclude(new 
CASTIdentifier(getDefaultFilename(FILE_HEADER, OUTPUT_CLIENT))));
     }
-
-  addWithTrailingSpacerTo(result, new CASTPreprocInclude(new 
CASTIdentifier(getDefaultFilename(FILE_HEADER, OUTPUT_SERVER))));
+       
+  //edit by ness
+  char* s=getDefaultFilename(FILE_HEADER, OUTPUT_SERVER);
+  unsigned i;
+  for(i=strlen(s)-1;(i>0)&&s[i]!='_';--i);
+  unsigned j;
+  for(j=i-1;(i>0)&&s[j]!='_';--j);
+  for(;s[i]!='\0';++i,++j)s[j]=s[i];
+  s[j]='\0';
+  
+  addWithTrailingSpacerTo(result, new CASTPreprocInclude(new 
CASTIdentifier(s)));
   
   if (debug_mode&DEBUG_TESTSUITE)
     addTo(result, buildTestDeclarations());
diff -Naur idl4-1.0.2/src/be/types/Makefile.am idl4/src/be/types/Makefile.am
--- idl4-1.0.2/src/be/types/Makefile.am 2002-10-30 17:10:53.000000000 +0100
+++ idl4/src/be/types/Makefile.am       2005-07-10 15:24:53.955087016 +0200
@@ -3,4 +3,4 @@
 noinst_LIBRARIES=      libtypes.a
 libtypes_a_SOURCES=    alias.cc enum.cc float.cc fpage.cc integer.cc \
                        object.cc opaque.cc pointer.cc sequence.cc string.cc \
-                       struct.cc union.cc
+                       struct.cc union.cc usertype.cc
diff -Naur idl4-1.0.2/src/be/types/usertype.cc idl4/src/be/types/usertype.cc
--- idl4-1.0.2/src/be/types/usertype.cc 1970-01-01 01:00:00.000000000 +0100
+++ idl4/src/be/types/usertype.cc       2005-07-13 17:40:39.346218864 +0200
@@ -0,0 +1,45 @@
+#include "ops.h"
+#include <cast.h>
+#define dprintln(a...) do { if (debug_mode&DEBUG_MARSHAL) println(a); } while 
(0)
+
+CBEMarshalOp *CBEUserType::buildMarshalOps(CMSConnection *connection, int 
channels, CASTExpression *rvalue, const char *name, CBEType *originalType, 
CBEParameter *param, int flags)
+{
+       CBEMarshalOp *result;
+       
+       dprintln("Marshalling %s (%s)", name, aoi->name);
+       indent(+1);
+       
+       result = new CBEOpSimpleCopy(connection, channels, rvalue, 
originalType, aoi->getAlign(), name, param, flags);
+       
+       indent(-1);
+       
+       return result;
+}
+
+CASTDeclaration *CBEUserType::buildDeclaration(CASTDeclarator *decl, 
CASTCompoundStatement *compound)
+{
+       return new CASTDeclaration(new CASTTypeSpecifier(new 
CASTIdentifier(aoi->name)), decl, compound);
+}
+
+int CBEUserType::getArgIndirLevel(CBEDeclType declType)
+{ 
+       if ((declType==INOUT) || (declType==OUT))
+               return 1;
+       
+       return 0;
+}
+
+CASTExpression *CBEUserType::buildBufferAllocation(CASTExpression *elements)
+{
+       //dummy:
+       return new CASTFunctionOp(
+    new 
CASTIdentifier("im_only_a_dummy_for_CBEUserType::buildBufferAllocation"),
+    new CASTUnaryOp("(unsigned)", 
+      elements)
+  );
+}
+
+CASTExpression *CBEUserType::buildDefaultValue()
+{
+       return new CASTIdentifier("{0,}");
+}
diff -Naur idl4-1.0.2/src/cast/cast.cc idl4/src/cast/cast.cc
--- idl4-1.0.2/src/cast/cast.cc 2003-08-25 06:41:22.000000000 +0200
+++ idl4/src/cast/cast.cc       2005-07-10 08:05:39.448861000 +0200
@@ -351,6 +351,7 @@
      } while (iterator!=this);     
 }
 
+//change by ness: print the atts before the identifier
 void CASTDeclarator::write()
 
 {
@@ -362,9 +363,17 @@
   if (qualifiers)
     {
       qualifiers->writeAll(" ");
-      if (identifier)
+      if (attributes)
         print(" ");
     }  
+       
+  if (attributes)
+    {
+      print(" ");
+      attributes->writeAll(" ");
+      if(identifier)
+        print(" ");
+    }
 
   if (identifier) 
     identifier->write();
@@ -406,12 +415,6 @@
       print(" : ");
       bitSize->write();
     }
-
-  if (attributes)
-    {
-      print(" ");
-      attributes->writeAll(" ");
-    }
     
   if (initializer)
     {
@@ -1532,4 +1535,3 @@
   
   leaveMajor("#undef");
 }
-  
diff -Naur idl4-1.0.2/src/fe/idl/parser.yy idl4/src/fe/idl/parser.yy
--- idl4-1.0.2/src/fe/idl/parser.yy     2003-03-27 09:59:17.000000000 +0100
+++ idl4/src/fe/idl/parser.yy   2005-07-10 20:29:09.287706664 +0200
@@ -331,18 +331,23 @@
 import         : IMPORT filenames {
                     while (!$2->isEmpty())
                       {
-                        CAoiConstString *thisFile = 
(CAoiConstString*)($2->removeFirstElement());
-                        CAoiList *importedTypes = importTypes(thisFile->value, 
getContext());
-                        if (importedTypes)
-                          {
-                            while (!importedTypes->isEmpty())
-                              {
-                                CAoiType *element = 
(CAoiType*)importedTypes->removeFirstElement();
-                                element->parentScope = currentScope;
-                                currentScope->types->add(element);
-                              }
-                            aoiRoot->includes->add(thisFile);
-                          } else ParseError(ERR_PARS_IMPORT_FAILED, 
thisFile->value);  
+                                                 if(globals.user_types)
+                                                         
aoiRoot->includes->add((CAoiConstString*)($2->removeFirstElement()));
+                                                 else
+                                                 {
+                                                       CAoiConstString 
*thisFile = (CAoiConstString*)($2->removeFirstElement());
+                                                       CAoiList *importedTypes 
= importTypes(thisFile->value, getContext());
+                                                       if (importedTypes)
+                                                         {
+                                                               while 
(!importedTypes->isEmpty())
+                                                                 {
+                                                                       
CAoiType *element = (CAoiType*)importedTypes->removeFirstElement();
+                                                                       
element->parentScope = currentScope;
+                                                                       
currentScope->types->add(element);
+                                                                 }
+                                                               
aoiRoot->includes->add(thisFile);
+                                                         } else 
ParseError(ERR_PARS_IMPORT_FAILED, thisFile->value);  
+                                                 }
                       }
                   }
                 | INCLUDE filenames {
@@ -408,8 +413,13 @@
                     CAoiBase *ref = currentScope->lookupSymbol($1, SYM_ANY);
                     if (!ref)
                       {
-                        GrammarError(ERR_PARS_REFERENCE_UNDEFINED);
-                        $$ = NULL;
+                        if(globals.user_types)
+                                                       $$ = 
aoiFactory->buildUserType($1,getContext());
+                                               else
+                                               {
+                                                       
GrammarError(ERR_PARS_REFERENCE_UNDEFINED);
+                                                       $$=0;
+                                               };
                       } else $$ = aoiFactory->buildRef(ref, getContext());
                   }   
                | SCOPE id {
diff -Naur idl4-1.0.2/src/include/aoi.h idl4/src/include/aoi.h
--- idl4-1.0.2/src/include/aoi.h        2002-10-30 17:15:04.000000000 +0100
+++ idl4/src/include/aoi.h      2005-07-10 14:55:41.561334360 +0200
@@ -79,6 +79,7 @@
   virtual bool isConstBase() { return false; };
   virtual bool isProperty() { return false; };
   virtual bool isParameter() { return false; };
+  virtual bool isUserType(){return false;};
 };
 
 class CAoiList : public CAoiBase
@@ -291,6 +292,21 @@
   virtual bool isVoid() { return false; };
 };
 
+class CAoiUserType : public CAoiType
+{
+protected:
+       unsigned size,align;
+public:
+       virtual bool isUserType(){return true;};
+       virtual void accept(CAoiVisitor *worker);
+       CAoiUserType(const char* ident,CAoiScope *parentScope, CAoiContext 
*context)
+               :CAoiType(ident, parentScope, context){};
+       unsigned getSize()const{return size;};
+       unsigned getAlign()const{return align;};        
+       void setAlign(unsigned a){align=a;};
+       void setSize(unsigned a){size=a;};
+};
+
 class CAoiStructType : public CAoiType
 
 {
@@ -549,6 +565,8 @@
 
 {
 public:
+  virtual CAoiRef* buildUserType(const char* id,CAoiContext *ctx)
+       {if(globals.types[id]==0)globals.types[id]=new 
CAoiUserType(id,aoiRoot,ctx);return buildRef(globals.types[id],ctx);};
   virtual CAoiRootScope *getRootScope()
     { return new CAoiRootScope(); };
   virtual CAoiModule *buildModule(CAoiScope *parentScope, const char 
*identifier, CAoiContext *context) 
@@ -655,6 +673,8 @@
   virtual void visit(CAoiProperty *peer) { assert(false); };
   virtual void visit(CAoiOperation *peer) { assert(false); };
   virtual void visit(CAoiAttribute *peer) { assert(false); };
+  
+  virtual void visit(CAoiUserType *peer) { assert(false); };
 };
 
 #endif
diff -Naur idl4-1.0.2/src/include/arch/v4_gnu.h idl4/src/include/arch/v4_gnu.h
--- idl4-1.0.2/src/include/arch/v4_gnu.h        1970-01-01 01:00:00.000000000 
+0100
+++ idl4/src/include/arch/v4_gnu.h      2005-07-13 14:34:50.867221560 +0200
@@ -0,0 +1,120 @@
+#ifndef ARCH_V4_GNU_H
+#define ARCH_V4_GNU_H ARCH_V4_GNU_H
+#include "v4.h"
+#include <be.h>
+#include <cross.h>
+#ifndef NDEBUG
+#define m_assert(a,b) if(!(a))panic(b)
+#else
+#define m_assert(a,b) if(0)
+#endif
+
+#define GNU_CALL_FN(name,par)\
+CASTExpressionStatement(\
+               new CASTFunctionOp(\
+                       name,\
+                       par))
+
+#define GNU_CALL_FN_NAME(name,par)\
+CASTExpressionStatement(\
+               new CASTFunctionOp(\
+                       new CASTIdentifier(name),\
+                       new CASTIdentifier(par)))
+
+class CMSConnection4_gnu
+       :public CMSConnection4
+{
+public:
+       CMSConnection4_gnu(CMSService4 *service, int numChannels, int fid, int 
iid, int bitsPerWord)
+               :CMSConnection4(service, numChannels, fid, iid, bitsPerWord) {};
+                       
+       virtual void dump(){};
+                       
+       virtual CASTStatement* buildClientLocalVars(CASTIdentifier* key);
+       virtual CASTDeclarationStatement* buildMessageMembers(int channel);
+       virtual CASTExpression *buildLabelExpr();
+       virtual CASTStatement *buildClientCall(CASTExpression *target, 
CASTExpression *env);
+       virtual CASTStatement *buildServerDeclarations(CASTIdentifier *key);
+       virtual CASTDeclaration *buildWrapperParams(CASTIdentifier *key);
+       virtual CASTStatement *buildServerLocalVars(CASTIdentifier *key);
+       virtual CBEType *getWrapperReturnType();
+       virtual CASTExpression *buildServerCallerID();
+               
+       virtual CASTExpression *buildSourceBufferRvalue(int channel);
+       virtual CASTExpression *buildTargetBufferRvalue(int channel);
+       virtual CASTExpression *buildFCCDataSourceExpr(int channel, ChunkID 
chunk);
+               
+       virtual CASTStatement* buildServerAppendData(const char* msg,const 
char* ret);
+       virtual CASTStatement* buildServerStoreData(const char* msg);
+               
+       virtual CASTStatement* appendRegFixedToMsg(int channel,CMSChunk4* 
chunk,const char* msg);
+       virtual CASTStatement* storeRegFixedFromMsg(int channel,CMSChunk4* 
chunk,unsigned nr,const char* msg);
+       virtual CASTExpression *buildClientCallSucceeded();
+};
+
+class CMSService4_gnu
+       :public CMSService4
+{
+public:
+       virtual CMSConnection *buildConnection(int numChannels, int fid, int 
iid)
+               {return new CMSConnection4_gnu(this, numChannels, fid, iid, 
32);};
+       virtual CASTStatement *buildServerLoop(CASTIdentifier *prefix, 
CASTExpression *utableRef, CASTExpression *ktableRef, bool useItable, bool 
hasKernelMessages);
+       virtual const char* getServerTemplateBucketName(){static const char* 
s="_bucket";return s;};
+       virtual CASTStatement* buildServerDemuxer       (const char* 
ctx,CASTIdentifier *prefix, CASTExpression *utableRef,
+                                                                               
                                                                        
CASTExpression *ktableRef, bool useItable, bool hasKernelMessages);
+};
+
+class CMSFactory4_gnu
+       :public CMSFactory
+{
+private:
+       CBEType *mw_type, *tid_type;
+protected:
+       CMSFactory4_gnu(CBEType* t1,CBEType* t2)
+               :mw_type(t1),tid_type(t2){};
+public:
+       CMSFactory4_gnu()
+               :       mw_type(new CBEOpaqueType("l4_word_t", 
globals.word_size, globals.word_size, true)),
+                       tid_type(new CBEOpaqueType("l4_thread_id_t", 
globals.word_size, globals.word_size, true)){}
+       virtual CMSService *getService() { return new CMSService4_gnu(); };
+       virtual CMSService *getLocalService() { return new CMSService4_gnu(); };
+       virtual const char *getInterfaceName() { return "V4_GNU"; };
+       virtual const char *getPlatformName() { return "Generic"; };
+       virtual CBEType *getMachineWordType() { return mw_type; };
+       virtual CBEType *getThreadIDType() { return tid_type; };
+       virtual void initRootScope(CAoiRootScope *rootScope);
+};
+
+class CBEInterface_gnu
+       :public CBEInterface
+{
+public:
+       CBEInterface_gnu(CAoiInterface *aoi, CBEList *inheritedOps) : 
CBEInterface(aoi,inheritedOps){};
+               
+       virtual CASTStatement *buildReferenceDefinition();
+       virtual CASTStatement *buildServerDefinitions();
+       virtual CASTIdentifier *buildServerDemuxerName();
+       virtual CASTStatement *buildServerTemplate();
+};
+
+class CBEOperation_gnu
+       :public CBEOperation
+{
+public:
+       CBEOperation_gnu(CAoiOperation *aoi)
+               :CBEOperation(aoi){};
+       virtual CASTStatement *buildClientHeader();
+       virtual CASTStatement *buildServerHeader();
+       virtual CASTCompoundStatement* buildServerStub();
+       virtual CASTStatement *buildServerTemplate();
+};
+
+class CAoiCrossVisitor_gnu
+       :public CAoiCrossVisitor
+{
+public:
+       virtual void visit(CAoiInterface *aoi);
+       virtual void visit(CAoiOperation *aoi);
+};
+
+#endif //ARCH_V4_GNU_H
diff -Naur idl4-1.0.2/src/include/arch/v4.h idl4/src/include/arch/v4.h
--- idl4-1.0.2/src/include/arch/v4.h    2003-03-29 20:57:19.000000000 +0100
+++ idl4/src/include/arch/v4.h  2005-07-10 08:05:39.454860088 +0200
@@ -107,7 +107,8 @@
   virtual CASTStatement *buildServerReplyDeclarations(CASTIdentifier *key);
   virtual CASTStatement *buildServerReply();
 
-  CASTDeclarationStatement *buildMessageMembers(int channel);
+  virtual CASTDeclarationStatement *buildMessageMembers(int channel);
+  
   CASTIdentifier *buildChannelIdentifier(int channel);
   virtual CASTExpression *buildSourceBufferRvalue(int channel);
   virtual CASTExpression *buildTargetBufferRvalue(int channel);
@@ -196,6 +197,9 @@
   virtual CASTStatement *buildServerBackjump(int channel, CASTExpression 
*environment);
   virtual CASTStatement *buildServerReplyDeclarations(CASTIdentifier *key);
   virtual CASTStatement *buildServerReply();
+         
+  //change by ness
+  virtual CASTBase *buildServerWrapper(CASTIdentifier *key, 
CASTCompoundStatement *compound);
 };
 
 class CMSServiceI4 : public CMSService4
diff -Naur idl4-1.0.2/src/include/base.h idl4/src/include/base.h
--- idl4-1.0.2/src/include/base.h       2003-03-12 14:11:14.000000000 +0100
+++ idl4/src/include/base.h     2005-07-10 14:32:16.661911536 +0200
@@ -54,5 +54,6 @@
 char *aprintf(const char *fmt, ...);
 void mfree(char *fmt);
 const char *getBuiltinMacro(int nr);
+void make_user_types();
 
 #endif
diff -Naur idl4-1.0.2/src/include/be.h idl4/src/include/be.h
--- idl4-1.0.2/src/include/be.h 2003-04-08 15:57:19.000000000 +0200
+++ idl4/src/include/be.h       2005-07-13 17:00:35.234699368 +0200
@@ -330,7 +330,7 @@
 class CBEInterface : public CBEScope
 
 {
-private: 
+protected: 
   CAoiInterface *aoi;
   CMSService *service;
   CBEList *inheritedOps;
@@ -343,12 +343,12 @@
   virtual void marshal();
   
   CASTStatement *buildTitleComment();
-  CASTStatement *buildReferenceDefinition();
-  CASTStatement *buildServerDefinitions();
+  virtual CASTStatement *buildReferenceDefinition();
+  virtual CASTStatement *buildServerDefinitions();
   CASTIdentifier *buildIdentifier();
   CASTStatement *buildClientHeader();
   CASTStatement *buildServerHeader();
-  CASTStatement *buildServerTemplate();
+  virtual CASTStatement *buildServerTemplate();
   CASTStatement *buildTestInvocation();
   CASTIdentifier *buildServerFuncName();
   CASTStatement *buildServerLoop();
@@ -497,6 +497,37 @@
   CASTStatement *buildTestServerCheckGeneric(CASTExpression *globalPath, 
CASTExpression *localPath, const char *text);
 };
 
+class CBEUserType : public CBEType
+{
+private: 
+  CAoiUserType *aoi;
+
+public: 
+  CBEUserType(CAoiUserType *aoi) : CBEType(aoi) { this->aoi = aoi; };
+  virtual CASTDeclaration *buildDeclaration(CASTDeclarator *decl, 
CASTCompoundStatement *compound = NULL);
+  virtual CASTStatement *buildDefinition() { return NULL; };
+  virtual CBEMarshalOp *buildMarshalOps(CMSConnection *connection, int 
channels, CASTExpression *rvalue, const char *name, CBEType *originalType, 
CBEParameter *param, int flags);
+  virtual CASTExpression *buildBufferAllocation(CASTExpression *elements);
+  virtual CASTExpression *buildDefaultValue();
+
+  virtual CASTStatement *buildTestClientInit(CASTExpression *globalPath, 
CASTExpression *localPath, CBEVarSource *varSource, CBEDeclType type, 
CBEParameter *param){panic("not implemented: 
CBEUserType::buildTestClientInit");};
+  virtual CASTStatement *buildTestClientCheck(CASTExpression *globalPath, 
CASTExpression *localPath, CBEVarSource *varSource, CBEDeclType 
type){panic("not implemented: CBEUserType::buildTestClientCheck");};
+  virtual CASTStatement *buildTestClientPost(CASTExpression *globalPath, 
CASTExpression *localPath, CBEVarSource *varSource, CBEDeclType 
type){panic("not implemented: CBEUserType::buildTestClientPost");};
+  virtual CASTStatement *buildTestClientCleanup(CASTExpression *globalPath, 
CASTExpression *localPath, CBEVarSource *varSource, CBEDeclType 
type){panic("not implemented: CBEUserType::buildTestClientCleanup");};
+  virtual CASTStatement *buildTestServerInit(CASTExpression *globalPath, 
CASTExpression *localPath, CBEVarSource *varSource, CBEDeclType type, 
CBEParameter *param, bool bufferAvailable){panic("not implemented: 
CBEUserType::buildTestServerInit");};
+  virtual CASTStatement *buildTestServerCheck(CASTExpression *globalPath, 
CASTExpression *localPath, CBEVarSource *varSource, CBEDeclType 
type){panic("not implemented: CBEUserType::buildTestServerCheck");};
+  virtual CASTStatement *buildTestServerRecheck(CASTExpression *globalPath, 
CASTExpression *localPath, CBEVarSource *varSource, CBEDeclType 
type){panic("not implemented: CBEUserType::buildTestServerRecheck");};
+  virtual CASTStatement *buildTestDisplayStmt(CASTExpression *globalPath, 
CASTExpression *localPath, CBEVarSource *varSource, CBEDeclType type, 
CASTExpression *value){panic("not implemented: 
CBEUserType::buildTestDisplayStmt");};;
+
+  virtual bool needsSpecialHandling() { return false; };
+  virtual bool needsDirectCopy() { return true; };
+  virtual int getArgIndirLevel(CBEDeclType type);
+  virtual int getFlatSize() { return aoi->getSize(); };
+  virtual int getAlignment(){ return aoi->getAlign(); };
+  virtual bool isScalar() { return false; };
+  virtual bool involvesMapping() { return false; };
+};
+
 class CBEFloatType : public CBEType
 
 {
diff -Naur idl4-1.0.2/src/include/check.h idl4/src/include/check.h
--- idl4-1.0.2/src/include/check.h      2002-10-30 17:16:57.000000000 +0100
+++ idl4/src/include/check.h    2005-07-10 14:19:43.853355832 +0200
@@ -71,6 +71,7 @@
   virtual void visit(CAoiOperation *peer);
   virtual void visit(CAoiAttribute *peer);
   virtual void visit(CAoiContext *peer);
+  virtual void visit(CAoiUserType *peer);
 };
 
 #endif
diff -Naur idl4-1.0.2/src/include/cross.h idl4/src/include/cross.h
--- idl4-1.0.2/src/include/cross.h      2002-10-30 17:16:57.000000000 +0100
+++ idl4/src/include/cross.h    2005-07-10 14:17:30.416641296 +0200
@@ -36,6 +36,8 @@
   virtual void visit(CAoiUnionElement *aoi);
   virtual void visit(CAoiOperation *aoi);
   virtual void visit(CAoiAttribute *aoi);
+  
+  virtual void visit(CAoiUserType *peer);
 };
 
 #endif
diff -Naur idl4-1.0.2/src/include/dump.h idl4/src/include/dump.h
--- idl4-1.0.2/src/include/dump.h       2002-10-30 17:16:57.000000000 +0100
+++ idl4/src/include/dump.h     2005-07-10 14:24:28.618065016 +0200
@@ -41,6 +41,8 @@
   virtual void visit(CAoiProperty *peer);
   virtual void visit(CAoiOperation *peer);
   virtual void visit(CAoiAttribute *peer);
+  
+  virtual void visit(CAoiUserType *peer);
 };
 
 #endif
diff -Naur idl4-1.0.2/src/include/globals.h idl4/src/include/globals.h
--- idl4-1.0.2/src/include/globals.h    2003-04-08 15:57:36.000000000 +0200
+++ idl4/src/include/globals.h  2005-07-13 16:35:15.258120520 +0200
@@ -3,6 +3,8 @@
 
 #include <stdio.h>
 #include <time.h>
+#include <string>
+#include <map>
 
 #define PARSER_ALLOW_UNBOUNDED
 #undef  PARSER_STRICT
@@ -31,6 +33,7 @@
 #define INTERFACE_X0 0
 #define INTERFACE_V4 1
 #define INTERFACE_V2 2
+#define INTERFACE_V4_GNU 3
 
 #define MAPPING_C 0
 #define MAPPING_CXX 1
@@ -50,6 +53,10 @@
 #define FLAG_LOOPONLY          (1<<6)
 #define FLAG_MODULESONLY       (1<<7)
 
+#define MAX_PATH 1024
+
+class CAoiUserType;
+       
 typedef struct {
                  char outfile_name[FILENAME_MAX];
                  char header_name[FILENAME_MAX];
@@ -70,6 +77,12 @@
                  int warnings;
                  int word_size;
                  struct tm time;
+                 bool with_cap_class;
+                                bool make_depend;
+                                std::string cc;
+                                bool user_types;
+                                std::map<std::string,CAoiUserType*> types;
+                                bool no_erase;
                } global_t;
 
 class CAoiRootScope;
diff -Naur idl4-1.0.2/src/include/ms.h idl4/src/include/ms.h
--- idl4-1.0.2/src/include/ms.h 2003-04-08 15:57:51.000000000 +0200
+++ idl4/src/include/ms.h       2005-07-10 13:16:50.479926632 +0200
@@ -168,6 +168,10 @@
   virtual CASTStatement *buildServerTestStructural() { panic("Not implemented: 
channel::buildServerTestStructural"); return NULL; };
   virtual CASTStatement *buildServerReplyDeclarations(CASTIdentifier *key) { 
panic("Not implemented: channel::buildServerReplyDeclarations"); return NULL; };
   virtual CASTStatement *buildServerReply() { panic("Not implemented: 
channel::buildServerReply"); return NULL; };
+
+  virtual CASTExpression *buildLabelExpr(){panic("Not implemented: 
channel::buildLabelExpr"); return NULL; };
+  virtual CASTStatement* buildServerStoreData(const char* msg){panic("Not 
implemented: channel::buildServerStoreData"); return NULL; };
+  virtual CASTStatement* buildServerAppendData(const char* msg,const char* 
ret){panic("Not implemented: channel::buildServerAppendData"); return NULL; };
 };
 
 class CMSService : public CMSBase
@@ -180,6 +184,8 @@
   virtual CASTStatement *buildServerLoop(CASTIdentifier *prefix, 
CASTExpression *utableRef, CASTExpression *ktableRef, bool useItable, bool 
hasKernelMessages) { panic("Not implemented: service::buildServerLoop"); return 
NULL; };
   virtual CMSConnection *getConnection(int numChannels, int fid, int iid) { 
panic("Not implemented: service::getConnection"); return NULL; };
   virtual void finalize() { panic("Not implemented: service::finalize()"); };
+  virtual const char* getServerTemplateBucketName(){panic("Not implemented: 
service::getServerTemplateBucketName()");};
+  virtual CASTStatement* buildServerDemuxer(const char* ctx,CASTIdentifier 
*prefix, CASTExpression *utableRef, CASTExpression *ktableRef, bool useItable, 
bool hasKernelMessages){panic("Not implemented: 
service::buildServerDemuxer()");};
 };
 
 class CMSFactory
diff -Naur idl4-1.0.2/src/include/user/idl4/api/v4_gnu/interface.h 
idl4/src/include/user/idl4/api/v4_gnu/interface.h
--- idl4-1.0.2/src/include/user/idl4/api/v4_gnu/interface.h     1970-01-01 
01:00:00.000000000 +0100
+++ idl4/src/include/user/idl4/api/v4_gnu/interface.h   2005-07-13 
16:16:07.881548272 +0200
@@ -0,0 +1,136 @@
+#ifndef __idl4_api_v4_gnu_interface_h__
+#define __idl4_api_v4_gnu_interface_h__
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+
+#include <l4.h>
+#include <hurd/cap-server.h>
+
+#define IDL4_FID_BITS 6
+#define IDL4_IID_BITS 10
+
+typedef l4_thread_id_t idl4_thread_id_t;
+typedef hurd_cap_handle_t idl4_cap_handle_t;
+typedef hurd_cap_rpc_context_t idl4_cap_rpc_context_t;
+typedef hurd_cap_bucket_t idl4_cap_bucket_t;
+typedef struct hurd_cap_class idl4_cap_class;
+typedef hurd_cap_class_t idl4_cap_class_t;
+typedef hurd_cap_obj_t idl4_cap_obj_t;
+
+#define IDL4_L4_ERROR_LABEL ((uint16_t) INT16_MIN)
+
+#define idl4_cap_class_init(a,b,c,d,e,f,g) hurd_cap_class_init(a,b,c,d,e,f,g)
+#define idl4_cap_class_alloc(a,b) hurd_cap_class_alloc(a,b)
+
+#define IDL4_PERM_READ                 4
+#define IDL4_PERM_WRITE        2
+#define IDL4_PERM_EXECUTE      1
+#define IDL4_PERM_FULL          7
+
+#define IDL4_MODE_MAP          0
+#define IDL4_MODE_GRANT                2
+
+typedef struct
+{
+       l4_word_t base;
+       l4_fpage_t fpage;
+} idl4_fpage_t;
+
+typedef struct
+{
+       l4_msg_t ibuf;
+       l4_msg_t obuf;
+       unsigned long rbuf[34];
+} idl4_msgbuf_t;
+
+typedef idl4_fpage_t idl4_mapitem;
+
+typedef struct
+{
+       unsigned long len;
+       void *ptr;
+} idl4_stringitem;
+
+typedef struct
+{
+       void *ptr;
+       unsigned long len;
+} idl4_inverse_stringitem;
+
+static inline void idl4_fpage_set_base(idl4_fpage_t *fpage, unsigned long base)
+{
+       fpage->base = (fpage->base & 2) + (base & 0xFFFFFC00u) + 8;
+}
+
+static inline unsigned idl4_fpage_get_base(idl4_fpage_t fpage)
+{
+       return fpage.base & (~0x3FFu);
+}
+
+static inline void idl4_fpage_set_page(idl4_fpage_t *fpage, l4_fpage_t p)
+{
+       fpage->fpage = (fpage->fpage&7) + (p&(~3u));
+}
+
+static inline l4_word_t idl4_msg_label(l4_msg_t msg)
+{
+       return l4_msg_label(msg);
+};
+
+static inline l4_fpage_t idl4_fpage_get_page(idl4_fpage_t fpage)
+{
+       l4_fpage_t result;
+       result = fpage.fpage&(~3u);
+       return result;
+}
+
+static inline void idl4_fpage_set_permissions(idl4_fpage_t *fpage, unsigned 
permissions)
+{
+       fpage->fpage = (fpage->fpage&(~7u)) + (permissions&7);
+}
+
+static inline unsigned idl4_fpage_get_permissions(idl4_fpage_t fpage)
+{
+       return fpage.fpage & 7;
+}
+
+static inline void idl4_fpage_set_mode(idl4_fpage_t *fpage, unsigned mode)
+{
+       fpage->base = (fpage->base&(~2u)) + (mode&2);
+}
+
+static inline unsigned idl4_fpage_get_mode(idl4_fpage_t fpage)
+{
+       return fpage.base&2;
+}
+
+static inline int idl4_is_kernel_message(l4_msg_tag_t msgtag)
+{
+       return ((l4_label(msgtag)&0xFF00) == 0xFF00);
+}
+
+static inline unsigned idl4_get_kernel_message_id(l4_msg_tag_t msgtag)
+{
+  return ((unsigned)-((l4_label(msgtag))>>4));
+}
+
+static inline unsigned idl4_get_function_id(l4_word_t msg)
+{
+       return (msg& ((1<<IDL4_FID_BITS)-1));
+}
+
+static inline unsigned idl4_get_interface_id(l4_msg_tag_t *msgtag)
+{
+       return ((l4_label(*msgtag)>>IDL4_FID_BITS) & ((1<<IDL4_IID_BITS)-1));
+}
+
+static inline unsigned idl4_is_error(l4_msg_tag_t *msgtag)
+{
+       return (l4_label(*msgtag)& 8);
+}
+
+#endif /* __idl4_api_v4_gnu_interface_h__ */
diff -Naur idl4-1.0.2/src/include/user/idl4/glue/v4_gnu-generic/runtime.h 
idl4/src/include/user/idl4/glue/v4_gnu-generic/runtime.h
--- idl4-1.0.2/src/include/user/idl4/glue/v4_gnu-generic/runtime.h      
1970-01-01 01:00:00.000000000 +0100
+++ idl4/src/include/user/idl4/glue/v4_gnu-generic/runtime.h    2005-07-10 
08:05:39.468857960 +0200
@@ -0,0 +1,9 @@
+#ifndef __idl4_glue_v4_generic_runtime_h__
+#define __idl4_glue_v4_generic_runtime_h__
+
+#include IDL4_INC_ARCH(helpers.h)
+#include IDL4_INC_API(interface.h)
+
+#define IDL4_INLINE inline
+
+#endif /* !defined(__idl4_glue_v4_generic_runtime_h__) */
diff -Naur idl4-1.0.2/src/include/user/idl4/glue/v4-ia32/runtime.h 
idl4/src/include/user/idl4/glue/v4-ia32/runtime.h
--- idl4-1.0.2/src/include/user/idl4/glue/v4-ia32/runtime.h     2003-11-07 
01:01:43.000000000 +0100
+++ idl4/src/include/user/idl4/glue/v4-ia32/runtime.h   2005-07-10 
08:05:39.469857808 +0200
@@ -5,10 +5,11 @@
 #include IDL4_INC_API(interface.h)
 
 #define IDL4_INLINE inline
+#define _IDL4_ALWAYS_INLINE inline __attribute__((always_inline)) 
 
 #define IDL4_IPC_ENTRY "__L4_Ipc"
  
-extern inline void *MyUTCB(void)
+_IDL4_ALWAYS_INLINE void *MyUTCB(void)
 
 {
   void *result;
@@ -18,13 +19,13 @@
   return result;
 }
 
-extern inline void *idl4_get_buffer_addr(unsigned int index)
+_IDL4_ALWAYS_INLINE void *idl4_get_buffer_addr(unsigned int index)
 
 {
   return ((void**)MyUTCB())[-(18+(index*2))];
 }
 
-extern inline int ErrorCode(void)
+_IDL4_ALWAYS_INLINE int ErrorCode(void)
 
 {
   int result;
@@ -38,7 +39,7 @@
   return result;
 }
 
-extern inline void idl4_process_request(L4_ThreadId_t *partner, L4_MsgTag_t 
*msgtag, idl4_msgbuf_t *msgbuf, long *cnt, void *func)
+_IDL4_ALWAYS_INLINE void idl4_process_request(L4_ThreadId_t *partner, 
L4_MsgTag_t *msgtag, idl4_msgbuf_t *msgbuf, long *cnt, void *func)
 
 {
   unsigned dummy;
@@ -54,7 +55,7 @@
                );
 }
 
-extern inline void idl4_reply_and_wait(L4_ThreadId_t *partner, L4_MsgTag_t 
*msgtag, idl4_msgbuf_t *msgbuf, long *cnt)
+_IDL4_ALWAYS_INLINE void idl4_reply_and_wait(L4_ThreadId_t *partner, 
L4_MsgTag_t *msgtag, idl4_msgbuf_t *msgbuf, long *cnt)
 
 {
   unsigned dummy;
@@ -90,7 +91,7 @@
                );
 }               
 
-extern inline void idl4_set_counter(unsigned value)
+_IDL4_ALWAYS_INLINE void idl4_set_counter(unsigned value)
 
 {
   asm volatile (
@@ -102,7 +103,7 @@
   );
 }
 
-extern inline void idl4_set_counter_minimum(unsigned value)
+_IDL4_ALWAYS_INLINE void idl4_set_counter_minimum(unsigned value)
 
 {
   asm volatile (
@@ -114,7 +115,7 @@
   );
 }
 
-extern inline void idl4_msgbuf_sync(idl4_msgbuf_t *msgbuf)
+_IDL4_ALWAYS_INLINE void idl4_msgbuf_sync(idl4_msgbuf_t *msgbuf)
 
 {
   unsigned dummy;
@@ -137,21 +138,21 @@
   );
 }
 
-extern inline void idl4_msgbuf_init(idl4_msgbuf_t *msgbuf)
+_IDL4_ALWAYS_INLINE void idl4_msgbuf_init(idl4_msgbuf_t *msgbuf)
 
 {
   msgbuf->rbuf[32] = 0;
   idl4_set_counter(1);
 }
 
-extern inline void idl4_msgbuf_set_rcv_window(idl4_msgbuf_t *msgbuf, 
L4_Fpage_t wnd)
+_IDL4_ALWAYS_INLINE void idl4_msgbuf_set_rcv_window(idl4_msgbuf_t *msgbuf, 
L4_Fpage_t wnd)
 
 {
   msgbuf->rbuf[32] = (msgbuf->rbuf[32]&1) + (wnd.raw & 0xFFFFFFF0u);
   idl4_set_counter_minimum(1);
 }
 
-extern inline void idl4_msgbuf_add_buffer(idl4_msgbuf_t *msgbuf, void *buf, 
unsigned len)
+_IDL4_ALWAYS_INLINE void idl4_msgbuf_add_buffer(idl4_msgbuf_t *msgbuf, void 
*buf, unsigned len)
 
 {
   int i=32;
diff -Naur idl4-1.0.2/src/include/user/idl4/Makefile.am 
idl4/src/include/user/idl4/Makefile.am
--- idl4-1.0.2/src/include/user/idl4/Makefile.am        2003-03-29 
20:57:34.000000000 +0100
+++ idl4/src/include/user/idl4/Makefile.am      2005-07-10 08:05:39.469857808 
+0200
@@ -21,6 +21,8 @@
                 glue/x0-generic/runtime.h \
                 glue/x0-ia32/runtime.h \
                 glue/x0-arm/runtime.h \
+               glue/v4_gnu-generic/runtime.h \
                 api/v2/interface.h \
                 api/x0/interface.h \
-                api/v4/interface.h
+                api/v4/interface.h \
+               api/v4_gnu/interface.h
diff -Naur idl4-1.0.2/src/Makefile.am idl4/src/Makefile.am
--- idl4-1.0.2/src/Makefile.am  2003-08-25 06:32:26.000000000 +0200
+++ idl4/src/Makefile.am        2005-07-10 08:05:39.470857656 +0200
@@ -9,6 +9,7 @@
                $(top_builddir)/src/arch/v4/libv4.a \
                $(top_builddir)/src/arch/v4/ia32/libv4i.a \
                $(top_builddir)/src/arch/v4/ia64/libv4m.a \
+                $(top_builddir)/src/arch/v4_gnu/libv4_gnu.a \
                $(top_builddir)/src/arch/x0/libx0.a \
                $(top_builddir)/src/arch/x0/ia32/libx0i.a \
                $(top_builddir)/src/base/libui.a \
@@ -39,6 +40,7 @@
                -L$(top_builddir)/src/arch/v4 -lv4 \
                -L$(top_builddir)/src/arch/v4/ia32 -lv4i \
                -L$(top_builddir)/src/arch/v4/ia64 -lv4m \
+                -L$(top_builddir)/src/arch/v4_gnu -lv4_gnu \
                -L$(top_builddir)/src/arch -larch \
                -L$(top_builddir)/src/be/types -ltypes \
                -L$(top_builddir)/src/be/ops -lops -lstdc++
diff -Naur idl4-1.0.2/TODO idl4/TODO
--- idl4-1.0.2/TODO     1970-01-01 01:00:00.000000000 +0100
+++ idl4/TODO   2005-07-13 17:21:52.949457200 +0200
@@ -0,0 +1,13 @@
+*There seems to be a problem transfering pointers?
+*in V4_GNU backend: don't transfer return values in labels
+ since hurd seems to use this to indicate internal errors
+*in V4_GNU backend: handle hurd internal errors (se above)
+*handle casts for return values  and return values that
+ can't be given through labels
+*remove all my hacks
+*cleanup the code
+*implement missing features
+*rewrite everything in (maybye a template-based completely static
+ variant and in) good C++ (use STL, no C-style casts,
+ no reinterpret_casts at all, no typeless (void*) data, no
+ C prefix, no global variables, no/very less makros).
diff -Naur hurd-l4/ruth/test.idl hurd-l4-new/ruth/test.idl
--- hurd-l4/ruth/test.idl       1970-01-01 01:00:00.000000000 +0100
+++ hurd-l4-new/ruth/test.idl   2005-07-13 18:30:52.427781080 +0200
@@ -0,0 +1,13 @@
+/*struct some_struct
+{
+       long a;
+       double c;
+};*/
+import "hurd/cap-server.h";
+interface ruth_class
+{
+       //int test(in short a, out short b, inout float c, in some_struct 
s1,out some_struct s2,in string str1,out string str2, in fpage f1,out fpage f2);
+       //void test(in string a);
+       //int test(in long a,out long b);
+       long test(out error_t e);
+};
--- hurd-l4-old/ruth/ruth-class.c       1970-01-01 01:00:00.000000000 +0100
+++ hurd-l4-idl4/ruth/ruth-class.c      2005-08-14 14:49:28.360735424 +0200
@@ -0,0 +1,57 @@
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+
+#include <l4.h>
+#include <hurd/cap-server.h>
+#include "output.h"
+#include "test_server.h"
+
+IDL4_INLINE CORBA_long ruth_class_test_implementation(idl4_cap_rpc_context_t 
_ctx, error_t *e)
+
+{
+  CORBA_long __retval = 0;
+
+  printf("in ruth_class_test\n");
+  
+  return __retval;
+}
+
+IDL4_PUBLISH_RUTH_CLASS_TEST(ruth_class_test_implementation);
+
+void *ruth_class_vtable[RUTH_CLASS_DEFAULT_VTABLE_SIZE] = 
RUTH_CLASS_DEFAULT_VTABLE;
+
+void ruth_class_server(idl4_cap_bucket_t _bucket)
+
+{
+  hurd_cap_bucket_manage_mt(_bucket,NULL,0,0);
+}
+
+void ruth_class_discard(idl4_cap_rpc_context_t _ctx)
+
+{
+}
+
+error_t ruth_class_demuxer(idl4_cap_rpc_context_t _ctx)
+
+{
+  
(*(void(*)(idl4_cap_rpc_context_t))(ruth_class_vtable[idl4_get_function_id(idl4_msg_label(_ctx->msg))
 & RUTH_CLASS_FID_MASK]))(_ctx);
+  return 0;
+}
+
+static struct hurd_cap_class ruth_class;
+       
+error_t ruth_class_init ()
+{
+  return hurd_cap_class_init (&ruth_class, int *,
+                             NULL, NULL, NULL, NULL,
+                             ruth_class_demuxer);
+}
+
+
+error_t ruth_class_alloc (hurd_cap_obj_t *r_obj)
+{
+       return hurd_cap_class_alloc (&ruth_class, r_obj);
+}
--- hurd-l4-old/ruth/ruth.c     2005-08-13 17:23:03.156668896 +0200
+++ hurd-l4-idl4/ruth/ruth.c    2005-08-15 10:47:33.377924256 +0200
@@ -31,6 +31,8 @@
 
 #include "ruth.h"
 #include "task-user.h"
+#include "test_client.h"
+#include "test_server.h"
 
 
 /* Initialized by the machine-specific startup-code.  */
@@ -152,23 +154,92 @@
 }
 #endif
 
+l4_thread_id_t mtid,ttid;
+hurd_cap_handle_t ruth_cap;
+
+volatile int lock=1;
+
+void * my_thread(void* a)
+{
+       ttid=l4_my_global_id();
+       lock=0;
+       ruth_class_server((idl4_cap_bucket_t)a);        
+       return 0;
+};
+
+void call_my_test()
+{
+       l4_thread_id_t deva_id=__hurd_startup_data->deva_master.server;
+       hurd_cap_handle_t deva_cap=__hurd_startup_data->deva_master.cap_handle;
+       
+         l4_msg_t msg;
+         l4_msg_tag_t tag;
+       
+         l4_accept (L4_UNTYPED_WORDS_ACCEPTOR);
+       
+         l4_msg_clear (msg);
+         l4_set_msg_label (msg, 770);
+         l4_msg_append_word (msg, deva_cap);
+         l4_msg_load (msg);
+         tag = l4_call (deva_id);
+};
+
+void call_ruth_class()
+{
+       error_t e;
+       ruth_class_test(ttid,ruth_cap,&e);
+};
+
 
 int
 main (int argc, char *argv[])
 {
-  error_t err;
-  l4_thread_id_t server_thread;
-  hurd_cap_bucket_t bucket;
-  pthread_t manager;
-
-  output_debug = 1;
-
-  debug ("%s " PACKAGE_VERSION "\n", program_name);
-
-  debug ("Hello, here is Ruth, your friendly root server!\n");
-
-  server_thread = setup_threads ();
-
+       mtid=l4_my_global_id();
+       
+       error_t err;
+       l4_thread_id_t server_thread;
+       hurd_cap_bucket_t bucket;
+       pthread_t manager;
+       
+       output_debug = 1;
+       
+       debug ("%s " PACKAGE_VERSION "\n", program_name);
+       
+       debug ("Hello, here is Ruth, your friendly root server!\n");
+       call_my_test();
+       debug ("Hello, here is Ruth, your friendly root server!\n");
+       
+       server_thread = setup_threads ();
+       hurd_cap_bucket_create (&bucket);
+       ruth_class_init();
+       
+       hurd_cap_obj_t obj;
+       if(ruth_class_alloc(&obj))
+       {
+               debug("Error: ruth_alloc\n");
+               return 1;
+       }
+       else
+               debug("Success: ruth_alloc\n");
+       
+       hurd_cap_obj_unlock(obj);
+       
+       if(hurd_cap_bucket_inject (bucket, obj, 
hurd_task_id_from_thread_id(mtid), &ruth_cap))
+       {
+               debug("Error: hurd_cap_bucket_inject\n");
+               return 2;
+       }
+       else
+               debug("Success: hurd_cap_bucket_inject\n");
+       pthread_t t;
+       pthread_create(&t,0,my_thread,bucket);
+       pthread_detach(t);
+       
+       while(lock);
+       printf("in ruth::main\n");
+       call_ruth_class();
+       printf("in ruth::main\n");
+       
 #if 0
   err = ruth_class_init ();
   if (err)
@@ -187,10 +258,10 @@
   if (err)
     panic ("pthread_create_from_l4_tid_np: %i\n", err);
   pthread_detach (manager);
-
   /* FIXME: get root filesystem cap (for loading drivers).  */
 #endif
-
+       
+  
   /* FIXME: Eventually, add shutdown support on wortels(?)
      request.  */
   while (1)
--- hurd-l4-old/ruth/Makefile.am        2005-08-13 17:23:03.135672088 +0200
+++ hurd-l4-idl4/ruth/Makefile.am       2005-08-14 15:00:59.918186792 +0200
@@ -26,13 +26,16 @@
 boot_PROGRAMS = ruth
 
 ruth_CPPFLAGS = -I$(top_builddir)/include                      \
-       -I$(top_srcdir)/libc-parts $(AM_CPPFLAGS)
+       -I$(top_srcdir)/libc-parts $(AM_CPPFLAGS)               
 
 ruth_SOURCES = $(ARCH_SOURCES)                                 \
        output.h output.c                                       \
        mmap.c malloc-wrap.c                                    \
        task-user.h task-user.c                                 \
-       ruth.h ruth.c
+       ruth.h ruth.c                                           \
+       ruth-class.c test.idl
+
+BUILT_SOURCES = test_client.h test_server.h
 
 # Doug Lea's malloc is included by malloc-wrap.c.
 EXTRA_ruth_SOURCES = malloc.c
@@ -46,3 +49,6 @@
        ../libhurd-ihash/libhurd-ihash.a                        \
        ../libhurd-btree/libhurd-btree.a                        \
        ../libc-parts/libc-parts.a -lgcc
+
+#include the idl suffix rules
+include $(top_srcdir)/Makefile.idl4
--- hurd-l4-old/ruth/ChangeLog  2005-08-13 17:23:03.135672088 +0200
+++ hurd-l4-idl4/ruth/ChangeLog 2005-08-15 11:31:34.930832392 +0200
@@ -1,3 +1,13 @@
+2005-08-15 Tom Bachmann  <address@hidden>
+
+        * ruth.c: edited for example use of an idl4-generated interface
+        * test.idl4: created
+        * ruth-class.c: created by idl4 as a template edited
+        (ruth_class_test_implementation): output for testing purpose
+        * Makefile.am: included $(top_srcdir)/Makefile.idl4
+        (ruth_SOURCES): added ruth-class.c and test.idl
+        (BUILT_SOURCES) [added] set to test_client.h test_server.h
+
 2005-04-06  Neal H. Walfield  <address@hidden>
 
        * mmap.c: Include <hurd/anonymous.h>.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]