Xavier de Gaye added the comment:

With the patch proposed by Victor in msg293873 the cross-compilation of 
posixmodule.c succeeds on android-21-x86 and android-21-x86_64.

Following my suggestion in msg292174, I propose the following patch instead:

diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index e8c15a9473..d7ff3c78bd 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -1927,14 +1927,12 @@ _pystat_fromstructstat(STRUCT_STAT *st)
         return NULL;
 
     PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long)st->st_mode));
-#if defined(HAVE_LARGEFILE_SUPPORT) || defined(MS_WINDOWS)
     Py_BUILD_ASSERT(sizeof(unsigned long long) >= sizeof(st->st_ino));
-    PyStructSequence_SET_ITEM(v, 1,
+    if (sizeof(unsigned long) >= sizeof(st->st_ino))
+        PyStructSequence_SET_ITEM(v, 1, PyLong_FromUnsignedLong(st->st_ino));
+    else
+        PyStructSequence_SET_ITEM(v, 1,
                               PyLong_FromUnsignedLongLong(st->st_ino));
-#else
-    Py_BUILD_ASSERT(sizeof(unsigned long) >= sizeof(st->st_ino));
-    PyStructSequence_SET_ITEM(v, 1, PyLong_FromUnsignedLong(st->st_ino));
-#endif
 #ifdef MS_WINDOWS
     PyStructSequence_SET_ITEM(v, 2, PyLong_FromUnsignedLong(st->st_dev));
 #else

This patch removes the conditional on HAVE_LARGEFILE_SUPPORT (explicit is 
better than implicit) and fixes the problem for any operating system where the 
size of off_t and the size of st_ino are different.
The compiler removes the dead branch of the <if (sizeof(unsigned long)...> 
conditional, so actually it compiles to the same binary as the other patch (gcc 
does this without any optimization configured on the command line, I didn't 
check this for clang).

The same kind of fix could also be applied elsewhere in posixmodule.c where 
behind the use of HAVE_LARGEFILE_SUPPORT there is an incorrect assumption that 
the size of off_t is the same as the size of another type:
  * In _pystat_fromstructstat() - a little bit further down this patch - where 
the other type is st_size.
  * In os_DirEntry_inode_impl() where the other type is ino_t.
Maybe this should be done in a new issue then ?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29619>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to