]> granicus.if.org Git - strace/commitdiff
Remove code which supports systems with long long off_t.
authorDenys Vlasenko <vda.linux@googlemail.com>
Mon, 18 Feb 2013 14:47:57 +0000 (15:47 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 18 Feb 2013 14:47:57 +0000 (15:47 +0100)
While looking at mmap mess, did experimenting in order
to figure out what gets used when.

Tried building armv4tl, armv5l, armv6l, mips, mipsel, i686,
x86_64 and none of they have long long off_t,
which isn't suprprising: we aren't using glibc defines
which enable that.

Moreover, we SHOULD NOT use off_t in syscall decode!
Its size depends on libc, not on arch! I.e. it is essentially
unpredictable and can even in theory vary on the same arch
with different libc.

We should use longs or long longs, in a way which matches
architectural ABI for the given syscall. There are usually
*at most* two permutations, no need to add yet another variable
(sizeof(off_t)) to the mix.

This change removes almost all HAVE_LONG_LONG_OFF_T conditionals,
which will reveal further possible simplifications.

* mem.c: Remove code conditional on HAVE_LONG_LONG_OFF_T.
As a result, never remap sys_mmap64 to sys_mmap.
(print_mmap): Compile unconditionally.
(sys_old_mmap): Compile unconditionally.
(sys_mmap): Compile unconditionally.
* io.c (sys_sendfile): Add a FIXME comment.
* file.c: Remove code conditional on HAVE_LONG_LONG_OFF_T.
As a result, never remap sys_*stat64 to sys_*stat etc.
(sys_truncate): Compile unconditionally.
(realprintstat): Likewise.
(sys_stat): Likewise.
(sys_fstat): Likewise.
(sys_lstat): Likewise.
* desc.c (printflock): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
desc.c
file.c
io.c
mem.c

diff --git a/desc.c b/desc.c
index 65e5ed061a4a0ad465ae888f08d96883ba6b7543..617f80a39b35694282dab02d34f4240c47014e7b 100644 (file)
--- a/desc.c
+++ b/desc.c
 # include  <linux/perf_event.h>
 #endif
 
-#if HAVE_LONG_LONG_OFF_T
-/*
- * Hacks for systems that have a long long off_t
- */
-# define flock64       flock           /* Horrid hack */
-# define printflock printflock64       /* Horrider hack */
-#endif
-
 static const struct xlat fcntlcmds[] = {
        { F_DUPFD,      "F_DUPFD"       },
        { F_GETFD,      "F_GETFD"       },
@@ -231,7 +223,6 @@ static const struct xlat perf_event_open_flags[] = {
        { 0,                            NULL                    },
 };
 
-#ifndef HAVE_LONG_LONG_OFF_T
 /* fcntl/lockf */
 static void
 printflock(struct tcb *tcp, long addr, int getlk)
@@ -282,9 +273,8 @@ printflock(struct tcb *tcp, long addr, int getlk)
        else
                tprints("}");
 }
-#endif
 
-#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
+#if _LFS64_LARGEFILE
 /* fcntl/lockf */
 static void
 printflock64(struct tcb *tcp, long addr, int getlk)
diff --git a/file.c b/file.c
index fb59f0d37fefe027b8a9e32116177c759b0de849..cfdd0bb98911323e845a83b1a1ee7115013d7063 100644 (file)
--- a/file.c
+++ b/file.c
@@ -183,19 +183,6 @@ struct stat64 {
 # define XATTR_REPLACE 2
 #endif
 
-#if HAVE_LONG_LONG_OFF_T
-/*
- * Ugly hacks for systems that have typedef long long off_t
- */
-# define stat64 stat
-# define HAVE_STAT64 1 /* Ugly hack */
-# define sys_stat64    sys_stat
-# define sys_fstat64   sys_fstat
-# define sys_lstat64   sys_lstat
-# define sys_truncate64        sys_truncate
-# define sys_ftruncate64       sys_ftruncate
-#endif
-
 #ifdef MAJOR_IN_SYSMACROS
 # include <sys/sysmacros.h>
 #endif
@@ -626,7 +613,6 @@ sys_readahead(struct tcb *tcp)
        return 0;
 }
 
-#ifndef HAVE_LONG_LONG_OFF_T
 int
 sys_truncate(struct tcb *tcp)
 {
@@ -636,9 +622,8 @@ sys_truncate(struct tcb *tcp)
        }
        return 0;
 }
-#endif
 
-#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
+#if _LFS64_LARGEFILE
 int
 sys_truncate64(struct tcb *tcp)
 {
@@ -650,7 +635,6 @@ sys_truncate64(struct tcb *tcp)
 }
 #endif
 
-#ifndef HAVE_LONG_LONG_OFF_T
 int
 sys_ftruncate(struct tcb *tcp)
 {
@@ -660,9 +644,8 @@ sys_ftruncate(struct tcb *tcp)
        }
        return 0;
 }
-#endif
 
