From b502bc7a1a1f7038f9fc0fd8cd3c1e65d45ad694 Mon Sep 17 00:00:00 2001 From: Jesse Noller Date: Thu, 2 Apr 2009 02:32:55 +0000 Subject: [PATCH] Issue 3110: Additional protection for SEM_VALUE_MAX on platforms, thanks to Martin Loewis --- Misc/NEWS | 2 ++ Modules/_multiprocessing/multiprocessing.h | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index b1e90bfcec4..6bf6dcd6815 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -202,6 +202,8 @@ Core and Builtins Library ------- +- Issue #3110: Add additional protect around SEM_VALUE_MAX for multiprocessing + - In Pdb, prevent the reassignment of __builtin__._ by sys.displayhook on printing out values. diff --git a/Modules/_multiprocessing/multiprocessing.h b/Modules/_multiprocessing/multiprocessing.h index f6ab9946572..f8750d21540 100644 --- a/Modules/_multiprocessing/multiprocessing.h +++ b/Modules/_multiprocessing/multiprocessing.h @@ -45,13 +45,18 @@ * Issue 3110 - Solaris does not define SEM_VALUE_MAX */ #ifndef SEM_VALUE_MAX -# ifdef _SEM_VALUE_MAX -# define SEM_VALUE_MAX _SEM_VALUE_MAX -# else -# define SEM_VALUE_MAX INT_MAX -# endif + #if defined(HAVE_SYSCONF) && defined(_SC_SEM_VALUE_MAX) + # define SEM_VALUE_MAX sysconf(_SC_SEM_VALUE_MAX) + #elif defined(_SEM_VALUE_MAX) + # define SEM_VALUE_MAX _SEM_VALUE_MAX + #elif definef(_POSIX_SEM_VALUE_MAX) + # define SEM_VALUE_MAX _POSIX_SEM_VALUE_MAX + #else + # define SEM_VALUE_MAX INT_MAX + #endif #endif + /* * Make sure Py_ssize_t available */