Add htons/htonl definitions and implementations
authorjsbell@chromium.org <jsbell@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Oct 2012 00:31:24 +0000 (00:31 +0000)
committerjsbell@chromium.org <jsbell@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Oct 2012 00:31:24 +0000 (00:31 +0000)
commit1b300018e249e29e45a30f68c64bf33a6c84e7b6
tree336f34bf7ff12e5dee88f3070648f5805a695b91
parent605620a6f9460e928d063290e48acf8a0f7910c8
Add htons/htonl definitions and implementations
https://bugs.webkit.org/show_bug.cgi?id=98054

Reviewed by Darin Adler.

Source/WebCore:

Update users of htons and friends to use new wtf/ByteOrder.h header.

No new tests - just refactoring.

* platform/graphics/WOFFFileFormat.cpp:
* platform/graphics/chromium/VDMXParser.cpp:

Source/WTF:

For parsing or serializing binary data, byte order matters. The canonical htons/htonl/
ntohs/ntohl functions are not present everywhere, so implementations are proliferating in
parsers. Expose a new WTF header (wtf/ByteOrder.h) that includes the standard
implementations on UNIX-like OSs and provides basic inlined implementations on Windows.

* GNUmakefile.list.am:
* WTF.gypi:
* WTF.pro:
* WTF.vcproj/WTF.vcproj:
* WTF.xcodeproj/project.pbxproj:
* wtf/ByteOrder.h: Added.
(WTF::wswap32): Inline functions so arguments are only evaluated once.
(WTF::bswap32):
(WTF::bswap16):
(ntohs): Inline functions on OS(WINDOWS) to match macros on OS(UNIX)
(htons):
(ntohl):
(htonl):
* wtf/CMakeLists.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130238 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/GNUmakefile.list.am
Source/WTF/WTF.gypi
Source/WTF/WTF.pro
Source/WTF/WTF.vcproj/WTF.vcproj
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/ByteOrder.h [new file with mode: 0644]
Source/WTF/wtf/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/WOFFFileFormat.cpp
Source/WebCore/platform/graphics/chromium/VDMXParser.cpp