Jrferguson wrote:
I have a C program that I am trying to port to a Motorola 68k based system. It
makes use of setjmp and longjmp which are not supported by my C compiler. I
understand the general principle behind setjmp/longjmp, but I am somewhat lost
in the detail of how to actually implement this in assembler. (My compiler
supports in-line assembler which I hope will prove usefull). I will be very
gratefull for any help or pointers with this problem. I am conversant with the
x86 architecture, so an example from one of these platforms would probably be
illuminating as well.
Are you sure setjmp() and longjmp() are not provided?
They are required to be present (and to work as advertised)
in any Standard-conforming hosted implementation.
A conforming "freestandi ng" implementation can omit most
of the Standard library facilities, including setjmp() and
longjmp(). If your implementation does in fact omit them,
the job of coming up with substitutes is likely to be more
than a little difficult. Not only must setjmp() and longjmp()
have intimate knowledge of the way the compiler generates code,
but the compiler must often be made aware that setjmp() and
longjmp() are "special" and violate the ordinary flow of
control. If setjmp() and longjmp() are absent, I'd suggest
you look long and hard for a suitable implementation that
provides them before undertaking to add them yourself. The
widely-available gcc compiler supports various M68K-based
systems, and it might well be easier to switch than fight.
Unfortunately, we here in comp.lang.c can't help you much
if you are eventually forced to roll your own. The tricks
you'll need to use will be highly specific to your machine
and to your compiler, and will have little or nothing to do
with the C language.
One thing we *might* be able to help with is rearranging
the code so it doesn't require setjmp() and longjmp() in the
first place. That's not always practical, but in cases where
it happens to be so the techniques you'll use will be part of
the C language and hence topical here.
Good luck: I have a feeling you'll need it ...
--
Er*********@sun .com