[PATCH] fcntl cleanup
Peter Mazinger
ps.m at gmx.net
Tue May 8 19:28:29 UTC 2012
Hi,
__libc_X() functions are relicts of locking implemented in linuxthreads_old, they (or their name) is only relevant, if linuxthreads_old is enabled
Regards, Peter
-------- Original-Nachricht --------
> Datum: Fri, 4 May 2012 08:16:34 -0400
> Von: Mark Salter <msalter at redhat.com>
> An: uclibc at uclibc.org
> Betreff: [PATCH] fcntl cleanup
> This patch aims to clean up the current support for fcntl in the
> following ways:
>
> * replace multiple istances of #ifdef selection between fcntl
> and fcntl64 syscalls with a single INLINE_SYSCALL_FCNTL macro.
> The fcntl64 syscall only exists on 32-bit systems and is
> identical to the fcntl syscall except for the addition of
> commands to support locking with 64-bit file offsets.
>
> * only check for unsupported 64-bit locking commands in the
> case of no LFS support or no fcntl64 syscall. This eliminates
> unnecessary code for configurations which do support the
> 64-bit locking commands.
>
> * add check for unsupported 64-bit locking commands which was
> missing from the native threads case.
>
> * in the non-native threads case, __libc_fcntl and __fcntl_nocancel
> are identical, so make __libc_fcntl an alias of __fcntl_nocancel
> to avoid two functions with the same code.
>
> Signed-off-by: Mark Salter <msalter at redhat.com>
> ---
> libc/sysdeps/linux/common/__syscall_fcntl.c | 55
> ++++++++++++--------------
> 1 files changed, 25 insertions(+), 30 deletions(-)
>
> diff --git a/libc/sysdeps/linux/common/__syscall_fcntl.c
> b/libc/sysdeps/linux/common/__syscall_fcntl.c
> index 6d4c339..06146b4 100644
> --- a/libc/sysdeps/linux/common/__syscall_fcntl.c
> +++ b/libc/sysdeps/linux/common/__syscall_fcntl.c
> @@ -16,6 +16,17 @@
> #include <fcntl.h>
> #include <bits/wordsize.h>
>
> +/*
> + * The fcntl64 syscall only exists on 32-Bit systems. It is identical to
> + * the fcntl syscall except for additial commands providing 32-bit
> systems
> + * with file locking operations using 64-bit offsets.
> + */
> +#if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
> +#define INLINE_SYSCALL_FCNTL(a,b,c) INLINE_SYSCALL(fcntl64, 3, (a), (b),
> (c))
> +#else
> +#define INLINE_SYSCALL_FCNTL(a,b,c) INLINE_SYSCALL(fcntl, 3, (a), (b),
> (c))
> +#endif
> +
> extern __typeof(fcntl) __libc_fcntl;
> libc_hidden_proto(__libc_fcntl)
>
> @@ -28,20 +39,17 @@ int __fcntl_nocancel (int fd, int cmd, ...)
> arg = va_arg (ap, void *);
> va_end (ap);
>
> -# if __WORDSIZE == 32
> +# if __WORDSIZE == 32 && !(defined __UCLIBC_HAS_LFS__ && defined
> __NR_fcntl64)
> if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64) {
> -# if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
> - return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
> -# else
> __set_errno(ENOSYS);
> return -1;
> -# endif
> }
> # endif
> - return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
> + return INLINE_SYSCALL_FCNTL (fd, cmd, arg);
> }
> libc_hidden_def(__fcntl_nocancel)
>
> +#ifdef __UCLIBC_HAS_THREADS_NATIVE__
> int __libc_fcntl (int fd, int cmd, ...)
> {
> va_list ap;
> @@ -51,39 +59,26 @@ int __libc_fcntl (int fd, int cmd, ...)
> arg = va_arg (ap, void *);
> va_end (ap);
>
> -#ifdef __UCLIBC_HAS_THREADS_NATIVE__
> - if (SINGLE_THREAD_P || (cmd != F_SETLKW && cmd != F_SETLKW64))
> -# if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
> - return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
> -# else
> - return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
> -# endif
> +#if __WORDSIZE == 32 && !(defined __UCLIBC_HAS_LFS__ && defined
> __NR_fcntl64)
> + if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64) {
> + __set_errno(ENOSYS);
> + return -1;
> + }
> +#endif
>
> + if (SINGLE_THREAD_P || (cmd != F_SETLKW && cmd != F_SETLKW64))
> + return INLINE_SYSCALL_FCNTL (fd, cmd, arg);
> int oldtype = LIBC_CANCEL_ASYNC ();
>
> -# if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
> - int result = INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
> -# else
> - int result = INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
> -# endif
> + int result = INLINE_SYSCALL_FCNTL (fd, cmd, arg);
>
> LIBC_CANCEL_RESET (oldtype);
>
> return result;
> +}
> #else
> -# if __WORDSIZE == 32
> - if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64) {
> -# if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
> - return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
> -# else
> - __set_errno(ENOSYS);
> - return -1;
> -# endif
> - }
> -# endif
> - return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
> +strong_alias(__fcntl_nocancel,__libc_fcntl)
> #endif
> -}
> libc_hidden_def(__libc_fcntl)
>
> libc_hidden_proto(fcntl)
> --
> 1.7.9.1
>
> _______________________________________________
> uClibc mailing list
> uClibc at uclibc.org
> http://lists.busybox.net/mailman/listinfo/uclibc
--
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
More information about the uClibc
mailing list