Compare commits

...

2 Commits

Author SHA1 Message Date
5c57a77ad4 remove types.h, and start using intdef.h 2025-08-08 12:37:31 +02:00
bdf4d7b22b remove atrb_* macros for the attributes, and replace with single-word, all uppercase versions.
improves briefity, and reduces confusion.
2025-08-08 12:30:59 +02:00
8 changed files with 14 additions and 24 deletions

View File

@@ -7,7 +7,7 @@
#include <string.h> #include <string.h>
#include "../util/compat/endian.h" #include "../util/compat/endian.h"
#include "../util/types.h" #include "../util/intdef.h"
int nbt_primsize(u8 tag) { int nbt_primsize(u8 tag) {
switch (tag) { switch (tag) {

View File

@@ -8,7 +8,7 @@
#include "../util/atrb.h" #include "../util/atrb.h"
#include "../util/compat/endian.h" #include "../util/compat/endian.h"
#include "../util/types.h" #include "../util/intdef.h"
/* NBT (named binary tag) is a tree data structure. Tags have a numeric type ID, name and a payload. /* NBT (named binary tag) is a tree data structure. Tags have a numeric type ID, name and a payload.
* NBT files are a compressed `compound` tag. GZip is the compression used in most cases, * NBT files are a compressed `compound` tag. GZip is the compression used in most cases,

View File

@@ -8,7 +8,7 @@
#include <stdint.h> #include <stdint.h>
#include "../error.h" #include "../error.h"
#include "../util/types.h" #include "../util/intdef.h"
#include "shader.h" #include "shader.h"
#define VERTC 3 #define VERTC 3

View File

@@ -57,13 +57,3 @@
#define NONNULL(...) #define NONNULL(...)
#endif #endif
#endif #endif
#define atrb_deprecated DEPRECATED
#define atrb_used USED
#define atrb_unused UNUSED
#define atrb_pure PURE
#define atrb_const CONST
#define atrb_noreturn NORET
#define atrb_malloc MALLOC
#define atrb_format FORMAT
#define atrb_nonnull NONNULL

View File

@@ -12,9 +12,9 @@
#include "../error.h" #include "../error.h"
#include "atrb.h" #include "atrb.h"
#include "types.h" #include "intdef.h"
int conf_procbuf(char const *restrict buf, char *restrict kout, char *restrict vout, size_t len) { int conf_procbuf(const char *restrict buf, char *restrict kout, char *restrict vout, size_t len) {
bool feq = false; // whether we've found the equal sign bool feq = false; // whether we've found the equal sign
// data traversal // data traversal
@@ -53,7 +53,7 @@ int conf_procbuf(char const *restrict buf, char *restrict kout, char *restrict v
return (pos == kout) ? CONF_ENODAT : (!feq ? CONF_ESYNTAX : 0); return (pos == kout) ? CONF_ENODAT : (!feq ? CONF_ESYNTAX : 0);
} }
struct conf_entry const *conf_matchopt(struct conf_entry const *opts, size_t optc, char const *restrict key) { struct conf_entry const *conf_matchopt(struct conf_entry const *opts, size_t optc, const char *restrict key) {
// find a match for the current key // find a match for the current key
size_t i = 0; size_t i = 0;
for (; i < optc; i++) { for (; i < optc; i++) {
@@ -63,7 +63,7 @@ struct conf_entry const *conf_matchopt(struct conf_entry const *opts, size_t opt
return NULL; return NULL;
} }
int conf_procval(struct conf_entry const *opt, char const *restrict val) { int conf_procval(struct conf_entry const *opt, const char *restrict val) {
// parse the data // parse the data
errno = 0; errno = 0;
char *end; char *end;
@@ -127,7 +127,8 @@ int conf_procval(struct conf_entry const *opt, char const *restrict val) {
} }
/* utility function for conf_getpat to concatenate 3 strings, where we already know the size */ /* utility function for conf_getpat to concatenate 3 strings, where we already know the size */
atrb_nonnull(1, 3) static char *conf_getpat_concat(char const *restrict s1, char const *restrict s2, char const *restrict s3, size_t s1len, size_t s2len, size_t s3len) { NONNULL(1, 3)
static char *conf_getpat_concat(const char *restrict s1, const char *restrict s2, const char *restrict s3, size_t s1len, size_t s2len, size_t s3len) {
assert(s2 || (!s2 && !s2len)); // ensuring the programmer passes both s2 and s2len as 0, if they intend to assert(s2 || (!s2 && !s2len)); // ensuring the programmer passes both s2 and s2len as 0, if they intend to
char *buf, *ptr; char *buf, *ptr;
@@ -146,7 +147,7 @@ atrb_nonnull(1, 3) static char *conf_getpat_concat(char const *restrict s1, char
} }
/* appends str to the config directory string we acquire from environment variables. */ /* appends str to the config directory string we acquire from environment variables. */
char *conf_getpat(char const *restrict str) { char *conf_getpat(const char *restrict str) {
char *buf = NULL; char *buf = NULL;
size_t len; size_t len;
size_t str_len = strlen(str); size_t str_len = strlen(str);

View File

@@ -3,10 +3,10 @@
#pragma once #pragma once
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "atrb.h" #include "atrb.h"
#include "intdef.h"
/* error codes */ /* error codes */
enum conf_err { enum conf_err {
@@ -43,7 +43,7 @@ struct conf_fstr {
struct conf_entry { struct conf_entry {
const char *key; // the key of this entry const char *key; // the key of this entry
void *out; // the pointer to which the data is written value is read if the given option is incorrect or missing void *out; // the pointer to which the data is written value is read if the given option is incorrect or missing
uint8_t type; // the primitive type which we are querying for u8 type; // the primitive type which we are querying for
}; };
/* processes an incoming buffer. /* processes an incoming buffer.
@@ -67,4 +67,4 @@ int conf_procval(struct conf_entry const *opts, const char *restrict val);
* - windows: reads %APPDATA%, if empty %USERPROFILE%\AppData\Roaming is used, if both are empty NULL is returned. * - windows: reads %APPDATA%, if empty %USERPROFILE%\AppData\Roaming is used, if both are empty NULL is returned.
* - osx: reads $HOME, uses $HOME/Library/Application Support, if $HOME is empty NULL is returned. * - osx: reads $HOME, uses $HOME/Library/Application Support, if $HOME is empty NULL is returned.
* !! A malloc'd null-terminated string is returned !! */ * !! A malloc'd null-terminated string is returned !! */
atrb_malloc atrb_nonnull(1) char *conf_getpat(const char *); MALLOC NONNULL((1)) char *conf_getpat(const char *);

View File

@@ -1 +0,0 @@
intdef.h

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include "types.h" #include "intdef.h"
#if defined(__has_attribute) && __has_attribute(vector_size) #if defined(__has_attribute) && __has_attribute(vector_size)
typedef float fvec2 __attribute__((vector_size(sizeof(float) * 2))); // SMID vector for 2 `float` typedef float fvec2 __attribute__((vector_size(sizeof(float) * 2))); // SMID vector for 2 `float`