Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /MLRISC/trunk/vararg-ccall/vararg.c
ViewVC logotype

Diff of /MLRISC/trunk/vararg-ccall/vararg.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3067, Thu Jun 5 22:18:34 2008 UTC revision 3068, Fri Jun 6 00:25:53 2008 UTC
# Line 1  Line 1 
1  #include <stdio.h>  #include <stdio.h>
2    
3  struct vararg_s {  struct zipped_arg_s {
4    union arg_u {    union val_u {
5      int i;      int i;
6      double d;      double d;
7      char* s;      char* s;
8    } arg;    } val;
9    long long kind;    long long kind;
10    long long loc;    long long loc;
11    long long ty;    long long ty;
12  };  };
13    
14  struct varargs_s {  extern void varargs (void* cFun, struct zipped_arg_s* args, struct zipped_arg_s* argsEnd);
   struct vararg_s* hd;  
   void* p;  
   struct varargs_s* tl;  
 };  
   
 extern int varargs (void* cFun, struct varargs_s* args, int stkSz);  
15    
16  int vararg_wrapper (void* cFun, struct varargs_s* args, int stkSz)  void vararg_wrapper (void* cFun, struct zipped_arg_s* args, struct zipped_arg_s* argsEnd)
17  {  {
18    printf ("vararg cFun=%p args=%p, stkSz=%d\n", cFun, varargs, stkSz);    printf ("vararg cFun=%p args=%p, end=%p\n", cFun, args, argsEnd);
19    struct varargs_s* tmp_args = args;    struct zipped_arg_s* tmp_args = args;
20    while (tmp_args) {  
21      struct vararg_s* hd = tmp_args->hd;    for(tmp_args = args; tmp_args < argsEnd; tmp_args++)
22      printf ("arg=%s kind=%d loc=%d ty=%d\n", hd->arg.s, (int)hd->kind, (int)hd->loc, (int)hd->ty);      if ((int)tmp_args->ty == 32)
23      tmp_args = tmp_args->tl;        printf ("arg=%d kind=%d loc=%d ty=%d\n", tmp_args->val.i, (int)tmp_args->kind, (int)tmp_args->loc, (int)tmp_args->ty);
24    }      else
25    int x = varargs(cFun, args, stkSz);        printf ("arg=%f kind=%d loc=%d ty=%d\n", tmp_args->val.d, (int)tmp_args->kind, (int)tmp_args->loc, (int)tmp_args->ty);
26    return 0;  
27      varargs(cFun, args, argsEnd);
28  }  }
29    

Legend:
Removed from v.3067  
changed lines
  Added in v.3068

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0