Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
0f621581
Unverified
Commit
0f621581
authored
Sep 04, 2018
by
Ge Jun
Committed by
GitHub
Sep 04, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #478 from gtlbupt/master
issue#346 move #include out of namespace butil
parents
b72be50f
c805fd58
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
sys_byteorder.h
src/butil/sys_byteorder.h
+9
-4
No files found.
src/butil/sys_byteorder.h
View file @
0f621581
...
...
@@ -20,23 +20,28 @@
#include <arpa/inet.h>
#endif
#if defined(COMPILER_MSVC)
#include <stdlib.h> // for _byteswap_*
#elif defined(OS_MACOSX)
// Mac OS X / Darwin features
#include <libkern/OSByteOrder.h> // for OSSwapInt*
#elif defined(OS_LINUX)
#include <byteswap.h> // for bswap_*
#endif
namespace
butil
{
#if defined(COMPILER_MSVC)
#include <stdlib.h>
inline
uint16_t
ByteSwap
(
uint16_t
x
)
{
return
_byteswap_ushort
(
x
);
}
inline
uint32_t
ByteSwap
(
uint32_t
x
)
{
return
_byteswap_ulong
(
x
);
}
inline
uint64_t
ByteSwap
(
uint64_t
x
)
{
return
_byteswap_uint64
(
x
);
}
#elif defined(OS_MACOSX)
// Mac OS X / Darwin features
#include <libkern/OSByteOrder.h>
inline
uint16_t
ByteSwap
(
uint16_t
x
)
{
return
OSSwapInt16
(
x
);
}
inline
uint32_t
ByteSwap
(
uint32_t
x
)
{
return
OSSwapInt32
(
x
);
}
inline
uint64_t
ByteSwap
(
uint64_t
x
)
{
return
OSSwapInt64
(
x
);
}
#elif defined(OS_LINUX)
#include <byteswap.h>
inline
uint16_t
ByteSwap
(
uint16_t
x
)
{
return
bswap_16
(
x
);
}
inline
uint32_t
ByteSwap
(
uint32_t
x
)
{
return
bswap_32
(
x
);
}
inline
uint64_t
ByteSwap
(
uint64_t
x
)
{
return
bswap_64
(
x
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment