main.c
is the sample usage code, spall_auto.h
is the single-header library.
You'll need spall.h, get it from here: https://github.com/colrdavidson/spall/blob/master/spall.h
build with:
cl main.c /O2 /GH /Gh
(also supports /Oy
)
or
static bool terminal_belongs_to_self(void) { | |
DWORD pid = 0; GetWindowThreadProcessId(GetConsoleWindow(), &pid); | |
return pid == GetCurrentProcessId(); | |
} |
main.c
is the sample usage code, spall_auto.h
is the single-header library.
You'll need spall.h, get it from here: https://github.com/colrdavidson/spall/blob/master/spall.h
build with:
cl main.c /O2 /GH /Gh
(also supports /Oy
)
or
// SPDX-FileCopyrightText: © 2022 Phillip Trudeau-Tavara <[email protected]> | |
// SPDX-License-Identifier: 0BSD | |
// https://hero.handmade.network/forums/code-discussion/t/7485-queryperformancefrequency_returning_10mhz_bug/2 | |
// https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlfs/timers#partition-reference-tsc-mechanism | |
#include <stdbool.h> | |
#include <stdint.h> | |
#define WIN32_LEAN_AND_MEAN |
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#include <string.h> | |
#include <ctype.h> | |
#include <stdarg.h> | |
//template <class F> struct deferrer { F f; ~deferrer() { f(); } }; | |
//struct defer_dummy {}; |
#include "parsing.h" | |
#include "buffer.h" | |
#include <ch_stl/time.h> | |
namespace parsing { | |
// This is a column-reduction table to map 128 ASCII values to a 11-input space. | |
// The values in this table are premultiplied with the number of DFA states | |
// to save one multiply when indexing the state transition table. | |
#define P (DFA_NUM_STATES) | |
static const u8 char_type[] = { |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
typedef struct Memory_Block { | |
uint8_t *data; | |
size_t num_bytes; | |
} Memory_Block; | |
typedef enum Allocator_Mode { |
#include <string.h> // for strcmp | |
#define Enum_Member(Name, Value) Name = Value, | |
#define Enum_To_String(Name, Value) if (e == Name) return # Name; | |
#define Enum_From_String(Name, Value) if (strcmp(str, # Name) == 0) return Name; | |
#define Define_Enum(EnumName) \ | |
\ |
static const char *const GL_funcnames[] = { | |
"wglDeleteContext", | |
"wglUseFontBitmapsA", | |
"wglSwapIntervalEXT", | |
"glGetError", | |
"glBlendFunc", | |
"glEnable", | |
"glDisable", | |
"glViewport", | |
"glVertex3f", |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#define WIN32_LEAN_AND_MEAN | |
#define VC_EXTRALEAN | |
#include <windows.h> | |
template <class T> struct Virtual_Array { | |
// Whatever, just example instructions. | |
#define INSTRUCTION_TYPE_LIST(instruction_type) \ | |
instruction_type(push, sizeof(u32)) \ | |
instruction_type(pop, sizeof(u32)) \ | |
instruction_type(move, sizeof(u32 *) + sizeof(u32 *)) | |
// Examples of usage (I didn't quite catch what the real usage was): | |
#define instruction_enum_name(name, size) Instruction_Type_ ## name, | |
#define instr_size(name, size) (size_t)size, |