diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2003-03-30 17:23:49 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2003-03-30 17:23:49 (GMT) |
commit | f26d63b3e19bf57e93010ec4a0a5af1a87e3bcef (patch) | |
tree | 574b19e53c61179b25770b35107ba34162198982 | |
parent | 852ba7eb2a38a4d57cea73bf34b11f8e65f004e1 (diff) | |
download | cpython-f26d63b3e19bf57e93010ec4a0a5af1a87e3bcef.zip cpython-f26d63b3e19bf57e93010ec4a0a5af1a87e3bcef.tar.gz cpython-f26d63b3e19bf57e93010ec4a0a5af1a87e3bcef.tar.bz2 |
Patch #650412: Check whether the address of flock and getpagesize
can be taken, and use _SC_PAGE_SIZE if getpagesize is not available.
-rw-r--r-- | Modules/resource.c | 14 | ||||
-rwxr-xr-x | configure | 111 | ||||
-rw-r--r-- | configure.in | 22 | ||||
-rw-r--r-- | pyconfig.h.in | 8 |
4 files changed, 144 insertions, 11 deletions
diff --git a/Modules/resource.c b/Modules/resource.c index 003599d..e82df6d 100644 --- a/Modules/resource.c +++ b/Modules/resource.c @@ -5,6 +5,10 @@ #include <sys/time.h> #include <string.h> #include <errno.h> +/* for sysconf */ +#if defined(HAVE_UNISTD_H) +#include <unistd.h> +#endif /* On some systems, these aren't in any header file. On others they are, with inconsistent prototypes. @@ -193,7 +197,15 @@ resource_getpagesize(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, ":getpagesize")) return NULL; - return Py_BuildValue("i", getpagesize()); + + long pagesize = 0; +#if defined(HAVE_GETPAGESIZE) + pagesize = getpagesize(); +#elif defined(HAVE_SYSCONF) + pagesize = sysconf(_SC_PAGE_SIZE); +#endif + return Py_BuildValue("i", pagesize); + } /* List of functions */ @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.397 . +# From configure.in Revision: 1.398 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53 for python 2.3. # @@ -908,7 +908,7 @@ esac # Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be # absolute. ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` -ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` @@ -12107,9 +12107,8 @@ echo "${ECHO_T}MACHDEP_OBJS" >&6 - for ac_func in alarm chown clock confstr ctermid execv \ - fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \ + fchdir fork fsync fdatasync fpathconf ftime ftruncate \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ getpriority getpwent getwd \ hstrerror inet_aton inet_pton kill killpg lchown lstat mkfifo mknod mktime \ @@ -12396,6 +12395,108 @@ echo "${ECHO_T}no" >&6 fi rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: checking for flock" >&5 +echo $ECHO_N "checking for flock... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +#include "confdefs.h" +#include <sys/file.h> + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +void* p = flock + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_FLOCK 1 +_ACEOF + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext + +echo "$as_me:$LINENO: checking for getpagesize" >&5 +echo $ECHO_N "checking for getpagesize... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +#include "confdefs.h" +#include <unistd.h> + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +void* p = getpagesize + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_GETPAGESIZE 1 +_ACEOF + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext + echo "$as_me:$LINENO: checking for setgroups" >&5 echo $ECHO_N "checking for setgroups... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF @@ -17722,7 +17823,7 @@ esac # Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be # absolute. ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` -ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` diff --git a/configure.in b/configure.in index 4378838..5f455c1 100644 --- a/configure.in +++ b/configure.in @@ -1849,7 +1849,7 @@ AC_MSG_RESULT(MACHDEP_OBJS) # checks for library functions AC_CHECK_FUNCS(alarm chown clock confstr ctermid execv \ - fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \ + fchdir fork fsync fdatasync fpathconf ftime ftruncate \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ getpriority getpwent getwd \ hstrerror inet_aton inet_pton kill killpg lchown lstat mkfifo mknod mktime \ @@ -1898,6 +1898,26 @@ AC_TRY_COMPILE([ AC_MSG_RESULT(no) ) +AC_MSG_CHECKING(for flock) +AC_TRY_COMPILE([ +#include "confdefs.h" +#include <sys/file.h> +], void* p = flock, + AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.) + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no) +) + +AC_MSG_CHECKING(for getpagesize) +AC_TRY_COMPILE([ +#include "confdefs.h" +#include <unistd.h> +], void* p = getpagesize, + AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.) + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no) +) + AC_MSG_CHECKING(for setgroups) AC_TRY_COMPILE([ #include "confdefs.h" diff --git a/pyconfig.h.in b/pyconfig.h.in index 9d2447b..32d1c3e 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -102,7 +102,7 @@ /* Define to 1 if you have the `fdatasync' function. */ #undef HAVE_FDATASYNC -/* Define to 1 if you have the `flock' function. */ +/* Define if you have the 'flock' function. */ #undef HAVE_FLOCK /* Define to 1 if you have the `fork' function. */ @@ -177,6 +177,9 @@ /* Define to 1 if you have the `getnameinfo' function. */ #undef HAVE_GETNAMEINFO +/* Define if you have the 'getpagesize' function. */ +#undef HAVE_GETPAGESIZE + /* Define to 1 if you have the `getpeername' function. */ #undef HAVE_GETPEERNAME @@ -682,9 +685,6 @@ /* Define if setpgrp() must be called as setpgrp(0, 0). */ #undef SETPGRP_HAVE_ARG -/* Define to 1 if the `setpgrp' function takes no argument. */ -#undef SETPGRP_VOID - /* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS |