!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);
// $ cc -g3 -fsanitize=thread,undefined test.c | |
// | |
// No data races detected because the mutex is unnecessary. To verify TSan | |
// is indeed working, modify newqueue to initialize improperly, such as | |
// setting a zero field to non-zero. This will cause a data race. | |
#define lenof(a) (int)(sizeof(a) / sizeof(*(a))) | |
typedef struct { | |
int count; |
#include <assert.h> | |
#include <stddef.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define S(s) (Str){s, sizeof(s)-1} | |
#define new(a, n, t) (t *)alloc(a, n, sizeof(t), _Alignof(t)) |
global _start | |
_start: | |
mov rdi, rsp | |
xor r10d, r10d | |
lea r13, [rel nl] | |
push r12 | |
push rbp | |
push rbx | |
mov rbx, rdi | |
sub rsp, 1040 |
// 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 | |
#include <stddef.h> | |
#include <string.h> | |
#define affirm(c) while (!(c)) 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} |
#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; |