mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	bpo-45847: Port fcntl to Py_STDLIB_MOD (GH-29696)
Co-authored-by: Christian Heimes <christian@python.org>
This commit is contained in:
		
							parent
							
								
									29699a2a2a
								
							
						
					
					
						commit
						5b946cadaa
					
				
					 5 changed files with 60 additions and 28 deletions
				
			
		|  | @ -87,6 +87,7 @@ | |||
| # Modules with some UNIX dependencies | ||||
| # | ||||
| 
 | ||||
| @MODULE_FCNTL_TRUE@fcntl fcntlmodule.c | ||||
| @MODULE_GRP_TRUE@grp grpmodule.c | ||||
| # needs sys/soundcard.h or linux/soundcard.h (Linux, FreeBSD) | ||||
| @MODULE_OSSAUDIODEV_TRUE@ossaudiodev ossaudiodev.c | ||||
|  |  | |||
							
								
								
									
										59
									
								
								configure
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										59
									
								
								configure
									
										
									
									
										vendored
									
									
								
							|  | @ -688,6 +688,8 @@ MODULE_OSSAUDIODEV_FALSE | |||
| MODULE_OSSAUDIODEV_TRUE | ||||
| MODULE_GRP_FALSE | ||||
| MODULE_GRP_TRUE | ||||
| MODULE_FCNTL_FALSE | ||||
| MODULE_FCNTL_TRUE | ||||
| MODULE__DATETIME_FALSE | ||||
| MODULE__DATETIME_TRUE | ||||
| MODULE_MATH_FALSE | ||||
|  | @ -13343,7 +13345,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext | |||
| fi | ||||
| { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_flock_decl" >&5 | ||||
| $as_echo "$ac_cv_flock_decl" >&6; } | ||||
| if test "x${ac_cv_flock_decl}" = xyes; then | ||||
| if test "x$ac_cv_flock_decl" = xyes; then : | ||||
|   for ac_func in flock | ||||
| do : | ||||
|   ac_fn_c_check_func "$LINENO" "flock" "ac_cv_func_flock" | ||||
|  | @ -13352,7 +13354,9 @@ if test "x$ac_cv_func_flock" = xyes; then : | |||
| #define HAVE_FLOCK 1 | ||||
| _ACEOF | ||||
| 
 | ||||
| else | ||||
| fi | ||||
| done | ||||
| 
 | ||||
|   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for flock in -lbsd" >&5 | ||||
| $as_echo_n "checking for flock in -lbsd... " >&6; } | ||||
| if ${ac_cv_lib_bsd_flock+:} false; then : | ||||
|  | @ -13390,18 +13394,10 @@ fi | |||
| { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_flock" >&5 | ||||
| $as_echo "$ac_cv_lib_bsd_flock" >&6; } | ||||
| if test "x$ac_cv_lib_bsd_flock" = xyes; then : | ||||
|   $as_echo "#define HAVE_FLOCK 1" >>confdefs.h | ||||
| 
 | ||||
| 
 | ||||
| $as_echo "#define FLOCK_NEEDS_LIBBSD 1" >>confdefs.h | ||||
| 
 | ||||
| 
 | ||||
|   FCNTL_LIBS="-lbsd" | ||||
| fi | ||||
| 
 | ||||
| 
 | ||||
| fi | ||||
| done | ||||
| 
 | ||||
| fi | ||||
| 
 | ||||
| 
 | ||||
|  | @ -19756,6 +19752,43 @@ fi | |||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module fcntl" >&5 | ||||
| $as_echo_n "checking for stdlib extension module fcntl... " >&6; } | ||||
|       case $py_stdlib_not_available in #( | ||||
|   *fcntl*) : | ||||
|     py_cv_module_fcntl=n/a ;; #( | ||||
|   *) : | ||||
|     if true; then : | ||||
|   if test "$ac_cv_header_sys_ioctl_h" = "yes" -a "$ac_cv_header_fcntl_h" = "yes"; then : | ||||
|   py_cv_module_fcntl=yes | ||||
| else | ||||
|   py_cv_module_fcntl=missing | ||||
| fi | ||||
| else | ||||
|   py_cv_module_fcntl=disabled | ||||
| fi | ||||
|    ;; | ||||
| esac | ||||
|   as_fn_append MODULE_BLOCK "MODULE_FCNTL=$py_cv_module_fcntl$as_nl" | ||||
|   if test "x$py_cv_module_fcntl" = xyes; then : | ||||
| 
 | ||||
| 
 | ||||
|     as_fn_append MODULE_BLOCK "MODULE_FCNTL_LDFLAGS=$FCNTL_LIBS$as_nl" | ||||
| 
 | ||||
| fi | ||||
|    if test "$py_cv_module_fcntl" = yes; then | ||||
|   MODULE_FCNTL_TRUE= | ||||
|   MODULE_FCNTL_FALSE='#' | ||||
| else | ||||
|   MODULE_FCNTL_TRUE='#' | ||||
|   MODULE_FCNTL_FALSE= | ||||
| fi | ||||
| 
 | ||||
