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