diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-08-31 15:46:10 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-08-31 15:46:10 -0700 |
commit | a96b03e9c1238fe37772e01e69c2e4f56ea36880 (patch) | |
tree | cc20fedfa8eec76b859e46a6fe11993ceca401b9 | |
parent | 52dae3e9b26dd8b4c6ce7989505c41532c090051 (diff) |
remove temporary enet fix, and define gethostbyname_r in a header, so that we can be sure at compilation time that it is used in the way it is expected to be (that function has more than one possible signature in various unixes)
-rw-r--r-- | src/library.js | 10 | ||||
-rw-r--r-- | system/include/netdb.h | 1 | ||||
-rw-r--r-- | tests/test_sockets.py | 2 |
3 files changed, 7 insertions, 6 deletions
diff --git a/src/library.js b/src/library.js index 2c60c8ba..f94bec13 100644 --- a/src/library.js +++ b/src/library.js @@ -7305,7 +7305,7 @@ LibraryManager.library = { name = Pointer_stringify(name); // generate hostent - var ret = _malloc(___hostent_struct_layout.__size__); + var ret = _malloc(___hostent_struct_layout.__size__); // XXX possibly leaked, as are others here var nameBuf = _malloc(name.length+1); writeStringToMemory(name, nameBuf); {{{ makeSetValue('ret', '___hostent_struct_layout.h_name', 'nameBuf', 'i8*') }}} @@ -7324,12 +7324,12 @@ LibraryManager.library = { }, gethostbyname_r__deps: ['gethostbyname'], - gethostbyname_r: function(name, hostData, buffer, bufferSize, hostEntry, errnum) { + gethostbyname_r: function(name, ret, buf, buflen, err) { var data = _gethostbyname(name); - _memcpy(hostData, data, ___hostent_struct_layout.__size__); + _memcpy(ret, data, ___hostent_struct_layout.__size__); _free(data); - {{{ makeSetValue('errnum', '0', '0', 'i32') }}} - return 0; + {{{ makeSetValue('err', '0', '0', 'i32') }}}; + return ret; }, getaddrinfo__deps: ['$Sockets', '$DNS', '_addrinfo_layout', '_inet_pton4_raw', '_inet_ntop4_raw', '_inet_pton6_raw', '_inet_ntop6_raw', '_write_sockaddr', 'htonl'], diff --git a/system/include/netdb.h b/system/include/netdb.h index df74a117..fa71f58f 100644 --- a/system/include/netdb.h +++ b/system/include/netdb.h @@ -101,6 +101,7 @@ struct hostent struct hostent* gethostbyaddr(const void* addr, socklen_t len, int type); struct hostent* gethostbyname(const char* name); +struct hostent* gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, int *err); // XXX not quite standard, see http://linux.die.net/man/3/gethostbyname_r void sethostent(int stayopen); void endhostent(void); void herror(const char* s); diff --git a/tests/test_sockets.py b/tests/test_sockets.py index c19b9d5d..d2bc46a2 100644 --- a/tests/test_sockets.py +++ b/tests/test_sockets.py @@ -297,7 +297,7 @@ class sockets(BrowserCore): pwd = os.getcwd() os.chdir(self.in_dir('enet')) Popen([PYTHON, path_from_root('emconfigure'), './configure']).communicate() - Popen([PYTHON, path_from_root('emmake'), 'make', 'CFLAGS=-UHAS_GETHOSTBYADDR_R -UHAS_GETHOSTBYNAME_R']).communicate() + Popen([PYTHON, path_from_root('emmake'), 'make']).communicate() enet = [self.in_dir('enet', '.libs', 'libenet.a'), '-I'+path_from_root('tests', 'enet', 'include')] os.chdir(pwd) |