|   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module_fcntl" >&5 | ||||
| $as_echo "$py_cv_module_fcntl" >&6; } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module grp" >&5 | ||||
| $as_echo_n "checking for stdlib extension module grp... " >&6; } | ||||
|       case $py_stdlib_not_available in #( | ||||
|  | @ -20892,6 +20925,10 @@ if test -z "${MODULE__DATETIME_TRUE}" && test -z "${MODULE__DATETIME_FALSE}"; th | |||
|   as_fn_error $? "conditional \"MODULE__DATETIME\" was never defined. | ||||
| Usually this means the macro was only invoked conditionally." "$LINENO" 5 | ||||
| fi | ||||
| if test -z "${MODULE_FCNTL_TRUE}" && test -z "${MODULE_FCNTL_FALSE}"; then | ||||
|   as_fn_error $? "conditional \"MODULE_FCNTL\" was never defined. | ||||
| Usually this means the macro was only invoked conditionally." "$LINENO" 5 | ||||
| fi | ||||
| if test -z "${MODULE_GRP_TRUE}" && test -z "${MODULE_GRP_FALSE}"; then | ||||
|   as_fn_error $? "conditional \"MODULE_GRP\" was never defined. | ||||
| Usually this means the macro was only invoked conditionally." "$LINENO" 5 | ||||
|  |  | |||
							
								
								
									
										18
									
								
								configure.ac
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								configure.ac
									
										
									
									
									
								
							|  | @ -3980,14 +3980,11 @@ AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl], | |||
|     [ac_cv_flock_decl=no] | ||||
|   ) | ||||
| ]) | ||||
| if test "x${ac_cv_flock_decl}" = xyes; then | ||||
|   AC_CHECK_FUNCS(flock,, | ||||
|     AC_CHECK_LIB(bsd,flock, | ||||
|       [AC_DEFINE(HAVE_FLOCK) | ||||
|        AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.) | ||||
|     ]) | ||||
|   ) | ||||
| fi | ||||
| dnl Linking with libbsd may be necessary on AIX for flock function. | ||||
| AS_VAR_IF([ac_cv_flock_decl], [yes], | ||||
|   AC_CHECK_FUNCS([flock]) | ||||
|   AC_CHECK_LIB([bsd], [flock], [FCNTL_LIBS="-lbsd"]) | ||||
| ) | ||||
| 
 | ||||
| PY_CHECK_FUNC([getpagesize], [#include <unistd.h>]) | ||||
| 
 | ||||
|  | @ -6095,6 +6092,11 @@ PY_STDLIB_MOD_SIMPLE([math], [], [$LIBM]) | |||
| dnl needs libm and on some platforms librt | ||||
| PY_STDLIB_MOD_SIMPLE([_datetime], [], [$TIMEMODULE_LIB $LIBM]) | ||||
| 
 | ||||
| dnl needs libbsd on some platforms | ||||
| PY_STDLIB_MOD([fcntl], | ||||
|   [], [test "$ac_cv_header_sys_ioctl_h" = "yes" -a "$ac_cv_header_fcntl_h" = "yes"], | ||||
|   [], [$FCNTL_LIBS]) | ||||
| 
 | ||||
| dnl platform specific extensions | ||||
| PY_STDLIB_MOD([grp], [], [test "$ac_cv_func_getgrgid" = yes -o "$ac_cv_func_getgrgid_r" = yes]) | ||||
| PY_STDLIB_MOD([ossaudiodev], | ||||
|  |  | |||
|  | @ -51,9 +51,6 @@ | |||
|    significant word first */ | ||||
| #undef FLOAT_WORDS_BIGENDIAN | ||||
| 
 | ||||
| /* Define if flock needs to be linked with bsd library. */ | ||||
| #undef FLOCK_NEEDS_LIBBSD | ||||
| 
 | ||||
| /* Define if getpgrp() must be called as getpgrp(0). */ | ||||
| #undef GETPGRP_HAVE_ARG | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										7
									
								
								setup.py
									
										
									
									
									
								
							
							
						
						
									
										7
									
								
								setup.py
									
										
									
									
									
								
							|  | @ -1030,12 +1030,7 @@ def detect_simple_extensions(self): | |||
|         # supported...) | ||||
| 
 | ||||
|         # fcntl(2) and ioctl(2) | ||||
|         libs = [] | ||||
|         if (self.config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)): | ||||
|             # May be necessary on AIX for flock function | ||||
|             libs = ['bsd'] | ||||
|         self.add(Extension('fcntl', ['fcntlmodule.c'], | ||||
|                            libraries=libs)) | ||||
|         self.addext(Extension('fcntl', ['fcntlmodule.c'])) | ||||
|         # grp(3) | ||||
|         self.addext(Extension('grp', ['grpmodule.c'])) | ||||
|         self.addext(Extension('spwd', ['spwdmodule.c'])) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Erlend Egeberg Aasland
						Erlend Egeberg Aasland