Skip to content
File

Blob: src/workerd/api/crypto/endianness.h

cpp26 lines
1// Copyright (c) 2017-2025 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4 
5#pragma once
6#include <stdint.h>
7 
8// This file provides cross platform support for endianness conversions.
9// It is intended to hide away the polluting includes of system headers to provide the functions
10// without polluting the global namespace.
11 
12uint16_t htobe16(uint16_t x);
13uint16_t htole16(uint16_t x);
14uint16_t be16toh(uint16_t x);
15uint16_t le16toh(uint16_t x);
16 
17uint32_t htobe32(uint32_t x);
18uint32_t htole32(uint32_t x);
19uint32_t be32toh(uint32_t x);
20uint32_t le32toh(uint32_t x);
21 
22uint64_t htobe64(uint64_t x);
23uint64_t htole64(uint64_t x);
24uint64_t be64toh(uint64_t x);
25uint64_t le64toh(uint64_t x);