[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [PYGRUB] Add python module for POSIX ptsname(2) function.



# HG changeset patch
# User Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>
# Date 1169466551 0
# Node ID 51ff4083947086bd48328698052b03421edb7c82
# Parent  6ce3b486f0d4ecdae6f6cd743137ca78beaa4af1
[PYGRUB] Add python module for POSIX ptsname(2) function.
Signed-off-by: Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>
---
 tools/Makefile          |    1 +
 tools/ptsname/Makefile  |   22 ++++++++++++++++++++++
 tools/ptsname/ptsname.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 tools/ptsname/setup.py  |   11 +++++++++++
 4 files changed, 78 insertions(+)

diff -r 6ce3b486f0d4 -r 51ff40839470 tools/Makefile
--- a/tools/Makefile    Mon Jan 22 11:49:05 2007 +0000
+++ b/tools/Makefile    Mon Jan 22 11:49:11 2007 +0000
@@ -26,6 +26,7 @@ ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_A
 ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
 SUBDIRS-y += python
 SUBDIRS-y += pygrub
+SUBDIRS-y += ptsname
 endif
 
 .PHONY: all
diff -r 6ce3b486f0d4 -r 51ff40839470 tools/ptsname/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/ptsname/Makefile    Mon Jan 22 11:49:11 2007 +0000
@@ -0,0 +1,22 @@
+
+XEN_ROOT = ../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+.PHONY: all
+all: build
+.PHONY: build
+build:
+       CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py build
+
+.PHONY: install
+ifndef XEN_PYTHON_NATIVE_INSTALL
+install: all
+       CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install 
--home="$(DESTDIR)/usr" --prefix=""
+else
+install: all
+       CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install 
--root="$(DESTDIR)"
+endif
+
+.PHONY: clean
+clean:
+       rm -rf build tmp *.pyc *.pyo *.o *.a *~ a.out
diff -r 6ce3b486f0d4 -r 51ff40839470 tools/ptsname/ptsname.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/ptsname/ptsname.c   Mon Jan 22 11:49:11 2007 +0000
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * ptsname.c
+ * 
+ * A python extension to expose the POSIX ptsname() function.
+ * 
+ * Copyright (C) 2007 XenSource Ltd
+ */
+
+#include <Python.h>
+#include <stdlib.h>
+
+/* Needed for Python versions earlier than 2.3. */
+#ifndef PyMODINIT_FUNC
+#define PyMODINIT_FUNC DL_EXPORT(void)
+#endif
+
+static PyObject *do_ptsname(PyObject *self, PyObject *args)
+{
+    int fd;
+    char *path;
+
+    if (!PyArg_ParseTuple(args, "i", &fd))
+        return NULL;
+
+    path = ptsname(fd);
+
+    if (!path)
+    {
+        PyErr_SetFromErrno(PyExc_IOError);
+        return NULL;
+    } 
+
+    return PyString_FromString(path);
+}
+
+static PyMethodDef ptsname_methods[] = { 
+    { "ptsname", do_ptsname, METH_VARARGS }, 
+    { NULL }
+};
+
+PyMODINIT_FUNC initptsname(void)
+{
+    Py_InitModule("ptsname", ptsname_methods);
+}
diff -r 6ce3b486f0d4 -r 51ff40839470 tools/ptsname/setup.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/ptsname/setup.py    Mon Jan 22 11:49:11 2007 +0000
@@ -0,0 +1,11 @@
+from distutils.core import setup, Extension
+
+extra_compile_args  = [ "-fno-strict-aliasing", "-Werror" ]
+
+setup(name         = 'ptsname',
+      version      = '1.0',
+      description  = 'POSIX ptsname() function',
+      author       = 'Tim Deegan',
+      author_email = 'Tim.Deegan@xxxxxxxxxxxxx',
+      license      = 'GPL',
+      ext_modules  = [ Extension("ptsname", [ "ptsname.c" ]) ])

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.