summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-01-06 18:44:57 (GMT)
committerGuido van Rossum <guido@python.org>1999-01-06 18:44:57 (GMT)
commit763737be528ed41d62d056afe616435b83622418 (patch)
tree10b0b128e955497210c78d00defd1d420b6be47c /Modules
parent056bad993c835a59c0fad07b2e569dd17ea03544 (diff)
downloadcpython-763737be528ed41d62d056afe616435b83622418.zip
cpython-763737be528ed41d62d056afe616435b83622418.tar.gz
cpython-763737be528ed41d62d056afe616435b83622418.tar.bz2
Changes for long file support by Steve Clift.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/resource.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/Modules/resource.c b/Modules/resource.c
index ab3f676..4e1c2b1 100644
--- a/Modules/resource.c
+++ b/Modules/resource.c
@@ -120,7 +120,15 @@ resource_getrlimit(self, args)
PyErr_SetFromErrno(ResourceError);
return NULL;
}
- return Py_BuildValue("ii", rl.rlim_cur, rl.rlim_max);
+
+#if defined(HAVE_LONG_LONG)
+ if (sizeof(rl.rlim_cur) > sizeof(long)) {
+ return Py_BuildValue("LL",
+ (LONG_LONG) rl.rlim_cur,
+ (LONG_LONG) rl.rlim_max);
+ }
+#endif
+ return Py_BuildValue("ii", (long) rl.rlim_cur, (long) rl.rlim_max);
}
static PyObject *
@@ -130,9 +138,9 @@ resource_setrlimit(self, args)
{
struct rlimit rl;
int resource;
+ PyObject *curobj, *maxobj;
- if (!PyArg_ParseTuple(args, "i(ii)", &resource, &rl.rlim_cur,
- &rl.rlim_max))
+ if (!PyArg_ParseTuple(args, "i(OO)", &resource, &curobj, &maxobj))
return NULL;
if (resource < 0 || resource >= RLIM_NLIMITS) {
@@ -141,6 +149,17 @@ resource_setrlimit(self, args)
return NULL;
}
+#if !defined(HAVE_LARGEFILE_SUPPORT)
+ rl.rlim_cur = PyInt_AsLong(curobj);
+ rl.rlim_max = PyInt_AsLong(maxobj);
+#else
+ /* The limits are probably bigger than a long */
+ rl.rlim_cur = PyLong_Check(curobj) ?
+ PyLong_AsLongLong(curobj) : PyInt_AsLong(curobj);
+ rl.rlim_max = PyLong_Check(maxobj) ?
+ PyLong_AsLongLong(maxobj) : PyInt_AsLong(maxobj);
+#endif
+
rl.rlim_cur = rl.rlim_cur & RLIM_INFINITY;
rl.rlim_max = rl.rlim_max & RLIM_INFINITY;
if (setrlimit(resource, &rl) == -1) {