Skip to content
Snippets Groups Projects
Unverified Commit 6b2a29a6 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa Committed by GitHub
Browse files

Merge pull request #259 from jblazquez/master

Fix Windows build
parents 6508b36f 33be56e3
Branches
No related merge requests found
......@@ -45,19 +45,19 @@ uint64_t ngtcp2_get_uint48(const uint8_t *p) {
uint32_t ngtcp2_get_uint32(const uint8_t *p) {
uint32_t n;
memcpy(&n, p, 4);
return ntohl(n);
return ngtcp2_ntohl(n);
}
uint32_t ngtcp2_get_uint24(const uint8_t *p) {
uint32_t n = 0;
memcpy(((uint8_t *)&n) + 1, p, 3);
return ntohl(n);
return ngtcp2_ntohl(n);
}
uint16_t ngtcp2_get_uint16(const uint8_t *p) {
uint16_t n;
memcpy(&n, p, 2);
return ntohs(n);
return ngtcp2_ntohs(n);
}
uint64_t ngtcp2_get_varint(size_t *plen, const uint8_t *p) {
......@@ -76,11 +76,11 @@ uint64_t ngtcp2_get_varint(size_t *plen, const uint8_t *p) {
case 2:
memcpy(&n, p, 2);
n.b[0] &= 0x3f;
return ntohs(n.n16);
return ngtcp2_ntohs(n.n16);
case 4:
memcpy(&n, p, 4);
n.b[0] &= 0x3f;
return ntohl(n.n32);
return ngtcp2_ntohl(n.n32);
case 8:
memcpy(&n, p, 8);
n.b[0] &= 0x3f;
......@@ -116,17 +116,17 @@ uint8_t *ngtcp2_put_uint48be(uint8_t *p, uint64_t n) {
}
uint8_t *ngtcp2_put_uint32be(uint8_t *p, uint32_t n) {
n = htonl(n);
n = ngtcp2_htonl(n);
return ngtcp2_cpymem(p, (const uint8_t *)&n, sizeof(n));
}
uint8_t *ngtcp2_put_uint24be(uint8_t *p, uint32_t n) {
n = htonl(n);
n = ngtcp2_htonl(n);
return ngtcp2_cpymem(p, ((const uint8_t *)&n) + 1, 3);
}
uint8_t *ngtcp2_put_uint16be(uint8_t *p, uint16_t n) {
n = htons(n);
n = ngtcp2_htons(n);
return ngtcp2_cpymem(p, (const uint8_t *)&n, sizeof(n));
}
......
......@@ -82,7 +82,7 @@
# define STIN static inline
# endif
STIN uint32_t htonl(uint32_t hostlong) {
STIN uint32_t ngtcp2_htonl(uint32_t hostlong) {
uint32_t res;
unsigned char *p = (unsigned char *)&res;
*p++ = hostlong >> 24;
......@@ -92,7 +92,7 @@ STIN uint32_t htonl(uint32_t hostlong) {
return res;
}
STIN uint16_t htons(uint16_t hostshort) {
STIN uint16_t ngtcp2_htons(uint16_t hostshort) {
uint16_t res;
unsigned char *p = (unsigned char *)&res;
*p++ = hostshort >> 8;
......@@ -100,7 +100,7 @@ STIN uint16_t htons(uint16_t hostshort) {
return res;
}
STIN uint32_t ntohl(uint32_t netlong) {
STIN uint32_t ngtcp2_ntohl(uint32_t netlong) {
uint32_t res;
unsigned char *p = (unsigned char *)&netlong;
res = *p++ << 24;
......@@ -110,7 +110,7 @@ STIN uint32_t ntohl(uint32_t netlong) {
return res;
}
STIN uint16_t ntohs(uint16_t netshort) {
STIN uint16_t ngtcp2_ntohs(uint16_t netshort) {
uint16_t res;
unsigned char *p = (unsigned char *)&netshort;
res = *p++ << 8;
......@@ -118,6 +118,13 @@ STIN uint16_t ntohs(uint16_t netshort) {
return res;
}
#else /* WIN32 */
#define ngtcp2_htonl htonl
#define ngtcp2_htons htons
#define ngtcp2_ntohl ntohl
#define ngtcp2_ntohs ntohs
#endif /* WIN32 */
/*
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment