diff options
author | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-01-28 14:28:51 -0500 |
---|---|---|
committer | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-01-28 14:28:51 -0500 |
commit | 426294bb1248945846a3265248484930dbded189 (patch) | |
tree | fb2679ed6fc2447a50531f9133b1b04cbd6f67b5 | |
parent | 1bbe851768ded820f7538fee5a8454a77c725517 (diff) | |
parent | dc84a84b531b3d2b79709dbe89ee3e1d34b19d6d (diff) |
Merge branch 'master' into glgears
-rw-r--r-- | src/library.js | 14 | ||||
-rwxr-xr-x | tests/runner.py | 46 |
2 files changed, 28 insertions, 32 deletions
diff --git a/src/library.js b/src/library.js index 89e52243..45c64bc7 100644 --- a/src/library.js +++ b/src/library.js @@ -5743,6 +5743,20 @@ LibraryManager.library = { }, // ========================================================================== + // 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 6e4054cb..f92793d4 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -3849,6 +3849,18 @@ def process(filename): ''' self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected)) + def test_inet(self): + src = r''' + #include <stdio.h> + #include <arpa/inet.h> + + 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 @@ -4457,27 +4469,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 +4488,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 = ''' |