This commit is contained in:
Liam Waldron 2025-04-15 17:45:50 -04:00
parent 8e41b63cc1
commit 32b02a1691
6 changed files with 77 additions and 0 deletions

14
Makefile Normal file
View File

@ -0,0 +1,14 @@
#
# Makefile
#
include config.mk
.PHONY: all install clean
all:
@echo "Run 'make install' to install util.h to PREFIX."
install:
install include/util.h $(PREFIX)/include -m 644

BIN
build/util.a Normal file

Binary file not shown.

16
build/util.h Executable file
View File

@ -0,0 +1,16 @@
#ifndef UTIL_H_
#define UTIL_H_
/*
* Aliases for concise data types
*/
typedef char i8;
typedef unsigned int u16;
typedef int i16;
typedef unsigned long u32;
typedef long i32;
typedef unsigned long long u64;
typedef long long i64;
#endif

BIN
build/util.o Normal file

Binary file not shown.

8
config.mk Normal file
View File

@ -0,0 +1,8 @@
#
# config.mk
#
CC = /bin/gcc
AR = /bin/ar
CFLAGS = -O2 -pipe -fstack-protector-strong -static -pie -std=c99

39
include/util.h Normal file
View File

@ -0,0 +1,39 @@
#ifndef UTIL_H_
#define UTIL_H_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_BUFFER_SIZE 128
/*
* Aliases for concise data types
*/
typedef void u1;
typedef char i8;
typedef unsigned int u16;
typedef int i16;
typedef unsigned long u32;
typedef long i32;
typedef unsigned long long u64;
typedef long long i64;
inline u1
die(i8 msg, i16 exitcode)
{
i8 buffer[128];
i8 *s = msg;
if (sizeof(s) > MAX_BUFFER_SIZE) {
return;
}
snprintf(buffer, MAX_BUFFER_SIZE, "%s\n\0, s);
fprintf(stderr, "%s\n", buffer);
exit(exitcode);
}
#endif