diff --git a/atomics.c b/atomics.c deleted file mode 100644 index 4ff5e5d..0000000 --- a/atomics.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include - -atomic_int x; // _Atomic int - -int thread1(void *arg) { - (void)arg; - - printf("Thread 1: Sleeping for 1.5 seconds\n"); - thrd_sleep(&(struct timespec){.tv_sec = 1, .tv_nsec = 500000000}, NULL); - - printf("Thread 1: Setting x to 3490\n"); - x = 3490; - - printf("Thread 1: Exiting\n"); - return 0; -} - -int thread2(void *arg) { - (void)arg; - - printf("Thread 2: Waiting for 3490\n"); - while (x != 3490); // spin here - - printf("Thread 2: Got 3490--exiting!\n"); - return 0; -} - -int main(void) { - x = 0; - - thrd_t t1, t2; - - thrd_create(&t1, thread1, NULL); - thrd_create(&t2, thread2, NULL); - - thrd_join(t1, NULL); - thrd_join(t2, NULL); - - printf("Main : Threads are done, so x better be 3490\n"); - printf("Main : And indeed, x == %d\n", x); -} diff --git a/cjson/.gitignore b/cjson/.gitignore deleted file mode 100644 index 904fe7c..0000000 --- a/cjson/.gitignore +++ /dev/null @@ -1 +0,0 @@ -cjson* diff --git a/cjson/Makefile b/cjson/Makefile index 1b69237..ff5f5ab 100644 --- a/cjson/Makefile +++ b/cjson/Makefile @@ -1,22 +1,12 @@ -CC ?= cc -CFLAGS ?= -Wall -O2 -I. -LDFLAGS ?= +CC ?= gcc +CFLAGS ?= -Wall -O2 -lcjson TARGET = main.elf -SRC = main.c ./cjson/cJSON.c +SRC = main.c $(TARGET): $(SRC) @echo CC $@ @$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) -CJSON_URL = https://github.com/DaveGamble/cJSON/archive/refs/heads/master.tar.gz -CJSON_TAR = cjson.tar.gz -CJSON_DIR = cJSON-master - -cjson: - curl -L $(CJSON_URL) -o $(CJSON_TAR) - tar -xzf $(CJSON_TAR) - mv ./cJSON-master ./cjson - clean: rm -f $(TARGET) diff --git a/cjson/main.c b/cjson/main.c index e54004b..30c5d87 100644 --- a/cjson/main.c +++ b/cjson/main.c @@ -1,6 +1,5 @@ -#include "cjson/cJSON.h" +#include #include -#include char *build_set_level_command(int level) { cJSON *root = cJSON_CreateObject(); @@ -10,12 +9,10 @@ char *build_set_level_command(int level) { // char *message = cJSON_PrintUnformatted(root); char *msg2 = cJSON_Print(root); cJSON_Delete(root); - return msg2; + return msg2; // Remember to free this when done! } int main(void) { - char *msg = build_set_level_command(10); - printf("%s\n", msg); - free(msg); + printf("%s\n", build_set_level_command(10)); return 0; } diff --git a/config_ini/conf.h b/config_ini/conf.h index 415a7e0..d158605 100644 --- a/config_ini/conf.h +++ b/config_ini/conf.h @@ -1,6 +1,3 @@ -#ifndef CONF_H -#define CONF_H - typedef struct ConfigEntry { char *key; char *value; @@ -14,5 +11,3 @@ typedef struct { Config *config_load(const char *filename); const char *config_get(Config *cfg, const char *key); void config_free(Config *cfg); - -#endif // CONF_H diff --git a/fir2.c b/fir2.c index f2aa6e5..adcf30a 100644 --- a/fir2.c +++ b/fir2.c @@ -6,7 +6,7 @@ /* This needs to be a power of two for the bitmask optimizations to work */ /* If a non power of two length is desired, change to modulo */ -#define FIR_LEN (1u << 5) // = 32 +#define FIR_LEN (1u << 5) _Static_assert((FIR_LEN & (FIR_LEN - 1u)) == 0, "FIR_LEN must be a power of two"); typedef struct { diff --git a/winsz.c b/winsz.c index e57c63b..19d66fb 100644 --- a/winsz.c +++ b/winsz.c @@ -5,10 +5,6 @@ int main(void) { struct winsize w; - /* See: man 2 ioctl */ - /* See: man 2 TIOCGWINSZ */ - /* See: linux/fs/ioctl.c */ - /* See: linux/drivers/tty/tty_io.c (L: ~2709 and ~2359) */ if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) == -1) { perror("ioctl"); return 1;