public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Brian Inglis <Brian.Inglis@Shaw.ca>
To: newlib@sourceware.org
Subject: Re: [PATCH] sparc: Improve setjmp()
Date: Thu, 12 Oct 2023 09:19:52 -0600	[thread overview]
Message-ID: <814d0dfb-7afb-4813-b8ec-cce10b9a51ca@Shaw.ca> (raw)
In-Reply-To: <2426c7bf-db5e-4bb4-a6f5-12266f729dfe@embedded-brains.de>

On 2023-10-12 03:39, Sebastian Huber wrote:
> On 06.10.23 07:31, Sebastian Huber wrote:
>> Flush the windows in setjmp().  This helps if the stack is changed after
>> the setjmp() and we want to jump back to the original stack using
>> longjmp().
>> ---
>>   newlib/libc/machine/sparc/setjmp.S | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/newlib/libc/machine/sparc/setjmp.S 
>> b/newlib/libc/machine/sparc/setjmp.S
>> index 613df2ba2..d7185be4c 100644
>> --- a/newlib/libc/machine/sparc/setjmp.S
>> +++ b/newlib/libc/machine/sparc/setjmp.S
>> @@ -110,6 +110,8 @@
>>   ENTRY(setjmp)
>>   ENTRY(_setjmp)
>> +        ta      0x03            /* Flush registers, just in case another stack
>> +                                   is used after the setjmp().  */
>>           st      %sp, [%o0]      /* caller's stack pointer */
>>           st      %i7, [%o0+4]    /* caller's return pc */
>>           st      %fp, [%o0+8]    /* store caller's frame pointer */
> 
> I am not sure if there is anyone left being able to review this change.

Hopefully someone is, but as a former SunOS/Sparc guy (sysadmin/board swapper 
but not assembler there) I got interested, and found one related discussion on 
the sparclinux list:

https://lore.kernel.org/sparclinux/20111007232209.GA11892@wooyd.org/t/#u

which seems to indicate that you are DTRT; also for comparison:

	https://gcc.gnu.org/onlinedocs/gcc/Nonlocal-Gotos.html
and
	$ info gcc 'nonlocal gotos'

although:

https://stackoverflow.com/questions/72711501/special-treatment-of-setjmp-longjmp-by-compilers
	https://gcc.gnu.org/legacy-ml/gcc/2018-03/msg00032.html
	https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83368

and some threads about LLVM enhancing and dropping Sparc __builtin_set/longjmp.

But as Knuth said about some code: "I have proved it correct, but not tested 
it.", which is the proof of the pudding: issue before patch; no issues after patch?

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry

      parent reply	other threads:[~2023-10-12 15:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-06  5:31 Sebastian Huber
2023-10-12  9:39 ` Sebastian Huber
2023-10-12 14:50   ` Jeff Johnston
2023-10-12 14:55     ` Sebastian Huber
2023-10-12 15:33       ` Jeff Johnston
2023-10-12 15:19   ` Brian Inglis [this message]

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=814d0dfb-7afb-4813-b8ec-cce10b9a51ca@Shaw.ca \
    --to=brian.inglis@shaw.ca \
    --cc=newlib@sourceware.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).