Fix more compiler warnings (gcc and clang)

This commit is contained in:
Ivan Baravy 2023-02-03 07:39:32 +03:00
parent 5b0cf9febc
commit ff1db047ff
19 changed files with 114 additions and 118 deletions

View File

@ -25,6 +25,6 @@ int get_fake_if(ucontext_t *ctx) {
return !(ctx->uc_mcontext.__gregs[REG_EFL] & (1 << 21)); return !(ctx->uc_mcontext.__gregs[REG_EFL] & (1 << 21));
} }
void system_shutdown() { void system_shutdown(void) {
exit(0); exit(0);
} }

View File

@ -24,14 +24,14 @@
#define TAP_DEV "/dev/net/tun" #define TAP_DEV "/dev/net/tun"
static STDCALL void static STDCALL void
vnet_unload_tap() { vnet_unload_tap(void) {
printf("vnet_unload_tap\n"); printf("vnet_unload_tap\n");
COVERAGE_ON(); COVERAGE_ON();
COVERAGE_OFF(); COVERAGE_OFF();
} }
static STDCALL void static STDCALL void
vnet_reset_tap() { vnet_reset_tap(void) {
printf("vnet_reset_tap\n"); printf("vnet_reset_tap\n");
COVERAGE_ON(); COVERAGE_ON();
COVERAGE_OFF(); COVERAGE_OFF();
@ -68,7 +68,7 @@ vnet_transmit_tap(net_buff_t *buf) {
} }
struct vnet * struct vnet *
vnet_init_tap() { vnet_init_tap(void) {
struct ifreq ifr = {.ifr_name = UMKA_VNET_NAME, struct ifreq ifr = {.ifr_name = UMKA_VNET_NAME,
.ifr_flags = IFF_TAP | IFF_NO_PI}; .ifr_flags = IFF_TAP | IFF_NO_PI};
int fd, err; int fd, err;

View File

@ -10,16 +10,18 @@ AR ?= ar
CC ?= gcc CC ?= gcc
WARNINGS_COMMON=-Wall -Wextra \ WARNINGS_COMMON=-Wall -Wextra \
-Wnull-dereference -Wshadow -Wformat=2 -Wswitch -Wswitch-enum \ -Wnull-dereference -Wshadow -Wformat=2 -Wswitch -Wswitch-enum \
-Wpedantic \ -Wpedantic -Wstrict-prototypes \
#-Wconversion -Wsign-conversion #-Wconversion -Wsign-conversion
NOWARNINGS_COMMON=-Wno-address-of-packed-member NOWARNINGS_COMMON=-Wno-address-of-packed-member
ifneq (,$(findstring gcc,$(CC))) ifneq (,$(findstring gcc,$(CC)))
WARNINGS=$(WARNINGS_COMMON) -Wduplicated-cond -Wduplicated-branches -Wrestrict -Wlogical-op -Wjump-misses-init WARNINGS=$(WARNINGS_COMMON) -Wduplicated-cond -Wduplicated-branches -Wrestrict -Wlogical-op -Wjump-misses-init
NOWARNINGS=$(NOWARNINGS_COMMON) NOWARNINGS=$(NOWARNINGS_COMMON)
CFLAGS_BESTLINE=-Wno-logical-op
else ifneq (,$(findstring clang,$(CC))) else ifneq (,$(findstring clang,$(CC)))
WARNINGS=$(WARNINGS_COMMON) WARNINGS=$(WARNINGS_COMMON)
NOWARNINGS=$(NOWARNINGS_COMMON) -Wno-missing-prototype-for-cc NOWARNINGS=$(NOWARNINGS_COMMON) -Wno-missing-prototype-for-cc
CFLAGS_BESTLINE=
else else
$(error your compiler is not supported) $(error your compiler is not supported)
endif endif
@ -95,10 +97,10 @@ lodepng.o: lodepng.c lodepng.h
$(CC) $(CFLAGS_32) -c $< $(CC) $(CFLAGS_32) -c $<
bestline32.o: bestline.c bestline.h bestline32.o: bestline.c bestline.h
$(CC) $(CFLAGS_32) -Wno-logical-op -Wno-switch-enum -c $< -o $@ $(CC) $(CFLAGS_32) $(CFLAGS_BESTLINE) -Wno-switch-enum -c $< -o $@
bestline.o: bestline.c bestline.h bestline.o: bestline.c bestline.h
$(CC) $(CFLAGS) -Wno-logical-op -Wno-switch-enum -c $< -o $@ $(CC) $(CFLAGS) -Wno-switch-enum -c $< -o $@
optparse32.o: optparse.c optparse.h optparse32.o: optparse.c optparse.h
$(CC) $(CFLAGS_32) -c $< -o $@ $(CC) $(CFLAGS_32) -c $< -o $@

View File

@ -259,7 +259,7 @@ shell_var_name(struct shell_ctx *ctx, const char *name) {
} }
struct shell_var * struct shell_var *
shell_var_new() { shell_var_new(void) {
struct shell_var *var = (struct shell_var*)malloc(sizeof(struct shell_var)); struct shell_var *var = (struct shell_var*)malloc(sizeof(struct shell_var));
var->next = NULL; var->next = NULL;
var->name[0] = '\0'; var->name[0] = '\0';
@ -1427,7 +1427,7 @@ cmd_get_keyboard_layout(struct shell_ctx *ctx, int argc, char **argv) {
fputs(usage, ctx->fout); fputs(usage, ctx->fout);
return; return;
} }
int type; int type = -1;
if (!strcmp(argv[1], "-t")) { if (!strcmp(argv[1], "-t")) {
const char *type_str = argv[2]; const char *type_str = argv[2];
char *endptr; char *endptr;
@ -4057,7 +4057,7 @@ run_test(struct shell_ctx *ctx) {
struct shell_ctx * struct shell_ctx *
shell_init(int reproducible, const char *hist_file, struct umka_ctx *umka, shell_init(int reproducible, const char *hist_file, struct umka_ctx *umka,
struct umka_io *io, FILE *fin, FILE *fout, const int *running) { struct umka_io *io, FILE *fin, FILE *fout, const atomic_int *running) {
struct shell_ctx *ctx = malloc(sizeof(struct shell_ctx)); struct shell_ctx *ctx = malloc(sizeof(struct shell_ctx));
ctx->umka = umka; ctx->umka = umka;
ctx->io = io; ctx->io = io;

View File

@ -10,6 +10,7 @@
#ifndef SHELL_H_INCLUDED #ifndef SHELL_H_INCLUDED
#define SHELL_H_INCLUDED #define SHELL_H_INCLUDED
#include <stdatomic.h>
#include <stdio.h> #include <stdio.h>
#include <pthread.h> #include <pthread.h>
#include "umka.h" #include "umka.h"
@ -42,7 +43,7 @@ struct shell_ctx {
struct shell_var *var; struct shell_var *var;
FILE *fin; FILE *fin;
FILE *fout; FILE *fout;
const int *running; const atomic_int *running;
pthread_cond_t cmd_done; pthread_cond_t cmd_done;
pthread_mutex_t cmd_mutex; pthread_mutex_t cmd_mutex;
struct optparse opts; struct optparse opts;
@ -50,7 +51,7 @@ struct shell_ctx {
struct shell_ctx * struct shell_ctx *
shell_init(int reproducible, const char *hist_file, struct umka_ctx *umka, shell_init(int reproducible, const char *hist_file, struct umka_ctx *umka,
struct umka_io *io, FILE *fin, FILE *fout, const int *running); struct umka_io *io, FILE *fin, FILE *fout, const atomic_int *running);
void void
shell_close(struct shell_ctx *shell); shell_close(struct shell_ctx *shell);

12
trace.c
View File

@ -10,18 +10,22 @@
uint32_t coverage; uint32_t coverage;
void trace_begin() { void
trace_begin(void) {
trace_lbr_begin(); trace_lbr_begin();
} }
void trace_end() { void
trace_end(void) {
trace_lbr_end(); trace_lbr_end();
} }
uint32_t trace_pause(void) { uint32_t
trace_pause(void) {
return trace_lbr_pause(); return trace_lbr_pause();
} }
void trace_resume(uint32_t value) { void
trace_resume(uint32_t value) {
trace_lbr_resume(value); trace_lbr_resume(value);
} }

View File

@ -66,7 +66,8 @@ void wrmsr(uint32_t reg, uint64_t data)
#endif #endif
} }
void handle_sigtrap() { void handle_sigtrap(int signo) {
(void)signo;
#ifndef _WIN32 #ifndef _WIN32
uint64_t from = rdmsr(MSR_IA32_LASTBRANCHFROMIP); uint64_t from = rdmsr(MSR_IA32_LASTBRANCHFROMIP);
uint64_t to = rdmsr(MSR_IA32_LASTBRANCHTOIP); uint64_t to = rdmsr(MSR_IA32_LASTBRANCHTOIP);
@ -87,11 +88,11 @@ void handle_sigtrap() {
uint32_t set_eflags_tf(uint32_t tf); uint32_t set_eflags_tf(uint32_t tf);
void trace_lbr_begin() { void trace_lbr_begin(void) {
#ifndef _WIN32 #ifndef _WIN32
struct sigaction action; struct sigaction action;
action.sa_sigaction = &handle_sigtrap; action.sa_handler = &handle_sigtrap;
action.sa_flags = SA_SIGINFO; action.sa_flags = 0;
sigaction(SIGTRAP, &action, NULL); sigaction(SIGTRAP, &action, NULL);
wrmsr(MSR_IA32_DEBUGCTL, MSR_IA32_DEBUGCTL_LBR + MSR_IA32_DEBUGCTL_BTF); wrmsr(MSR_IA32_DEBUGCTL, MSR_IA32_DEBUGCTL_LBR + MSR_IA32_DEBUGCTL_BTF);
@ -105,7 +106,7 @@ void trace_lbr_begin() {
#endif #endif
} }
void trace_lbr_end() { void trace_lbr_end(void) {
#ifndef _WIN32 #ifndef _WIN32
wrmsr(MSR_IA32_DEBUGCTL, 0); wrmsr(MSR_IA32_DEBUGCTL, 0);
close(msrfd); close(msrfd);

129
umka.h
View File

@ -13,6 +13,7 @@
#include <assert.h> #include <assert.h>
#include <inttypes.h> #include <inttypes.h>
#include <signal.h> #include <signal.h>
#include <stdatomic.h>
#include <stddef.h> #include <stddef.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
@ -30,7 +31,7 @@ typedef void siginfo_t;
struct umka_ctx { struct umka_ctx {
int booted; int booted;
int running; atomic_int running;
}; };
#define UMKA_DEFAULT_DISPLAY_BPP 32 #define UMKA_DEFAULT_DISPLAY_BPP 32
@ -527,11 +528,11 @@ typedef struct {
} kos_node_package_t; } kos_node_package_t;
static inline void static inline void
umka_osloop() { umka_osloop(void) {
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"pushad;" "pusha;"
"call kos_osloop;" "call kos_osloop;"
"popad" "popa"
: :
: :
: "memory", "cc"); : "memory", "cc");
@ -660,21 +661,21 @@ kos_wait_event(void *event, uint32_t uid) {
: "memory", "cc"); : "memory", "cc");
} }
typedef uint32_t (*wait_test_t)(void *); typedef uint32_t (*wait_test_t)(void);
static inline void * static inline void *
kos_wait_events(wait_test_t wait_test, void *wait_param) { kos_wait_events(wait_test_t wait_test, void *wait_param) {
void *res; void *res;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"push %%ebx;" "push ebx;"
"push %%esi;" "push esi;"
"push %%edi;" "push edi;"
"push %%ebp;" "push ebp;"
"call _kos_wait_events;" "call _kos_wait_events;"
"pop %%ebp;" "pop ebp;"
"pop %%edi;" "pop edi;"
"pop %%esi;" "pop esi;"
"pop %%ebx" "pop ebx"
: "=a"(res) : "=a"(res)
: "c"(wait_param), : "c"(wait_param),
"d"(wait_test) "d"(wait_test)
@ -690,9 +691,9 @@ umka_fs_execute(const char *filename) {
// eax String length // eax String length
int32_t result; int32_t result;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"push %%ebp;" "push ebp;"
"call kos_fs_execute;" "call kos_fs_execute;"
"pop %%ebp" "pop ebp"
: "=a"(result) : "=a"(result)
: "a"(strlen(filename)), : "a"(strlen(filename)),
"b"(filename), "b"(filename),
@ -703,16 +704,16 @@ umka_fs_execute(const char *filename) {
} }
static inline size_t static inline size_t
umka_new_sys_threads(uint32_t flags, void (*entry)(), void *stack) { umka_new_sys_threads(uint32_t flags, void (*entry)(void), void *stack) {
size_t tid; size_t tid;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"push %%ebx;" "push ebx;"
"push %%esi;" "push esi;"
"push %%edi;" "push edi;"
"call kos_new_sys_threads;" "call kos_new_sys_threads;"
"pop %%edi;" "pop edi;"
"pop %%esi;" "pop esi;"
"pop %%ebx" "pop ebx"
: "=a"(tid) : "=a"(tid)
: "b"(flags), : "b"(flags),
"c"(entry), "c"(entry),
@ -722,7 +723,7 @@ umka_new_sys_threads(uint32_t flags, void (*entry)(), void *stack) {
} }
static inline void static inline void
kos_enable_acpi() { kos_enable_acpi(void) {
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"pusha;" "pusha;"
"call enable_acpi;" "call enable_acpi;"
@ -780,7 +781,7 @@ struct pci_dev {
extern struct pci_dev *kos_pci_root; extern struct pci_dev *kos_pci_root;
void void
kos_acpi_aml_init(); kos_acpi_aml_init(void);
STDCALL void STDCALL void
kos_aml_attach(acpi_node_t *parent, acpi_node_t *node); kos_aml_attach(acpi_node_t *parent, acpi_node_t *node);
@ -789,7 +790,7 @@ STDCALL void
kos_acpi_fill_pci_irqs(void *ctx); kos_acpi_fill_pci_irqs(void *ctx);
STDCALL amlctx_t* STDCALL amlctx_t*
kos_acpi_aml_new_thread(); kos_acpi_aml_new_thread(void);
STDCALL acpi_node_t* STDCALL acpi_node_t*
kos_aml_alloc_node(int32_t type); kos_aml_alloc_node(int32_t type);
@ -834,7 +835,7 @@ typedef struct {
} f76ret_t; } f76ret_t;
static inline void static inline void
umka_stack_init() { umka_stack_init(void) {
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"pusha;" "pusha;"
"call kos_stack_init;" "call kos_stack_init;"
@ -1127,36 +1128,16 @@ umka_scheduler_add_thread(appdata_t *thread, int32_t priority) {
extern appdata_t *kos_scheduler_current[KOS_NR_SCHED_QUEUES]; extern appdata_t *kos_scheduler_current[KOS_NR_SCHED_QUEUES];
typedef struct { void
appdata_t *appdata; i40_asm(uint32_t eax,
void *taskdata; uint32_t ebx,
int same; uint32_t ecx,
} find_next_task_t; uint32_t edx,
uint32_t esi,
static inline find_next_task_t uint32_t edi,
umka_find_next_task(int32_t priority) { uint32_t ebp,
find_next_task_t fnt; uint32_t *eax_out,
__asm__ __inline__ __volatile__ ( uint32_t *ebx_out);
"call find_next_task;"
"setz %%al;"
"movzx %%eax, %%al"
: "=b"(fnt.appdata),
"=D"(fnt.taskdata),
"=a"(fnt.same)
: "b"(priority)
: "memory", "cc");
return fnt;
}
void i40_asm(uint32_t eax,
uint32_t ebx,
uint32_t ecx,
uint32_t edx,
uint32_t esi,
uint32_t edi,
uint32_t ebp,
uint32_t *eax_out,
uint32_t *ebx_out);
static inline void static inline void
umka_i40(pushad_t *regs) { umka_i40(pushad_t *regs) {
@ -1203,7 +1184,7 @@ umka_sys_set_pixel(size_t x, size_t y, uint32_t color, int invert) {
} }
static inline uint32_t static inline uint32_t
umka_get_key() { umka_get_key(void) {
uint32_t key; uint32_t key;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
@ -1282,7 +1263,7 @@ umka_sys_process_info(int32_t pid, void *param) {
} }
static inline uint32_t static inline uint32_t
umka_sys_wait_for_event() { umka_sys_wait_for_event(void) {
uint32_t event; uint32_t event;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
@ -1293,7 +1274,7 @@ umka_sys_wait_for_event() {
} }
static inline uint32_t static inline uint32_t
umka_sys_check_for_event() { umka_sys_check_for_event(void) {
uint32_t event; uint32_t event;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
@ -1363,7 +1344,7 @@ umka_sys_bg_put_pixel(uint32_t offset, uint32_t color) {
} }
static inline void static inline void
umka_sys_bg_redraw() { umka_sys_bg_redraw(void) {
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
: :
@ -1397,7 +1378,7 @@ umka_sys_bg_put_img(void *image, size_t offset, size_t size) {
} }
static inline void * static inline void *
umka_sys_bg_map() { umka_sys_bg_map(void) {
void *addr; void *addr;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
@ -1488,7 +1469,7 @@ umka_sys_get_keyboard_layout(int type, void *layout) {
} }
static inline int static inline int
umka_sys_get_keyboard_lang() { umka_sys_get_keyboard_lang(void) {
int status; int status;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
@ -1501,7 +1482,7 @@ umka_sys_get_keyboard_lang() {
} }
static inline int static inline int
umka_sys_get_system_lang() { umka_sys_get_system_lang(void) {
int status; int status;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
@ -1536,7 +1517,7 @@ umka_sys_get_cwd(const char *buf, size_t len) {
} }
static inline struct point16s static inline struct point16s
umka_sys_get_mouse_pos_screen() { umka_sys_get_mouse_pos_screen(void) {
struct point16s pos; struct point16s pos;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
@ -1548,7 +1529,7 @@ umka_sys_get_mouse_pos_screen() {
} }
static inline struct point16s static inline struct point16s
umka_sys_get_mouse_pos_window() { umka_sys_get_mouse_pos_window(void) {
struct point16s pos; struct point16s pos;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
@ -1560,7 +1541,7 @@ umka_sys_get_mouse_pos_window() {
} }
static inline struct mouse_state static inline struct mouse_state
umka_sys_get_mouse_buttons_state() { umka_sys_get_mouse_buttons_state(void) {
struct mouse_state mouse; struct mouse_state mouse;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
@ -1572,7 +1553,7 @@ umka_sys_get_mouse_buttons_state() {
} }
static inline struct mouse_state_events static inline struct mouse_state_events
umka_sys_get_mouse_buttons_state_events() { umka_sys_get_mouse_buttons_state_events(void) {
union {uint32_t x; struct mouse_state_events m;} u; union {uint32_t x; struct mouse_state_events m;} u;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
@ -1694,7 +1675,7 @@ umka_sys_get_window_colors(void *colors) {
} }
static inline uint32_t static inline uint32_t
umka_sys_get_skin_height() { umka_sys_get_skin_height(void) {
uint32_t skin_height; uint32_t skin_height;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
@ -1766,7 +1747,7 @@ umka_sys_set_skin(const char *path) {
} }
static inline int static inline int
umka_sys_get_font_smoothing() { umka_sys_get_font_smoothing(void) {
int type; int type;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
@ -1789,7 +1770,7 @@ umka_sys_set_font_smoothing(int type) {
} }
static inline int static inline int
umka_sys_get_font_size() { umka_sys_get_font_size(void) {
uint32_t size; uint32_t size;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
@ -1823,7 +1804,7 @@ umka_sys_board_put(char c) {
} }
static inline struct board_get_ret static inline struct board_get_ret
umka_sys_board_get() { umka_sys_board_get(void) {
struct board_get_ret ret; struct board_get_ret ret;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
@ -1862,7 +1843,7 @@ umka_sys_set_keyboard_mode(int mode) {
} }
static inline int static inline int
umka_sys_get_keyboard_mode() { umka_sys_get_keyboard_mode(void) {
int mode; int mode;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
@ -1936,7 +1917,7 @@ umka_sys_blit_bitmap(int operation, int background, int transparent,
} }
static inline uint32_t static inline uint32_t
umka_sys_net_get_dev_count() { umka_sys_net_get_dev_count(void) {
uint32_t count; uint32_t count;
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"call i40" "call i40"
@ -2439,7 +2420,7 @@ struct cmd_ret_sys_get_mouse_pos_screen {
}; };
struct umka_cmd { struct umka_cmd {
uint32_t status; atomic_int status;
uint32_t type; uint32_t type;
union { union {
struct cmd_set_mouse_data set_mouse_data; struct cmd_set_mouse_data set_mouse_data;

View File

@ -33,7 +33,7 @@ struct umka_fuse_ctx {
}; };
static struct umka_fuse_ctx * static struct umka_fuse_ctx *
umka_fuse_init() { umka_fuse_init(void) {
struct umka_fuse_ctx *ctx = malloc(sizeof(struct umka_fuse_ctx)); struct umka_fuse_ctx *ctx = malloc(sizeof(struct umka_fuse_ctx));
ctx->umka = umka_init(); ctx->umka = umka_init();
ctx->io = io_init(&ctx->umka->running); ctx->io = io_init(&ctx->umka->running);

View File

@ -142,7 +142,9 @@ void acpi_process_dev(char *path) {
} }
int int
main () { main (int argc, char *argv[]) {
(void)argc;
(void)argv;
kos_boot.bpp = 32; kos_boot.bpp = 32;
kos_boot.x_res = UMKA_DEFAULT_DISPLAY_WIDTH; kos_boot.x_res = UMKA_DEFAULT_DISPLAY_WIDTH;
kos_boot.y_res = UMKA_DEFAULT_DISPLAY_HEIGHT; kos_boot.y_res = UMKA_DEFAULT_DISPLAY_HEIGHT;

View File

@ -84,7 +84,7 @@ umka_os_init(FILE *fin, FILE *fout, FILE *fboardlog) {
return ctx; return ctx;
} }
void build_history_filename() { void build_history_filename(void) {
const char *dir_name; const char *dir_name;
if (!(dir_name = getenv("HOME"))) { if (!(dir_name = getenv("HOME"))) {
dir_name = "."; dir_name = ".";
@ -107,7 +107,7 @@ thread_start(int is_kernel, void (*entry)(void), size_t stack_size) {
} }
static void static void
dump_procs() { dump_procs(void) {
for (int i = 0; i < KOS_NR_SCHED_QUEUES; i++) { for (int i = 0; i < KOS_NR_SCHED_QUEUES; i++) {
fprintf(stderr, "sched queue #%i:", i); fprintf(stderr, "sched queue #%i:", i);
appdata_t *p_begin = kos_scheduler_current[i]; appdata_t *p_begin = kos_scheduler_current[i];
@ -203,7 +203,7 @@ umka_display(void *arg) {
return NULL; return NULL;
} }
void (*copy_display)(void *); void (*copy_display)(void *) = NULL;
switch (window_surface->format->format) { switch (window_surface->format->format) {
case SDL_PIXELFORMAT_RGB888: case SDL_PIXELFORMAT_RGB888:
@ -225,8 +225,8 @@ umka_display(void *arg) {
return NULL; return NULL;
} }
uint32_t static uint32_t
umka_run_cmd_wait_test(/* void *wait_param in ebx */) { umka_run_cmd_wait_test(void /* struct appdata * with wait_param is in ebx */) {
appdata_t *app; appdata_t *app;
__asm__ __volatile__ __inline__ ("":"=b"(app)::); __asm__ __volatile__ __inline__ ("":"=b"(app)::);
struct umka_cmd *cmd = (struct umka_cmd*)app->wait_param; struct umka_cmd *cmd = (struct umka_cmd*)app->wait_param;
@ -234,7 +234,7 @@ umka_run_cmd_wait_test(/* void *wait_param in ebx */) {
} }
static void static void
umka_thread_cmd_runner() { umka_thread_cmd_runner(void) {
umka_sti(); umka_sti();
while (1) { while (1) {
kos_wait_events(umka_run_cmd_wait_test, umka_cmd_buf); kos_wait_events(umka_run_cmd_wait_test, umka_cmd_buf);
@ -250,7 +250,7 @@ umka_monitor(void *arg) {
} }
static void static void
umka_thread_board() { umka_thread_board(void) {
struct board_get_ret c; struct board_get_ret c;
while (1) { while (1) {
c = umka_sys_board_get(); c = umka_sys_board_get();

View File

@ -41,7 +41,7 @@ umka_shell_init(int reproducible, FILE *fin, FILE *fout) {
return ctx; return ctx;
} }
void build_history_filename() { void build_history_filename(void) {
const char *dir_name; const char *dir_name;
if (!(dir_name = getenv("HOME"))) { if (!(dir_name = getenv("HOME"))) {
dir_name = "."; dir_name = ".";

View File

@ -40,7 +40,7 @@ thread_io(void *arg) {
switch (cmd->type) { switch (cmd->type) {
case IOT_CMD_TYPE_READ: case IOT_CMD_TYPE_READ:
ret = read(cmd->read.arg.fd, cmd->read.arg.buf, cmd->read.arg.count); ret = read(cmd->read.arg.fd, cmd->read.arg.buf, cmd->read.arg.count);
atomic_store_explicit(&cmd->read.ret.val, ret, memory_order_release); cmd->read.ret.val = ret;
break; break;
case IOT_CMD_TYPE_WRITE: case IOT_CMD_TYPE_WRITE:
cmd->read.ret.val = write(cmd->read.arg.fd, cmd->read.arg.buf, cmd->read.ret.val = write(cmd->read.arg.fd, cmd->read.arg.buf,
@ -57,7 +57,7 @@ thread_io(void *arg) {
} }
static uint32_t static uint32_t
io_async_submit_wait_test() { io_async_submit_wait_test(void) {
// appdata_t *app; // appdata_t *app;
// __asm__ __volatile__ ("":"=b"(app)::); // __asm__ __volatile__ ("":"=b"(app)::);
// struct io_uring_queue *q = app->wait_param; // struct io_uring_queue *q = app->wait_param;
@ -66,7 +66,7 @@ io_async_submit_wait_test() {
} }
static uint32_t static uint32_t
io_async_complete_wait_test() { io_async_complete_wait_test(void) {
// appdata_t *app; // appdata_t *app;
// __asm__ __volatile__ ("":"=b"(app)::); // __asm__ __volatile__ ("":"=b"(app)::);
// struct io_uring_queue *q = app->wait_param; // struct io_uring_queue *q = app->wait_param;
@ -89,7 +89,7 @@ io_async_read(int fd, void *buf, size_t count, void *arg) {
pthread_cond_signal(&cmd->iot_cond); pthread_cond_signal(&cmd->iot_cond);
kos_wait_events(io_async_complete_wait_test, NULL); kos_wait_events(io_async_complete_wait_test, NULL);
ssize_t res = atomic_load_explicit(&cmd->read.ret.val, memory_order_acquire); ssize_t res = cmd->read.ret.val;
atomic_store_explicit(&cmd->status, UMKA_CMD_STATUS_EMPTY, memory_order_release); atomic_store_explicit(&cmd->status, UMKA_CMD_STATUS_EMPTY, memory_order_release);
pthread_mutex_unlock(&cmd->mutex); pthread_mutex_unlock(&cmd->mutex);
@ -107,7 +107,7 @@ io_async_write(int fd, const void *buf, size_t count, void *arg) {
} }
struct umka_io * struct umka_io *
io_init(int *running) { io_init(atomic_int *running) {
struct umka_io *io = malloc(sizeof(struct umka_io)); struct umka_io *io = malloc(sizeof(struct umka_io));
io->running = running; io->running = running;
if (running) { if (running) {

View File

@ -10,11 +10,12 @@
#ifndef UMKAIO_H_INCLUDED #ifndef UMKAIO_H_INCLUDED
#define UMKAIO_H_INCLUDED #define UMKAIO_H_INCLUDED
#include <stdatomic.h>
#include <stddef.h> #include <stddef.h>
#include <pthread.h> #include <pthread.h>
struct umka_io { struct umka_io {
const int *running; const atomic_int *running;
pthread_t iot; pthread_t iot;
}; };
@ -57,7 +58,7 @@ struct iot_cmd {
pthread_cond_t iot_cond; pthread_cond_t iot_cond;
pthread_mutex_t iot_mutex; pthread_mutex_t iot_mutex;
pthread_mutex_t mutex; pthread_mutex_t mutex;
int status; atomic_int status;
int type; int type;
union { union {
union iot_cmd_read read; union iot_cmd_read read;
@ -66,7 +67,7 @@ struct iot_cmd {
}; };
struct umka_io * struct umka_io *
io_init(int *running); io_init(atomic_int *running);
void void
io_close(struct umka_io *io); io_close(struct umka_io *io);

View File

@ -6,12 +6,13 @@
Copyright (C) 2021, 2023 Ivan Baravy <dunkaist@gmail.com> Copyright (C) 2021, 2023 Ivan Baravy <dunkaist@gmail.com>
*/ */
#include <stdatomic.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "umka.h" #include "umka.h"
#include "shell.h" #include "shell.h"
uint32_t umka_irq_number; atomic_int umka_irq_number;
struct devices_dat_entry { struct devices_dat_entry {
uint8_t fun:3; uint8_t fun:3;

View File

@ -9,9 +9,12 @@
#ifndef UMKART_H_INCLUDED #ifndef UMKART_H_INCLUDED
#define UMKART_H_INCLUDED #define UMKART_H_INCLUDED
#include <stdatomic.h>
#include "umka.h" #include "umka.h"
#include "shell.h" #include "shell.h"
extern atomic_int umka_irq_number;
extern struct umka_cmd umka_cmd_buf[CMD_BUF_LEN]; extern struct umka_cmd umka_cmd_buf[CMD_BUF_LEN];
void void

1
vnet.c
View File

@ -19,6 +19,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "umka.h" #include "umka.h"
#include "umkart.h"
#include "trace.h" #include "trace.h"
#include "vnet.h" #include "vnet.h"
#include "vnet/tap.h" #include "vnet/tap.h"

1
vnet.h
View File

@ -14,7 +14,6 @@
#define UMKA_VNET_NAME "umka%d" #define UMKA_VNET_NAME "umka%d"
#define VNET_BUFIN_CAP (NET_BUFFER_SIZE - offsetof(net_buff_t, data)) #define VNET_BUFIN_CAP (NET_BUFFER_SIZE - offsetof(net_buff_t, data))
extern uint32_t umka_irq_number;
enum vnet_type { enum vnet_type {
VNET_FILE, VNET_FILE,

View File

@ -17,14 +17,14 @@
#include "vnet.h" #include "vnet.h"
static STDCALL void static STDCALL void
vnet_unload_file() { vnet_unload_file(void) {
printf("vnet_unload_file\n"); printf("vnet_unload_file\n");
COVERAGE_ON(); COVERAGE_ON();
COVERAGE_OFF(); COVERAGE_OFF();
} }
static STDCALL void static STDCALL void
vnet_reset_file() { vnet_reset_file(void) {
printf("vnet_reset_file\n"); printf("vnet_reset_file\n");
COVERAGE_ON(); COVERAGE_ON();
COVERAGE_OFF(); COVERAGE_OFF();
@ -58,7 +58,7 @@ vnet_transmit_file(net_buff_t *buf) {
} }
struct vnet * struct vnet *
vnet_init_file() { vnet_init_file(void) {
int fdin; int fdin;
int fdout; int fdout;