8000 bpo-45847: Port fcntl to Py_STDLIB_MOD (GH-29696) · python/cpython@5b946ca · GitHub
[go: up one dir, main page]

Skip to content

Commit 5b946ca

Browse files
Erlend Egeberg Aaslandtiran
Erlend Egeberg Aasland
andauthored
bpo-45847: Port fcntl to Py_STDLIB_MOD (GH-29696)
Co-authored-by: Christian Heimes <christian@python.org>
1 parent 29699a2 commit 5b946ca

File tree

5 files changed

+60
-28
lines changed

5 files changed

+60
-28
lines changed

Modules/Setup.stdlib.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
# Modules with some UNIX dependencies
8888
#
8989

90+
@MODULE_FCNTL_TRUE@fcntl fcntlmodule.c
9091
@MODULE_GRP_TRUE@grp grpmodule.c
9192
# needs sys/soundcard.h or linux/soundcard.h (Linux, FreeBSD)
9293
@MODULE_OSSAUDIODEV_TRUE@ossaudiodev ossaudiodev.c

configure

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,8 @@ MODULE_OSSAUDIODEV_FALSE
688688
MODULE_OSSAUDIODEV_TRUE
689689
MODULE_GRP_FALSE
690690
MODULE_GRP_TRUE
691+
MODULE_FCNTL_FALSE
692+
MODULE_FCNTL_TRUE
691693
MODULE__DATETIME_FALSE
692694
MODULE__DATETIME_TRUE
693695
MODULE_MATH_FALSE
@@ -13343,7 +13345,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1334313345
fi
1334413346
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_flock_decl" >&5
1334513347
$as_echo "$ac_cv_flock_decl" >&6; }
13346-
if test "x${ac_cv_flock_decl}" = xyes; then
13348+
if test "x$ac_cv_flock_decl" = xyes; then :
1334713349
for ac_func in flock
1334813350
do :
1334913351
ac_fn_c_check_func "$LINENO" "flock" "ac_cv_func_flock"
@@ -13352,7 +13354,9 @@ if test "x$ac_cv_func_flock" = xyes; then :
1335213354
#define HAVE_FLOCK 1
1335313355
_ACEOF
1335413356

13355-
else
13357+
fi
13358+
done
13359+
1335613360
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for flock in -lbsd" >&5
1335713361
$as_echo_n "checking for flock in -lbsd... " >&6; }
1335813362
if ${ac_cv_lib_bsd_flock+:} false; then :
@@ -13390,18 +13394,10 @@ fi
1339013394
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_flock" >&5
1339113395
$as_echo "$ac_cv_lib_bsd_flock" >&6; }
1339213396
if test "x$ac_cv_lib_bsd_flock" = xyes; then :
13393-
$as_echo "#define HAVE_FLOCK 1" >>confdefs.h
13394-
13395-
13396-
$as_echo "#define FLOCK_NEEDS_LIBBSD 1" >>confdefs.h
13397-
13398-
13397+
FCNTL_LIBS="-lbsd"
1339913398
fi
1340013399

1340113400

13402-
fi
13403-
done
13404-
1340513401
fi
1340613402

1340713403

@@ -19756,6 +19752,43 @@ fi
1975619752

1975719753

1975819754

