[PATCH v2 39/46] fcntl: Use fcntl64 is arch does not have the fcntl syscall

Markos Chandras markos.chandras at gmail.com
Mon Nov 26 14:24:21 UTC 2012


From: Markos Chandras <markos.chandras at imgtec.com>

Signed-off-by: Markos Chandras <markos.chandras at imgtec.com>
---
 libc/sysdeps/linux/common/__syscall_fcntl.c   | 57 +++++++++++++++++++++++++--
 libc/sysdeps/linux/common/__syscall_fcntl64.c |  5 +++
 2 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/libc/sysdeps/linux/common/__syscall_fcntl.c b/libc/sysdeps/linux/common/__syscall_fcntl.c
index 6d4c339..7cc598c 100644
--- a/libc/sysdeps/linux/common/__syscall_fcntl.c
+++ b/libc/sysdeps/linux/common/__syscall_fcntl.c
@@ -19,6 +19,53 @@
 extern __typeof(fcntl) __libc_fcntl;
 libc_hidden_proto(__libc_fcntl)
 
+
+#if defined(__NR_fcntl64) && !defined (__NR_fcntl)
+
+int __libc_fcntl (int fd, int cmd, ...)
+{
+	va_list ap;
+	void *arg;
+
+	va_start (ap, cmd);
+	arg = va_arg (ap, void*);
+	va_end (ap);
+
+	return INLINE_SYSCALL(fcntl64, 3, fd, cmd, arg);
+}
+libc_hidden_def(__libc_fcntl)
+
+int __fcntl_nocancel (int fd, int cmd, ...)
+{
+	va_list ap;
+	void *arg;
+
+	va_start (ap, cmd);
+	arg = va_arg (ap, void*);
+	va_end (ap);
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+	if (SINGLE_THREAD_P)
+		return INLINE_SYSCALL(fcntl64, 3, fd, cmd, arg);
+
+	int oldtype = LIBC_CANCEL_ASYNC ();
+
+	int result = INLINE_SYSCALL(fcntl64, 3, fd, cmd, arg);
+
+	LIBC_CANCEL_RESET (oldtype);
+
+	return result;
+
+#else
+
+	return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
+
+#endif
+}
+libc_hidden_def(__fcntl_nocancel)
+
+#else
+
 int __fcntl_nocancel (int fd, int cmd, ...)
 {
 	va_list ap;
@@ -70,7 +117,9 @@ int __libc_fcntl (int fd, int cmd, ...)
 	LIBC_CANCEL_RESET (oldtype);
 
 	return result;
-#else
+
+#else /* __UCLIBC_HAS_THREADS_NATIVE__ */
+
 # if __WORDSIZE == 32
 	if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64) {
 #  if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
@@ -80,12 +129,14 @@ int __libc_fcntl (int fd, int cmd, ...)
 		return -1;
 #  endif
 	}
-# endif
+# endif /* __WORDSIZE */
 	return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
-#endif
+#endif /* __UCLIBC_HAS_THREADS_NATIVE__ */
 }
 libc_hidden_def(__libc_fcntl)
 
+#endif
+
 libc_hidden_proto(fcntl)
 weak_alias(__libc_fcntl,fcntl)
 libc_hidden_weak(fcntl)
diff --git a/libc/sysdeps/linux/common/__syscall_fcntl64.c b/libc/sysdeps/linux/common/__syscall_fcntl64.c
index e8782e9..96f1bae 100644
--- a/libc/sysdeps/linux/common/__syscall_fcntl64.c
+++ b/libc/sysdeps/linux/common/__syscall_fcntl64.c
@@ -27,4 +27,9 @@ int fcntl64(int fd, int cmd, ...)
 	return (__syscall_fcntl64(fd, cmd, arg));
 }
 libc_hidden_def(fcntl64)
+
+#if !defined(__NR_fcntl)
+strong_alias(fcntl64, fcntl)
+#endif /* !__NR_fcntl__ */
+
 #endif
-- 
1.8.0




More information about the uClibc mailing list