Skip to content

Commit

Permalink
Fix symbol clash with Linux's printk
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Dec 21, 2020
1 parent 76c105b commit 3111729
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
#include <stdio.h>
#include <stdlib.h>

void printk(const char *msg, ...);
void vprintk(const char *msg, va_list args);
void ish_printk(const char *msg, ...);
void ish_vprintk(const char *msg, va_list args);
#define printk ish_printk

// debug output utilities
// save me
Expand Down
15 changes: 8 additions & 7 deletions jit/jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include "emu/memory.h"
#include "emu/interrupt.h"
#include "util/list.h"
#include "kernel/calls.h"

extern int current_pid(void);

static void jit_block_disconnect(struct jit *jit, struct jit_block *block);
static void jit_block_free(struct jit *jit, struct jit_block *block);
Expand Down Expand Up @@ -70,7 +71,7 @@ void jit_invalidate_all(struct jit *jit) {
}

static void jit_resize_hash(struct jit *jit, size_t new_size) {
TRACE_(verbose, "%d resizing hash to %lu, using %lu bytes for gadgets\n", current ? current->pid : 0, new_size, jit->mem_used);
TRACE_(verbose, "%d resizing hash to %lu, using %lu bytes for gadgets\n", current_pid(), new_size, jit->mem_used);
struct list *new_hash = calloc(new_size, sizeof(struct list));
for (size_t i = 0; i < jit->hash_size; i++) {
if (list_null(&jit->hash[i]))
Expand Down Expand Up @@ -113,7 +114,7 @@ static struct jit_block *jit_lookup(struct jit *jit, addr_t addr) {

static struct jit_block *jit_block_compile(addr_t ip, struct tlb *tlb) {
struct gen_state state;
TRACE("%d %08x --- compiling:\n", current->pid, ip);
TRACE("%d %08x --- compiling:\n", current_pid(), ip);
gen_start(ip, &state);
while (true) {
if (!gen_step32(&state, tlb))
Expand Down Expand Up @@ -196,7 +197,7 @@ static int cpu_step_to_interrupt(struct cpu_state *cpu, struct tlb *tlb) {
block = jit_block_compile(ip, tlb);
jit_insert(jit, block);
} else {
TRACE("%d %08x --- missed cache\n", current->pid, ip);
TRACE("%d %08x --- missed cache\n", current_pid(), ip);
}
cache[cache_index] = block;
unlock(&jit->lock);
Expand Down Expand Up @@ -225,12 +226,12 @@ static int cpu_step_to_interrupt(struct cpu_state *cpu, struct tlb *tlb) {
// block may be jetsam, but that's ok, because it can't be freed until
// every thread on this jit is not executing anything

TRACE("%d %08x --- cycle %ld\n", current->pid, ip, cpu->cycle);
TRACE("%d %08x --- cycle %ld\n", current_pid(), ip, frame->cpu.cycle);

interrupt = jit_enter(block, frame, tlb);
*cpu = frame->cpu;
if (interrupt == INT_NONE && ++cpu->cycle % (1 << 10) == 0)
if (interrupt == INT_NONE && ++frame->cpu.cycle % (1 << 10) == 0)
interrupt = INT_TIMER;
*cpu = frame->cpu;
}

free(frame);
Expand Down
6 changes: 3 additions & 3 deletions kernel/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static void output_line(const char *line) {
log_buf_append("\n");
}

void vprintk(const char *msg, va_list args) {
void ish_vprintk(const char *msg, va_list args) {
// format the message
// I'm trusting you to not pass an absurdly long message
static __thread char buf[16384] = "";
Expand All @@ -124,10 +124,10 @@ void vprintk(const char *msg, va_list args) {
unlock(&log_lock);
memmove(buf, b, strlen(b) + 1);
}
void printk(const char *msg, ...) {
void ish_printk(const char *msg, ...) {
va_list args;
va_start(args, msg);
vprintk(msg, args);
ish_vprintk(msg, args);
va_end(args);
}

Expand Down

0 comments on commit 3111729

Please sign in to comment.