From 66b60aebd4f94069136ee6af5e768ad586eb948f Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 26 Jan 2012 21:04:21 -0800 Subject: ntohl etc. --- src/library.js | 14 ++++++++++++++ tests/runner.py | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/library.js b/src/library.js index 5a429131..355a0c61 100644 --- a/src/library.js +++ b/src/library.js @@ -5714,6 +5714,20 @@ LibraryManager.library = { return 0; }, + // ========================================================================== + // arpa/inet.h + // ========================================================================== + + htonl: function(value) { + return ((value & 0xff) << 24) + ((value & 0xff00) << 8) + + ((value & 0xff0000) >> 8) + ((value & 0xff000000) >> 24); + }, + htons: function(value) { + return ((value & 0xff) << 8) + ((value & 0xff00) >> 8); + }, + ntohl: 'htonl', + ntohs: 'htons', + // ========================================================================== // emscripten.h // ========================================================================== diff --git a/tests/runner.py b/tests/runner.py index 126071a0..68ad6361 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -3837,6 +3837,18 @@ def process(filename): ''' self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected)) + def test_inet(self): + src = r''' + #include + #include + + int main() { + printf("*%x,%x,%x,%x*\n", htonl(0x12345678), htons(0xabcd), ntohl(0x43211234), ntohs(0xbeaf)); + return 0; + } + ''' + self.do_run(src, '*78563412,cdab,34122143,afbe*') + def test_ctype(self): # The bit fiddling done by the macros using __ctype_b_loc requires this. Settings.CORRECT_SIGNS = 1 -- cgit v1.2.3-18-g5258 From dc84a84b531b3d2b79709dbe89ee3e1d34b19d6d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 27 Jan 2012 12:01:19 -0800 Subject: remove autodebugger test concrete outputs, they differ on different machines --- tests/runner.py | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/tests/runner.py b/tests/runner.py index 97d3b6fb..4e260bf5 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -4457,27 +4457,7 @@ def process(filename): self.do_autodebug(filename) # Compare to each other, and to expected output - self.do_ll_run(path_from_root('tests', filename+'.o.ll.ll'), '''AD:-1,15 -AD:15,0 -AD:21,5 -AD:24,6 -AD:27,101 -AD:30,7009 -AD:37,5 -AD:40,10 -AD:45,7009 -AD:48,7008 -AD:54,7008 -AD:57,7018 -AD:60,10 -AD:63,6 -AD:66,101 -AD:69,7018 -AD:73,101 -AD:77,7018 -AD:81,101 -AD:85,7018 -*10,6,101,7018,101,7018,101,7018*''') + self.do_ll_run(path_from_root('tests', filename+'.o.ll.ll'), '''AD:-1,1''') assert open('stdout').read().startswith('AD:-1'), 'We must note when we enter functions' # Test using build_ll_hook @@ -4496,17 +4476,7 @@ AD:85,7018 return 0; } ''' - self.do_run(src, '''AD:-1,13 -AD:13,0 -AD:16,25 -AD:20,51 -AD:23,25 -AD:26,25 -AD:29,11.520000 -AD:31,25 -AD:33,51 -AD:36,11.520000 -*25,51,11.52*''', build_ll_hook=self.do_autodebug) + self.do_run(src, '''AD:-1,1''', build_ll_hook=self.do_autodebug) def test_profiling(self): src = ''' -- cgit v1.2.3-18-g5258