Mostly reformat. Also set an error and return NULL if neither MS_WINDOWS

nor UNIX is defined.  This may have caused problems on cygwin.
This commit is contained in:
Neal Norwitz 2008-01-27 07:36:03 +00:00
parent 3e1a373616
commit 448654f1f8
1 changed files with 14 additions and 16 deletions

View File

@ -532,23 +532,21 @@ mmap_flush_method(mmap_object *self, PyObject *args)
if ((size_t)(offset + size) > self->size) {
PyErr_SetString(PyExc_ValueError, "flush values out of range");
return NULL;
} else {
#ifdef MS_WINDOWS
return PyInt_FromLong((long)
FlushViewOfFile(self->data+offset, size));
#endif /* MS_WINDOWS */
#ifdef UNIX
/* XXX semantics of return value? */
/* XXX flags for msync? */
if (-1 == msync(self->data + offset, size,
MS_SYNC))
{
PyErr_SetFromErrno(mmap_module_error);
return NULL;
}
return PyInt_FromLong(0);
#endif /* UNIX */
}
#ifdef MS_WINDOWS
return PyInt_FromLong((long) FlushViewOfFile(self->data+offset, size));
#elif defined(UNIX)
/* XXX semantics of return value? */
/* XXX flags for msync? */
if (-1 == msync(self->data + offset, size, MS_SYNC)) {
PyErr_SetFromErrno(mmap_module_error);
return NULL;
}
return PyInt_FromLong(0);
#else
PyErr_SetString(PyExc_ValueError, "flush not supported on this system");
return NULL;
#endif
}
static PyObject *