Author: Amaury Forgeot d'Arc <[email protected]>
Branch: kill_ll_termios
Changeset: r75279:42c4131556e2
Date: 2015-01-10 00:33 +0100
http://bitbucket.org/pypy/pypy/changeset/42c4131556e2/
Log: Move all other functions. ll_termios is now empty.
diff --git a/rpython/rlib/rtermios.py b/rpython/rlib/rtermios.py
--- a/rpython/rlib/rtermios.py
+++ b/rpython/rlib/rtermios.py
@@ -17,15 +17,23 @@
class CConfig:
_compilation_info_ = eci
NCCS = rffi_platform.DefinedConstantInteger('NCCS')
- TCSANOW = rffi_platform.ConstantInteger('TCSANOW')
_HAVE_STRUCT_TERMIOS_C_ISPEED = rffi_platform.Defined(
'_HAVE_STRUCT_TERMIOS_C_ISPEED')
_HAVE_STRUCT_TERMIOS_C_OSPEED = rffi_platform.Defined(
'_HAVE_STRUCT_TERMIOS_C_OSPEED')
+ TCSANOW = rffi_platform.ConstantInteger('TCSANOW')
+ TCIOFLUSH = rffi_platform.ConstantInteger('TCIOFLUSH')
+ TCOON = rffi_platform.ConstantInteger('TCOON')
+
+
+
c_config = rffi_platform.configure(CConfig)
NCCS = c_config['NCCS']
+
TCSANOW = c_config['TCSANOW']
+TCIOFLUSH = c_config['TCIOFLUSH']
+TCOON = c_config['TCOON']
TCFLAG_T = rffi.UINT
CC_T = rffi.UCHAR
@@ -51,6 +59,11 @@
c_cfsetispeed = c_external('cfsetispeed', [TERMIOSP, SPEED_T], rffi.INT)
c_cfsetospeed = c_external('cfsetospeed', [TERMIOSP, SPEED_T], rffi.INT)
+c_tcsendbreak = c_external('tcsendbreak', [rffi.INT, rffi.INT], rffi.INT)
+c_tcdrain = c_external('tcdrain', [rffi.INT], rffi.INT)
+c_tcflush = c_external('tcflush', [rffi.INT, rffi.INT], rffi.INT)
+c_tcflow = c_external('tcflow', [rffi.INT, rffi.INT], rffi.INT)
+
def tcgetattr(fd):
with lltype.scoped_alloc(TERMIOSP.TO) as c_struct:
@@ -84,3 +97,19 @@
raise OSError(rposix.get_errno(), 'tcsetattr failed')
if c_tcsetattr(fd, when, c_struct) < 0:
raise OSError(rposix.get_errno(), 'tcsetattr failed')
+
+def tcsendbreak(fd, duration):
+ if c_tcsendbreak(fd, duration) < 0:
+ raise OSError(rposix.get_errno(), 'tcsendbreak failed')
+
+def tcdrain(fd):
+ if c_tcdrain(fd) < 0:
+ raise OSError(rposix.get_errno(), 'tcdrain failed')
+
+def tcflush(fd, queue_selector):
+ if c_tcflush(fd, queue_selector) < 0:
+ raise OSError(rposix.get_errno(), 'tcflush failed')
+
+def tcflow(fd, action):
+ if c_tcflow(fd, action) < 0:
+ raise OSError(rposix.get_errno(), 'tcflow failed')
diff --git a/rpython/rtyper/module/ll_termios.py
b/rpython/rtyper/module/ll_termios.py
--- a/rpython/rtyper/module/ll_termios.py
+++ b/rpython/rtyper/module/ll_termios.py
@@ -50,34 +50,6 @@
def c_external(name, args, result):
return rffi.llexternal(name, args, result, compilation_info=eci)
-c_tcsendbreak = c_external('tcsendbreak', [INT, INT], INT)
-c_tcdrain = c_external('tcdrain', [INT], INT)
-c_tcflush = c_external('tcflush', [INT, INT], INT)
-c_tcflow = c_external('tcflow', [INT, INT], INT)
# a bit C-c C-v code follows...
-def tcsendbreak_llimpl(fd, duration):
- if c_tcsendbreak(fd, duration):
- raise OSError(rposix.get_errno(), 'tcsendbreak failed')
-register_external(termios.tcsendbreak, [int, int],
- llimpl=tcsendbreak_llimpl,
- export_name='termios.tcsendbreak')
-
-def tcdrain_llimpl(fd):
- if c_tcdrain(fd) < 0:
- raise OSError(rposix.get_errno(), 'tcdrain failed')
-register_external(termios.tcdrain, [int], llimpl=tcdrain_llimpl,
- export_name='termios.tcdrain')
-
-def tcflush_llimpl(fd, queue_selector):
- if c_tcflush(fd, queue_selector) < 0:
- raise OSError(rposix.get_errno(), 'tcflush failed')
-register_external(termios.tcflush, [int, int], llimpl=tcflush_llimpl,
- export_name='termios.tcflush')
-
-def tcflow_llimpl(fd, action):
- if c_tcflow(fd, action) < 0:
- raise OSError(rposix.get_errno(), 'tcflow failed')
-register_external(termios.tcflow, [int, int], llimpl=tcflow_llimpl,
- export_name='termios.tcflow')
diff --git a/rpython/rtyper/module/test/test_ll_termios.py
b/rpython/rtyper/module/test/test_ll_termios.py
--- a/rpython/rtyper/module/test/test_ll_termios.py
+++ b/rpython/rtyper/module/test/test_ll_termios.py
@@ -78,12 +78,12 @@
def test_tcrest(self):
from rpython.translator.c.test.test_genc import compile
from rpython.rtyper.module import ll_termios
- import termios, time
+ from rpython.rlib import rtermios
def runs_tcall():
- termios.tcsendbreak(2, 0)
- termios.tcdrain(2)
- termios.tcflush(2, termios.TCIOFLUSH)
- termios.tcflow(2, termios.TCOON)
+ rtermios.tcsendbreak(2, 0)
+ rtermios.tcdrain(2)
+ rtermios.tcflush(2, rtermios.TCIOFLUSH)
+ rtermios.tcflow(2, rtermios.TCOON)
print "ok"
fn = compile(runs_tcall, [], backendopt=False)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit