Merge pull request #15799 from AspirinSJL/htonl

Add endianness conversion for long
reviewable/pr15196/r15
Juanli Shen 7 years ago committed by GitHub
commit c82cd7c5cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/core/lib/iomgr/socket_utils.h
  2. 4
      src/core/lib/iomgr/socket_utils_common_posix.cc
  3. 4
      src/core/lib/iomgr/socket_utils_uv.cc
  4. 4
      src/core/lib/iomgr/socket_utils_windows.cc

@ -23,12 +23,21 @@
#include <stddef.h>
// TODO(juanlishen): The following functions might be simple enough to implement
// ourselves, so that they don't cause any portability hassle.
/* A wrapper for htons on POSIX and Windows */
uint16_t grpc_htons(uint16_t hostshort);
/* A wrapper for ntohs on POSIX and WINDOWS */
uint16_t grpc_ntohs(uint16_t netshort);
/* A wrapper for htonl on POSIX and Windows */
uint32_t grpc_htonl(uint32_t hostlong);
/* A wrapper for ntohl on POSIX and WINDOWS */
uint32_t grpc_ntohl(uint32_t netlong);
/* A wrapper for inet_pton on POSIX and WINDOWS */
int grpc_inet_pton(int af, const char* src, void* dst);

@ -339,6 +339,10 @@ uint16_t grpc_htons(uint16_t hostshort) { return htons(hostshort); }
uint16_t grpc_ntohs(uint16_t netshort) { return ntohs(netshort); }
uint32_t grpc_htonl(uint32_t hostlong) { return htonl(hostlong); }
uint32_t grpc_ntohl(uint32_t netlong) { return ntohl(netlong); }
int grpc_inet_pton(int af, const char* src, void* dst) {
return inet_pton(af, src, dst);
}

@ -33,6 +33,10 @@ uint16_t grpc_htons(uint16_t hostshort) { return htons(hostshort); }
uint16_t grpc_ntohs(uint16_t netshort) { return ntohs(netshort); }
uint32_t grpc_htonl(uint32_t hostlong) { return htonl(hostlong); }
uint32_t grpc_ntohl(uint32_t netlong) { return ntohl(netlong); }
int grpc_inet_pton(int af, const char* src, void* dst) {
return inet_pton(af, src, dst);
}

@ -31,6 +31,10 @@ uint16_t grpc_htons(uint16_t hostshort) { return htons(hostshort); }
uint16_t grpc_ntohs(uint16_t netshort) { return ntohs(netshort); }
uint32_t grpc_htonl(uint32_t hostlong) { return htonl(hostlong); }
uint32_t grpc_ntohl(uint32_t netlong) { return ntohl(netlong); }
int grpc_inet_pton(int af, const char* src, void* dst) {
return inet_pton(af, src, dst);
}

Loading…
Cancel
Save