mirror of
https://github.com/qicosmos/rest_rpc.git
synced 2026-08-29 08:34:47 +08:00
add for mac
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#endif
|
||||
|
||||
namespace rest_rpc::detail {
|
||||
#ifndef htonll
|
||||
inline uint64_t htonll(uint64_t value) {
|
||||
return ((uint64_t)htonl(value & 0xFFFFFFFF) << 32) | htonl(value >> 32);
|
||||
}
|
||||
@@ -14,9 +15,9 @@ inline uint64_t htonll(uint64_t value) {
|
||||
inline uint64_t ntohll(uint64_t value) {
|
||||
return ((uint64_t)ntohl(value & 0xFFFFFFFF) << 32) | ntohl(value >> 32);
|
||||
}
|
||||
#endif
|
||||
} // namespace rest_rpc::detail
|
||||
|
||||
|
||||
namespace rest_rpc {
|
||||
inline constexpr uint8_t REST_MAGIC_NUM = 39;
|
||||
struct rest_rpc_header {
|
||||
@@ -31,16 +32,18 @@ struct rest_rpc_header {
|
||||
};
|
||||
|
||||
inline void prepare_for_send(rest_rpc_header &header) {
|
||||
using namespace detail;
|
||||
header.function_id = htonl(header.function_id);
|
||||
header.seq_num = detail::htonll(header.seq_num);
|
||||
header.body_len = detail::htonll(header.body_len);
|
||||
header.attach_length = detail::htonll(header.attach_length);
|
||||
header.seq_num = htonll(header.seq_num);
|
||||
header.body_len = htonll(header.body_len);
|
||||
header.attach_length = htonll(header.attach_length);
|
||||
}
|
||||
|
||||
inline void parse_recieved(rest_rpc_header &header) {
|
||||
using namespace detail;
|
||||
header.function_id = ntohl(header.function_id);
|
||||
header.seq_num = detail::ntohll(header.seq_num);
|
||||
header.body_len = detail::ntohll(header.body_len);
|
||||
header.attach_length = detail::ntohll(header.attach_length);
|
||||
header.seq_num = ntohll(header.seq_num);
|
||||
header.body_len = ntohll(header.body_len);
|
||||
header.attach_length = ntohll(header.attach_length);
|
||||
}
|
||||
} // namespace rest_rpc
|
||||
Reference in New Issue
Block a user