public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Chris Metcalf <cmetcalf@ezchip.com>
To: Carlos O'Donell <carlos@redhat.com>,
	Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH] tile: use better variable naming in INLINE_SYSCALL
Date: Wed, 27 May 2015 09:07:00 -0000	[thread overview]
Message-ID: <556517D6.4040607@ezchip.com> (raw)
In-Reply-To: <5564DB29.7020109@redhat.com>

On 5/26/2015 4:44 PM, Carlos O'Donell wrote:
> On 05/26/2015 02:19 PM, Chris Metcalf wrote:
>> At issue for INLINE_SYSCALL was that it used "err" and "val"
>> as variable names in a #define, so that if it was used in a context
>> where the "caller" was also using "err" or "val", and those
>> variables were passed in to INLINE_SYSCALL, we would end up
>> referencing the internal shadowed variables instead.
>>
>> For example, "char val" in check_may_shrink_heap() in
>> sysdeps/unix/sysv/linux/malloc-sysdep.h was being shadowed by
>> the syscall return "val" in INLINE_SYSCALL, causing the "char val"
>> not to get updated at all, and may_shrink_heap ended up always false.
>>
>> A similar fix was made to INTERNAL_VSYSCALL_CALL.
> Established practice appears to be to use `sc_err`.
>
> A quick look shows that other sysdep.h also suffer this problem,
> but have been lucky that nobody uses `sc_ret` or similarly named
> variables in the outer scope.
>
> Doesn't this also impact MIPS, Microblaze, SPARC and NIOS2?
>
> sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h:  ({ INTERNAL_SYSCALL_DECL(err);					\
> sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h:#undef INTERNAL_SYSCALL_DECL
> sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h:  ({ INTERNAL_SYSCALL_DECL(err);					\
> sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h:#undef INTERNAL_SYSCALL_DECL
> sysdeps/unix/sysv/linux/mips/mips32/sysdep.h:  ({ INTERNAL_SYSCALL_DECL(err);					\
> sysdeps/unix/sysv/linux/mips/mips32/sysdep.h:#undef INTERNAL_SYSCALL_DECL
> sysdeps/unix/sysv/linux/microblaze/sysdep.h:({  INTERNAL_SYSCALL_DECL(err);                                      \
> sysdeps/unix/sysv/linux/microblaze/sysdep.h:# undef INTERNAL_SYSCALL_DECL
> sysdeps/unix/sysv/linux/sparc/sysdep.h:({	INTERNAL_SYSCALL_DECL(err);  					\
> sysdeps/unix/sysv/linux/sparc/sysdep.h:#undef INTERNAL_SYSCALL_DECL
> sysdeps/unix/sysv/linux/nios2/sysdep.h:  ({ INTERNAL_SYSCALL_DECL(err);					\
> sysdeps/unix/sysv/linux/nios2/sysdep.h:#undef INTERNAL_SYSCALL_DECL
>
> I dislike the use of `sc_err`, and I'd rather blanket fix
> *every* port to use `_sc_err` instead, but that's just me.
>
> Fixing tile is more than good enough.

Thanks for looking at this, and you're right that probably fixing everything is
a better approach, but one that I was too lazy to undertake this minute.  :-)
I updated my change to use _sc_err instead of _sys_err (likewise for _sc_val) and
committed.

This is the convention already used in sysdeps/unix/alpha/sysdep.h, by the way.

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com

  reply	other threads:[~2015-05-27  1:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-20 15:07 [PATCH] Use inline syscalls for non-cancellable versions Adhemerval Zanella
2015-05-22 10:05 ` Adhemerval Zanella
2015-05-24  3:43   ` Carlos O'Donell
2015-05-24 15:27     ` Chris Metcalf
2015-05-26 18:57     ` [PATCH] tile: use better variable naming in INLINE_SYSCALL Chris Metcalf
2015-05-27  0:30       ` Carlos O'Donell
2015-05-27  9:07         ` Chris Metcalf [this message]
2015-05-28 17:54         ` Joseph Myers
2015-05-26 18:24   ` [PATCH] Use inline syscalls for non-cancellable versions Chris Metcalf
2015-05-26 22:31     ` Adhemerval Zanella
2015-05-28 17:36     ` Joseph Myers
2015-06-04 14:17 ` Adhemerval Zanella

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=556517D6.4040607@ezchip.com \
    --to=cmetcalf@ezchip.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=carlos@redhat.com \
    --cc=libc-alpha@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).