Skip to content

Commit 09f8287

Browse files
committed
compat/endian: sync with GPUJPEG
ported changes from GPUJPEG, mostly cosmetic For Win32 implementation, winsock2 is not used at all - Windows stdlib.h contains _byteswap_* family so it is better to use these and not pull the whole winsock2.h header struff (and also the winsock library but this is irrelevannt for UG because we need to link with it unconditionally).
1 parent f3f7f58 commit 09f8287

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/compat/endian.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* required by POSIX 2024.
99
*/
1010
/*
11-
* Copyright (c) 2025 CESNET
11+
* Copyright (c) 2025 CESNET, zájmové sdružení právnických osob
1212
* All rights reserved.
1313
*
1414
* Redistribution and use in source and binary forms, with or without
@@ -40,8 +40,8 @@
4040
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4141
*/
4242

43-
#ifndef COMPAT_NET_H_A5D7C443_895D_465E_A46D_BF5E6DAA833F
44-
#define COMPAT_NET_H_A5D7C443_895D_465E_A46D_BF5E6DAA833F
43+
#ifndef COMPAT_ENDIAN_H_A5D7C443_895D_465E_A46D_BF5E6DAA833F
44+
#define COMPAT_ENDIAN_H_A5D7C443_895D_465E_A46D_BF5E6DAA833F
4545

4646
#ifdef __APPLE__
4747
// https://github.com/zeromq/zmqpp/issues/164#issuecomment-246346344
@@ -72,15 +72,15 @@
7272
defined(_M_ARM64) || \
7373
(defined(__BYTE_ORDER__) && \
7474
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
75-
#include<winsock2.h>
75+
#include <stdlib.h>
7676
#ifndef be16toh
77-
#define be16toh(x) ntohs(x)
78-
#define be32toh(x) ntohl(x)
79-
#define be64toh(x) ntohll(x)
77+
#define be16toh(x) _byteswap_ushort(x)
78+
#define be32toh(x) _byteswap_ulong(x)
79+
#define be64toh(x) _byteswap_uint64(x)
8080

81-
#define htobe16(x) htons(x)
82-
#define htobe32(x) htonl(x)
83-
#define htobe64(x) htonll(x)
81+
#define htobe16(x) _byteswap_ushort(x)
82+
#define htobe32(x) _byteswap_ulong(x)
83+
#define htobe64(x) _byteswap_uint64(x)
8484

8585
#define htole16(x) (x)
8686
#define htole32(x) (x)
@@ -103,4 +103,4 @@
103103
#include <endian.h>
104104
#endif
105105

106-
#endif // defined COMPAT_NET_H_A5D7C443_895D_465E_A46D_BF5E6DAA833F
106+
#endif // defined COMPAT_ENDIAN_H_A5D7C443_895D_465E_A46D_BF5E6DAA833F

0 commit comments

Comments
 (0)