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
// Assumes input is a 1080x1527 PPM with minimal header named maze.ppm. | |
// Outputs output.ppm with the solution drawn on top, and maze.txt with | |
// the raw maze structure. | |
// | |
// This is free and unencumbered software released into the public domain. | |
#include <math.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <string.h> |
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
ALL = skeetocrt.dll skeetocrt.dll.a crt0.o | |
all: $(ALL) | |
skeetocrt.dll skeetocrt.dll.a: skeetocrt.c stdio.h | |
cc -shared -g3 -fno-builtin -nostartfiles --entry=0 \ | |
-Wl,--out-implib=skeetocrt.dll.a -o skeetocrt.dll skeetocrt.c | |
crt0.o: crt0.c stdio.h | |
cc -c -g3 -fno-builtin -nostdlib -nostdinc -isystem . -o crt0.o crt0.c |
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
#include <assert.h> | |
#include <pthread.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#define lenof(a) (int)(sizeof(a) / sizeof(*(a))) | |
typedef uint16_t QueueUint; | |
typedef struct { |
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
--- a/SRC/IO.H | |
+++ b/SRC/IO.H | |
@@ -3,3 +3,3 @@ | |
-#include <_defs.h> | |
+//#include <_defs.h> | |
--- a/SRC/PSYMANDL.C | |
+++ b/SRC/PSYMANDL.C | |
@@ -1,4 +1,4 @@ |
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
// $ eval cc main_sdl2.c $(pkg-config --cflags --libs sdl2) -lm | |
char *SDL_itoa(int, char *, int); | |
#undef main // undo SDL_main from pkg-config | |
#define main appmain | |
#define itoa SDL_itoa | |
#include "SRC/AABB.C" | |
#include "SRC/BALL.C" | |
#include "SRC/BREAKOUT.C" | |
#include "SRC/GAMELVL.C" |
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
// $ 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; |
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
#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)) |
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
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 |
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
// 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 { |
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
// 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} |
NewerOlder