Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dbf9be7

Browse files
author
Erlend E. Aasland
committed
bpo-45847: Port fcntl to Py_STDLIB_MOD_SIMPLE
1 parent 39f7d2f commit dbf9be7

File tree

5 files changed

+64
-28
lines changed

5 files changed

+64
-28
lines changed

Modules/Setup.stdlib.in

+1
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

+51-11
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

@@ -19813,6 +19809,46 @@ fi
1981319809

1981419810

1981519811

19812+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module fcntl" >&5
19813+
$as_echo_n "checking for stdlib extension module fcntl... " >&6; }
19814+
case $py_stdlib_not_available in #(
19815+
*fcntl*) :
19816+
py_cv_module_fcntl=n/a ;; #(
19817+
*) :
19818+
19819+
if true; then :
19820+
if test "$ac_cv_header_sys_ioctl_h" = "yes" -a "$ac_cv_header_fcntl_h" = "yes"; then :
19821+
py_cv_module_fcntl=yes
19822+
else
19823+
py_cv_module_fcntl=missing
19824+
fi
19825+
else
19826+
py_cv_module_fcntl=disabled
19827+
19828+
fi
19829+
19830+
;;
19831+
esac
19832+
as_fn_append MODULE_BLOCK "MODULE_FCNTL=$py_cv_module_fcntl$as_nl"
19833+
if test "x$py_cv_module_fcntl" = xyes; then :
19834+
19835+
19836+
as_fn_append MODULE_BLOCK "MODULE_FCNTL_LDFLAGS=$FCNTL_LIBS$as_nl"
19837+
19838+
fi
19839+
if test "$py_cv_module_fcntl" = yes; then
19840+
MODULE_FCNTL_TRUE=
19841+
MODULE_FCNTL_FALSE='#'
19842+
else
19843+
MODULE_FCNTL_TRUE='#'
19844+
MODULE_FCNTL_FALSE=
19845+
fi
19846+
19847+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module_fcntl" >&5
19848+
$as_echo "$py_cv_module_fcntl" >&6; }
19849+
19850+
19851+
1981619852
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module grp" >&5
1981719853
$as_echo_n "checking for stdlib extension module grp... " >&6; }
1981819854
case $py_stdlib_not_available in #(
@@ -21045,6 +21081,10 @@ if test -z "${MODULE__DATETIME_TRUE}" && test -z "${MODULE__DATETIME_FALSE}"; th
2104521081
as_fn_error $? "conditional \"MODULE__DATETIME\" was never defined.
2104621082
Usually this means the macro was only invoked conditionally." "$LINENO" 5
2104721083
fi
21084+
if test -z "${MODULE_FCNTL_TRUE}" && test -z "${MODULE_FCNTL_FALSE}"; then
21085+
as_fn_error $? "conditional \"MODULE_FCNTL\" was never defined.
21086+
Usually this means the macro was only invoked conditionally." "$LINENO" 5
21087+
fi
2104821088
if test -z "${MODULE_GRP_TRUE}" && test -z "${MODULE_GRP_FALSE}"; then
2104921089
as_fn_error $? "conditional \"MODULE_GRP\" was never defined.
2105021090
Usually this means the macro was only invoked conditionally." "$LINENO" 5

configure.ac

+11-8
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

@@ -6097,6 +6094,12 @@ PY_STDLIB_MOD_SIMPLE([math], [], [$LIBM])
60976094
dnl needs libm and on some platforms librt
60986095
PY_STDLIB_MOD_SIMPLE([_datetime], [], [$TIMEMODULE_LIB $LIBM])
60996096

6097+
dnl needs libbsd on some platforms
6098+
PY_STDLIB_MOD([fcntl], [],
6099+
m4_flatten([test "$ac_cv_header_sys_ioctl_h" = "yes"
6100+
-a "$ac_cv_header_fcntl_h" = "yes"]),
6101+
[], [$FCNTL_LIBS])
6102+
61006103
dnl platform specific extensions
61016104
PY_STDLIB_MOD([grp], [], [test "$ac_cv_func_getgrgid" = yes -o "$ac_cv_func_getgrgid_r" = yes])
61026105
PY_STDLIB_MOD([ossaudiodev],

pyconfig.h.in

-3
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

+1-6
Original file line numberDiff line numberDiff line change
@@ -1032,12 +1032,7 @@ def detect_simple_extensions(self):
10321032
# supported...)
10331033

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

0 commit comments

Comments
 (0)