Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions booter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,39 @@ BOOTVM_IMAGE_HEAP_SIZE := 0x1000000

all: $(BUILD_DIR)/hello $(BUILD_DIR)/should_crash $(BUILD_DIR)/should_pagefault $(BUILD_DIR)/bigio $(BOOTVM_PROG)

CFLAGS = $(OPTIMIZE) -mv$(TOOLARCH) -DARCHV=$(ARCHV) -Wall -Werror -Wno-builtin-requires-header -g -I. -I$(INSTALLPATH)/include -I$(KERNEL_BUILD_DIR)/include
LDFLAGS = -L$(INSTALLPATH)/lib -moslib=h2 -Qunused-arguments
ifeq ($(PICOLIBC),1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about pulling all these if pico sections into one make include file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, I could do something like that
but maybe I should wait till H2 unit tests are cleaned up, so I don't have to rebase multiple times?

OSLIB_CFLAGS = --target=hexagon-h2-elf --cstdlib=picolibc
OSLIB_LDFLAGS = --target=hexagon-h2-elf --cstdlib=picolibc
# Derive template path from the resolved compiler location: bin/../templates/staticExecutable/
PICOLIBC_LCS := $(abspath $(dir $(shell which $(CC)))/../templates/staticExecutable/static-executable-h2-picolibc.lcs.template)
GUEST_LDSCRIPT = -Wl,--script=$(PICOLIBC_LCS)
else
OSLIB_CFLAGS =
OSLIB_LDFLAGS = -moslib=h2
GUEST_LDSCRIPT =
endif

CFLAGS = $(OSLIB_CFLAGS) $(OPTIMIZE) -mv$(TOOLARCH) -DARCHV=$(ARCHV) -Wall -Wno-builtin-requires-header -g -I. -I$(INSTALLPATH)/include -I$(KERNEL_BUILD_DIR)/include
LDFLAGS = -L$(INSTALLPATH)/lib $(OSLIB_LDFLAGS) -Qunused-arguments

include $(H2DIR)/scripts/Makefile.inc.config
include $(H2DIR)/scripts/Makefile.inc.opensource
include $(H2DIR)/scripts/Makefile.inc.bootvm


$(BUILD_DIR)/hello: $(BUILD_DIR)/hello.o
${CC} $(LDFLAGS) $(CFLAGS) -Wl,--section-start=.start=$(H2K_GUEST_START) -o $@ $<
${CC} $(LDFLAGS) $(CFLAGS) $(GUEST_LDSCRIPT) -Wl,--section-start=.start=$(H2K_GUEST_START) -o $@ $<

$(BUILD_DIR)/should_pagefault: OPTIMIZE = -O0
$(BUILD_DIR)/should_pagefault: $(BUILD_DIR)/should_pagefault.o
${CC} $(LDFLAGS) $(CFLAGS) -O0 -Wl,--section-start=.start=$(H2K_GUEST_START) -o $@ $<
${CC} $(LDFLAGS) $(CFLAGS) $(GUEST_LDSCRIPT) -O0 -Wl,--section-start=.start=$(H2K_GUEST_START) -o $@ $<

$(BUILD_DIR)/should_crash: OPTIMIZE = -O0
$(BUILD_DIR)/should_crash: $(BUILD_DIR)/should_crash.o
${CC} $(LDFLAGS) $(CFLAGS) -O0 -Wl,--section-start=.start=$(H2K_GUEST_START) -o $@ $<
${CC} $(LDFLAGS) $(CFLAGS) $(GUEST_LDSCRIPT) -O0 -Wl,--section-start=.start=$(H2K_GUEST_START) -o $@ $<

$(BUILD_DIR)/bigio: $(BUILD_DIR)/bigio.o
${CC} $(LDFLAGS) $(CFLAGS) -O0 -Wl,--section-start=.start=$(H2K_GUEST_START) -o $@ $<
${CC} $(LDFLAGS) $(CFLAGS) $(GUEST_LDSCRIPT) -O0 -Wl,--section-start=.start=$(H2K_GUEST_START) -o $@ $<

$(BOOTVM_IMAGE): $(BUILD_DIR)/booter.o $(BUILD_DIR)/booter_event.o $(BOOTVM_IMAGE_DEPS)
${CC} $(LDFLAGS) $(CFLAGS) $(BOOTVM_IMAGE_CFLAGS) -Wl,--defsym=HEAP_SIZE=$(BOOTVM_IMAGE_HEAP_SIZE) -Wl,--defsym=STACK_SIZE=0x1000 -Wl,--defsym=__h2_thread_stop_hook__=0xfffffff0 -o $@ $(BUILD_DIR)/booter.o $(BUILD_DIR)/booter_event.o $(BOOTVM_ENTRY_O)
Expand Down
6 changes: 4 additions & 2 deletions booter/booter.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ void add_linear_trans(unsigned int idx, unsigned long va, unsigned long long pa,
vm_params[idx].pmap_added = 1;
}

if (NULL == (pmap->base.raw = (h2_u32_t)realloc((void *)(pmap->base.raw), sizeof(H2K_linear_fmt_t) * (end + npages + 1)))) {
if (0 == (pmap->base.raw = (h2_u32_t)realloc((void *)(pmap->base.raw), sizeof(H2K_linear_fmt_t) * (end + npages + 1)))) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 0?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

booter.c:673:11: warning: comparison between pointer and integer ('void *' and 'h2_u32_t' (aka 'unsigned int')) [-Wpointer-integer-compare]
  673 |         if (NULL == (pmap->base.raw = (h2_u32_t)realloc((void *)(pmap->base.raw), sizeof(H2K_linear_fmt_t) * (end + npages + 1)))) {
      |             ~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So pico defines NULL differently? I thought that def was part of the tools and we don't get the same warning when building with the existing dinkum tools.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in Pico toolchain NULL in preprocessed to ((void*)0) (comes from clang's stddef.h)
existing tools might be just defining NULL to 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then the right thing to do is probably this, which works with dinkum also:

diff --git a/booter/booter.c b/booter/booter.c
index 071702bc6..93fcf9adc 100644
--- a/booter/booter.c
+++ b/booter/booter.c
@@ -670,7 +670,7 @@ void add_linear_trans(unsigned int idx, unsigned long va, unsigned long long pa,
vm_params[idx].pmap_added = 1;
}

  • if (NULL == (pmap->base.raw = (h2_u32_t)realloc((void *)(pmap->base.raw), sizeof(H2K_linear_fmt_t) * (end + npages + 1)))) {
  • if (NULL == (void *)(pmap->base.raw = (h2_u32_t)realloc((void *)(pmap->base.raw), sizeof(H2K_linear_fmt_t) * (end + npages + 1)))) {
    error("realloc pmap->base", NULL);
    }
    base = (H2K_linear_fmt_t *)(pmap->base.raw);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason int types are used for pointers?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably H2K_offset_t should union a H2K_linear_fmt_t * so that it can be used without the funny casts here. But all this code is kind of "wrong" in the sense that we shouldn't really have the guest's initial translations allocating in booter's heap. So all of this needs to be reworked and we can fix this type of thing then.

error("realloc pmap->base", NULL);
}
base = (H2K_linear_fmt_t *)(pmap->base.raw);
Expand Down Expand Up @@ -763,7 +763,7 @@ void clade_setup(unsigned int idx, long offset) {
/* Copy high-prio exception data to TCM */
ex_hi_size = ex_hi_end - ex_hi_start;
if (ex_hi_size && tcm_size) {
if (NULL == (vm_params[idx].clade_ex_hi = (unsigned int)h2_galloc(&tcm_alloc, ex_hi_size, 4096, 0))) {
if (0 == (vm_params[idx].clade_ex_hi = (unsigned int)h2_galloc(&tcm_alloc, ex_hi_size, 4096, 0))) {
FAIL("\tgalloc ex_hi", "");
}
// BOOTER_PRINTF("memcpy(0x%08x, 0x%08lx, 0x%08lx\n", vm_params[idx].clade_ex_hi, ex_hi_start + offset, ex_hi_size);
Expand Down Expand Up @@ -2309,6 +2309,7 @@ unsigned int process_line(int argc, char **argv, unsigned int idx) {
return idx;
}

#ifndef __PICOLIBC__
size_t getline(char **lineptr, size_t *n, FILE *stream) {

char *buf = NULL;
Expand Down Expand Up @@ -2361,6 +2362,7 @@ size_t getline(char **lineptr, size_t *n, FILE *stream) {

return p - buf - 1;
}
#endif /* !__PICOLIBC__ */

int main(int argc, char **argv)
{
Expand Down
6 changes: 5 additions & 1 deletion kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ H2DIR ?= ..

include ../scripts/Makefile.inc.tools

# Ensure toolchain path override is honored even when kernel is built directly.
ifneq ($(TOOLCHAIN_BIN),)
export PATH := $(TOOLCHAIN_BIN):$(PATH)
endif

ifeq ($(USE_PKW),1)
export PKW_VERSIONS := hexagon-tools=$(TOOLS_FLAVOR_KERNEL) arch=$(ARCH_FLAVOR)
endif
Expand Down Expand Up @@ -228,4 +233,3 @@ ifeq ($(USE_PKW),1)
endif

check: $(BUILD_DIR)/libh2check.a

20 changes: 18 additions & 2 deletions kernel/build/offsets/make.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Yo. -*- Makefile -*-

# offsets is a target-side generator program (run under simulator) and uses
# libc headers like <stdio.h>. When building with PICOLIBC, select the picolibc
# sysroot via --target and --cstdlib flags.
ifeq ($(PICOLIBC),1)
OFFSETS_TARGET_FLAG := --target=hexagon-none-elf --cstdlib=picolibc
else
OFFSETS_TARGET_FLAG :=
endif

ifeq ($(PICOLIBC),1)
# Provide heap symbols and default memory layout expected by picolibc's libc.
# Ask the compiler for the sysroot-relative path so this works across toolchains.
OFFSETS_LDSCRIPT := -Wl,-T,$(shell $(CC) $(OFFSETS_TARGET_FLAG) -print-file-name=picolibc.ld)
else
OFFSETS_LDSCRIPT :=
endif

$(BUILD_DIR)/include/asm_offsets.h: $(BUILD_DIR)/offsets
mkdir -p $(dir $@)
ifeq ($(RUN), $(RUN_TOOLSIM))
Expand All @@ -10,9 +27,8 @@ endif

$(BUILD_DIR)/offsets: $(DIR)offsets.ref.c includes
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -o $@ $<
$(CC) $(OFFSETS_TARGET_FLAG) $(OFFSETS_LDSCRIPT) $(CFLAGS) -o $@ $<

DEST_HFILES += $(BUILD_DIR)/include/asm_offsets.h

CLEAN_EXTRAS += $(BUILD_DIR)/offsets

1 change: 1 addition & 0 deletions kernel/build/offsets/offsets.ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ int main(int argc, char **argv)
fprintf(outfile, "#define STATUS_INTBLOCKED %d\n",H2K_STATUS_INTBLOCKED);
fprintf(outfile, "#define STATUS_VMWAIT %d\n",H2K_STATUS_VMWAIT);

fclose(outfile);
return 0;
}

2 changes: 1 addition & 1 deletion kernel/data/intconfig/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#define BAD ((void *)(0xdeadbeef))

#define TEST_FASTINT_TRAPMASK 0x9
#define TEST_FASTINT_TRAPMASK 0xb

H2K_thread_context a;

Expand Down
19 changes: 18 additions & 1 deletion kernel/mem/tlbmisc/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,29 @@ int main()
}

u64_t tlb_entry = H2K_mem_tlb_read(tlb_index_last_used); // tlb entry as template
u32_t va = H2K_LINK_ADDR; // VA set H2K_LINK_ADDR OK to use if just within a unit test
/* Use a guest VA that is NOT in the kernel's TLB. H2K_LINK_ADDR (0xff000000)
* cannot be used: the kernel's boot TLB entries for that address have the
* GLOBAL bit set, so H2K_mem_tlb_probe() finds the kernel's own entry
* (global entries match any ASID) and H2K_mem_tlb_invalidate_va() then
* zeroes it, causing an instruction TLB miss and a fatal crash.
* 0x02000000 is the default H2K_GUEST_START -- never mapped by the kernel. */
u32_t va = 0x02000000;
volatile u32_t asid = 0; // ASID set for running thread
__asm__ __volatile(
" %0 = ssr \n"
" %0 = extractu(%0,#7,#8)\n"
: "=r"(asid));

/* Clear the global bit from the template so the entry is ASID-specific.
* Kernel boot entries have global=1; writing a global entry for a guest VA
* would make tlbp match it regardless of ASID, which is not what we want
* to test here. */
{
H2K_mem_tlbfmt_t entry_fmt;
entry_fmt.raw = tlb_entry;
entry_fmt.global = 0;
tlb_entry = entry_fmt.raw;
}

tlb_entry = update_tlb_entry_va_asid(tlb_entry, va, asid); // ensure tlb entry not duplicate va by update
set_tlb_entry_at_table_index(tlb_index_first_free, tlb_entry); // overwrite free tlb index's entry with va update
Expand Down
8 changes: 8 additions & 0 deletions kernel/traps/config/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,23 @@ H2K_thread_context a;
s32_t asid;

int TH_expected_intinfo_ints = 0;
/* TH_test_started: when the kernel boot path (H2K_init_setup_bootvm) runs
* before main(), it calls H2K_trap_config(SET_CPUS_INTS) with the boot vm's
* default values, which would otherwise trip the assertion below. main()
* sets this flag so only test-driven calls are checked.
*/
int TH_test_started = 0;
void H2K_vm_int_intinfo_init(H2K_vmblock_t *vmblock, u32_t num_ints)
{
if (!TH_test_started) return;
if (num_ints != TH_expected_intinfo_ints) FAIL("intinfo ints");
}

int main()
{
u32_t i, vm, ret;
__asm__ __volatile(GLOBAL_REG_STR " = %0 " : : "r"(&H2K_kg));
TH_test_started = 1;
H2K_thread_init();
H2K_trace_init();
H2K_mem_alloc_init(Heap, DEFAULT_ALLOC_HEAP_SIZE);
Expand Down
7 changes: 5 additions & 2 deletions kernel/util/tree/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ EXEC=test.elf
PYTHON_GENERATOR_SCRIPT=gentests.py
PYTHON_GENERATED_FILES=generated_tests.dat

include Makefile.inc
# Use 'override' so Makefile.inc.test's default (H2K_HEAP_SIZE = 0x00010000)
# cannot overwrite this value. The tree test needs 1 MB to hold 700-node
# trees across 32 test cases without exhausting the heap.
override H2K_HEAP_SIZE := 0x00100000

H2K_HEAP_SIZE := 0x00100000
include Makefile.inc

OSLIB=
18 changes: 18 additions & 0 deletions kernel/vm/vmmap/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ void H2K_fatal_thread()

H2K_kg_t H2K_kg;

/* TH_test_started: see kernel/traps/config/test for rationale. The kernel
* boot path (H2K_thread_boot -> H2K_init_setup) calls H2K_asid_table_inc
* (and may exercise other paths) before main() runs. Stubs in this file
* early-return safe defaults until main() flips this flag.
*/
u32_t TH_test_started = 0;

u32_t TH_expected_stlb_invasid = 0;
u32_t TH_expected_tlb_invasid = 0;
u32_t TH_expected_stlb_inv_va = 0;
Expand All @@ -46,13 +53,15 @@ u32_t TH_newasid = 0;

void H2K_mem_stlb_invalidate_asid(u32_t asid)
{
if (!TH_test_started) return;
if (TH_expected_stlb_invasid == 0) FAIL("Unexpected invalidate stlb");
TH_expected_stlb_invasid = 0;
if (asid != TH_oldasid) FAIL("unexpected asid inv stlb");
TH_saw_stlb_invasid = 1;
}

void H2K_mem_stlb_invalidate_va(u32_t va, u32_t count, u32_t asid, H2K_thread_context *me) {
if (!TH_test_started) return;
if (TH_expected_stlb_inv_va == 0) FAIL("Unexpected invalidate stlb va");
TH_expected_stlb_inv_va = 0;
if (asid != TH_oldasid) FAIL("unexpected asid inv stlb");
Expand All @@ -61,13 +70,15 @@ void H2K_mem_stlb_invalidate_va(u32_t va, u32_t count, u32_t asid, H2K_thread_co

void H2K_mem_tlb_invalidate_asid(u32_t asid)
{
if (!TH_test_started) return;
if (TH_expected_tlb_invasid == 0) FAIL("Unexpected invalidate tlb");
TH_expected_tlb_invasid = 0;
if (asid != TH_oldasid) FAIL("unexpected asid inv tlb");
TH_saw_tlb_invasid = 1;
}

void H2K_mem_tlb_invalidate_va(u32_t va, u32_t count, u32_t asid, H2K_thread_context *me) {
if (!TH_test_started) return;
if (TH_expected_tlb_inv_va == 0) FAIL("Unexpected invalidate tlb va");
TH_expected_tlb_inv_va = 0;
if (asid != TH_oldasid) FAIL("unexpected asid inv tlb");
Expand All @@ -81,6 +92,11 @@ u32_t TH_saw_table_dec = 0;

s32_t H2K_asid_table_inc(u32_t newptb, translation_type type, tlb_invalidate_flag flag, u32_t extra, H2K_vmblock_t *vmblock)
{
if (!TH_test_started) {
/* Boot's H2K_init_setup_bootvm calls this once with the boot
* vm's offset translation; any nonzero return is a valid ASID. */
return 1;
}
if (TH_expected_table_inc == 0) FAIL("Unexpected inc");
TH_expected_table_inc = 0;
if (newptb != a.r00) FAIL("newptb arg");
Expand All @@ -93,6 +109,7 @@ s32_t H2K_asid_table_inc(u32_t newptb, translation_type type, tlb_invalidate_fla

void H2K_asid_table_dec(u32_t asid)
{
if (!TH_test_started) return;
if (TH_expected_table_dec == 0) FAIL("Unexpected inc");
if (asid != TH_oldasid) FAIL("Wrong ASID");
TH_saw_table_dec = 1;
Expand All @@ -101,6 +118,7 @@ void H2K_asid_table_dec(u32_t asid)
int main()
{
__asm__ __volatile(GLOBAL_REG_STR " = %0 " : : "r"(&H2K_kg));
TH_test_started = 1;

a.vmblock = &av;

Expand Down
13 changes: 11 additions & 2 deletions libs/blast/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@




# Picolibc support: if PICOLIBC=1, use --target=hexagon-h2-elf --cstdlib=picolibc
ifeq ($(PICOLIBC),1)
TARGET_FLAG = --target=hexagon-h2-elf --cstdlib=picolibc
else
TARGET_FLAG =
endif

CC = hexagon-clang
AR = hexagon-ar
CFLAGS = -mv$(TOOLARCH) -DARCHV=$(ARCHV) -Iinclude -Wall -I../h2/include -I../../kernel/include -g $(OPTIMIZE) $(OPT_ADD) -G0
ASFLAGS = -mv$(TOOLARCH) -DARCHV=$(ARCHV) -Iinclude -Wall -I../h2/include -I../../kernel/include
CFLAGS = $(TARGET_FLAG) -mv$(TOOLARCH) -DARCHV=$(ARCHV) -Iinclude -Wall -I../h2/include -I../../kernel/include -g $(OPTIMIZE) $(OPT_ADD) -G0
ASFLAGS = $(TARGET_FLAG) -mv$(TOOLARCH) -DARCHV=$(ARCHV) -Iinclude -Wall -I../h2/include -I../../kernel/include
OPTIMIZE := -O2

export BLAST_LIB_INCLUDE=$(shell pwd)/include
Expand Down
9 changes: 8 additions & 1 deletion libs/h2/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@

ALL: dummy

# Picolibc support: if PICOLIBC=1, use --target=hexagon-h2-elf --cstdlib=picolibc
ifeq ($(PICOLIBC),1)
TARGET_FLAG = --target=hexagon-h2-elf --cstdlib=picolibc
else
TARGET_FLAG =
endif

OPTIMIZE := -Os

CFLAGS := -I$(INSTALLPATH)/include -G0 $(OPTIMIZE) $(OPT_ADD) -mv$(TOOLARCH) -DARCHV=$(ARCHV) -Wall -Wno-builtin-requires-header -Werror -g
CFLAGS := $(TARGET_FLAG) -I$(INSTALLPATH)/include -G0 $(OPTIMIZE) $(OPT_ADD) -mv$(TOOLARCH) -DARCHV=$(ARCHV) -Wall -Wno-builtin-requires-header -Werror -g

ifdef DEBUG
CFLAGS += -DDEBUG
Expand Down
9 changes: 8 additions & 1 deletion libs/h2_compat/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ ALL: dummy

OPTIMIZE := -Os

CFLAGS := -I$(INSTALLPATH)/include -I../../libs/syscall/angel/include -G0 $(OPTIMIZE) $(OPT_ADD) -mv$(TOOLARCH) -DARCHV=$(ARCHV) -Wall -Wno-builtin-requires-header -Werror -g
# Picolibc support: if PICOLIBC=1, use --target=hexagon-h2-elf --cstdlib=picolibc
ifeq ($(PICOLIBC),1)
TARGET_FLAG = --target=hexagon-h2-elf --cstdlib=picolibc
else
TARGET_FLAG =
endif

CFLAGS := $(TARGET_FLAG) -I$(INSTALLPATH)/include -I../../libs/syscall/angel/include -G0 $(OPTIMIZE) $(OPT_ADD) -mv$(TOOLARCH) -DARCHV=$(ARCHV) -Wall -Wno-builtin-requires-header -Werror -g

ifdef DEBUG
CFLAGS += -DDEBUG
Expand Down
3 changes: 3 additions & 0 deletions libs/h2_compat/alloc/h2_alloc.ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include <h2_alloc.h>
#include <h2_plainmutex.h>
#include <stdlib.h>
#ifdef __PICOLIBC__
#include <malloc.h>
#endif

/*
* h2_alloc.c
Expand Down
6 changes: 3 additions & 3 deletions libs/h2_compat/coproc/h2_coproc.ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#include <h2_coproc.h>
#include <h2_alloc.h>

static unsigned int *configs[CFG_TYPE_MAX][CFG_SUBTYPE_MAX] = {NULL};
static unsigned int nunits[CFG_TYPE_MAX][CFG_SUBTYPE_MAX] = {0};
static unsigned int *counts[CFG_TYPE_MAX][CFG_SUBTYPE_MAX][CFG_MAX] = {NULL};
static unsigned int *configs[CFG_TYPE_MAX][CFG_SUBTYPE_MAX] = {{NULL}};
static unsigned int nunits[CFG_TYPE_MAX][CFG_SUBTYPE_MAX] = {{0}};
static unsigned int *counts[CFG_TYPE_MAX][CFG_SUBTYPE_MAX][CFG_MAX] = {{{NULL}}};
static unsigned int oldstyle = 0;
static unsigned int init_done = 0;

Expand Down
2 changes: 1 addition & 1 deletion libs/h2_compat/prof/h2_prof.ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ unsigned int h2_prof_sample(unsigned long long int **res) {
unsigned int hthreads_mask;

if (NULL == (*res = (unsigned long long int *)h2_malloc(sizeof(unsigned long long int) * 6))) {
return NULL;
return 0;
}

asm volatile
Expand Down
9 changes: 8 additions & 1 deletion libs/posix/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@

ALL: dummy

# Picolibc support: if PICOLIBC=1, use --target=hexagon-h2-elf --cstdlib=picolibc
ifeq ($(PICOLIBC),1)
TARGET_FLAG = --target=hexagon-h2-elf --cstdlib=picolibc
else
TARGET_FLAG =
endif

OPTIMIZE := -Os

CFLAGS := -G0 $(OPTIMIZE) $(OPT_ADD) -mv$(TOOLARCH) -DARCHV=$(ARCHV) -Wall -Wno-builtin-requires-header -Werror -g
CFLAGS := $(TARGET_FLAG) -G0 $(OPTIMIZE) $(OPT_ADD) -mv$(TOOLARCH) -DARCHV=$(ARCHV) -Wall -Wno-builtin-requires-header -Werror -g

ifdef DEBUG
CFLAGS += -DDEBUG
Expand Down
Loading
Loading