[PATCH v3 43/48] fcntl: Use fcntl64 is arch does not have the fcntl syscall

Markos Chandras markos.chandras at gmail.com
Wed Jan 23 11:42:07 UTC 2013


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   | 18 ++++++++++++++++--
 libc/sysdeps/linux/common/__syscall_fcntl64.c |  1 +
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/libc/sysdeps/linux/common/__syscall_fcntl.c b/libc/sysdeps/linux/common/__syscall_fcntl.c
index d56f4a2..da4b067 100644
--- a/libc/sysdeps/linux/common/__syscall_fcntl.c
+++ b/libc/sysdeps/linux/common/__syscall_fcntl.c
@@ -18,15 +18,21 @@ int __NC(fcntl)(int fd, int cmd, long arg)
 {
 #if __WORDSIZE == 32
 	if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64) {
-# if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
-		return __NC(fcntl64)(fd, cmd, arg);
+# if (defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64) || !defined(__NR_fcntl)
+		return INLINE_SYSCALL(fcntl64, 3, fd, cmd, arg);
 # else
 		__set_errno(ENOSYS);
 		return -1;
 # endif
 	}
 #endif
+
+#if defined(__NR_fcntl)
 	return INLINE_SYSCALL(fcntl, 3, fd, cmd, arg);
+#else
+	__set_errno(ENOSYS);
+	return -1;
+#endif
 }
 
 int fcntl(int fd, int cmd, ...)
@@ -39,10 +45,18 @@ int fcntl(int fd, int cmd, ...)
 	va_end (ap);
 
 	if (SINGLE_THREAD_P || (cmd != F_SETLKW && cmd != F_SETLKW64))
+#if defined(__NR_fcntl)
 		return __NC(fcntl)(fd, cmd, arg);
+#else
+		return INLINE_SYSCALL(fcntl64, 3, fd, cmd, arg);
+#endif
 #ifdef __NEW_THREADS
 	int oldtype = LIBC_CANCEL_ASYNC ();
+#if defined(__NR_fcntl)
 	int result = __NC(fcntl)(fd, cmd, arg);
+#else
+	int result = INLINE_SYSCALL(fcntl64, 3, fd, cmd, arg);
+#endif
 	LIBC_CANCEL_RESET (oldtype);
 	return result;
 #endif
diff --git a/libc/sysdeps/linux/common/__syscall_fcntl64.c b/libc/sysdeps/linux/common/__syscall_fcntl64.c
index eaef22b..f17cbb4 100644
--- a/libc/sysdeps/linux/common/__syscall_fcntl64.c
+++ b/libc/sysdeps/linux/common/__syscall_fcntl64.c
@@ -39,4 +39,5 @@ int fcntl64(int fd, int cmd, ...)
 }
 lt_strong_alias(fcntl64)
 lt_libc_hidden(fcntl64)
+
 #endif
-- 
1.8.1.1




More information about the uClibc mailing list