[pypy-svn] r42288 - in pypy/dist/pypy: rlib translator/c/src
afa at codespeak.net
afa at codespeak.net
Tue Apr 24 18:04:59 CEST 2007
Author: afa
Date: Tue Apr 24 18:04:59 2007
New Revision: 42288
Modified:
pypy/dist/pypy/rlib/_rsocket_ctypes.py
pypy/dist/pypy/translator/c/src/thread_nt.h
Log:
Finally managed to get rsocket translate on windows!
Ouf.
The resulting pypy-c.exe works on basic samples (SimpleHTTPServer)
Lots of hacks because:
- winsock functions have the __stdcall convention, so correct .h must be included
- 'in_addr' is passed by *value* to inet_ntoa, so the original name must be used
(conversion between unrelated pointers is a warning, but conversion between structs is an error)
- 'in6_addr' fields names are actually macros, so we cannot define its real contents.
pypy must declare it under another name.
All these problems belong to the task:
"- clean up the tangle of including headers in the C backend"
in pypy/doc/cleanup-todo.txt
In the end, some warnings during compilation, but no more than with Unix IMO.
Modified: pypy/dist/pypy/rlib/_rsocket_ctypes.py
==============================================================================
--- pypy/dist/pypy/rlib/_rsocket_ctypes.py (original)
+++ pypy/dist/pypy/rlib/_rsocket_ctypes.py Tue Apr 24 18:04:59 2007
@@ -273,6 +273,16 @@
pass
cConfig.__dict__.update(ctypes_platform.configure(CConfig))
+# HACK HACK HACK
+if _MS_WINDOWS:
+ from ctypes import Structure
+ for struct in cConfig.__dict__.values():
+ if isinstance(struct, type) and issubclass(struct, Structure):
+ if struct.__name__ == 'in6_addr':
+ struct.__name__ = '_in6_addr'
+ else:
+ struct._external_ = True # hack to avoid redeclaration of the struct in C
+
# fill in missing constants with reasonable defaults
cConfig.NI_MAXHOST = cConfig.NI_MAXHOST or 1025
cConfig.NI_MAXSERV = cConfig.NI_MAXSERV or 32
@@ -568,6 +578,7 @@
WSAStartup = socketdll.WSAStartup
WSAStartup.argtypes = [c_int, POINTER(WSAData)]
WSAStartup.restype = c_int
+ WSAStartup.libraries = ('ws2_32',)
WSAGetLastError = socketdll.WSAGetLastError
WSAGetLastError.argtypes = []
Modified: pypy/dist/pypy/translator/c/src/thread_nt.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/thread_nt.h (original)
+++ pypy/dist/pypy/translator/c/src/thread_nt.h Tue Apr 24 18:04:59 2007
@@ -6,7 +6,9 @@
/* Windows.h includes winsock.h, but the socket module needs */
/* winsock2.h. So I include it before. Ugly. */
+
#include <winsock2.h>
+#include <ws2tcpip.h>
#include <windows.h>
#include <limits.h>
More information about the Pypy-commit
mailing list