]> granicus.if.org Git - python/commitdiff
Patch #650412: Check whether the address of flock and getpagesize
authorMartin v. Löwis <martin@v.loewis.de>
Sun, 30 Mar 2003 17:23:49 +0000 (17:23 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sun, 30 Mar 2003 17:23:49 +0000 (17:23 +0000)
can be taken, and use _SC_PAGE_SIZE if getpagesize is not available.

Modules/resource.c
configure
configure.in
pyconfig.h.in

index 003599d7420cb53120d50c46092aad9061479e49..e82df6d97627c04ba7f78004e6671b49497ec3d3 100644 (file)
@@ -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 */
index e7c64a0eed48545125a0d3c543f5fa9416c9dcec..a7c4a9d421a723883825c1a5a3581ce7c4bff0b6 100755 (executable)
--- a/configure
+++ b/configure
@@ -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`
 
@@ -12105,11 +12105,10 @@ 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`
 
index 437883870f8252278de310363ab6109c3e79e63b..5f455c127b59c0b3b957140663fb273fe50ddeba 100644 (file)
@@ -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" 
index 9d2447b146ce2b7062d535862c2bc70eeb008d1c..32d1c3ead91d285a5934552dc6eed74c28adc6cc 100644 (file)
 /* 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. */
 /* 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
 
 /* 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