Skip to content

Commit aaf4222

Browse files
author
Erlend Egeberg Aasland
authored
bpo-45847: Port _multiprocessing to PY_STDLIB_MOD (GH-29768)
1 parent 46c8d91 commit aaf4222

File tree

4 files changed

+183
-159
lines changed

4 files changed

+183
-159
lines changed

Modules/Setup.stdlib.in

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124

125125
# multiprocessing
126126
@MODULE__POSIXSHMEM_TRUE@_posixshmem _multiprocessing/posixshmem.c
127+
@MODULE__MULTIPROCESSING_TRUE@_multiprocessing _multiprocessing/multiprocessing.c _multiprocessing/semaphore.c
127128

128129

129130
############################################################################

configure

+103-85
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,6 @@ MODULE_OSSAUDIODEV_FALSE
712712
MODULE_OSSAUDIODEV_TRUE
713713
MODULE_GRP_FALSE
714714
MODULE_GRP_TRUE
715-
MODULE__POSIXSHMEM_FALSE
716-
MODULE__POSIXSHMEM_TRUE
717715
MODULE_MMAP_FALSE
718716
MODULE_MMAP_TRUE
719717
MODULE_FCNTL_FALSE
@@ -728,6 +726,10 @@ MODULE__STATISTICS_FALSE
728726
MODULE__STATISTICS_TRUE
729727
MODULE_AUDIOOP_FALSE
730728
MODULE_AUDIOOP_TRUE
729+
MODULE__POSIXSHMEM_FALSE
730+
MODULE__POSIXSHMEM_TRUE
731+
MODULE__MULTIPROCESSING_FALSE
732+
MODULE__MULTIPROCESSING_TRUE
731733
MODULE__ZONEINFO_FALSE
732734
MODULE__ZONEINFO_TRUE
733735
MODULE__XXSUBINTERPRETERS_FALSE
@@ -17647,11 +17649,6 @@ done
1764717649

1764817650
LIBS=$LIBS_SAVE
1764917651

17650-
# For multiprocessing module, check that sem_open
17651-
# actually works. For FreeBSD versions <= 7.2,
17652-
# the kernel module that provides POSIX semaphores
17653-
# isn't loaded by default, so an attempt to call
17654-
# sem_open results in a 'Signal 12' error.
1765517652
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether POSIX semaphores are enabled" >&5
1765617653
$as_echo_n "checking whether POSIX semaphores are enabled... " >&6; }
1765717654
if ${ac_cv_posix_semaphores_enabled+:} false; then :
@@ -17663,22 +17660,24 @@ else
1766317660
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1766417661
/* end confdefs.h. */
1766517662

17666-
#include <unistd.h>
17667-
#include <fcntl.h>
17668-
#include <stdio.h>
17669-
#include <semaphore.h>
17670-
#include <sys/stat.h>
1767117663

17672-
int main(void) {
17673-
sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
17674-
if (a == SEM_FAILED) {
17675-
perror("sem_open");
17676-
return 1;
17677-
}
17678-
sem_close(a);
17679-
sem_unlink("/autoconf");
17680-
return 0;
17681-
}
17664+
#include <unistd.h>
17665+
#include <fcntl.h>
17666+
#include <stdio.h>
17667+
#include <semaphore.h>
17668+
#include <sys/stat.h>
17669+
17670+
int main(void) {
17671+
sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
17672+
if (a == SEM_FAILED) {
17673+
perror("sem_open");
17674+
return 1;
17675+
}
17676+
sem_close(a);
17677+
sem_unlink("/autoconf");
17678+
return 0;
17679+
}
17680+
1768217681

1768317682
_ACEOF
1768417683
if ac_fn_c_try_run "$LINENO"; then :
@@ -17694,14 +17693,14 @@ fi
1769417693
fi
1769517694
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_posix_semaphores_enabled" >&5
1769617695
$as_echo "$ac_cv_posix_semaphores_enabled" >&6; }
17697-
if test $ac_cv_posix_semaphores_enabled = no
17698-
then
17696+
if test "x$ac_cv_posix_semaphores_enabled" = xno; then :
17697+
1769917698

1770017699
$as_echo "#define POSIX_SEMAPHORES_NOT_ENABLED 1" >>confdefs.h
1770117700

17701+
1770217702
fi
1770317703

17704-
# Multiprocessing check for broken sem_getvalue
1770517704
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for broken sem_getvalue" >&5
1770617705
$as_echo_n "checking for broken sem_getvalue... " >&6; }
1770717706
if ${ac_cv_broken_sem_getvalue+:} false; then :
@@ -17713,26 +17712,28 @@ else
1771317712
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1771417713
/* end confdefs.h. */
1771517714

