Patch #657889: Implement posix.getloadavg.
diff --git a/Doc/lib/libos.tex b/Doc/lib/libos.tex
index 6674e88..2e0f8ae 100644
--- a/Doc/lib/libos.tex
+++ b/Doc/lib/libos.tex
@@ -1431,6 +1431,14 @@
 Availability: \UNIX.
 \end{datadesc}
 
+\begin{funcdesc}{getloadavg}{}
+Return the number of processes in the system run queue averaged over
+the last 1, 5, and 15 minutes or raises OSError if the load average
+was unobtainable.
+
+\versionadded{2.3}
+\end{funcdesc}
+
 \begin{funcdesc}{sysconf}{name}
 Return integer-valued system configuration values.
 If the configuration value specified by \var{name} isn't defined,
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index b8475af..1d8697e 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -7135,6 +7135,28 @@
 }
 #endif
 
+#ifdef HAVE_GETLOADAVG
+PyDoc_STRVAR(posix_getloadavg__doc__,
+"getloadavg() -> (float, float, float)\n\n\
+Return the number of processes in the system run queue averaged over\n\
+the last 1, 5, and 15 minutes or raises OSError if the load average\n\
+was unobtainable");
+
+static PyObject *
+posix_getloadavg(PyObject *self, PyObject *args)
+{
+    double loadavg[3];
+    if (!PyArg_ParseTuple(args, ":getloadavg"))
+        return NULL;
+    if (getloadavg(loadavg, 3)!=3) {
+        PyErr_SetString(PyExc_OSError, "Load averages are unobtainable");
+        return NULL;
+    } else
+        return Py_BuildValue("ddd", loadavg[0], loadavg[1], loadavg[2]);
+}
+#endif
+
+
 static PyMethodDef posix_methods[] = {
 	{"access",	posix_access, METH_VARARGS, posix_access__doc__},
 #ifdef HAVE_TTYNAME
@@ -7409,6 +7431,9 @@
 #ifdef MS_WINDOWS
 	{"_getfullpathname",	posix__getfullpathname, METH_VARARGS, NULL},
 #endif
+#ifdef HAVE_GETLOADAVG
+	{"getloadavg",	posix_getloadavg, METH_VARARGS, posix_getloadavg__doc__},
+#endif
 	{NULL,		NULL}		 /* Sentinel */
 };
 
diff --git a/configure b/configure
index 0103ba1..207eddf 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.377 .
+# From configure.in Revision: 1.378 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.53 for python 2.3.
 #
@@ -12009,9 +12009,11 @@
 
 
 
+
 for ac_func in alarm chown clock confstr ctermid execv \
  fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \
- gai_strerror getgroups getlogin getpeername getpgid getpid getpwent getwd \
+ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
+ getpriority getpwent getwd \
  hstrerror inet_pton kill killpg lchown lstat mkfifo mknod mktime \
  mremap nice pathconf pause plock poll pthread_init \
  putenv readlink \
@@ -12019,7 +12021,7 @@
  setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
  sigaction siginterrupt sigrelse strftime strptime \
  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
- truncate uname unsetenv utimes waitpid wcscoll _getpty getpriority
+ truncate uname unsetenv utimes waitpid wcscoll _getpty
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
diff --git a/configure.in b/configure.in
index b6a266d..b4bbdb6 100644
--- a/configure.in
+++ b/configure.in
@@ -1762,7 +1762,8 @@
 # checks for library functions
 AC_CHECK_FUNCS(alarm chown clock confstr ctermid execv \
  fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \
- gai_strerror getgroups getlogin getpeername getpgid getpid getpwent getwd \
+ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
+ getpriority getpwent getwd \
  hstrerror inet_pton kill killpg lchown lstat mkfifo mknod mktime \
  mremap nice pathconf pause plock poll pthread_init \
  putenv readlink \
@@ -1770,7 +1771,7 @@
  setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
  sigaction siginterrupt sigrelse strftime strptime \
  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
- truncate uname unsetenv utimes waitpid wcscoll _getpty getpriority)
+ truncate uname unsetenv utimes waitpid wcscoll _getpty)
 
 # For some functions, having a definition is not sufficient, since
 # we want to take their address.
diff --git a/pyconfig.h.in b/pyconfig.h.in
index d63c36c..dd52efb 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -159,6 +159,9 @@
 /* Define this if you have the 6-arg version of gethostbyname_r(). */
 #undef HAVE_GETHOSTBYNAME_R_6_ARG
 
+/* Define to 1 if you have the `getloadavg' function. */
+#undef HAVE_GETLOADAVG
+
 /* Define to 1 if you have the `getlogin' function. */
 #undef HAVE_GETLOGIN