The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: helbig@Informatik.BA-Stuttgart.DE (Wolfgang Helbig)
Subject: [pups] V7 setjmp/longjmp
Date: Tue, 31 Dec 2002 12:04:27 +0100 (MET)	[thread overview]
Message-ID: <200212311307.gBVD7p600218@bsd.korb> (raw)

Michael Davidson distrusted:
>Note that this means that r4, r3 and r2 get restored to the values
>that they had at the time that the next stack frame was established
>(ie when the "next" function down was called from the original context)
>and that these are not necessarily the values that they had at the
>moment when the original call to setjnp returned. Hence the various
>caveats about not relying on the value of any register variables
>after returning via longjmp.

You can trust register variables when setjmp() returns the second time. Then
the registers are restored to the values they had when the "next" function was 
called, that is the "values as of the time longjmp() was called" (quoted from
longjmp(3)'s man page. Thus any variable behaves the same, regardless of its
storage class.

By the way, this is not the case in V6. The register variables-- and only
the register variables-- are restored to the values as of the time setexit() was
called. (In V6 "setjmp()" is named "setexit()" and "longjmp()" is named "reset()").
Thus the value of a variable depends on its storage class. If it is register,
you get the value when setexit() was called, if it is not register, you get
the value when reset() was called. This might be considered a bug.

Greetings

Wolfgang




             reply	other threads:[~2002-12-31 11:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-31 11:04 Wolfgang Helbig [this message]
2002-12-31 16:02 ` Michael Davidson
  -- strict thread matches above, loose matches on Subject: below --
2003-03-25  5:14 Dennis Ritchie
2003-03-23 12:32 Wolfgang Helbig
2002-12-30 18:51 bwc
2002-12-31  2:23 ` Michael Davidson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200212311307.gBVD7p600218@bsd.korb \
    --to=helbig@informatik.ba-stuttgart.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).