The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] C entry keyword
@ 2018-10-30  8:02 Steve Simon
  2018-10-30  8:51 ` Lars Brinkhoff
  2018-10-30  9:12 ` Angelo Papenhoff
  0 siblings, 2 replies; 6+ messages in thread
From: Steve Simon @ 2018-10-30  8:02 UTC (permalink / raw)
  To: tuhs


“entry” was a reserved word in K&R Ed.1,
my personal favourite C trivia. I have never seen it used outside fortran on mainframes though.

-Steve



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [TUHS] C entry keyword
  2018-10-30  8:02 [TUHS] C entry keyword Steve Simon
@ 2018-10-30  8:51 ` Lars Brinkhoff
  2018-10-30  9:12 ` Angelo Papenhoff
  1 sibling, 0 replies; 6+ messages in thread
From: Lars Brinkhoff @ 2018-10-30  8:51 UTC (permalink / raw)
  To: Steve Simon; +Cc: tuhs

Steve Simon wrote:
> “entry” was a reserved word in K&R Ed.1,
> my personal favourite C trivia. I have never seen it used outside
> fortran on mainframes though.

It's there in Snyder's C compiler, but not used.  From the grammar:

    statement:
    ...
        | ENTRY identifier ':' statement       {val=aentry(#2,#4);}

But the supporting code in the compiler:

    aentry (idn, stmt)
        {return (stmt);}    /* not implemented */

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [TUHS] C entry keyword
  2018-10-30  8:02 [TUHS] C entry keyword Steve Simon
  2018-10-30  8:51 ` Lars Brinkhoff
@ 2018-10-30  9:12 ` Angelo Papenhoff
  2018-10-30 13:32   ` Paul Winalski
  2018-10-30 13:56   ` Warner Losh
  1 sibling, 2 replies; 6+ messages in thread
From: Angelo Papenhoff @ 2018-10-30  9:12 UTC (permalink / raw)
  To: tuhs

On 30/10/18, Steve Simon wrote:
> 
> “entry” was a reserved word in K&R Ed.1,
> my personal favourite C trivia. I have never seen it used outside fortran on mainframes though.

I think PL/1 on Multics uses it, which is probably how it "got into" C.

aap

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [TUHS] C entry keyword
  2018-10-30  9:12 ` Angelo Papenhoff
@ 2018-10-30 13:32   ` Paul Winalski
  2018-10-30 13:56   ` Warner Losh
  1 sibling, 0 replies; 6+ messages in thread
From: Paul Winalski @ 2018-10-30 13:32 UTC (permalink / raw)
  To: Angelo Papenhoff; +Cc: tuhs

On 10/30/18, Angelo Papenhoff <aap@papnet.eu> wrote:
> On 30/10/18, Steve Simon wrote:
>>
>> “entry” was a reserved word in K&R Ed.1,
>> my personal favourite C trivia. I have never seen it used outside fortran
>> on mainframes though.
>
> I think PL/1 on Multics uses it, which is probably how it "got into" C.
>
PL/1 inherited the concept of routines with multiple entry points from Fortran.

Did the early K&R C compilers actually implement multiple entry point
routines, or was the keyword simply reserved for future use?

-Paul W.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [TUHS] C entry keyword
  2018-10-30  9:12 ` Angelo Papenhoff
  2018-10-30 13:32   ` Paul Winalski
@ 2018-10-30 13:56   ` Warner Losh
  2018-10-30 17:53     ` Paul Winalski
  1 sibling, 1 reply; 6+ messages in thread
From: Warner Losh @ 2018-10-30 13:56 UTC (permalink / raw)
  To: Angelo Papenhoff; +Cc: TUHS main list

[-- Attachment #1: Type: text/plain, Size: 938 bytes --]

I'd imagine you'd use it like so (in more modern C):

void *memcpy(void *src, void *dst, size_t len)
{
char *rv = dst;
top:
while (len--) *dst++ =*src; /* not always a trivial body */
return(rv);
entry bcopy:
rv = dst; /* Swap args and jump to memcpy */
dst = src;
src = rv;
goto top:
}

Variations on this theme are often done in assembler for these routines,
though the example is an attempt to cope with the diversity of interfaces
that grew up after v6 unix was released in the world, so it's not likely
this particular example inspired it...

Warner

On Tue, Oct 30, 2018 at 4:00 AM Angelo Papenhoff <aap@papnet.eu> wrote:

> On 30/10/18, Steve Simon wrote:
> >
> > “entry” was a reserved word in K&R Ed.1,
> > my personal favourite C trivia. I have never seen it used outside
> fortran on mainframes though.
>
> I think PL/1 on Multics uses it, which is probably how it "got into" C.
>
> aap
>

[-- Attachment #2: Type: text/html, Size: 1379 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [TUHS] C entry keyword
  2018-10-30 13:56   ` Warner Losh
@ 2018-10-30 17:53     ` Paul Winalski
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Winalski @ 2018-10-30 17:53 UTC (permalink / raw)
  To: Warner Losh; +Cc: TUHS main list

In Fortran secondary entry points served two main purposes.  It
allowed for sharing of code for similar routines (as in Angelo
Papenhoff's C example), which was important when your program had to
fit in only a few K of memory.  Secondly, it provided partial relief
for Fortran's very restrictive variable-scoping rules.

It's a pain in the butt for compiler optimizers, although certain
modern interprocedural optimizations emit code that is the moral
equivalent of a routine with multiple entry points.

-Paul W.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-10-30 19:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-30  8:02 [TUHS] C entry keyword Steve Simon
2018-10-30  8:51 ` Lars Brinkhoff
2018-10-30  9:12 ` Angelo Papenhoff
2018-10-30 13:32   ` Paul Winalski
2018-10-30 13:56   ` Warner Losh
2018-10-30 17:53     ` Paul Winalski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).