diff --git a/bare-arm/mpconfigport.h b/bare-arm/mpconfigport.h
index 59f246e2b829ee64e3bf4454da111a5518368d85..0015541f9828cb7bcb9d7194c3fe16548d242f3e 100644
--- a/bare-arm/mpconfigport.h
+++ b/bare-arm/mpconfigport.h
@@ -46,6 +46,7 @@ typedef int32_t mp_int_t; // must be pointer size
 typedef uint32_t mp_uint_t; // must be pointer size
 typedef void *machine_ptr_t; // must be of pointer size
 typedef const void *machine_const_ptr_t; // must be of pointer size
+typedef long mp_off_t;
 
 // extra built in names to add to the global namespace
 extern const struct _mp_obj_fun_builtin_t mp_builtin_open_obj;
diff --git a/qemu-arm/mpconfigport.h b/qemu-arm/mpconfigport.h
index e3c0969a5d3802b4b61fd60071509be25db0c3e4..45c7737413e2e5356376eef72199d8b1f9270c92 100644
--- a/qemu-arm/mpconfigport.h
+++ b/qemu-arm/mpconfigport.h
@@ -29,6 +29,7 @@ typedef int32_t mp_int_t; // must be pointer size
 typedef uint32_t mp_uint_t; // must be pointer size
 typedef void *machine_ptr_t; // must be of pointer size
 typedef const void *machine_const_ptr_t; // must be of pointer size
+typedef long mp_off_t;
 
 // extra built in names to add to the global namespace
 extern const struct _mp_obj_fun_builtin_t mp_builtin_open_obj;
diff --git a/teensy/mpconfigport.h b/teensy/mpconfigport.h
index 8e2ba4afd937483552f0843618aa39cfdb17f2ac..efe51fecda243e4374587466db0ce4cea0a883ff 100644
--- a/teensy/mpconfigport.h
+++ b/teensy/mpconfigport.h
@@ -55,6 +55,7 @@ typedef int32_t mp_int_t; // must be pointer size
 typedef unsigned int mp_uint_t; // must be pointer size
 typedef void *machine_ptr_t; // must be of pointer size
 typedef const void *machine_const_ptr_t; // must be of pointer size
+typedef long mp_off_t;
 
 // We have inlined IRQ functions for efficiency (they are generally
 // 1 machine instruction).
diff --git a/unix-cpy/mpconfigport.h b/unix-cpy/mpconfigport.h
index 4d1deb87931d5656cf054cbae4ff41fa0696c2c3..2c1d5d7b27c6b313060e9e0adf339790557ae0f0 100644
--- a/unix-cpy/mpconfigport.h
+++ b/unix-cpy/mpconfigport.h
@@ -48,6 +48,7 @@ typedef unsigned int mp_uint_t; // must be pointer size
 typedef void *machine_ptr_t; // must be of pointer size
 typedef const void *machine_const_ptr_t; // must be of pointer size
 typedef double machine_float_t;
+typedef long mp_off_t;
 
 // We need to provide a declaration/definition of alloca()
 #ifdef __FreeBSD__
diff --git a/windows/mpconfigport.h b/windows/mpconfigport.h
index ee207c1ef895fdcc52d969ca7c37acb93c6482cd..7b23f5cb1b12457dc97e62ad5384ff583e973faa 100644
--- a/windows/mpconfigport.h
+++ b/windows/mpconfigport.h
@@ -92,6 +92,13 @@ typedef unsigned int mp_uint_t; // must be pointer size
 // define standard endianness macros.
 #define MP_ENDIANNESS_LITTLE (1)
 
+// Cannot include <sys/types.h>, as it may lead to symbol name clashes
+#if _FILE_OFFSET_BITS == 64 && !defined(__LP64__)
+typedef long long mp_off_t;
+#else
+typedef long mp_off_t;
+#endif
+
 typedef void *machine_ptr_t; // must be of pointer size
 typedef const void *machine_const_ptr_t; // must be of pointer size