Created
July 30, 2026 21:42
-
-
Save dockimbel/ddfe8c9eda260b51199a2e1e5fccba0d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red/System [ | |
| Title: "llama.cpp static binding for Red" | |
| Purpose: "Imports the llama-red shim (llama-red.c) bundled with llama.cpp + ggml" | |
| Note: { | |
| Extension-less import: Red's -s static linker resolves llama-red.lib, | |
| a dynamic build would resolve llama-red.dll. The shim keeps every | |
| by-value struct of llama.h on the C side -- only scalars cross here. | |
| } | |
| ] | |
| #import [ | |
| "llama-red" cdecl [ | |
| lr-init: "lr_init" [] | |
| lr-quiet: "lr_quiet" [] | |
| lr-system-info: "lr_system_info" [ | |
| return: [c-string!] | |
| ] | |
| lr-last-error: "lr_last_error" [ | |
| return: [c-string!] | |
| ] | |
| lr-load: "lr_load" [ | |
| path [c-string!] | |
| n-ctx [integer!] | |
| threads [integer!] | |
| temp [float!] | |
| seed [integer!] | |
| return: [int-ptr!] | |
| ] | |
| lr-free: "lr_free" [ | |
| llm [int-ptr!] | |
| ] | |
| lr-n-ctx: "lr_n_ctx" [ | |
| llm [int-ptr!] | |
| return: [integer!] | |
| ] | |
| lr-start: "lr_start" [ | |
| llm [int-ptr!] | |
| text [c-string!] | |
| template? [integer!] | |
| return: [integer!] | |
| ] | |
| lr-next: "lr_next" [ | |
| llm [int-ptr!] | |
| buf [byte-ptr!] | |
| buf-size [integer!] | |
| return: [integer!] | |
| ] | |
| ] | |
| ] | |
| #switch OS [ | |
| Windows [ | |
| #import [ | |
| "kernel32.dll" stdcall [ | |
| lr-ticks: "GetTickCount" [ | |
| return: [integer!] | |
| ] | |
| ] | |
| ] | |
| ] | |
| #default [ | |
| #import [ | |
| "libc.so.6" cdecl [ | |
| lr-gtod: "gettimeofday" [ | |
| tv [int-ptr!] | |
| tz [int-ptr!] | |
| return: [integer!] | |
| ] | |
| ] | |
| ] | |
| lr-tv: declare struct! [ | |
| sec [integer!] | |
| usec [integer!] | |
| ] | |
| lr-ticks: func [return: [integer!] /local s [integer!]][ | |
| lr-gtod as int-ptr! lr-tv null | |
| s: lr-tv/sec // 100000 ;-- keep sec * 1000 in 32 bits | |
| (s * 1000) + (lr-tv/usec / 1000) | |
| ] | |
| ] | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment