Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA
Path: utzoo!linus!philabs!cmcl2!seismo!brl-tgr!tgr!cottrell@NBS-VMS.ARPA
From: cottrell@NBS-VMS.ARPA (COTTRELL, JAMES)
Newsgroups: net.lang.c
Subject: Multiple Entry Points in C
Message-ID: <2801@brl-tgr.ARPA>
Date: Mon, 4-Nov-85 14:01:09 EST
Article-I.D.: brl-tgr.2801
Posted: Mon Nov  4 14:01:09 1985
Date-Received: Tue, 5-Nov-85 07:17:48 EST
Sender: news@brl-tgr.ARPA
Lines: 39

/*
> I have a question that I hope some wizard can answer,
> with respect to achieving multiple function-entries in C.
> I know this is possible in Fortran; a module might look like:
> 
>       subroutine a(i,j)
>       i = j/i
>       entry b(i,j)
>       i = i + j
>       return
>       end
> 
> and the resulting assembly code would look something like this:

[Fortran ASM deleted. Boy was it UGLY!]

> But I am at a loss as to how to express this in C.  Any hints
> or pointers [:-)] will be appreciated....

You cannot do this directly, but you can achieve the same effect by 
specifying an extra arg specifying which entry you want. Then use it
in a switch statement to select the proper processing.

#define A 0
#define B 1
func(which,i,j) int which, i, j;
{	switch (which)
	case A:	i = j / i;
	case B: i += j;		/* use C notation */
	}
}

When I figured this out I no longer craved multiple entry points, altho
I don't condemn them either. Information can be passed by way of the PC
as well as any general register, altho it seems more prone to abuse.

	jim		cottrell@nbs
*/
------