unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
To: Florian Weimer <fweimer@redhat.com>,
	GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH 1/3] linux: Use INTERNAL_SYSCALL on fstatat{64}
Date: Thu, 15 Oct 2020 14:09:48 -0300	[thread overview]
Message-ID: <9223297c-4a33-2e34-8bdb-51a797294399@linaro.org> (raw)
In-Reply-To: <87wnzrfq7k.fsf@oldenburg2.str.redhat.com>



On 15/10/2020 12:45, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
> 
>> +  return INTERNAL_SYSCALL_ERROR_P (r)
>> +	 ? INLINE_SYSCALL_ERROR_RETURN_VALUE (-r)
>> +	 : 0;
> 
> I'm not really happy how the expression -r breaks the INTERNAL_*
> abstraction.  Do you really have to change the calling convention for
> __cp_kstat_stat?  I expect that if you don't do that (and make calls to
> __cp_kstat_stat tail calls), you can preserve the abstraction.

The INTERNAL_* abstractions is something I would like to get rid of
since currently INTERNAL_SYSCALL follows the same convention for all
architectures (meaning that there is no extra auxiliary variable that
hold whether the syscall has failed, as previously for powerpc and
sparc) and Linux assumes that errno values are all in the range of
[-4096UL, -1UL].

We can now simplify the INTERNAL_SYSCALL tests to check for specific
errno value without the need to resorting the extra macros.  I really
see that we can move to something simpler and more readable internal
APIs as:

  #define INTERNAL_SYSCALL_CALL (syscall, ...) ...

  static inline _Bool internal_syscall_failed (unsigned long int val)
  {
    return val > -4096UL;
  }

  static inline long int __syscall_ret (unsigned long int val)
  {
    if (internal_syscall_failed (val))
      {
        errno = -val;
        return -1;
      }
    return 0;
  }

  #define INLINE_SYSCALL_CALL (...) \
   __syscall_ret (NTERNAL_SYSCALL_CALL (__VA_ARGS__))


And so we can write more specific syscall wrappers as:

  int r = INTERNAL_SYSCALL_CALL (syscall, ...);
  if (r == 0 || -r == ENOSYS)
    return __syscall_ret (r);
  r = INTERNAL_SYSCALL_CALL (syscall_fallback, ...);
  return __syscall_ret (r);

Or similar if there is no need to handle errno:

  return -INTERNAL_SYSCALL_CALL (syscall, ...);

  reply	other threads:[~2020-10-15 17:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-14 20:37 [PATCH 1/3] linux: Use INTERNAL_SYSCALL on fstatat{64} Adhemerval Zanella via Libc-alpha
2020-10-14 20:37 ` [PATCH 2/3] rtld: Fix wrong errno check on open_path Adhemerval Zanella via Libc-alpha
2020-10-14 20:37 ` [PATCH 3/3] locale: Fix locale construct_output_path error handling Adhemerval Zanella via Libc-alpha
2020-10-15 12:32 ` [PATCH 1/3] linux: Use INTERNAL_SYSCALL on fstatat{64} Adhemerval Zanella via Libc-alpha
2020-10-15 15:45 ` Florian Weimer via Libc-alpha
2020-10-15 17:09   ` Adhemerval Zanella via Libc-alpha [this message]
2020-10-15 18:01     ` Adhemerval Zanella via Libc-alpha
2020-10-19 12:56     ` Florian Weimer via Libc-alpha
2020-10-19 13:39       ` Adhemerval Zanella via Libc-alpha

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

  List information: https://www.gnu.org/software/libc/involved.html

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

  git send-email \
    --in-reply-to=9223297c-4a33-2e34-8bdb-51a797294399@linaro.org \
    --to=libc-alpha@sourceware.org \
    --cc=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    /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).