This commit is contained in:
veclavtlica
2026-10-12 21:52:52 +03:00
parent 8d2bb5575e
commit 964e623644
5 changed files with 28 additions and 16 deletions
+2 -2
View File
@@ -28,14 +28,14 @@ com_std_fd com_std_open(char const *path, uint32_t flags) {
}
bool com_std_write(com_std_fd fd, void const *data, uint32_t bytes) {
com_std_assert(fd != NULL && data != NULL && bytes != 0);
com_std_assert(data != NULL && bytes != 0);
bool s = fwrite(data, 1, bytes, fd) == bytes;
fflush(fd);
return s;
}
int32_t com_std_read(com_std_fd fd, void *data, uint32_t upto) {
com_std_assert(fd != NULL && data != NULL && upto != 0);
com_std_assert(data != NULL && upto != 0);
return fread(data, 1, upto, fd);
}
+3 -3
View File
@@ -10,9 +10,9 @@
#include <stddef.h>
#include <stdint.h>
#if COM_DEF_TARGET == COM_DEF_TARGET_WASM
#define COM_STD_INFD 0
#define COM_STD_OUTFD 1
#if COM_DEF_TARGET != COM_DEF_TARGET_COSMO
#define COM_STD_INFD (void *)0
#define COM_STD_OUTFD (void *)1
#else
/* TODO: Make it more graceful, probably with static func. */
#include <unistd.h>
+8 -2
View File
@@ -408,6 +408,10 @@ static bool plr_x11_establish_connection(com_std_fd xfd, int argc,
char const *const *argv) {
com_buf_make_on_stack(char, xauthbuf, 1024, 0);
/* TODO: Genralize inside std? */
#if COM_DEF_TARGET == COM_DEF_TARGET_COSMO
char const *xauthpath = getenv("XAUTHORITY");
#else
/* First we need to authenticate X11 connection, which requires some funk.
*/
/* We assume that $XAUTHORITY is set and I hope it is true. */
@@ -419,10 +423,11 @@ static bool plr_x11_establish_connection(com_std_fd xfd, int argc,
break;
}
}
#endif
/* Open it and parse. */
com_std_fd const xauthfd = com_std_open(xauthpath, COM_STD_OPEN_READ);
if (xauthfd < 0) {
if (!xauthfd) {
com_std_print('c', "Failure to initialize X11");
return false;
}
@@ -481,8 +486,9 @@ extern int plr_display_x11_main(int argc, char const *const *argv) {
// com_vec_t v0 = com_mat_vec_project(com_mat_reoder(m0), com_vec_identity());
// com_fix_print(v0.a[0]);
/* TODO: Move to separate executable maybe? */
#ifndef NDEBUG
com_test_run();
// com_test_run();
#endif
// com_fix_run_tests();
+1 -3
View File
@@ -1,7 +1,5 @@
#include "../../Common/std.h"
#include "../Display/display.h"
#include <stdio.h>
extern int main(int argc, char const *const *argv) {
com_std_write(COM_STD_OUTFD, "TEST?", sizeof "TEST?" - 1);
return plr_display_x11_main(argc, argv);
}
+14 -6
View File
@@ -8,6 +8,11 @@ RUN ?= 0
ISCLANG = 1
ifeq ($(MAKECMDGOALS),cosmo)
ISCLANG = 0
ifeq ($(DEBUG), 1)
CFLAGS += -mdbg
else
CFLAGS += -mtiny
endif
endif
CFLAGS = -Wall -std=gnu99 -ffast-math -fno-ident -fvisibility=hidden
ifeq ($(ISCLANG), 1)
@@ -40,13 +45,15 @@ endif
ifeq ($(DEBUG), 1)
CFLAGS += -g3
else
CFLAGS += -DNDEBUG -Wl,--strip-all
CFLAGS += -DNDEBUG -s
endif
ifeq ($(RELEASE), 1)
CFLAGS += -O3 -fmerge-all-constants -Wl,-O3 \
-ffunction-sections -fdata-sections -Wl,--gc-sections \
-Wl,-mllvm,--vectorize-slp=true \
-Wl,-mllvm,--enable-gvn-hoist=true
-ffunction-sections -fdata-sections -Wl,--gc-sections
ifeq ($(ISCLANG), 1)
CFLAGS += -Wl,-mllvm,--vectorize-slp=true \
-Wl,-mllvm,--enable-gvn-hoist=true
endif
endif
linux: CFLAGS += -static -mbmi2 -nostdlib
@@ -59,9 +66,10 @@ wasm:
$(CC) -o player.wasm ./amalgam.c $(CFLAGS)
# todo: Add -mtiny for release without debug
cosmo: CC = ./Cosmo/bin/cosmocc -I /usr/include/X11 -mdbg
cosmo: CC = ./Cosmo/bin/cosmocc
cosmo: CFLAGS += -I /usr/include/X11 -mclang
cosmo: ./amalgam.c
$(CC) -o ./Out/Cosmo/player $^
$(CC) $(CFLAGS) -o ./Out/Cosmo/player $^
ifeq ($(RUN), 1)
ifeq ($(DEBUG), 1)
gdb ./Out/Cosmo/player.com.dbg