17716-
#include <unistd.h>
17717-
#include <fcntl.h>
17718-
#include <stdio.h>
17719-
#include <semaphore.h>
17720-
#include <sys/stat.h>
1772117715

17722-
int main(void){
17723-
sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
17724-
int count;
17725-
int res;
17726-
if(a==SEM_FAILED){
17727-
perror("sem_open");
17728-
return 1;
17716+
#include <unistd.h>
17717+
#include <fcntl.h>
17718+
#include <stdio.h>
17719+
#include <semaphore.h>
17720+
#include <sys/stat.h>
17721+
17722+
int main(void){
17723+
sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
17724+
int count;
17725+
int res;
17726+
if(a==SEM_FAILED){
17727+
perror("sem_open");
17728+
return 1;
17729+
17730+
}
17731+
res = sem_getvalue(a, &count);
17732+
sem_close(a);
17733+
sem_unlink("/autocftw");
17734+
return res==-1 ? 1 : 0;
17735+
}
1772917736

17730-
}
17731-
res = sem_getvalue(a, &count);
17732-
sem_close(a);
17733-
sem_unlink("/autocftw");
17734-
return res==-1 ? 1 : 0;
17735-
}
1773617737

1773717738
_ACEOF
1773817739
if ac_fn_c_try_run "$LINENO"; then :
@@ -17748,11 +17749,12 @@ fi
1774817749
fi
1774917750
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_broken_sem_getvalue" >&5
1775017751
$as_echo "$ac_cv_broken_sem_getvalue" >&6; }
17751-
if test $ac_cv_broken_sem_getvalue = yes
17752-
then
17752+
if test "x$ac_cv_broken_sem_getvalue" = xyes; then :
17753+
1775317754

1775417755
$as_echo "#define HAVE_BROKEN_SEM_GETVALUE 1" >>confdefs.h
1775517756

17757+
1775617758
fi
1775717759

1775817760
ac_fn_c_check_decl "$LINENO" "RTLD_LAZY" "ac_cv_have_decl_RTLD_LAZY" "#include <dlfcn.h>
@@ -21262,6 +21264,54 @@ fi
2126221264
as_fn_append MODULE_BLOCK "MODULE__ZONEINFO=yes$as_nl"
2126321265

2126421266

21267+
if true; then
21268+
MODULE__MULTIPROCESSING_TRUE=
21269+
MODULE__MULTIPROCESSING_FALSE='#'
21270+
else
21271+
MODULE__MULTIPROCESSING_TRUE='#'
21272+
MODULE__MULTIPROCESSING_FALSE=
21273+
fi
21274+
as_fn_append MODULE_BLOCK "MODULE__MULTIPROCESSING=yes$as_nl"
21275+
as_fn_append MODULE_BLOCK "MODULE__MULTIPROCESSING_CFLAGS=-I\$(srcdir)/Modules/_multiprocessing$as_nl"
21276+
21277+
21278+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _posixshmem" >&5
21279+
$as_echo_n "checking for stdlib extension module _posixshmem... " >&6; }
21280+
case $py_stdlib_not_available in #(
21281+
*_posixshmem*) :
21282+
py_cv_module__posixshmem=n/a ;; #(
21283+
*) :
21284+
if true; then :
21285+
if test "$have_posix_shmem" = "yes"; then :
21286+
py_cv_module__posixshmem=yes
21287+
else
21288+
py_cv_module__posixshmem=missing
21289+
fi
21290+
else
21291+
py_cv_module__posixshmem=disabled
21292+
fi
21293+
;;
21294+
esac
21295+
as_fn_append MODULE_BLOCK "MODULE__POSIXSHMEM=$py_cv_module__posixshmem$as_nl"
21296+
if test "x$py_cv_module__posixshmem" = xyes; then :
21297+
21298+
as_fn_append MODULE_BLOCK "MODULE__POSIXSHMEM_CFLAGS=$POSIXSHMEM_CFLAGS$as_nl"
21299+
as_fn_append MODULE_BLOCK "MODULE__POSIXSHMEM_LDFLAGS=$POSIXSHMEM_LIBS$as_nl"
21300+
21301+
fi
21302+
if test "$py_cv_module__posixshmem" = yes; then
21303+
MODULE__POSIXSHMEM_TRUE=
21304+
MODULE__POSIXSHMEM_FALSE='#'
21305+
else
21306+
MODULE__POSIXSHMEM_TRUE='#'
21307+
MODULE__POSIXSHMEM_FALSE=
21308+
fi
21309+
21310+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module__posixshmem" >&5
21311+
$as_echo "$py_cv_module__posixshmem" >&6; }
21312+
21313+
21314+
2126521315
if true; then
2126621316
MODULE_AUDIOOP_TRUE=
2126721317
MODULE_AUDIOOP_FALSE='#'
@@ -21391,42 +21441,6 @@ fi
2139121441
$as_echo "$py_cv_module_mmap" >&6; }
2139221442

