# New Ticket Created by  Jürgen Bömmels 
# Please include the string:  [perl #23044]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=23044 >


nci.c generates a bunch of prototype warnings when compiled with gcc
and callframes are not build at runtime. The attached patch removes
these warnings. While at it the function definitions are changed to
match PDD07.

bye
boe



-- attachment  1 ------------------------------------------------------
url: http://rt.perl.org/rt2/attach/61352/45287/493625/build_nativecall.diff

Index: build_nativecall.pl
===================================================================
RCS file: /cvs/public/parrot/build_nativecall.pl,v
retrieving revision 1.14
diff -u -r1.14 build_nativecall.pl
--- build_nativecall.pl	14 Jun 2003 17:48:31 -0000	1.14
+++ build_nativecall.pl	18 Jul 2003 20:46:27 -0000
@@ -26,6 +26,18 @@
 		  v => "void",
                  );
 
+my (%proto_type) = (p => "void *",
+		    i => "int",
+		    l => "long",
+		    c => "char",
+		    s => "short",
+		    f => "float",
+		    d => "double",
+		    t => "char *",
+		    v => "void",
+		    I => "struct Parrot_Interp *",
+		   );
+
 my (%other_decl) = (p => "PMC *final_destination = pmc_new(interpreter, enum_class_UnManagedStruct);");
 
 my (%ret_type_decl) = (p => "void *",
@@ -108,7 +120,9 @@
 /* All our static functions that call in various ways. Yes, terribly
    hackish, but that's just fine */
 
-static void set_return_val(struct Parrot_Interp *interpreter, int stack, int ints, int strings, int pmcs, int nums) {
+static void 
+set_return_val(struct Parrot_Interp *interpreter, int stack, int ints, 
+               int strings, int pmcs, int nums) {
     INT_REG(0) = stack;
     INT_REG(1) = ints;
     INT_REG(2) = strings;
@@ -135,7 +149,9 @@
     }
 
     # Header
-    generate_func_header($ret, $args, (join ",", @arg), $ret_type{$ret}, $ret_type_decl{$ret}, $func_call_assign{$ret}, $other_decl{$ret},  $ret_assign{$ret});
+    generate_func_header($ret, $args, (join ",", @arg), $ret_type{$ret}, 
+			 $ret_type_decl{$ret}, $func_call_assign{$ret}, 
+			 $other_decl{$ret},  $ret_assign{$ret});
 
     # Body
 
@@ -151,8 +167,10 @@
 /* This function serves a single purpose. It takes the function
    signature for a C function we want to call and returns a pointer
    to a function that can call it. */
-void *build_call_func(struct Parrot_Interp *interpreter, PMC *pmc_nci,
-                      String *signature) {
+void *
+build_call_func(struct Parrot_Interp *interpreter, PMC *pmc_nci,
+                String *signature)
+{
 #if defined(CAN_BUILD_CALL_FRAMES)
     /* This would be a good place to put the code that builds the
        frames. Undoubtedly painfully platform-dependent */
@@ -206,33 +224,46 @@
 
 sub set_return_count {
     my ($stack, $int, $string, $pmc, $num) = @_;
-    print NCI "  set_return_val(interpreter, $stack, $int, $string, $pmc, $num);\nreturn;\n}\n\n"
+    print NCI <<FOOTER;
+    set_return_val(interpreter, $stack, $int, $string, $pmc, $num);
+    return;
+}
+
+
+FOOTER
 }
 
 sub generate_func_header {
-    my ($return, $params, $call_params, $ret_type, $ret_type_decl, $return_assign, $other_decl, $final_assign) = @_;
+    my ($return, $params, $call_params, $ret_type, $ret_type_decl, 
+	$return_assign, $other_decl, $final_assign) = @_;
     $other_decl ||= "";
 
     if (defined $params) {
+    my $proto = join ', ', map { $proto_type{$_} } split '', $params;
     print NCI <<HEADER;
-static void pcf_${return}_$params(struct Parrot_Interp *interpreter, PMC *self) {
-    $ret_type (*pointer)();
+static void 
+pcf_${return}_$params(struct Parrot_Interp *interpreter, PMC *self)
+{
+    typedef $ret_type (*func_t)($proto);
+    func_t pointer;
     $ret_type_decl return_data;
     $other_decl
 
-    pointer =  ($ret_type (*)())D2FPTR(self->cache.struct_val);
+    pointer =  (func_t)D2FPTR(self->cache.struct_val);
     $return_assign ($ret_type)(*pointer)($call_params);
     $final_assign
 HEADER
   }
   else {
     print NCI <<HEADER;
-static void pcf_${return}(struct Parrot_Interp *interpreter, PMC *self) {
-    $ret_type (*pointer)();
+static void 
+pcf_${return}(struct Parrot_Interp *interpreter, PMC *self)
+{
+    $ret_type (*pointer)(void);
     $ret_type_decl return_data;
     $other_decl
 
-    pointer =  ($ret_type (*)())D2FPTR(self->cache.struct_val);
+    pointer =  ($ret_type (*)(void))D2FPTR(self->cache.struct_val);
     $return_assign ($ret_type)(*pointer)();
     $final_assign
 HEADER
-- 
Juergen Boemmels                        [EMAIL PROTECTED]
Fachbereich Physik                      Tel: ++49-(0)631-205-2817
Universitaet Kaiserslautern             Fax: ++49-(0)631-205-3906
PGP Key fingerprint = 9F 56 54 3D 45 C1 32 6F  23 F6 C7 2F 85 93 DD 47

Reply via email to