Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ttrdc.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!mgnetp!ltuxa!ttrdc!levy From: levy@ttrdc.UUCP (Daniel R. Levy) Newsgroups: net.lang.c Subject: Multiple function-entries in C? Message-ID: <553@ttrdc.UUCP> Date: Sat, 2-Nov-85 05:52:22 EST Article-I.D.: ttrdc.553 Posted: Sat Nov 2 05:52:22 1985 Date-Received: Sun, 3-Nov-85 09:32:59 EST Distribution: net Organization: AT&T, Computer Systems Division, Skokie, IL Lines: 76 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 (please excuse the length--this is from the f77 compiler with the -Sg options; more text follows): .globl a_ .globl b_ .align 4 .text .align 4 a_: save &.R1 addw2 &.F1,%sp jmp .L13 .L14: divw3 *0(%ap),*4(%ap),*0(%ap) jmp .L17 .align 4 b_: save &.R1 addw2 &.F1,%sp jmp .L16 .L17: addw3 *4(%ap),*0(%ap),*0(%ap) jmp .L12 .L12: .L11: ret &0 .set .R1,0 .set .FSP1,12 .L13: movw 0(%ap),4(%fp) movw 4(%ap),8(%fp) addw3 &4,%fp,%ap .set .F1,0+.FSP1 jmp .L14 .L16: movw 0(%ap),4(%fp) movw 4(%ap),8(%fp) addw3 &4,%fp,%ap .set .F1,0+.FSP1 jmp .L17 Now in C, I am aware of the setjmp and longjmp facilities, which allow you to mark a place in a higher level module and return to it later at will from a lower level module. But this seems to be very much the reverse, where you want to jump into the middle of a lower level module. This can conceivably be a great code-saving technique, where two "different" functions that have a lot in common can share that code without putting the code in yet another function and increasing the function-calling overhead. But I am at a loss as to how to express this in C. Any hints or pointers [:-)] will be appreciated.... -- ------------------------------- Disclaimer: The views contained herein are | dan levy | yvel nad | my own and are not at all those of my em- | an engihacker @ | ployer or the administrator of any computer | at&t computer systems division | upon which I may hack. | skokie, illinois | -------------------------------- Path: ..!ihnp4!ttrdc!levy -- ------------------------------- Disclaimer: The views contained herein are | dan levy | yvel nad | my own and are not at all those of my em- | an engihacker @ | ployer or the administrator of any computer | at&t computer systems division | upon which I may hack. | skokie, illinois | -------------------------------- Path: ..!ihnp4!ttrdc!levy