File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626endif
2727headers = [
2828 ' nvme/accessors.h' ,
29+ ' nvme/endian.h' ,
2930 ' nvme/filters.h' ,
3031 ' nvme/ioctl.h' ,
3132 ' nvme/lib-types.h' ,
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: LGPL-2.1-or-later
2+ /*
3+ * This file is part of libnvme.
4+ * Copyright (c) 2026 SUSE Software Solutions
5+ *
6+ * Authors: Daniel Wagner <[email protected] > 7+ */
8+
9+ #pragma once
10+
11+ #if defined(_WIN32 ) || defined(_WIN64 )
12+ #if defined(__BYTE_ORDER__ ) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
13+ #define htobe16 (x ) (x)
14+ #define htobe32 (x ) (x)
15+ #define htobe64 (x ) (x)
16+ #define htole16 (x ) __builtin_bswap16(x)
17+ #define htole32 (x ) __builtin_bswap32(x)
18+ #define htole64 (x ) __builtin_bswap64(x)
19+ #define le16toh (x ) __builtin_bswap16(x)
20+ #define le32toh (x ) __builtin_bswap32(x)
21+ #define le64toh (x ) __builtin_bswap64(x)
22+ #else
23+ /* Little-endian (most common case for Windows) */
24+ #define htobe16 (x ) __builtin_bswap16(x)
25+ #define htobe32 (x ) __builtin_bswap32(x)
26+ #define htobe64 (x ) __builtin_bswap64(x)
27+ #define htole16 (x ) (x)
28+ #define htole32 (x ) (x)
29+ #define htole64 (x ) (x)
30+ #define le16toh (x ) (x)
31+ #define le32toh (x ) (x)
32+ #define le64toh (x ) (x)
33+ #endif
34+ #else
35+ #include <endian.h>
36+ #endif
Original file line number Diff line number Diff line change 77 */
88#pragma once
99
10- #include <endian.h>
1110#include <stdint.h>
1211
12+ #include <nvme/endian.h>
1313#include <nvme/nvme-types.h>
1414
1515/**
Original file line number Diff line number Diff line change 1010
1111#pragma once
1212
13- #include <endian.h>
1413#include <errno.h>
1514#include <string.h>
1615
16+ #include <nvme/endian.h>
1717#include <nvme/ioctl.h>
1818#include <nvme/nvme-types.h>
1919
Original file line number Diff line number Diff line change @@ -194,6 +194,7 @@ if openssl_dep.found()
194194endif
195195
196196foreach hdr : [
197+ ' endian' ,
197198 ' fabrics' ,
198199 ' filters' ,
199200 ' ioctl' ,
Original file line number Diff line number Diff line change 1717#define _NVME_H
1818
1919#include <dirent.h>
20- #include <endian.h>
2120#include <stdbool.h>
2221#include <stdint.h>
2322#include <stdio.h>
You can’t perform that action at this time.
0 commit comments