-#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
+#if _LFS64_LARGEFILE
 int
 sys_ftruncate64(struct tcb *tcp)
 {
@@ -920,7 +903,6 @@ static const struct xlat fileflags[] = {
        { 0,            NULL            },
 };
 
-#ifndef HAVE_LONG_LONG_OFF_T
 static void
 realprintstat(struct tcb *tcp, struct stat *statbuf)
 {
@@ -1027,7 +1009,6 @@ printstat(struct tcb *tcp, long addr)
 
        realprintstat(tcp, &statbuf);
 }
-#endif /* !HAVE_LONG_LONG_OFF_T */
 
 #if !defined HAVE_STAT64 && defined X86_64
 /*
@@ -1181,7 +1162,7 @@ printstat64(struct tcb *tcp, long addr)
 }
 #endif /* HAVE_STAT64 */
 
-#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) && !defined(HAVE_LONG_LONG_OFF_T)
+#if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
 static void
 convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf)
 {
@@ -1232,7 +1213,6 @@ printoldstat(struct tcb *tcp, long addr)
 }
 #endif
 
-#ifndef HAVE_LONG_LONG_OFF_T
 int
 sys_stat(struct tcb *tcp)
 {
@@ -1244,7 +1224,6 @@ sys_stat(struct tcb *tcp)
        }
        return 0;
 }
-#endif
 
 int
 sys_stat64(struct tcb *tcp)
@@ -1311,7 +1290,7 @@ sys_newfstatat(struct tcb *tcp)
        return 0;
 }
 
-#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) && !defined(HAVE_LONG_LONG_OFF_T)
+#if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
 int
 sys_oldstat(struct tcb *tcp)
 {
@@ -1325,7 +1304,6 @@ sys_oldstat(struct tcb *tcp)
 }
 #endif
 
-#ifndef HAVE_LONG_LONG_OFF_T
 int
 sys_fstat(struct tcb *tcp)
 {
@@ -1337,7 +1315,6 @@ sys_fstat(struct tcb *tcp)
        }
        return 0;
 }
-#endif
 
 int
 sys_fstat64(struct tcb *tcp)
@@ -1355,7 +1332,7 @@ sys_fstat64(struct tcb *tcp)
 #endif
 }
 
-#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) && !defined(HAVE_LONG_LONG_OFF_T)
+#if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
 int
 sys_oldfstat(struct tcb *tcp)
 {
@@ -1369,7 +1346,6 @@ sys_oldfstat(struct tcb *tcp)
 }
 #endif
 
-#ifndef HAVE_LONG_LONG_OFF_T
 int
 sys_lstat(struct tcb *tcp)
 {
@@ -1381,7 +1357,6 @@ sys_lstat(struct tcb *tcp)
        }
        return 0;
 }
-#endif
 
 int
 sys_lstat64(struct tcb *tcp)
@@ -1399,7 +1374,7 @@ sys_lstat64(struct tcb *tcp)
 #endif
 }
 
-#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) && !defined(HAVE_LONG_LONG_OFF_T)
+#if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
 int
 sys_oldlstat(struct tcb *tcp)
 {
diff --git a/io.c b/io.c
index 6b3f4b70d9f8c665198dd33a8690f5b1235c78d0..f0f07560d0b806257a4026c3c95666d65515eacc 100644 (file)
--- a/io.c
+++ b/io.c
@@ -262,6 +262,10 @@ sys_sendfile(struct tcb *tcp)
                tprints(", ");
                if (!tcp->u_arg[2])
                        tprints("NULL");
+//FIXME: obviously bogus.
+//Probably should use explicit long.
+//Arches with long long offset param should use
+//sys_sendfile64, not this fn.
                else if (umove(tcp, tcp->u_arg[2], &offset) < 0)
                        tprintf("%#lx", tcp->u_arg[2]);
                else
diff --git a/mem.c b/mem.c
index 389e098c52fd207304b677a40e81ce9f40595113..653429b3dd68405e1f9d089d3c36dd3aadcdd461 100644 (file)
--- a/mem.c
+++ b/mem.c
@@ -202,7 +202,6 @@ addtileflags(long flags)
 }
 #endif
 
-#if !HAVE_LONG_LONG_OFF_T
 static int
 print_mmap(struct tcb *tcp, long *u_arg, unsigned long long offset)
 {
@@ -300,20 +299,13 @@ sys_mmap(struct tcb *tcp)
 #endif
        return print_mmap(tcp, tcp->u_arg, offset);
 }
-#endif /* !HAVE_LONG_LONG_OFF_T */
 
-#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
+#if _LFS64_LARGEFILE
 /* TODO: comment which arches use this routine.
  * For one, does ALPHA on Linux use this??
  * From code it seems that it might use 7 or 8 registers,
  * which is strange - Linux syscalls can pass maximum of 6 parameters!
  */
-# ifdef HAVE_LONG_LONG_OFF_T
-/* For systems that have a long long off_t,
- * sys_mmap in syscall tables is handled by sys_mmap64:
- */
-#  define sys_mmap64 sys_mmap
-# endif
 int
 sys_mmap64(struct tcb *tcp)
 {
@@ -359,7 +351,7 @@ sys_mmap64(struct tcb *tcp)
        }
        return RVAL_HEX;
 }
-#endif /* _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T */
+#endif
 
 int
 sys_munmap(struct tcb *tcp)