summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorRonald Oussoren <ronaldoussoren@mac.com>2006-04-23 11:59:25 (GMT)
committerRonald Oussoren <ronaldoussoren@mac.com>2006-04-23 11:59:25 (GMT)
commitd06b6f28a0c81401e3c22ab00d1b476b72db552d (patch)
tree6cddf22d5085ca93986a49feecbdc16a5ece961f /Modules/posixmodule.c
parenta1d3b1011e9e2db1e163a99081400e56fe09f35a (diff)
downloadcpython-d06b6f28a0c81401e3c22ab00d1b476b72db552d.zip
cpython-d06b6f28a0c81401e3c22ab00d1b476b72db552d.tar.gz
cpython-d06b6f28a0c81401e3c22ab00d1b476b72db552d.tar.bz2
Patch 1471925 - Weak linking support for OSX
This patch causes several symbols in the socket and posix module to be weakly linked on OSX and disables usage of ftime on OSX. These changes make it possible to use a binary build on OSX 10.4 on a 10.3 system.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 816e3eb..ac74a67 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -13,6 +13,18 @@
/* See also ../Dos/dosmodule.c */
+#ifdef __APPLE__
+ /*
+ * Step 1 of support for weak-linking a number of symbols existing on
+ * OSX 10.4 and later, see the comment in the #ifdef __APPLE__ block
+ * at the end of this file for more information.
+ */
+# pragma weak lchown
+# pragma weak statvfs
+# pragma weak fstatvfs
+
+#endif /* __APPLE__ */
+
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -8266,6 +8278,45 @@ INITFUNC(void)
PyModule_AddObject(m, "statvfs_result",
(PyObject*) &StatVFSResultType);
initialized = 1;
+
+#ifdef __APPLE__
+ /*
+ * Step 2 of weak-linking support on Mac OS X.
+ *
+ * The code below removes functions that are not available on the
+ * currently active platform.
+ *
+ * This block allow one to use a python binary that was build on
+ * OSX 10.4 on OSX 10.3, without loosing access to new APIs on
+ * OSX 10.4.
+ */
+#ifdef HAVE_FSTATVFS
+ if (fstatvfs == NULL) {
+ if (PyObject_DelAttrString(m, "fstatvfs") == -1) {
+ return;
+ }
+ }
+#endif /* HAVE_FSTATVFS */
+
+#ifdef HAVE_STATVFS
+ if (statvfs == NULL) {
+ if (PyObject_DelAttrString(m, "statvfs") == -1) {
+ return;
+ }
+ }
+#endif /* HAVE_STATVFS */
+
+# ifdef HAVE_LCHOWN
+ if (lchown == NULL) {
+ if (PyObject_DelAttrString(m, "lchown") == -1) {
+ return;
+ }
+ }
+#endif /* HAVE_LCHOWN */
+
+
+#endif /* __APPLE__ */
+
}
#ifdef __cplusplus