File
Blob: src/workerd/api/crypto/endianness.h
| 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 | |
| 12 | uint16_t htobe16(uint16_t x); |
| 13 | uint16_t htole16(uint16_t x); |
| 14 | uint16_t be16toh(uint16_t x); |
| 15 | uint16_t le16toh(uint16_t x); |
| 16 | |
| 17 | uint32_t htobe32(uint32_t x); |
| 18 | uint32_t htole32(uint32_t x); |
| 19 | uint32_t be32toh(uint32_t x); |
| 20 | uint32_t le32toh(uint32_t x); |
| 21 | |
| 22 | uint64_t htobe64(uint64_t x); |
| 23 | uint64_t htole64(uint64_t x); |
| 24 | uint64_t be64toh(uint64_t x); |
| 25 | uint64_t le64toh(uint64_t x); |