This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 13/15] linux: Consolidate INLINE_SYSCALL
* Adhemerval Zanella:
> diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h
> index c7f3e54d37..389c94cfda 100644
> --- a/sysdeps/unix/sysv/linux/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/sysdep.h
> @@ -15,8 +15,44 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
> +#ifndef _SYSDEP_LINUX_H
> +#define _SYSDEP_LINUX_H
> +
> #include <bits/wordsize.h>
> #include <kernel-features.h>
> +#include <errno.h>
> +
> +#ifndef __ASSEMBLER__
> +
> +#undef INTERNAL_SYSCALL_DECL
> +#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
I think these preprocessor directives should be indented (including most
of the rest of the file).
> +#undef INTERNAL_SYSCALL_ERROR_P
> +#define INTERNAL_SYSCALL_ERROR_P(val, err) \
> + ((unsigned long) (val) > -4096UL)
> +
> +#ifndef SYSCALL_ERROR_LABEL
> +# define SYSCALL_ERROR_LABEL(sc_err) \
> + ({ \
> + __set_errno (sc_err); \
> + -1L; \
> + })
> +#endif
> +
> +/* This version is for kernels that implement system calls that
> + behave like function calls as far as register saving. */
> +#undef INLINE_SYSCALL
> +#define INLINE_SYSCALL(name, nr, args...) \
> + ({ \
> + INTERNAL_SYSCALL_DECL (sc_err); \
> + long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args); \
> + __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
> + ? SYSCALL_ERROR_LABEL (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)) \
> + : sc_ret; \
> + })
The comment seems misleading to me. Does “register saving” really
matter here? I think it's about the -errno behavior. I think the
comment should explain how this macro is to be used (i.e., it sets errno
on failure).
Thanks,
Florian