[pypy-svn] r15358 - in pypy/dist/pypy: module/posix translator/c translator/c/src translator/c/test
cfbolz at codespeak.net
cfbolz at codespeak.net
Fri Jul 29 17:37:05 CEST 2005
Author: cfbolz
Date: Fri Jul 29 17:37:02 2005
New Revision: 15358
Modified:
pypy/dist/pypy/module/posix/__init__.py
pypy/dist/pypy/translator/c/extfunc.py
pypy/dist/pypy/translator/c/src/ll_os.h
pypy/dist/pypy/translator/c/test/test_extfunc.py
Log:
added some more constants to our posix module
added external function implementation for os.lseek
tests as well
Modified: pypy/dist/pypy/module/posix/__init__.py
==============================================================================
--- pypy/dist/pypy/module/posix/__init__.py (original)
+++ pypy/dist/pypy/module/posix/__init__.py Fri Jul 29 17:37:02 2005
@@ -35,7 +35,7 @@
'O_DIRECTORY', 'O_DSYNC', 'O_EXCL', 'O_LARGEFILE', 'O_NDELAY',
'O_NOCTTY', 'O_NOFOLLOW', 'O_NONBLOCK', 'O_RDONLY', 'O_RDWR',
'O_RSYNC', 'O_SYNC', 'O_TRUNC', 'O_WRONLY', 'R_OK', 'TMP_MAX',
- 'W_OK', 'X_OK']:
+ 'WCONTINUED', 'WNOHANG', 'WUNTRACED', 'W_OK', 'X_OK']:
try:
Module.interpleveldefs[constant] = ("space.wrap(%s)" %
(getattr(os, constant), ))
Modified: pypy/dist/pypy/translator/c/extfunc.py
==============================================================================
--- pypy/dist/pypy/translator/c/extfunc.py (original)
+++ pypy/dist/pypy/translator/c/extfunc.py Fri Jul 29 17:37:02 2005
@@ -16,6 +16,7 @@
ll_os .ll_os_getcwd: 'LL_os_getcwd',
ll_os .ll_os_stat: 'LL_os_stat',
ll_os .ll_os_fstat: 'LL_os_fstat',
+ ll_os .ll_os_lseek: 'LL_os_lseek',
ll_time.ll_time_clock: 'LL_time_clock',
ll_math.ll_math_frexp: 'LL_math_frexp',
ll_math.ll_math_atan2: 'LL_math_atan2',
Modified: pypy/dist/pypy/translator/c/src/ll_os.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/ll_os.h (original)
+++ pypy/dist/pypy/translator/c/src/ll_os.h Fri Jul 29 17:37:02 2005
@@ -132,3 +132,26 @@
return _stat_construct_result_helper(st);
}
+long LL_os_lseek(long fd, long pos, long how) {
+#if defined(MS_WIN64) || defined(MS_WINDOWS)
+ PY_LONG_LONG res;
+#else
+ off_t res;
+#endif
+#ifdef SEEK_SET
+ /* Turn 0, 1, 2 into SEEK_{SET,CUR,END} */
+ switch (how) {
+ case 0: how = SEEK_SET; break;
+ case 1: how = SEEK_CUR; break;
+ case 2: how = SEEK_END; break;
+ }
+#endif /* SEEK_END */
+#if defined(MS_WIN64) || defined(MS_WINDOWS)
+ res = _lseeki64(fd, pos, how);
+#else
+ res = lseek(fd, pos, how);
+#endif
+ if (res < 0)
+ RAISE_OSERROR(errno);
+ return res;
+}
Modified: pypy/dist/pypy/translator/c/test/test_extfunc.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_extfunc.py (original)
+++ pypy/dist/pypy/translator/c/test/test_extfunc.py Fri Jul 29 17:37:02 2005
@@ -37,7 +37,7 @@
py.test.raises(OSError, f1)
assert not os.path.exists(tmpfile)
-def test_open_read_write_close():
+def test_open_read_write_seek_close():
filename = str(udir.join('test_open_read_write_close.txt'))
def does_stuff():
fd = os.open(filename, os.O_WRONLY | os.O_CREAT, 0777)
@@ -45,8 +45,10 @@
assert count == len("hello world\n")
os.close(fd)
fd = os.open(filename, os.O_RDONLY, 0777)
+ result = os.lseek(fd, 1, 0)
+ assert result == 1
data = os.read(fd, 500)
- assert data == "hello world\n"
+ assert data == "ello world\n"
os.close(fd)
f1 = compile(does_stuff, [])
More information about the Pypy-commit
mailing list