chore: scaffold CMake build system
Add the CMake build for the Swift + C++ macOS port, mirroring the refix layout: deps/ modules (Platform, Flags, Sanitizers, FindUnity), per-module static libraries (usb, auth, mt76, gip, hid, api), a Swift app entry point with a pure C bridge header, and a Unity test suite behind BUILD_TESTING. Swift requires the Ninja or Xcode generator; a guard in CMakeLists.txt rejects anything else. Co-Authored-By: qwen (qwen/qwen3.8-27b@q2_k_xl): scaffolded CMake build + tests
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
// ==============================================================================
|
||||
// Platform types and endianness helpers (user-space)
|
||||
// ==============================================================================
|
||||
// Replaces the kernel's __le16/__le32/guid_t machinery for user-space use.
|
||||
// All wire formats of the MT76 chip and the GIP protocol are little-endian;
|
||||
// these byte-wise helpers stay correct on any host endianness.
|
||||
// ==============================================================================
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace xone {
|
||||
|
||||
// 128-bit GUID used by the GIP protocol (port of the kernel guid_t).
|
||||
struct guid_t {
|
||||
std::uint8_t data[16];
|
||||
};
|
||||
|
||||
inline auto load_le16(void const *p) -> std::uint16_t
|
||||
{
|
||||
auto const b = static_cast<std::uint8_t const *>(p);
|
||||
return static_cast<std::uint16_t>(b[0] | (b[1] << 8));
|
||||
}
|
||||
|
||||
inline auto store_le16(void *p, std::uint16_t v) -> void
|
||||
{
|
||||
auto *b = static_cast<std::uint8_t *>(p);
|
||||
b[0] = static_cast<std::uint8_t>(v & 0xFF);
|
||||
b[1] = static_cast<std::uint8_t>((v >> 8) & 0xFF);
|
||||
}
|
||||
|
||||
inline auto load_le32(void const *p) -> std::uint32_t
|
||||
{
|
||||
auto const b = static_cast<std::uint8_t const *>(p);
|
||||
return static_cast<std::uint32_t>(
|
||||
b[0] | (b[1] << 8) | (b[2] << 16) | (static_cast<std::uint32_t>(b[3]) << 24));
|
||||
}
|
||||
|
||||
inline auto store_le32(void *p, std::uint32_t v) -> void
|
||||
{
|
||||
auto *b = static_cast<std::uint8_t *>(p);
|
||||
b[0] = static_cast<std::uint8_t>(v & 0xFF);
|
||||
b[1] = static_cast<std::uint8_t>((v >> 8) & 0xFF);
|
||||
b[2] = static_cast<std::uint8_t>((v >> 16) & 0xFF);
|
||||
b[3] = static_cast<std::uint8_t>((v >> 24) & 0xFF);
|
||||
}
|
||||
|
||||
} // namespace xone
|
||||
Reference in New Issue
Block a user