Skip to content

Instantly share code, notes, and snippets.

@nadako
Last active October 22, 2025 00:32
Show Gist options
  • Save nadako/caee1d1ef91dddbb54c775f6b5a4318f to your computer and use it in GitHub Desktop.
Save nadako/caee1d1ef91dddbb54c775f6b5a4318f to your computer and use it in GitHub Desktop.
Minimal Superluminal Odin API
package superluminal
// use -extra-linker-flags:"/ignore:4099" to ignore missing PDBs
foreign import lib "PerformanceAPI_MT.lib"
DEFAULT_COLOR :: 0xFFFFFFFF
@(default_calling_convention="c", link_prefix="PerformanceAPI_", private="file")
foreign lib {
SetCurrentThreadName_N :: proc(inThreadName: cstring, inThreadNameLength: u16) ---
BeginEvent_N :: proc(inID: cstring, inIDLength: u16, inData: cstring, inDataLength: u16, inColor: u32) ---
EndEvent :: proc() -> [3]i64 ---
}
set_current_thread_name :: #force_inline proc(inThreadName: string) {
SetCurrentThreadName_N(auto_cast raw_data(inThreadName), u16(len(inThreadName)))
}
begin_event :: #force_inline proc(inID: string, inData: string = "", inColor: u32 = DEFAULT_COLOR) {
BeginEvent_N(auto_cast raw_data(inID), u16(len(inID)), auto_cast raw_data(inData), u16(len(inData)), inColor)
}
@(deferred_none=end_event)
scope :: #force_inline proc(inID: string, inData: string = "", inColor: u32 = DEFAULT_COLOR) {
begin_event(inID, inData, inColor)
}
end_event :: #force_inline proc() { EndEvent() }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment