ia64/xen-unstable
changeset 13553:51ff40839470
[PYGRUB] Add python module for POSIX ptsname(2) function.
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author | Tim Deegan <Tim.Deegan@xensource.com> |
---|---|
date | Mon Jan 22 11:49:11 2007 +0000 (2007-01-22) |
parents | 6ce3b486f0d4 |
children | 5f998c3170f7 |
files | tools/Makefile tools/ptsname/Makefile tools/ptsname/ptsname.c tools/ptsname/setup.py |
line diff
1.1 --- a/tools/Makefile Mon Jan 22 11:49:05 2007 +0000 1.2 +++ b/tools/Makefile Mon Jan 22 11:49:11 2007 +0000 1.3 @@ -26,6 +26,7 @@ SUBDIRS-$(LIBXENAPI_BINDINGS) += libxen 1.4 ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH)) 1.5 SUBDIRS-y += python 1.6 SUBDIRS-y += pygrub 1.7 +SUBDIRS-y += ptsname 1.8 endif 1.9 1.10 .PHONY: all
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/tools/ptsname/Makefile Mon Jan 22 11:49:11 2007 +0000 2.3 @@ -0,0 +1,22 @@ 2.4 + 2.5 +XEN_ROOT = ../.. 2.6 +include $(XEN_ROOT)/tools/Rules.mk 2.7 + 2.8 +.PHONY: all 2.9 +all: build 2.10 +.PHONY: build 2.11 +build: 2.12 + CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py build 2.13 + 2.14 +.PHONY: install 2.15 +ifndef XEN_PYTHON_NATIVE_INSTALL 2.16 +install: all 2.17 + CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix="" 2.18 +else 2.19 +install: all 2.20 + CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" 2.21 +endif 2.22 + 2.23 +.PHONY: clean 2.24 +clean: 2.25 + rm -rf build tmp *.pyc *.pyo *.o *.a *~ a.out
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/tools/ptsname/ptsname.c Mon Jan 22 11:49:11 2007 +0000 3.3 @@ -0,0 +1,44 @@ 3.4 +/****************************************************************************** 3.5 + * ptsname.c 3.6 + * 3.7 + * A python extension to expose the POSIX ptsname() function. 3.8 + * 3.9 + * Copyright (C) 2007 XenSource Ltd 3.10 + */ 3.11 + 3.12 +#include <Python.h> 3.13 +#include <stdlib.h> 3.14 + 3.15 +/* Needed for Python versions earlier than 2.3. */ 3.16 +#ifndef PyMODINIT_FUNC 3.17 +#define PyMODINIT_FUNC DL_EXPORT(void) 3.18 +#endif 3.19 + 3.20 +static PyObject *do_ptsname(PyObject *self, PyObject *args) 3.21 +{ 3.22 + int fd; 3.23 + char *path; 3.24 + 3.25 + if (!PyArg_ParseTuple(args, "i", &fd)) 3.26 + return NULL; 3.27 + 3.28 + path = ptsname(fd); 3.29 + 3.30 + if (!path) 3.31 + { 3.32 + PyErr_SetFromErrno(PyExc_IOError); 3.33 + return NULL; 3.34 + } 3.35 + 3.36 + return PyString_FromString(path); 3.37 +} 3.38 + 3.39 +static PyMethodDef ptsname_methods[] = { 3.40 + { "ptsname", do_ptsname, METH_VARARGS }, 3.41 + { NULL } 3.42 +}; 3.43 + 3.44 +PyMODINIT_FUNC initptsname(void) 3.45 +{ 3.46 + Py_InitModule("ptsname", ptsname_methods); 3.47 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/tools/ptsname/setup.py Mon Jan 22 11:49:11 2007 +0000 4.3 @@ -0,0 +1,11 @@ 4.4 +from distutils.core import setup, Extension 4.5 + 4.6 +extra_compile_args = [ "-fno-strict-aliasing", "-Werror" ] 4.7 + 4.8 +setup(name = 'ptsname', 4.9 + version = '1.0', 4.10 + description = 'POSIX ptsname() function', 4.11 + author = 'Tim Deegan', 4.12 + author_email = 'Tim.Deegan@xensource.com', 4.13 + license = 'GPL', 4.14 + ext_modules = [ Extension("ptsname", [ "ptsname.c" ]) ])