ntohl etc.
This commit is contained in:
Родитель
01e21e5412
Коммит
66b60aebd4
|
@ -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
|
||||
// ==========================================================================
|
||||
|
|
|
@ -3837,6 +3837,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
|
||||
|
|
Загрузка…
Ссылка в новой задаче