Commit 7820f82c authored by Mark Peek's avatar Mark Peek

Remove legacy system definitions and use Cython builtins instead

The system definitions included in the pyrex directory have been
migrated into Cython directly. The pyrex directory has been removed
and remaining files moved into coro.
parent c7ffb54b
......@@ -6,7 +6,7 @@ from cpython.ref cimport PyObject
from libc.stdint cimport intptr_t, uintptr_t, uint64_t
from libc.string cimport memcpy, memset
from posix.unistd cimport off_t
from xlibc.time cimport timeval
from posix.time cimport timeval
cdef extern from "Python.h":
......
......@@ -137,10 +137,10 @@ IF UNAME_SYSNAME == "FreeBSD":
cdef int get_sysctl_int (name) except? -1:
cdef int result
cdef size_t oldlen
oldlen = sizeof (result)
oldlen = sizeof (int)
if sysctlbyname (name, <void*>&result, &oldlen, NULL, 0) == -1:
raise_oserror()
elif oldlen != sizeof (result):
elif oldlen != sizeof (int):
raise SysctlError, "sizeof (sysctl(%s)) != sizeof(int)" % (name,)
else:
return result
......
......@@ -194,16 +194,23 @@ TODO
`relative_tsc_time`.
"""
include "python.pxi"
include "pyrex_helpers.pyx"
import time
from libc.stdint cimport uint64_t, int64_t, uint32_t
from libc.stddef cimport size_t
from libc.string cimport strlen
# cython does not have a libc/time.pxd yet
from xlibc cimport time
from libc cimport stdlib
from libc cimport time
from posix.time cimport gettimeofday, timeval
from cpython.float cimport *
from cpython.int cimport *
from cpython.long cimport *
from cpython.number cimport *
from cpython.string cimport *
from cpython.cobject cimport PyCObject_FromVoidPtr
from cpython.tuple cimport *
cdef extern from "rdtsc.h":
uint64_t _c_rdtsc "rdtsc" ()
......@@ -227,9 +234,9 @@ c_rdtsc = _c_rdtsc
cdef int64_t c_get_kernel_usec():
global emulation_offset_usec
cdef time.timeval tv_now
cdef timeval tv_now
time.gettimeofday(&tv_now, NULL)
gettimeofday(&tv_now, NULL)
return ((<int64_t>tv_now.tv_sec) * 1000000 + tv_now.tv_usec) + emulation_offset_usec
......@@ -446,7 +453,7 @@ def set_time(posix_timestamp):
current time. Pass in a value of 0 to disable emulation.
"""
global emulation_offset_usec, emulation_offset_tsc, c_rdtsc
cdef time.timeval tv_now
cdef timeval tv_now
cdef int64_t diff
if posix_timestamp == 0:
......@@ -454,7 +461,7 @@ def set_time(posix_timestamp):
emulation_offset_tsc = 0
c_rdtsc = _c_rdtsc
else:
time.gettimeofday(&tv_now, NULL)
gettimeofday(&tv_now, NULL)
diff = posix_timestamp - tv_now.tv_sec
emulation_offset_usec = diff * 1000000
......
......@@ -22,7 +22,7 @@
__event_queue_version__ = "$Id: event_queue.pyx,v 1.1 2007/01/03 00:19:50 ehuss Exp $"
include "python.pxi"
from cpython.ref cimport *
from cython.operator cimport dereference as deref, preincrement as inc
from libcpp.utility cimport pair
from libc.stdint cimport uint64_t
......
......@@ -31,7 +31,9 @@ __poller_version__ = "$Id"
from libc.stdint cimport uint64_t, uint32_t
from posix cimport unistd
from libc cimport errno
from xlibc.stdlib cimport alloca
cdef extern from "stdlib.h":
void * alloca (size_t size)
IF COMPILE_LINUX_AIO:
include "linux_aio.pyx"
......
......@@ -26,8 +26,6 @@ exceptions derive from OSError, so it is compatible with regular OSError
handling.
"""
include "python.pxi"
import errno
import new
import sys
......
......@@ -33,7 +33,8 @@ cdef extern from "sys/time.h":
unsigned int tv_sec
unsigned int tv_nsec
from xlibc.stdlib cimport alloca
cdef extern from "stdlib.h":
void * alloca (size_t size)
# XXX consider putting these into a pxd file
cdef extern from "sys/event.h":
......
......@@ -24,7 +24,6 @@
cdef object oserrors
from coro import oserrors
from xlibc cimport stdarg
from libc cimport string
from libc cimport errno
......@@ -43,9 +42,6 @@ bool = __builtin__.bool
cdef extern from "pyrex_helpers.h":
int va_int(stdarg.va_list)
char * va_charptr(stdarg.va_list)
object PySequence_Fast_GET_ITEM_SAFE (object, int)
object PyList_GET_ITEM_SAFE (object, int)
......
This directory contains a collection of generic Pyrex include files.
Do not put any pyrex modules in here.
Note: early in Shrapnel's history, we built our own 'libc.pxd' and 'python.pxi' files
that eventually made their way into the Pyrex/Cython distribution, and have since been
split into separate 'packages' (e.g., libc.string.memcpy). What remains here should
truly be either platform or shrapnel-specific.
This diff is collapsed.
This diff is collapsed.
The idea here is that the pxd files distributed with Cython are
missing some things. Since we expect/hope that they'll eventually
make it into the distribution, we want to ease the transition as much
as possible. To that end, 'xlibc.time' should eventually be fixed as
'libc.time'.
# -*- Mode: Cython -*-
cdef extern from "stdlib.h":
void * alloca (size_t size)
# -*- Mode: Cython -*-
cdef extern from "time.h":
ctypedef long time_t
ctypedef long suseconds_t
cdef struct tm:
int tm_sec
int tm_min
int tm_hour
int tm_mday
int tm_mon
int tm_year
int tm_wday
int tm_yday
int tm_isdst
char *tm_zone
long tm_gmtoff
char * ctime(time_t *clock)
tm * localtime(time_t *clock)
tm * gmtime(time_t *clock)
size_t strftime(char * buf, size_t maxsize, char * format, tm * timeptr)
time_t mktime(tm *)
cdef extern from "sys/time.h":
cdef struct timeval:
time_t tv_sec
suseconds_t tv_usec
cdef struct timezone:
int tz_minuteswest
int dsttime
int gettimeofday(timeval *tp, timezone *tzp)
......@@ -128,10 +128,8 @@ setup (
'coro.event_queue',
['coro/event_queue.pyx'],
language='c++',
depends=[os.path.join(include_dir, 'pyrex', 'python.pxi'), ],
pyrex_include_dirs=[
cython_include_dirs=[
os.path.join(include_dir, '.'),
os.path.join(include_dir, 'pyrex'),
],),
Extension (
'coro._coro',
......@@ -141,22 +139,18 @@ setup (
glob.glob('coro/*.pyx') +
glob.glob('coro/*.pxi') +
glob.glob('coro/*.pxd') + [
os.path.join(include_dir, 'pyrex', 'python.pxi'),
os.path.join(include_dir, 'pyrex', 'pyrex_helpers.pyx'),
os.path.join(include_dir, 'include', 'pyrex_helpers.h'),
os.path.join(include_dir, 'pyrex', 'tsc_time_include.pyx'),
os.path.join(include_dir, 'include', 'tsc_time.h'),
]
),
pyrex_include_dirs=[
cython_include_dirs=[
os.path.join(include_dir, '.'),
os.path.join(include_dir, 'pyrex'),
],
include_dirs=[
os.path.join(include_dir, '.'),
os.path.join(include_dir, 'include'),
],
pyrex_compile_time_env=compile_time_env,
cython_compile_time_env=compile_time_env,
# to enable LZO|LZ4 for stack compression, set COMPILE_LZO|COMPILE_LZ4 above
# and uncomment one of the following:
# libraries=['lzo2', 'z']
......@@ -176,7 +170,6 @@ setup (
Extension (
'coro.clocks.tsc_time',
['coro/clocks/tsc_time.pyx', ],
pyrex_include_dirs=[os.path.join(include_dir, 'pyrex')],
include_dirs=[
os.path.join(include_dir, '.'),
os.path.join(include_dir, 'include'),
......@@ -189,6 +182,6 @@ setup (
py_modules = ['backdoor', 'coro.read_stream', 'coro_process', 'coro_unittest', ],
scripts=['coro/log/catlog'],
download_url = 'https://pypi.python.org/pypi?name=coro',
install_requires = ['cython>=0.20.1', 'pycrypto'],
install_requires = ['cython>=0.22', 'pycrypto'],
cmdclass={'build_ext': build_ext},
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment