ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
platform.h
Go to the documentation of this file.
1#pragma once
2
15
16#include <stdint.h>
17
18#ifdef _WIN32
19#include <winsock2.h>
20#include <ws2tcpip.h>
21#else
22#include <netinet/in.h>
23#include <arpa/inet.h>
24#include <netdb.h>
25
26#endif
27
34#ifndef htonll
35#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
36#define htonll(x) (x)
37#define ntohll(x) (x)
38#elif defined(__GNUC__) || defined(__clang__)
39#define htonll(x) __builtin_bswap64(x)
40#define ntohll(x) __builtin_bswap64(x)
41#else
42static inline uint64_t htonll(uint64_t val) {
43 return ((val & 0x00000000000000FFULL) << 56) | ((val & 0x000000000000FF00ULL) << 40) | ((val & 0x0000000000FF0000ULL) << 24) | ((val & 0x00000000FF000000ULL) << 8) |
44 ((val & 0x000000FF00000000ULL) >> 8) | ((val & 0x0000FF0000000000ULL) >> 24) | ((val & 0x00FF000000000000ULL) >> 40) | ((val & 0xFF00000000000000ULL) >> 56);
45}
46#define ntohll(x) htonll(x)
47#endif
48#endif
49
unsigned long long uint64_t