2139321443

21394-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _posixshmem" >&5
21395-
$as_echo_n "checking for stdlib extension module _posixshmem... " >&6; }
21396-
case $py_stdlib_not_available in #(
21397-
*_posixshmem*) :
21398-
py_cv_module__posixshmem=n/a ;; #(
21399-
*) :
21400-
if true; then :
21401-
if test "$have_posix_shmem" = "yes"; then :
21402-
py_cv_module__posixshmem=yes
21403-
else
21404-
py_cv_module__posixshmem=missing
21405-
fi
21406-
else
21407-
py_cv_module__posixshmem=disabled
21408-
fi
21409-
;;
21410-
esac
21411-
as_fn_append MODULE_BLOCK "MODULE__POSIXSHMEM=$py_cv_module__posixshmem$as_nl"
21412-
if test "x$py_cv_module__posixshmem" = xyes; then :
21413-
21414-
as_fn_append MODULE_BLOCK "MODULE__POSIXSHMEM_CFLAGS=$POSIXSHMEM_CFLAGS$as_nl"
21415-
as_fn_append MODULE_BLOCK "MODULE__POSIXSHMEM_LDFLAGS=$POSIXSHMEM_LIBS$as_nl"
21416-
21417-
fi
21418-
if test "$py_cv_module__posixshmem" = yes; then
21419-
MODULE__POSIXSHMEM_TRUE=
21420-
MODULE__POSIXSHMEM_FALSE='#'
21421-
else
21422-
MODULE__POSIXSHMEM_TRUE='#'
21423-
MODULE__POSIXSHMEM_FALSE=
21424-
fi
21425-
21426-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module__posixshmem" >&5
21427-
$as_echo "$py_cv_module__posixshmem" >&6; }
21428-
21429-
2143021444

2143121445
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module grp" >&5
2143221446
$as_echo_n "checking for stdlib extension module grp... " >&6; }
@@ -22984,6 +22998,14 @@ if test -z "${MODULE__ZONEINFO_TRUE}" && test -z "${MODULE__ZONEINFO_FALSE}"; th
2298422998
as_fn_error $? "conditional \"MODULE__ZONEINFO\" was never defined.
2298522999
Usually this means the macro was only invoked conditionally." "$LINENO" 5
2298623000
fi
23001+
if test -z "${MODULE__MULTIPROCESSING_TRUE}" && test -z "${MODULE__MULTIPROCESSING_FALSE}"; then
23002+
as_fn_error $? "conditional \"MODULE__MULTIPROCESSING\" was never defined.
23003+
Usually this means the macro was only invoked conditionally." "$LINENO" 5
23004+
fi
23005+
if test -z "${MODULE__POSIXSHMEM_TRUE}" && test -z "${MODULE__POSIXSHMEM_FALSE}"; then
23006+
as_fn_error $? "conditional \"MODULE__POSIXSHMEM\" was never defined.
23007+
Usually this means the macro was only invoked conditionally." "$LINENO" 5
23008+
fi
2298723009
if test -z "${MODULE_AUDIOOP_TRUE}" && test -z "${MODULE_AUDIOOP_FALSE}"; then
2298823010
as_fn_error $? "conditional \"MODULE_AUDIOOP\" was never defined.
2298923011
Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -23012,10 +23034,6 @@ if test -z "${MODULE_MMAP_TRUE}" && test -z "${MODULE_MMAP_FALSE}"; then
2301223034
as_fn_error $? "conditional \"MODULE_MMAP\" was never defined.
2301323035
Usually this means the macro was only invoked conditionally." "$LINENO" 5
2301423036
fi
23015-
if test -z "${MODULE__POSIXSHMEM_TRUE}" && test -z "${MODULE__POSIXSHMEM_FALSE}"; then
23016-
as_fn_error $? "conditional \"MODULE__POSIXSHMEM\" was never defined.
23017-
Usually this means the macro was only invoked conditionally." "$LINENO" 5
23018-
fi
2301923037
if test -z "${MODULE_GRP_TRUE}" && test -z "${MODULE_GRP_FALSE}"; then
2302023038
as_fn_error $? "conditional \"MODULE_GRP\" was never defined.
2302123039
Usually this means the macro was only invoked conditionally." "$LINENO" 5

0 commit comments

Comments
 (0)