19755+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module fcntl" >&5
19756+
$as_echo_n "checking for stdlib extension module fcntl... " >&6; }
19757+
case $py_stdlib_not_available in #(
19758+
*fcntl*) :
19759+
py_cv_module_fcntl=n/a ;; #(
19760+
*) :
19761+
if true; then :
19762+
if test "$ac_cv_header_sys_ioctl_h" = "yes" -a "$ac_cv_header_fcntl_h" = "yes"; then :
19763+
py_cv_module_fcntl=yes
19764+
else
19765+
py_cv_module_fcntl=missing
19766+
fi
19767+
else
19768+
py_cv_module_fcntl=disabled
19769+
fi
19770+
;;
19771+
esac
19772+
as_fn_append MODULE_BLOCK "MODULE_FCNTL=$py_cv_module_fcntl$as_nl"
19773+
if test "x$py_cv_module_fcntl" = xyes; then :
19774+
19775+
19776+
as_fn_append MODULE_BLOCK "MODULE_FCNTL_LDFLAGS=$FCNTL_LIBS$as_nl"
19777+
19778+
fi
19779+
if test "$py_cv_module_fcntl" = yes; then
19780+
MODULE_FCNTL_TRUE=
19781+
MODULE_FCNTL_FALSE='#'
19782+
else
19783+
MODULE_FCNTL_TRUE='#'
19784+
MODULE_FCNTL_FALSE=
19785+
fi
19786+
19787+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module_fcntl" >&5
19788+
$as_echo "$py_cv_module_fcntl" >&6; }
19789+
19790+
19791+
1975919792
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module grp" >&5
1976019793
$as_echo_n "checking for stdlib extension module grp... " >&6; }
1976119794
case $py_stdlib_not_available in #(
@@ -20892,6 +20925,10 @@ if test -z "${MODULE__DATETIME_TRUE}" && test -z "${MODULE__DATETIME_FALSE}"; th
2089220925
as_fn_error $? "conditional \"MODULE__DATETIME\" was never defined.
2089320926
Usually this means the macro was only i F438 nvoked conditionally." "$LINENO" 5
2089420927
fi
20928+
if test -z "${MODULE_FCNTL_TRUE}" && test -z "${MODULE_FCNTL_FALSE}"; then
20929+
as_fn_error $? "conditional \"MODULE_FCNTL\" was never defined.
20930+
Usually this means the macro was only invoked conditionally." "$LINENO" 5
20931+
fi
2089520932
if test -z "${MODULE_GRP_TRUE}" && test -z "${MODULE_GRP_FALSE}"; then
2089620933
as_fn_error $? "conditional \"MODULE_GRP\" was never defined.
2089720934
Usually this means the macro was only invoked conditionally." "$LINENO" 5

configure.ac

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3980,14 +3980,11 @@ AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
39803980
[ac_cv_flock_decl=no]
39813981
)
39823982
])
3983-
if test "x${ac_cv_flock_decl}" = xyes; then
3984-
AC_CHECK_FUNCS(flock,,
3985-
AC_CHECK_LIB(bsd,flock,
3986-
[AC_DEFINE(HAVE_FLOCK)
3987-
AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
3988-
])
3989-
)
3990-
fi
3983+
dnl Linking with libbsd may be necessary on AIX for flock function.
3984+
AS_VAR_IF([ac_cv_flock_decl], [yes],
3985+
AC_CHECK_FUNCS([flock])
3986+
AC_CHECK_LIB([bsd], [flock], [FCNTL_LIBS="-lbsd"])
3987+
)
39913988

39923989
PY_CHECK_FUNC([getpagesize], [#include <unistd.h>])
39933990

@@ -6095,6 +6092,11 @@ PY_STDLIB_MOD_SIMPLE([math], [], [$LIBM])
60956092
dnl needs libm and on some platforms librt
60966093
PY_STDLIB_MOD_SIMPLE([_datetime], [], [$TIMEMODULE_LIB $LIBM])
60976094

6095+
dnl needs libbsd on some platforms
6096+
PY_STDLIB_MOD([fcntl],
6097+
[], [test "$ac_cv_header_sys_ioctl_h" = "yes" -a "$ac_cv_header_fcntl_h" = "yes"],
6098+
[], [$FCNTL_LIBS])
6099+
60986100
dnl platform specific extensions
60996101
PY_STDLIB_MOD([grp], [], [test "$ac_cv_func_getgrgid" = yes -o "$ac_cv_func_getgrgid_r" = yes])
61006102
PY_STDLIB_MOD([ossaudiodev],

pyconfig.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151
significant word first */
5252
#undef FLOAT_WORDS_BIGENDIAN
5353

54-
/* Define if flock needs to be linked with bsd library. */
55-
#undef FLOCK_NEEDS_LIBBSD
56-
5754
/* Define if getpgrp() must be called as getpgrp(0). */
5855
#undef GETPGRP_HAVE_ARG
5956

setup.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,12 +1030,7 @@ def detect_simple_extensions(self):
10301030
# supported...)
10311031

10321032
# fcntl(2) and ioctl(2)
1033-
libs = []
1034-
if (self.config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)):
1035-
# May be necessary on AIX for flock function
1036-
libs = ['bsd']
1037-
self.add(Extension('fcntl', ['fcntlmodule.c'],
1038-
libraries=libs))
1033+
self.addext(Extension('fcntl', ['fcntlmodule.c']))
10391034
# grp(3)
10401035
self.addext(Extension('grp', ['grpmodule.c']))
10411036
self.addext(Extension('spwd', ['spwdmodule.c']))

0 commit comments

Comments
 (0)
0