!note https://old.reddit.com/r/C_Programming/comments/1kf7l7w/_/mqpavfa/
!profile openai
!:model gpt-4.1
!user
uint64_t dualmix128(uint64_t s[2])
{
uint64_t m = s[0] + s[1];
s[0] = m + (s[0]<<26 | s[0]>>38);
// https://old.reddit.com/r/C_Programming/comments/1l1hxeu | |
#include <assert.h> | |
#include <stddef.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define S(s) (Str){s, sizeof(s)-1} | |
typedef struct { |
// Requires GNU C23: GCC >= 15 or Clang >= 21 | |
#define affirm(c) while (!(c)) __builtin_unreachable() | |
#define lenof(a) (iz)(sizeof(a) / sizeof(*(a))) | |
#define new(a, n, t) (t *)alloc(a, n, sizeof(t), _Alignof(t)) | |
#define maxof(t) ((t)-1<1 ? (((t)1<<(sizeof(t)*8-2))-1)*2+1 : (t)-1) | |
#define S(s) (Str){(u8 *)s, lenof(s)-1} | |
typedef unsigned char u8; | |
typedef int i32; |
#include <stdint.h> | |
// Return the RGB value of the named color. Does not validate that the | |
// input matches a real color name. | |
int32_t svg2rgb(char *s) | |
{ | |
static int32_t t[1024] = { | |
[ 0]=0x9acd32, [ 4]=0xa9a9a9, [ 16]=0x808080, [ 18]=0xda70d6, | |
[ 21]=0x40e0d0, [ 26]=0xffe4b5, [ 27]=0xf5fffa, [ 29]=0xa0522d, | |
[ 38]=0xfaf0e6, [ 41]=0x2f4f4f, [ 43]=0x6a5acd, [ 55]=0xb22222, |
#!/bin/sh | |
set -ex | |
clang --target=wasm32 -nostdlib -O2 -fno-builtin -Wl,--no-entry -o staz.wasm wasm.c |
!note https://old.reddit.com/r/C_Programming/comments/1kf7l7w/_/mqpavfa/
!profile openai
!:model gpt-4.1
!user
uint64_t dualmix128(uint64_t s[2])
{
uint64_t m = s[0] + s[1];
s[0] = m + (s[0]<<26 | s[0]>>38);
!note https://old.reddit.com/r/C_Programming/comments/1kf7l7w/_/mqpavfa/
!profile openai
!:model o4-mini
!user
uint64_t dualmix128(uint64_t s[2])
{
uint64_t m = s[0] + s[1];
s[0] = m + (s[0]<<26 | s[0]>>38);
// Single consumer, single producer circular buffer using Win32 SRW | |
// Ref: https://github.com/vibhav950/cbuf | |
// Ref: https://old.reddit.com/r/C_Programming/comments/1jwnlrf | |
// Ref: https://nullprogram.com/blog/2024/10/03/ | |
#include <stddef.h> | |
#include <stdint.h> | |
#include <string.h> | |
typedef uint8_t u8; | |
typedef int32_t b32; |
!profile claude | |
!user | |
Please give me an example of using WASI `path_open` to open a file for writing. In particular, I don't know where to get the `dirfd` parameter. | |
!assistant | |
# Example of using WASI `path_open` to open a file for writing | |
The WASI `path_open` function requires a directory file descriptor (`dirfd`) as its first parameter because WASI uses a capability-based security model. Here's how to use it: |
// Robust Lock: if a "thread" exits while holding a lock, it is unlocked | |
// linux $ cc -pthread example.c | |
// w64dk $ cc example.c -lntdll | |
// Ref: https://old.reddit.com/r/C_Programming/comments/1jd82ux | |
// Ref: https://github.com/cozis/timestamp_lock | |
// This is free and unencumbered software released into the public domain. | |
#include <assert.h> | |
#include <stddef.h> | |
#include <stdint.h> | |
#include <stdio.h> |
// https://old.reddit.com/r/C_Programming/comments/1iljkn2 | |
// https://github.com/jamesnolanverran/dmap | |
#include "dmap.c" | |
#include <string.h> | |
#define KEYLEN 8 | |
#define RUNS 10 | |
#define KEYS 1000000 | |
static void encode(char *key, int x) |