// #pragma once // #include // #include // #include // #include // using file = void*; // enum FileOpenMode // { // FRead = 1 << 0, // FWrite = 1 << 1, // FAppend = 1 << 2, // }; // auto FileValid(file file) -> bool; // auto FileOpen(byteview path, FileOpenMode mode) -> file; // void FileClose(file file); // auto FileRead(file file, uint32_t size, uint8_t* out) -> uint32_t; // auto FileWrite(file file, uint32_t size, const uint8_t* in) -> bool; // enum file_seek_mode // { // FileSeekBegin, // FileSeekCurrent, // FileSeekEnd // }; // void FileSeek(file file, int64_t at, file_seek_mode mode); // auto FileTell(file file) -> uint64_t; // void FileSetEnd(file file); // auto FileExists(byteview path) -> bool; // auto IsDirectory(byteview path) -> bool; // auto FileDelete(byteview path) -> bool; // auto CreateDirectory(byteview path) -> bool; // auto RemoveDirectory(byteview path) -> bool; // auto GetStdin() -> file; // auto GetStdout() -> file; // auto GetStderr() -> file; // void FileWriteFmt_(file handle, byteview buffer, byteview fmt, va_list args); // void FileWriteFmt(file handle, byteview buffer, byteview fmt, ...); // void FileWriteFmt_(file handle, byteview fmt, va_list args); // void FileWriteFmt(file handle, byteview fmt, ...); // auto StringWriteFmt_(byteview out, byteview fmt, va_list args) -> uint64_t; // auto StringWriteFmt(byteview out, byteview fmt, ...) -> uint64_t; // auto StringWriteFmt_(byteview fmt, va_list args) -> byteview; // auto StringWriteFmt(byteview fmt, ...) -> byteview; // template // struct limits // { // }; // template // struct limits // { // static constexpr auto Max() -> T // { // return (T)-1; // } // static constexpr auto Min() -> T // { // return (T)0; // } // }; // template // struct limits // { // static constexpr auto Max() -> T // { // return (T)(((uint64_t)1 << (sizeof(T) * 8 - 1)) - 1); // } // static constexpr auto Min() -> T // { // return (T)((uint64_t)1 << (sizeof(T) * 8 - 1)); // } // }; // INLINE constexpr auto AlignedUp(uint64_t n, uint64_t align) -> uint64_t // { // return (n + align - 1) & ~(align - 1); // } // template // INLINE constexpr auto AlignedUp(T* ptr, uint64_t align) -> T* // { // return (T*)AlignedUp((uint64_t)ptr, align); // } // constexpr inline auto CastU32(uint64_t a) -> uint32_t // { // ASSERT(a <= limits::Max()); // return static_cast(a); // } // constexpr inline auto CastI32(int64_t a) -> int32_t // { // ASSERT(a <= limits::Max() && a >= limits::Min()); // return static_cast(a); // } // constexpr inline auto CastI32(uint64_t a) -> int32_t // { // ASSERT(a <= limits::Max()); // return static_cast(a); // } // void LibMain(void (*userMain)()); // INLINE char* // CStr(byteview String) // { // ASSERT(String.data[String.size] == 0); // return (char*)String.data; // }