From b895046d099aaa768f51d1007fbb9856108fd1ec Mon Sep 17 00:00:00 2001 From: Michael Felt Date: Fri, 22 Dec 2017 09:13:29 +0000 Subject: [PATCH 1/7] Modify syntax to satisify xlC compiler requirements. Error message was: "./Modules/posixmodule.c", line 9328.64: 1506-280 (S) Function argument assignment between types "unsigned long" and "struct fsid_t" is not allowed. --- Modules/posixmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 38b6c80e6bdd42..8371b6e4bda7c7 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -9325,7 +9325,7 @@ _pystatvfs_fromstructstatvfs(struct statvfs st) { PyStructSequence_SET_ITEM(v, 8, PyLong_FromLong((long) st.f_flag)); PyStructSequence_SET_ITEM(v, 9, PyLong_FromLong((long) st.f_namemax)); #endif - PyStructSequence_SET_ITEM(v, 10, PyLong_FromUnsignedLong(st.f_fsid)); + PyStructSequence_SET_ITEM(v, 10, PyLong_FromUnsignedLong(st.f_fsid.val[0])); if (PyErr_Occurred()) { Py_DECREF(v); return NULL; From 86275ea7cee9b47fb188a94ad251464a22e7111c Mon Sep 17 00:00:00 2001 From: Michael Felt Date: Fri, 22 Dec 2017 10:33:50 +0000 Subject: [PATCH 2/7] Syntax requirement seems to be specific to AIX, regardless of compiler (gcc/xlc) Adding #ifdef logic to distinguish platform --- Modules/posixmodule.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 8371b6e4bda7c7..d48fe91841df88 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -9325,7 +9325,11 @@ _pystatvfs_fromstructstatvfs(struct statvfs st) { PyStructSequence_SET_ITEM(v, 8, PyLong_FromLong((long) st.f_flag)); PyStructSequence_SET_ITEM(v, 9, PyLong_FromLong((long) st.f_namemax)); #endif +#ifndef _AIX + PyStructSequence_SET_ITEM(v, 10, PyLong_FromUnsignedLong(st.f_fsid)); +#else PyStructSequence_SET_ITEM(v, 10, PyLong_FromUnsignedLong(st.f_fsid.val[0])); +#endif if (PyErr_Occurred()) { Py_DECREF(v); return NULL; From a7b666f124baf4bbea4a87a212c0829b91aa1bc3 Mon Sep 17 00:00:00 2001 From: Michael Felt Date: Fri, 22 Dec 2017 12:38:03 +0000 Subject: [PATCH 3/7] add blurb --- .../Core and Builtins/2017-12-22-13-28-07.bpo-32390.QPj083.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2017-12-22-13-28-07.bpo-32390.QPj083.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2017-12-22-13-28-07.bpo-32390.QPj083.rst b/Misc/NEWS.d/next/Core and Builtins/2017-12-22-13-28-07.bpo-32390.QPj083.rst new file mode 100644 index 00000000000000..bca6c67a76594b --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2017-12-22-13-28-07.bpo-32390.QPj083.rst @@ -0,0 +1,2 @@ +Correct compiler syntax error on AIX for st.f_fsid addition +Error message: 1506-280 (S) Function argument assignment between types "unsigned long" and "struct fsid_t" is not allowed. From cc0e94bac10b572640cc89c7af641012675ae86d Mon Sep 17 00:00:00 2001 From: Michael Felt Date: Sun, 24 Dec 2017 18:45:41 +0000 Subject: [PATCH 4/7] undef _ALL_SOURCE to resolve issue on AIX --- .../2017-12-22-13-28-07.bpo-32390.QPj083.rst | 4 ++- Modules/posixmodule.c | 29 ++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Misc/NEWS.d/next/Core and Builtins/2017-12-22-13-28-07.bpo-32390.QPj083.rst b/Misc/NEWS.d/next/Core and Builtins/2017-12-22-13-28-07.bpo-32390.QPj083.rst index bca6c67a76594b..e2bdbe668f387a 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2017-12-22-13-28-07.bpo-32390.QPj083.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2017-12-22-13-28-07.bpo-32390.QPj083.rst @@ -1,2 +1,4 @@ -Correct compiler syntax error on AIX for st.f_fsid addition +Fix os.statvfs(path) on AIX +when _ALL_SOURCE is defined f_fsid member of the statvfs structure is a structure instead of unsigned long. +when _ALL_SOURCE is not defined f_fsid member of the statvfs structure is nearly identical to Linux Error message: 1506-280 (S) Function argument assignment between types "unsigned long" and "struct fsid_t" is not allowed. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index d48fe91841df88..185b49b5cdeef5 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -9288,6 +9288,31 @@ os_WSTOPSIG_impl(PyObject *module, int status) needed definitions in sys/statvfs.h */ #define _SVID3 #endif +#if defined(_AIX) && defined(_ALL_SOURCE) +/* + * https://www.gnu.org/software/autoconf/manual/autoconf-2.64/html_node/Posix-Variants.html + * describes _ALL_SOURCE as a macro for AIX3 + * With _ALL_SOURCE undefined the variable name on AIX is the same as + * Linux +/usr/include/bits/typesizes.h:72:#define __FSID_T_TYPE struct { int __val[2]; } + * AIX: /usr/include/sys/types.h + +360 / * typedef for the File System Identifier (fsid). This must correspond + +361 * to the "struct fsid" structure in _ALL_SOURCE below. + +362 * / + +363 typedef struct fsid_t { + +364 #ifdef __64BIT_KERNEL + +365 unsigned long val[2]; + +366 #else / * __64BIT_KERNEL * / + +367 #ifdef _ALL_SOURCE + +368 unsigned int val[2]; + +369 #else / * _ALL_SOURCE * / + +370 unsigned int __val[2]; + +371 #endif / * _ALL_SOURCE * / + +372 #endif / * __64BIT_KERNEL * / + +373 } fsid_t; + */ +#undef _ALL_SOURCE +#endif #include static PyObject* @@ -9325,11 +9350,7 @@ _pystatvfs_fromstructstatvfs(struct statvfs st) { PyStructSequence_SET_ITEM(v, 8, PyLong_FromLong((long) st.f_flag)); PyStructSequence_SET_ITEM(v, 9, PyLong_FromLong((long) st.f_namemax)); #endif -#ifndef _AIX PyStructSequence_SET_ITEM(v, 10, PyLong_FromUnsignedLong(st.f_fsid)); -#else - PyStructSequence_SET_ITEM(v, 10, PyLong_FromUnsignedLong(st.f_fsid.val[0])); -#endif if (PyErr_Occurred()) { Py_DECREF(v); return NULL; From ca74fc26e1d366d39cada2ec155096fc359dd2cd Mon Sep 17 00:00:00 2001 From: Michael Felt Date: Mon, 1 Jan 2018 16:31:56 +0000 Subject: [PATCH 5/7] modifications per reviewer request --- Modules/posixmodule.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 185b49b5cdeef5..1089470fd2be43 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -9288,29 +9288,14 @@ os_WSTOPSIG_impl(PyObject *module, int status) needed definitions in sys/statvfs.h */ #define _SVID3 #endif -#if defined(_AIX) && defined(_ALL_SOURCE) -/* - * https://www.gnu.org/software/autoconf/manual/autoconf-2.64/html_node/Posix-Variants.html - * describes _ALL_SOURCE as a macro for AIX3 - * With _ALL_SOURCE undefined the variable name on AIX is the same as - * Linux -/usr/include/bits/typesizes.h:72:#define __FSID_T_TYPE struct { int __val[2]; } - * AIX: /usr/include/sys/types.h - +360 / * typedef for the File System Identifier (fsid). This must correspond - +361 * to the "struct fsid" structure in _ALL_SOURCE below. - +362 * / - +363 typedef struct fsid_t { - +364 #ifdef __64BIT_KERNEL - +365 unsigned long val[2]; - +366 #else / * __64BIT_KERNEL * / - +367 #ifdef _ALL_SOURCE - +368 unsigned int val[2]; - +369 #else / * _ALL_SOURCE * / - +370 unsigned int __val[2]; - +371 #endif / * _ALL_SOURCE * / - +372 #endif / * __64BIT_KERNEL * / - +373 } fsid_t; +/* Issue #32390: On AIX platform, _ALL_SOURCE is defined by default. + When _ALL_SOURCE is defined the AIX system headers needed for + os.statvfs(path) define (typedef) f_fsid member of the statvfs structure + in a way that is not compatible with the PyStructSequence_SET_ITEM() statement. + With _ALL_SOURCE undefined the AIX system headers provide equivalent definitions + and the code works asis */ +#if defined(_AIX) && defined(_ALL_SOURCE) #undef _ALL_SOURCE #endif #include From 47af93438677011c1492d60f9d682557b0d71493 Mon Sep 17 00:00:00 2001 From: Michael Felt Date: Wed, 3 Jan 2018 18:02:08 +0000 Subject: [PATCH 6/7] Modify patch following discussion in: https://bugs.python.org/issue32390 See also http://hg.python.org/lookup/e0bb4ba869 --- Modules/posixmodule.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 1089470fd2be43..ed91c8e35ed3b9 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -9288,16 +9288,6 @@ os_WSTOPSIG_impl(PyObject *module, int status) needed definitions in sys/statvfs.h */ #define _SVID3 #endif -/* Issue #32390: On AIX platform, _ALL_SOURCE is defined by default. - When _ALL_SOURCE is defined the AIX system headers needed for - os.statvfs(path) define (typedef) f_fsid member of the statvfs structure - in a way that is not compatible with the PyStructSequence_SET_ITEM() statement. - With _ALL_SOURCE undefined the AIX system headers provide equivalent definitions - and the code works asis - */ -#if defined(_AIX) && defined(_ALL_SOURCE) -#undef _ALL_SOURCE -#endif #include static PyObject* @@ -9335,7 +9325,16 @@ _pystatvfs_fromstructstatvfs(struct statvfs st) { PyStructSequence_SET_ITEM(v, 8, PyLong_FromLong((long) st.f_flag)); PyStructSequence_SET_ITEM(v, 9, PyLong_FromLong((long) st.f_namemax)); #endif +/* Issue #32390: On AIX platform, _ALL_SOURCE is defined by default. + When _ALL_SOURCE is defined the AIX system headers define f_fsid + in a way that is not compatible with the PyStructSequence_SET_ITEM() statement. + This change makes os.statvfs(path) work on AIX + */ +#if defined(_AIX) && defined(_ALL_SOURCE) + PyStructSequence_SET_ITEM(v, 10, PyLong_FromUnsignedLong(st.f_fsid.val[0])); +#else PyStructSequence_SET_ITEM(v, 10, PyLong_FromUnsignedLong(st.f_fsid)); +#endif if (PyErr_Occurred()) { Py_DECREF(v); return NULL; From bd675b790616398a69c145a14b099da98b4223e6 Mon Sep 17 00:00:00 2001 From: Xavier de Gaye Date: Fri, 5 Jan 2018 11:53:57 +0100 Subject: [PATCH 7/7] Update the comment and Misc/NEWS entry --- .../2017-12-22-13-28-07.bpo-32390.QPj083.rst | 5 +---- Modules/posixmodule.c | 7 ++----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Misc/NEWS.d/next/Core and Builtins/2017-12-22-13-28-07.bpo-32390.QPj083.rst b/Misc/NEWS.d/next/Core and Builtins/2017-12-22-13-28-07.bpo-32390.QPj083.rst index e2bdbe668f387a..0e9c1bff540d1f 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2017-12-22-13-28-07.bpo-32390.QPj083.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2017-12-22-13-28-07.bpo-32390.QPj083.rst @@ -1,4 +1 @@ -Fix os.statvfs(path) on AIX -when _ALL_SOURCE is defined f_fsid member of the statvfs structure is a structure instead of unsigned long. -when _ALL_SOURCE is not defined f_fsid member of the statvfs structure is nearly identical to Linux -Error message: 1506-280 (S) Function argument assignment between types "unsigned long" and "struct fsid_t" is not allowed. +Fix the compilation failure on AIX after the f_fsid field has been added to the object returned by os.statvfs() (issue #32143). Original patch by Michael Felt. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 0f8dcaf989ea20..b0e48dabbd55cf 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -9336,11 +9336,8 @@ _pystatvfs_fromstructstatvfs(struct statvfs st) { PyStructSequence_SET_ITEM(v, 8, PyLong_FromLong((long) st.f_flag)); PyStructSequence_SET_ITEM(v, 9, PyLong_FromLong((long) st.f_namemax)); #endif -/* Issue #32390: On AIX platform, _ALL_SOURCE is defined by default. - When _ALL_SOURCE is defined the AIX system headers define f_fsid - in a way that is not compatible with the PyStructSequence_SET_ITEM() statement. - This change makes os.statvfs(path) work on AIX - */ +/* The _ALL_SOURCE feature test macro defines f_fsid as a structure + * (issue #32390). */ #if defined(_AIX) && defined(_ALL_SOURCE) PyStructSequence_SET_ITEM(v, 10, PyLong_FromUnsignedLong(st.f_fsid.val[0])); #else