This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC PATCH] __fxstat: replace if() with #if when checking version
- From: Yury Norov <ynorov at caviumnetworks dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: <libc-alpha at sourceware dot org>
- Date: Tue, 6 Sep 2016 18:59:18 +0300
- Subject: Re: [RFC PATCH] __fxstat: replace if() with #if when checking version
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Yuri dot Norov at caviumnetworks dot com;
- References: <1473166521-24827-1-git-send-email-ynorov@caviumnetworks.com> <mvmmvjlfa51.fsf@hawking.suse.de>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
On Tue, Sep 06, 2016 at 03:08:58PM +0200, Andreas Schwab wrote:
> On Sep 06 2016, Yury Norov <ynorov@caviumnetworks.com> wrote:
>
> > __fxstat() is always passed with _STAT_VER as vers parameter and it's
> > in internal namespace.
>
> It is part of the glibc ABI.
>
> > If patch is found reasonable, I can check and fix other platforms and
> > stat syscalls. Could someone explain me, what for we need 'vers',
> > if we pass it with the only value everywhere. Maybe it's time to remove it
> > completely?
>
> _STAT_VER has changed over time.
>
> Andreas.
OK, now I see. It seems like STAT_IS_KERNEL_STAT hint is used not
optimal way. In my understanding, it forces user pass vers == _STAT_VER_KERNEL.
But if so, glibc may avoid generating the text of __xstat_conv(), and
so no struct kernel_stat is needed. Take a look at the patch below.
Does it make sense to you?
Yury.
diff --git a/sysdeps/unix/sysv/linux/fxstat.c b/sysdeps/unix/sysv/linux/fxstat.c
index e33023b..e9777df 100644
--- a/sysdeps/unix/sysv/linux/fxstat.c
+++ b/sysdeps/unix/sysv/linux/fxstat.c
@@ -35,20 +35,25 @@
int
__fxstat (int vers, int fd, struct stat *buf)
{
+#ifdef STAT_IS_KERNEL_STAT
if (vers == _STAT_VER_KERNEL)
return INLINE_SYSCALL (fstat, 2, fd, buf);
-
-#ifdef STAT_IS_KERNEL_STAT
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ else
+ return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
#else
- struct kernel_stat kbuf;
- int result;
+ if (vers == _STAT_VER_KERNEL)
+ return INLINE_SYSCALL (fstat, 2, fd, buf);
+ else
+ {
+ struct kernel_stat kbuf;
+ int result;
- result = INLINE_SYSCALL (fstat, 2, fd, &kbuf);
- if (result == 0)
- result = __xstat_conv (vers, &kbuf, buf);
+ result = INLINE_SYSCALL (fstat, 2, fd, &kbuf);
+ if (result == 0)
+ result = __xstat_conv (vers, &kbuf, buf);
- return result;
+ return result;
+ }
#endif
}