summaryrefslogtreecommitdiffstats
path: root/Modules/_multiprocessing
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2010-10-17 02:14:36 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2010-10-17 02:14:36 (GMT)
commit68e0135e4121b3e341aea7acf1cd017be74b50cf (patch)
tree07274405533df20a2d1337673d7c3a0602eae7c1 /Modules/_multiprocessing
parented7916dd001d5d49b5be04a745c2f83826b27fe2 (diff)
downloadcpython-68e0135e4121b3e341aea7acf1cd017be74b50cf.zip
cpython-68e0135e4121b3e341aea7acf1cd017be74b50cf.tar.gz
cpython-68e0135e4121b3e341aea7acf1cd017be74b50cf.tar.bz2
Fix multiprocessing Semaphore's on netbsd5. SEM_VALUE_MAX is defined
as (~0U) on NetBSD which was causing it to appear as -1 when used as a signed int for _multprocessing.SemLock.SEM_VALUE_MAX. This works around the problem by substituting INT_MAX on systems where it appears negative when used as an int.
Diffstat (limited to 'Modules/_multiprocessing')
-rw-r--r--Modules/_multiprocessing/multiprocessing.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/Modules/_multiprocessing/multiprocessing.c b/Modules/_multiprocessing/multiprocessing.c
index c584f2b..6858146 100644
--- a/Modules/_multiprocessing/multiprocessing.c
+++ b/Modules/_multiprocessing/multiprocessing.c
@@ -269,8 +269,19 @@ PyInit__multiprocessing(void)
if (PyType_Ready(&SemLockType) < 0)
return NULL;
Py_INCREF(&SemLockType);
- PyDict_SetItemString(SemLockType.tp_dict, "SEM_VALUE_MAX",
- Py_BuildValue("i", SEM_VALUE_MAX));
+ {
+ PyObject *py_sem_value_max;
+ /* Some systems define SEM_VALUE_MAX as an unsigned value that
+ * causes it to be negative when used as an int (NetBSD). */
+ if ((int)(SEM_VALUE_MAX) < 0)
+ py_sem_value_max = PyLong_FromLong(INT_MAX);
+ else
+ py_sem_value_max = PyLong_FromLong(SEM_VALUE_MAX);
+ if (py_sem_value_max == NULL)
+ return NULL;
+ PyDict_SetItemString(SemLockType.tp_dict, "SEM_VALUE_MAX",
+ py_sem_value_max);
+ }
PyModule_AddObject(module, "SemLock", (PyObject*)&SemLockType);
#endif