diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4860a02 --- /dev/null +++ b/Makefile @@ -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 + diff --git a/build/util.a b/build/util.a new file mode 100644 index 0000000..fa317d3 Binary files /dev/null and b/build/util.a differ diff --git a/build/util.h b/build/util.h new file mode 100755 index 0000000..82fa5b6 --- /dev/null +++ b/build/util.h @@ -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 diff --git a/build/util.o b/build/util.o new file mode 100644 index 0000000..fa590cb Binary files /dev/null and b/build/util.o differ diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..1784d2f --- /dev/null +++ b/config.mk @@ -0,0 +1,8 @@ +# +# config.mk +# + +CC = /bin/gcc +AR = /bin/ar + +CFLAGS = -O2 -pipe -fstack-protector-strong -static -pie -std=c99 diff --git a/include/util.h b/include/util.h new file mode 100644 index 0000000..2eb2b16 --- /dev/null +++ b/include/util.h @@ -0,0 +1,39 @@ +#ifndef UTIL_H_ +#define UTIL_H_ + +#include +#include +#include + +#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