Define printflock64 only if it is referenced by other code
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 12 Nov 2013 21:49:03 +0000 (21:49 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 12 Nov 2013 22:10:44 +0000 (22:10 +0000)
* configure.ac (AC_CHECK_TYPES): Add struct flock64.
* desc.c (HAVE_F_SETLK64, HAVE_F_SETLKW64, HAVE_F_GETLK64): New macros.
[!HAVE_STRUCT_FLOCK64] (struct flock64): Define.
(printflock64): Define only if referenced by other code.
(sys_fcntl): Handle F_FREESP64, F_SETLK64, F_SETLKW64, and F_GETLK64 iff
these constants are defined and differ from their non-64bit versions.

configure.ac
desc.c

index 3ea195601ca1ba555d41b72ab8605e0782dd7114..fa4a4bd6101575a9fd08f2a3507563332c46b658 100644 (file)
@@ -257,6 +257,8 @@ AC_CHECK_MEMBERS([struct utsname.domainname],,, [#include <sys/utsname.h>])
 AC_CHECK_MEMBERS([struct sigevent._sigev_un._pad,
                  struct sigevent.__pad],,, [#include <signal.h>])
 
+AC_CHECK_TYPES([struct flock64],,, [#include <fcntl.h>])
+
 AC_CHECK_DECLS([sys_errlist])
 AC_CHECK_DECLS([sys_siglist, _sys_siglist],,, [#include <signal.h>])
 AC_CHECK_DECLS(m4_normalize([
diff --git a/desc.c b/desc.c
index 58c9f1376427048366c812c6bda80780d59e8635..3ccf422af01cdb4c46084a1a231ca19707143820 100644 (file)
--- a/desc.c
+++ b/desc.c
@@ -220,7 +220,35 @@ static const struct xlat perf_event_open_flags[] = {
        { 0,                            NULL                    },
 };
 
-#if _LFS64_LARGEFILE
+#if defined(F_SETLK64) && F_SETLK64 + 0 != F_SETLK
+# define HAVE_F_SETLK64 1
+#else
+# define HAVE_F_SETLK64 0
+#endif
+
+#if defined(F_SETLKW64) && F_SETLKW64 + 0 != F_SETLKW
+# define HAVE_F_SETLKW64 1
+#else
+# define HAVE_F_SETLKW64 0
+#endif
+
+#if defined(F_GETLK64) && F_GETLK64+0 != F_GETLK
+# define HAVE_F_GETLK64 1
+#else
+# define HAVE_F_GETLK64 0
+#endif
+
+#if defined(X32) || defined(F_FREESP64) || \
+    HAVE_F_SETLK64 || HAVE_F_SETLKW64 || HAVE_F_GETLK64
+
+#ifndef HAVE_STRUCT_FLOCK64
+struct flock64 {
+       short int l_type, l_whence;
+       int64_t l_start, l_len;
+       int l_pid;
+};
+#endif
+
 /* fcntl/lockf */
 static void
 printflock64(struct tcb *tcp, long addr, int getlk)
@@ -333,22 +361,22 @@ sys_fcntl(struct tcb *tcp)
                        tprints(", ");
                        printflock(tcp, tcp->u_arg[2], 0);
                        break;
-#if _LFS64_LARGEFILE
+#if defined(F_FREESP64) || HAVE_F_SETLK64 || HAVE_F_SETLKW64
 #ifdef F_FREESP64
                case F_FREESP64:
 #endif
                /* Linux glibc defines SETLK64 as SETLK,
                   even though the kernel has different values - as does Solaris. */
-#if defined(F_SETLK64) && F_SETLK64 + 0 != F_SETLK
+#if HAVE_F_SETLK64
                case F_SETLK64:
 #endif
-#if defined(F_SETLKW64) && F_SETLKW64 + 0 != F_SETLKW
+#if HAVE_F_SETLKW64
                case F_SETLKW64:
 #endif
                        tprints(", ");
                        printflock64(tcp, tcp->u_arg[2], 0);
                        break;
-#endif
+#endif /* defined(F_FREESP64) || HAVE_F_SETLK64 || HAVE_F_SETLKW64 */
 #ifdef F_NOTIFY
                case F_NOTIFY:
                        tprints(", ");
@@ -393,10 +421,8 @@ sys_fcntl(struct tcb *tcp)
                        tprints(", ");
                        printflock(tcp, tcp->u_arg[2], 1);
                        break;
-#if _LFS64_LARGEFILE
-#if defined(F_GETLK64) && F_GETLK64+0 != F_GETLK
+#if HAVE_F_GETLK64
                case F_GETLK64:
-#endif
                        tprints(", ");
                        printflock64(tcp, tcp->u_arg[2], 1);
                        break;