alloca... (and setjmp/longjmp coroutines)

Henry Spencer henry at utzoo.uucp
Tue Jun 14 07:05:21 AEST 1988


> I'm no C wizard... but it seems to me that longjmp is the most suitable 
> technique going, by default...  What else is there?  You could use [abuse?]
> sigvec and kill...

In the same way that you're abusing longjmp, you mean?  The fact is, there
is -->**NO**<-- portable way to accomplish what you're trying to do.  None.
Coroutines simply cannot be done without some degree of cooperation from
the language or the compiler.  C doesn't cooperate on the language level,
so you're stuck.  Yes, you can write code that will more-or-less work, so
long as the compiler doesn't spring any surprises on you.  Portable it isn't.
That being the case, the proper approach is to admit defeat, study your
compiler carefully, and write twenty lines of assembler to do things right.
-- 
Man is the best computer we can      |  Henry Spencer @ U of Toronto Zoology
put aboard a spacecraft. --Von Braun | {ihnp4,decvax,uunet!mnetor}!utzoo!henry



More information about the Comp.unix.wizards mailing list