🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sun
Article #7295

Re: HELP! What's wrong with my program? (Arg passing)

#7295
From: Basile STARYNKEVITCH
Date: Wed, 27 Mar 1991 21:35
32 lines
2229 bytes
Your code is implicitly built on the assumption that arguments are passed
on a stack (such as Mc680x0 machines, eg. Sun3s). Actually this is false
on many RISC machines, such as Sun4s. On SPARC machines, arguments are
passed in registers (each calling frame is actually a set of registers -
there are 32 sets of 24 (overlapping) registers), so calls (especially to
leaf routines) is really fast. The system flushs the register set to the
(memory) stack when it is full.  On Vaxen, a calling frame is supported by
hardware (on the calling stack).  By the way, your code is neither lint
nor Ansi-C (or C++) compliant.

For this reason, varargs (with setjmp, etc) facilities are peculiar to
each compiler&machine (and their interface should be and is normalized in
Ansi-C or K&R-C or C++). On Sun3, varargs are plain C (machine and
compiler dependant) macros. On Sun4, varargs use  special identifiers
__builtin_va_alist & __builtin_va_arg_incr (see /usr/include/varargs.h)
known by the compiler. On Vaxen, varargs call a special routine (assembly
coded in libc.a).

By the way, C is lacking of the varargs reciprocial: calling a routine
(given by its adress) with a variable sized list of arguments. More
specifically, i'm seeking for a "varapply" capability to call a routine
whose argument list is known at run time - e.g. given by a null terminated
array of (argument size, argument adress) tuples.

   	Basile STARYNKEVITCH
   	Commissariat a l' Energie Atomique
   	DRN/DMT/SERMA
   	C.E. Saclay
   	91191 GIF/YVETTE CEDEX
   	France

     email: basile@soleil.saclay.cea.fr
Technical Details
Message-ID: <2225@brchh104.bnr.ca>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews!bnrgate!brtph3!brchh104!brchs1!bnr.ca!rice.edu!sun-spots-request

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews!bnrgate!brtph3!brchh104!brchs1!bnr.ca!rice.edu!sun-spots-request
From: basile@soleil.cea.fr (Basile STARYNKEVITCH)
Newsgroups: comp.sys.sun
Subject: Re: HELP! What's wrong with my program? (Arg passing)
Keywords: Miscellaneous
Message-ID: <2225@brchh104.bnr.ca>
Date: 27 Mar 91 21:35:00 GMT
Sender: news@brchh104.bnr.ca
Organization: Sun-Spots
Lines: 32
Approved: Sun-Spots@rice.edu
X-Original-Date: 27 Mar 91 08:27:40+0100
X-Refs:  Original: v10n57
X-Sun-Spots-Digest: Volume 10, Issue 69, message 15
X-Note: Submissions: sun-spots@rice.edu, Admin: sun-spots-request@rice.edu