xref: /AOO41X/main/python/python-freebsd.patch (revision df26b2344d5dde90a7be84c4b8029bbf6a73a2f1)
1*df26b234SDonLewisFreeBSDdiff -ruN misc/Python-2.7.18/Modules/fcntlmodule.c misc/build/Python-2.7.18/Modules/fcntlmodule.c
2*df26b234SDonLewisFreeBSD--- misc/Python-2.7.18/Modules/fcntlmodule.c	2019-10-19 13:38:44.000000000 -0500
3*df26b234SDonLewisFreeBSD+++ misc/build/Python-2.7.18/Modules/fcntlmodule.c	2020-01-09 22:59:15.052886000 -0500
46ee2a585SPedro Giffuni@@ -98,20 +98,15 @@
5723f57f2SPedro Giffuni {
6723f57f2SPedro Giffuni #define IOCTL_BUFSZ 1024
7723f57f2SPedro Giffuni     int fd;
8723f57f2SPedro Giffuni-    /* In PyArg_ParseTuple below, we use the unsigned non-checked 'I'
9723f57f2SPedro Giffuni+    /* In PyArg_ParseTuple below, we use the unsigned non-checked 'k'
10723f57f2SPedro Giffuni        format for the 'code' parameter because Python turns 0x8000000
11723f57f2SPedro Giffuni        into either a large positive number (PyLong or PyInt on 64-bit
12723f57f2SPedro Giffuni        platforms) or a negative number on others (32-bit PyInt)
13723f57f2SPedro Giffuni        whereas the system expects it to be a 32bit bit field value
14723f57f2SPedro Giffuni        regardless of it being passed as an int or unsigned long on
15723f57f2SPedro Giffuni-       various platforms.  See the termios.TIOCSWINSZ constant across
166ee2a585SPedro Giffuni-       platforms for an example of this.
17723f57f2SPedro Giffuni-
18723f57f2SPedro Giffuni-       If any of the 64bit platforms ever decide to use more than 32bits
19723f57f2SPedro Giffuni-       in their unsigned long ioctl codes this will break and need
20723f57f2SPedro Giffuni-       special casing based on the platform being built on.
21723f57f2SPedro Giffuni+       various platforms.
22723f57f2SPedro Giffuni      */
23723f57f2SPedro Giffuni-    unsigned int code;
24723f57f2SPedro Giffuni+    unsigned long code;
25723f57f2SPedro Giffuni     int arg;
26723f57f2SPedro Giffuni     int ret;
27723f57f2SPedro Giffuni     char *str;
286ee2a585SPedro Giffuni@@ -119,7 +114,7 @@
29723f57f2SPedro Giffuni     int mutate_arg = 1;
30723f57f2SPedro Giffuni     char buf[IOCTL_BUFSZ+1];  /* argument plus NUL byte */
31723f57f2SPedro Giffuni
32723f57f2SPedro Giffuni-    if (PyArg_ParseTuple(args, "O&Iw#|i:ioctl",
33723f57f2SPedro Giffuni+    if (PyArg_ParseTuple(args, "O&kw#|i:ioctl",
34723f57f2SPedro Giffuni                          conv_descriptor, &fd, &code,
35723f57f2SPedro Giffuni                          &str, &len, &mutate_arg)) {
36723f57f2SPedro Giffuni         char *arg;
376ee2a585SPedro Giffuni@@ -170,7 +165,7 @@
38723f57f2SPedro Giffuni     }
39723f57f2SPedro Giffuni
40723f57f2SPedro Giffuni     PyErr_Clear();
41723f57f2SPedro Giffuni-    if (PyArg_ParseTuple(args, "O&Is#:ioctl",
42723f57f2SPedro Giffuni+    if (PyArg_ParseTuple(args, "O&ks#:ioctl",
43723f57f2SPedro Giffuni                          conv_descriptor, &fd, &code, &str, &len)) {
44723f57f2SPedro Giffuni         if (len > IOCTL_BUFSZ) {
45723f57f2SPedro Giffuni             PyErr_SetString(PyExc_ValueError,
466ee2a585SPedro Giffuni@@ -192,7 +187,7 @@
47723f57f2SPedro Giffuni     PyErr_Clear();
48723f57f2SPedro Giffuni     arg = 0;
49723f57f2SPedro Giffuni     if (!PyArg_ParseTuple(args,
50723f57f2SPedro Giffuni-         "O&I|i;ioctl requires a file or file descriptor,"
51723f57f2SPedro Giffuni+         "O&k|i;ioctl requires a file or file descriptor,"
52723f57f2SPedro Giffuni          " an integer and optionally an integer or buffer argument",
53723f57f2SPedro Giffuni                           conv_descriptor, &fd, &code, &arg)) {
54723f57f2SPedro Giffuni       return NULL;
55*df26b234SDonLewisFreeBSDdiff -ruN misc/Python-2.7.18/Python/thread_pthread.h misc/build/Python-2.7.18/Python/thread_pthread.h
56*df26b234SDonLewisFreeBSD--- misc/Python-2.7.18/Python/thread_pthread.h	2019-10-19 13:38:44.000000000 -0500
57*df26b234SDonLewisFreeBSD+++ misc/build/Python-2.7.18/Python/thread_pthread.h	2020-01-09 22:59:15.053731000 -0500
58723f57f2SPedro Giffuni@@ -38,13 +38,18 @@
59723f57f2SPedro Giffuni #endif
60723f57f2SPedro Giffuni #endif
61723f57f2SPedro Giffuni
62723f57f2SPedro Giffuni+#ifdef __FreeBSD__
63723f57f2SPedro Giffuni+#include <osreldate.h>
64723f57f2SPedro Giffuni+#endif
65723f57f2SPedro Giffuni+
66723f57f2SPedro Giffuni /* The POSIX spec says that implementations supporting the sem_*
67723f57f2SPedro Giffuni    family of functions must indicate this by defining
68723f57f2SPedro Giffuni    _POSIX_SEMAPHORES. */
69723f57f2SPedro Giffuni #ifdef _POSIX_SEMAPHORES
70723f57f2SPedro Giffuni /* On FreeBSD 4.x, _POSIX_SEMAPHORES is defined empty, so
71723f57f2SPedro Giffuni    we need to add 0 to make it work there as well. */
72723f57f2SPedro Giffuni-#if (_POSIX_SEMAPHORES+0) == -1
73723f57f2SPedro Giffuni+#if defined(__FreeBSD__) && __FreeBSD_version < 701104 && \
74723f57f2SPedro Giffuni+    (_POSIX_SEMAPHORES+0) == -1
75723f57f2SPedro Giffuni #define HAVE_BROKEN_POSIX_SEMAPHORES
76723f57f2SPedro Giffuni #else
77723f57f2SPedro Giffuni #include <semaphore.h>
78723f57f2SPedro Giffuni@@ -56,7 +61,6 @@
790a45483eSPedro Giffuni    in default setting.  So the process scope is preferred to get
800a45483eSPedro Giffuni    enough number of threads to work. */
810a45483eSPedro Giffuni #ifdef __FreeBSD__
820a45483eSPedro Giffuni-#include <osreldate.h>
830a45483eSPedro Giffuni #if __FreeBSD_version >= 500000 && __FreeBSD_version < 504101
840a45483eSPedro Giffuni #undef PTHREAD_SYSTEM_SCHED_SUPPORTED
850a45483eSPedro Giffuni #endif
86da02c194SPedro Giffuni@@ -184,6 +188,7 @@
870a45483eSPedro Giffuni {
880a45483eSPedro Giffuni     pthread_t th;
890a45483eSPedro Giffuni     int status;
900a45483eSPedro Giffuni+    sigset_t set, oset;
910a45483eSPedro Giffuni #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
920a45483eSPedro Giffuni     pthread_attr_t attrs;
930a45483eSPedro Giffuni #endif
94da02c194SPedro Giffuni@@ -212,6 +217,8 @@
950a45483eSPedro Giffuni #if defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
960a45483eSPedro Giffuni     pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM);
970a45483eSPedro Giffuni #endif
980a45483eSPedro Giffuni+    sigfillset(&set);
990a45483eSPedro Giffuni+    SET_THREAD_SIGMASK(SIG_BLOCK, &set, &oset);
100723f57f2SPedro Giffuni
101da02c194SPedro Giffuni     pythread_callback *callback = malloc(sizeof(pythread_callback));
102da02c194SPedro Giffuni
103da02c194SPedro Giffuni@@ -230,6 +237,7 @@
104da02c194SPedro Giffuni #endif
105da02c194SPedro Giffuni                              pythread_wrapper, callback);
1060a45483eSPedro Giffuni
1070a45483eSPedro Giffuni+    SET_THREAD_SIGMASK(SIG_SETMASK, &oset, NULL);
1080a45483eSPedro Giffuni #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
1090a45483eSPedro Giffuni     pthread_attr_destroy(&attrs);
1100a45483eSPedro Giffuni #endif
111*df26b234SDonLewisFreeBSDdiff -ruN misc/Python-2.7.18/configure misc/build/Python-2.7.18/configure
112*df26b234SDonLewisFreeBSD--- misc/Python-2.7.18/configure	2019-10-19 13:38:44.000000000 -0500
113*df26b234SDonLewisFreeBSD+++ misc/build/Python-2.7.18/configure	2020-01-09 22:59:15.072666000 -0500
114da02c194SPedro Giffuni@@ -5477,7 +5477,7 @@
1150a45483eSPedro Giffuni           ;;
1160a45483eSPedro Giffuni     SunOS*)
1170a45483eSPedro Giffuni 	  LDLIBRARY='libpython$(VERSION).so'
1180a45483eSPedro Giffuni-	  BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
1190a45483eSPedro Giffuni+	  BLDLIBRARY=-R\'\$\$ORIGIN\'' -L. -lpython$(VERSION)'
1206ee2a585SPedro Giffuni 	  RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
1210a45483eSPedro Giffuni 	  INSTSONAME="$LDLIBRARY".$SOVERSION
1220a45483eSPedro Giffuni           ;;
123da02c194SPedro Giffuni@@ -5485,11 +5485,6 @@
1240a45483eSPedro Giffuni 	  LDLIBRARY='libpython$(VERSION).so'
1250a45483eSPedro Giffuni 	  BLDLIBRARY='-L. -lpython$(VERSION)'
1266ee2a585SPedro Giffuni 	  RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
1270a45483eSPedro Giffuni-	  case $ac_sys_system in
1280a45483eSPedro Giffuni-	      FreeBSD*)
1290a45483eSPedro Giffuni-		SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
1300a45483eSPedro Giffuni-		;;
1310a45483eSPedro Giffuni-	  esac
1320a45483eSPedro Giffuni 	  INSTSONAME="$LDLIBRARY".$SOVERSION
1330a45483eSPedro Giffuni 	  ;;
1340a45483eSPedro Giffuni     hp*|HP*)
135