[Checkins] SVN: zc.FileStorage/dev/s Added an experimental extension to access posix_fadvise. This doesn't

Jim Fulton jim at zope.com
Tue Dec 4 12:35:49 EST 2007


Log message for revision 82121:
  Added an experimental extension to access posix_fadvise.  This doesn't
  seem to provide any benefit on my system. (Ubuntu Ubuntu 7.04, kernal
  2.6.20-16-lowlatency).  I'll try it on some other systems before
  ripping it out.
  

Changed:
  U   zc.FileStorage/dev/setup.py
  A   zc.FileStorage/dev/src/zc/FileStorage/_zc_FileStorage_posix_fadvise.c

-=-
Modified: zc.FileStorage/dev/setup.py
===================================================================
--- zc.FileStorage/dev/setup.py	2007-12-04 16:41:43 UTC (rev 82120)
+++ zc.FileStorage/dev/setup.py	2007-12-04 17:35:49 UTC (rev 82121)
@@ -1,4 +1,5 @@
 from setuptools import setup, find_packages
+from distutils.core import Extension
 
 name = 'zc.FileStorage'
 setup(
@@ -10,6 +11,10 @@
     license = 'ZPL 2.1',
 
     packages = find_packages('src'),
+    ext_modules=[
+        Extension('zc.FileStorage._zc_FileStorage_posix_fadvise',
+                  ['src/zc/FileStorage/_zc_FileStorage_posix_fadvise.c'])
+        ],
     namespace_packages = ['zc'],
     package_dir = {'': 'src'},
     install_requires = [

Added: zc.FileStorage/dev/src/zc/FileStorage/_zc_FileStorage_posix_fadvise.c
===================================================================
--- zc.FileStorage/dev/src/zc/FileStorage/_zc_FileStorage_posix_fadvise.c	                        (rev 0)
+++ zc.FileStorage/dev/src/zc/FileStorage/_zc_FileStorage_posix_fadvise.c	2007-12-04 17:35:49 UTC (rev 82121)
@@ -0,0 +1,59 @@
+/*###########################################################################
+ #
+ # Copyright (c) 2003 Zope Corporation and Contributors.
+ # All Rights Reserved.
+ #
+ # This software is subject to the provisions of the Zope Public License,
+ # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+ # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+ # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+ # FOR A PARTICULAR PURPOSE.
+ #
+ ############################################################################*/
+
+#include <fcntl.h>
+#include "Python.h"
+
+#define OBJECT(O) ((PyObject*)(O))
+
+static PyObject *
+py_posix_fadvise(PyObject *self, PyObject *args)
+{  
+  int fd, advice;
+  
+  if (! PyArg_ParseTuple(args, "ii", &fd, &advice))
+    return NULL; 
+  return PyInt_FromLong(posix_fadvise(fd, 0, 0, advice));
+}
+
+static struct PyMethodDef m_methods[] = {
+  {"advise", (PyCFunction)py_posix_fadvise, METH_VARARGS, ""},
+  
+  {NULL,	 (PyCFunction)NULL, 0, NULL}		/* sentinel */
+};
+
+
+#ifndef PyMODINIT_FUNC	/* declarations for DLL import/export */
+#define PyMODINIT_FUNC void
+#endif
+PyMODINIT_FUNC
+init_zc_FileStorage_posix_fadvise(void)
+{
+  PyObject *m;
+  
+  /* Create the module and add the functions */
+  m = Py_InitModule3("_zc_FileStorage_posix_fadvise", m_methods, "");
+  if (m == NULL)
+    return;
+  if (PyModule_AddObject(m, 
+                         "POSIX_FADV_SEQUENTIAL",
+                         OBJECT(PyInt_FromLong(POSIX_FADV_SEQUENTIAL))
+                         ) < 0)
+    return;
+  if (PyModule_AddObject(m, 
+                         "POSIX_FADV_NOREUSE",
+                         OBJECT(PyInt_FromLong(POSIX_FADV_NOREUSE))
+                         ) < 0)
+    return;
+}


Property changes on: zc.FileStorage/dev/src/zc/FileStorage/_zc_FileStorage_posix_fadvise.c
___________________________________________________________________
Name: svn:eol-style
   + native



More information about the Checkins mailing list