diff --git a/configure.in b/configure.in
index d45d510f7884153fc4f741901ca64b1dc27cf824..71f3294e945a57f5a4bdecfb54d62eb54cf1559f 100644
--- a/configure.in
+++ b/configure.in
@@ -15,7 +15,7 @@ AC_CHECK_HEADERS(
   AC_MSG_ERROR([required header file not found]))
 
 # Check for typedefs, structures, and compiler characteristics.
-AC_TYPE_OFF_T
+AC_TYPE_INT64_T
 AC_SYS_LARGEFILE
 AC_STRUCT_ST_BLOCKS
 
diff --git a/src/dir.h b/src/dir.h
index 5fb207a20e9a2fe6e3631e7707c43ec14c86b40b..94899ab406ab9379a7cb164698450c08633d394a 100644
--- a/src/dir.h
+++ b/src/dir.h
@@ -79,7 +79,7 @@ struct dir_output {
 
   /* The output code is responsible for updating these stats. Can be 0 when not
    * available. */
-  off_t size;
+  int64_t size;
   long items;
 };
 
diff --git a/src/dirlist.c b/src/dirlist.c
index 7c2fd0049f840b6d61dff872a1db5e04861fbda4..0ffde2d88b8729404f7321a22ba6088112c87b85 100644
--- a/src/dirlist.c
+++ b/src/dirlist.c
@@ -30,8 +30,8 @@
 
 /* public variables */
 struct dir *dirlist_parent = NULL;
-off_t  dirlist_maxs        = 0,
-       dirlist_maxa        = 0;
+int64_t dirlist_maxs       = 0,
+        dirlist_maxa       = 0;
 
 int    dirlist_sort_desc   = 1,
        dirlist_sort_col    = DL_COL_SIZE,
diff --git a/src/dirlist.h b/src/dirlist.h
index 5927c1f712ca5b1ce91bd9771475720e940289f5..fb4709b9178f8cd5ac00be51b13018f4f7be958e 100644
--- a/src/dirlist.h
+++ b/src/dirlist.h
@@ -74,7 +74,7 @@ extern int dirlist_sort_desc, dirlist_sort_col, dirlist_sort_df;
 extern int dirlist_hidden;
 
 /* maximum size of an item in the opened dir */
-extern off_t dirlist_maxs, dirlist_maxa;
+extern int64_t dirlist_maxs, dirlist_maxa;
 
 
 #endif
diff --git a/src/global.h b/src/global.h
index c34f44c0288de3a7baa7ee0814677ea9497186bf..e244d27678c960dcca060dc12ca75dd42d383f33 100644
--- a/src/global.h
+++ b/src/global.h
@@ -31,6 +31,13 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+
 /* File Flags (struct dir -> flags) */
 #define FF_DIR    0x01
 #define FF_FILE   0x02
@@ -53,7 +60,7 @@
  *      fixed-size integers instead, which are much more predictable */
 struct dir {
   struct dir *parent, *next, *prev, *sub, *hlnk;
-  off_t size, asize;
+  int64_t size, asize;
   ino_t ino;
   long items;
   dev_t dev;
diff --git a/src/util.c b/src/util.c
index e4f1e228616c34947f11d5d96b7807652c0c62f9..f78bddd42f2d1887fbbfab9e4cac007c085f93ca 100644
--- a/src/util.c
+++ b/src/util.c
@@ -54,7 +54,7 @@ char *cropstr(const char *from, int s) {
 }
 
 
-char *formatsize(const off_t from) {
+char *formatsize(int64_t from) {
   static char dat[9]; /* "xxx.xMiB" */
   float r = from; 
   char c = ' ';
@@ -68,10 +68,10 @@ char *formatsize(const off_t from) {
 }
 
 
-char *fullsize(const off_t from) {
+char *fullsize(int64_t from) {
   static char dat[20]; /* max: 999.999.999.999.999 */
   char tmp[20];
-  off_t n = from;
+  int64_t n = from;
   int i, j;
 
   /* the K&R method - more portable than sprintf with %lld */
@@ -283,7 +283,7 @@ struct dir *getroot(struct dir *d) {
 }
 
 
-void addparentstats(struct dir *d, off_t size, off_t asize, long items) {
+void addparentstats(struct dir *d, int64_t size, int64_t asize, long items) {
   while(d) {
     d->size += size;
     d->asize += asize;
diff --git a/src/util.h b/src/util.h
index a0d76419c9a7608f0841d01f3618eeab59900ac8..a8dd11675b4402b92b3b1c9e42cd8141fb1e8367 100644
--- a/src/util.h
+++ b/src/util.h
@@ -66,10 +66,10 @@ void ncprint(int, int, char *, ...);
 char *cropstr(const char *, int);
 
 /* formats size in the form of xxx.xXB */
-char *formatsize(const off_t);
+char *formatsize(int64_t );
 
 /* int2string with thousand separators */
-char *fullsize(const off_t);
+char *fullsize(int64_t);
 
 /* recursively free()s a directory tree */
 void freedir(struct dir *);
@@ -82,7 +82,7 @@ char *getpath(struct dir *);
 struct dir *getroot(struct dir *);
 
 /* Adds a value to the size, asize and items fields of *d and its parents */
-void addparentstats(struct dir *, off_t, off_t, long);
+void addparentstats(struct dir *, int64_t, int64_t, long);
 
 #endif