Patch #650412: Check whether the address of flock and getpagesize

can be taken, and use _SC_PAGE_SIZE if getpagesize is not available.
This commit is contained in:
Martin v. Löwis 2003-03-30 17:23:49 +00:00
parent 852ba7eb2a
commit f26d63b3e1
4 changed files with 144 additions and 11 deletions

View File

@ -5,6 +5,10 @@
#include <sys/time.h> #include <sys/time.h>
#include <string.h> #include <string.h>
#include <errno.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 some systems, these aren't in any header file.
On others they are, with inconsistent prototypes. On others they are, with inconsistent prototypes.
@ -193,7 +197,15 @@ resource_getpagesize(PyObject *self, PyObject *args)
{ {
if (!PyArg_ParseTuple(args, ":getpagesize")) if (!PyArg_ParseTuple(args, ":getpagesize"))
return NULL; 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 */ /* List of functions */

111
configure vendored
View File

@ -1,5 +1,5 @@
#! /bin/sh #! /bin/sh
# From configure.in Revision: 1.397 . # From configure.in Revision: 1.398 .
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.53 for python 2.3. # 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 # Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
# absolute. # absolute.
ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` 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_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
@ -12105,11 +12105,10 @@ echo "${ECHO_T}MACHDEP_OBJS" >&6
for ac_func in alarm chown clock confstr ctermid execv \ 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 \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
getpriority getpwent getwd \ getpriority getpwent getwd \
hstrerror inet_aton inet_pton kill killpg lchown lstat mkfifo mknod mktime \ hstrerror inet_aton inet_pton kill killpg lchown lstat mkfifo mknod mktime \
@ -12396,6 +12395,108 @@ echo "${ECHO_T}no" >&6
fi fi
rm -f conftest.$ac_objext conftest.$ac_ext 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 "$as_me:$LINENO: checking for setgroups" >&5
echo $ECHO_N "checking for setgroups... $ECHO_C" >&6 echo $ECHO_N "checking for setgroups... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF 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 # Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
# absolute. # absolute.
ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` 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_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`

View File

@ -1849,7 +1849,7 @@ AC_MSG_RESULT(MACHDEP_OBJS)
# checks for library functions # checks for library functions
AC_CHECK_FUNCS(alarm chown clock confstr ctermid execv \ 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 \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
getpriority getpwent getwd \ getpriority getpwent getwd \
hstrerror inet_aton inet_pton kill killpg lchown lstat mkfifo mknod mktime \ 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_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_MSG_CHECKING(for setgroups)
AC_TRY_COMPILE([ AC_TRY_COMPILE([
#include "confdefs.h" #include "confdefs.h"

View File

@ -102,7 +102,7 @@
/* Define to 1 if you have the `fdatasync' function. */ /* Define to 1 if you have the `fdatasync' function. */
#undef HAVE_FDATASYNC #undef HAVE_FDATASYNC
/* Define to 1 if you have the `flock' function. */ /* Define if you have the 'flock' function. */
#undef HAVE_FLOCK #undef HAVE_FLOCK
/* Define to 1 if you have the `fork' function. */ /* Define to 1 if you have the `fork' function. */
@ -177,6 +177,9 @@
/* Define to 1 if you have the `getnameinfo' function. */ /* Define to 1 if you have the `getnameinfo' function. */
#undef HAVE_GETNAMEINFO #undef HAVE_GETNAMEINFO
/* Define if you have the 'getpagesize' function. */
#undef HAVE_GETPAGESIZE
/* Define to 1 if you have the `getpeername' function. */ /* Define to 1 if you have the `getpeername' function. */
#undef HAVE_GETPEERNAME #undef HAVE_GETPEERNAME
@ -682,9 +685,6 @@
/* Define if setpgrp() must be called as setpgrp(0, 0). */ /* Define if setpgrp() must be called as setpgrp(0, 0). */
#undef SETPGRP_HAVE_ARG #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 */ /* Define if i>>j for signed int i does not extend the sign bit when i < 0 */
#undef SIGNED_RIGHT_SHIFT_ZERO_FILLS #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS