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
28 changes: 20 additions & 8 deletions booter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,48 @@ export KERNELPATH := $(H2DIR)/kernel
endif

# All intermediate build artifacts go here.
BUILD_DIR := $(patsubst %/install,%/build/booter,$(INSTALLPATH))
KERNEL_BUILD_DIR := $(patsubst %/install,%/build/kernel,$(INSTALLPATH))
BUILD_DIR := $(INSTALLPATH)/../build/booter
KERNEL_BUILD_DIR := $(INSTALLPATH)/../build/kernel

BOOTVM_PROG := $(BUILD_DIR)/booter

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-picolibc
OSLIB_LDFLAGS = --target=hexagon-h2-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);

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
12 changes: 9 additions & 3 deletions 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 @@ -113,9 +118,11 @@ OPT_V81_CFILES :=
OPT_V81_SFILES :=
OPT_V81_OFILES :=

# Derive build dir from INSTALLPATH (encodes both ARCHV and variant).
# Derive build dir as a sibling of INSTALLPATH so it works regardless of
# whether INSTALLPATH ends in /install or is a user-supplied arbitrary path.
# e.g. artifacts/v81/opt/install → artifacts/v81/opt/build/kernel
BUILD_DIR := $(patsubst %/install,%/build/kernel,$(INSTALLPATH))
# install-my → install-my/../build/kernel
BUILD_DIR := $(INSTALLPATH)/../build/kernel

# Add per-ARCHV/variant include dir so asm_offsets.h (generated into
# BUILD_DIR/include/) is found by all kernel compilation units.
Expand Down Expand Up @@ -235,4 +242,3 @@ opt_install: info opt check
cp $(BUILD_DIR)/include/asm_offsets.h $(INSTALLPATH)/include # for state trap

check: $(BUILD_DIR)/libh2check.a

24 changes: 22 additions & 2 deletions kernel/build/offsets/make.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# 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 the target triple.
ifeq ($(PICOLIBC),1)
OFFSETS_TARGET_FLAG := --target=hexagon-none-picolibc
else
OFFSETS_TARGET_FLAG :=
endif

ifeq ($(PICOLIBC),1)
# Provide heap symbols and default memory layout expected by picolibc's libc.
# Use the linker script from the selected toolchain sysroot.
ifneq ($(TOOLCHAIN_BIN),)
OFFSETS_LDSCRIPT := -Wl,-T,$(abspath $(TOOLCHAIN_BIN)/../target/hexagon-unknown-none-picolibc/lib/v$(ARCHV)/G0/picolibc.ld)
else
OFFSETS_LDSCRIPT := -Wl,-T,$(shell $(CC) $(OFFSETS_TARGET_FLAG) -print-file-name=picolibc.ld)
endif
else
OFFSETS_LDSCRIPT :=
endif

$(BUILD_DIR)/include/asm_offsets.h: $(BUILD_DIR)/offsets
mkdir -p $(dir $@)
ifeq ($(RUN), $(RUN_TOOLSIM))
Expand All @@ -10,9 +31,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/event/error/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ EXEC=test.elf

include Makefile.inc

KERNEL_BUILD_DIR := $(patsubst %/install,%/build/kernel,$(INSTALLPATH))
KERNEL_BUILD_DIR := $(INSTALLPATH)/../build/kernel
CFLAGS += -ffixed-r28 -I$(KERNEL_BUILD_DIR)/include
ASFLAGS += -ffixed-r28 -I$(KERNEL_BUILD_DIR)/include

2 changes: 1 addition & 1 deletion kernel/init/boot/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ EXEC=test.elf

include Makefile.inc

KERNEL_BUILD_DIR := $(patsubst %/install,%/build/kernel,$(INSTALLPATH))
KERNEL_BUILD_DIR := $(INSTALLPATH)/../build/kernel
CFLAGS += -ffixed-r28 -I$(KERNEL_BUILD_DIR)/include
29 changes: 15 additions & 14 deletions libs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ IMPL=ref
endif

# Derive lib archive paths and tmp staging dir from INSTALLPATH.
# Keeps all intermediate artifacts under artifacts/v$(ARCHV)/$(T)/build/.
H2_LIB := $(patsubst %/install,%/build/libs/h2,$(INSTALLPATH))/libh2.a
H2_COMPAT_LIB := $(patsubst %/install,%/build/libs/h2_compat,$(INSTALLPATH))/libh2_compat.a
POSIX_LIB := $(patsubst %/install,%/build/libs/posix,$(INSTALLPATH))/libposix.a
# Use $(INSTALLPATH)/../build/... so this works for any INSTALLPATH value,
# not just ones ending in /install.
H2_LIB := $(INSTALLPATH)/../build/libs/h2/libh2.a
H2_COMPAT_LIB := $(INSTALLPATH)/../build/libs/h2_compat/libh2_compat.a
POSIX_LIB := $(INSTALLPATH)/../build/libs/posix/libposix.a

QURT_LIB := $(patsubst %/install,%/build/libs/qurt,$(INSTALLPATH))/libqurt.a
ANGEL_LIB := $(patsubst %/install,%/build/libs/syscall/angel,$(INSTALLPATH))/libangel.a
QURT_LIB := $(INSTALLPATH)/../build/libs/qurt/libqurt.a
ANGEL_LIB := $(INSTALLPATH)/../build/libs/syscall/angel/libangel.a

H2_DIR=h2/
H2_COMPAT_DIR=h2_compat/
Expand All @@ -29,8 +30,8 @@ MOST_LIBS= $(ANGEL_LIB) $(QURT_LIB)
# Picolibc support: if PICOLIBC=1, build syscall wrapper and locks
ifeq ($(PICOLIBC),1)
export PICOLIBC
SYS_WRAPPER_LIB = syscall/wrapper/libsyscall_wrapper.a
LOCKS_LIB = locks/liblocks.a
SYS_WRAPPER_LIB = $(INSTALLPATH)/../build/libs/syscall/wrapper/libsyscall_wrapper.a
LOCKS_LIB = $(INSTALLPATH)/../build/libs/locks/liblocks.a
else
SYS_WRAPPER_LIB =
LOCKS_LIB =
Expand All @@ -42,12 +43,12 @@ LIB_DIRS= $(dir $(MOST_LIBS) $(H2_DIR) $(POSIX_DIR) $(H2_COMPAT_DIR) $(SYS_WRAPP
# Source directories used for installing headers (not build dirs).
HEADER_DIRS = $(H2_DIR) $(POSIX_DIR) $(H2_COMPAT_DIR) syscall/angel/ qurt/

TMP_DIR := $(patsubst %/install,%/build/libs/tmp,$(INSTALLPATH))
TMP_DIR := $(INSTALLPATH)/../build/libs/tmp

# Per-variant header dirs for the three generated-header sub-libs.
_H2_HDR_DIR := $(patsubst %/install,%/build/libs/h2,$(INSTALLPATH))/include
_POSIX_HDR_DIR := $(patsubst %/install,%/build/libs/posix,$(INSTALLPATH))/include
_H2COMPAT_HDR_DIR := $(patsubst %/install,%/build/libs/h2_compat,$(INSTALLPATH))/include
_H2_HDR_DIR := $(INSTALLPATH)/../build/libs/h2/include
_POSIX_HDR_DIR := $(INSTALLPATH)/../build/libs/posix/include
_H2COMPAT_HDR_DIR := $(INSTALLPATH)/../build/libs/h2_compat/include

MAKE_LIB=${MAKE} -C $(dir $@)

Expand All @@ -72,10 +73,10 @@ $(ANGEL_LIB): $(H2_LIB) $(H2_COMPAT_LIB) $(POSIX_LIB)

ifeq ($(PICOLIBC),1)
$(SYS_WRAPPER_LIB):
+${MAKE_LIB};
+${MAKE} -C syscall/wrapper

$(LOCKS_LIB):
+${MAKE_LIB};
+${MAKE} -C locks
endif

clean:
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-picolibc
ifeq ($(PICOLIBC),1)
TARGET_FLAG = --target=hexagon-h2-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
11 changes: 9 additions & 2 deletions 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-picolibc
ifeq ($(PICOLIBC),1)
TARGET_FLAG = --target=hexagon-h2-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 Expand Up @@ -73,7 +80,7 @@ OPT_V81_CFILES :=
OPT_V81_SFILES :=
OPT_V81_OFILES :=

BUILD_DIR := $(patsubst %/install,%/build/libs/h2,$(INSTALLPATH))
BUILD_DIR := $(INSTALLPATH)/../build/libs/h2
CFLAGS += -I$(BUILD_DIR)/include

MKINCLUDES := $(shell find . -name make.inc)
Expand Down
15 changes: 11 additions & 4 deletions 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-picolibc
ifeq ($(PICOLIBC),1)
TARGET_FLAG = --target=hexagon-h2-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 Expand Up @@ -70,9 +77,9 @@ OPT_V81_CFILES :=
OPT_V81_SFILES :=
OPT_V81_OFILES :=

BUILD_DIR := $(patsubst %/install,%/build/libs/h2_compat,$(INSTALLPATH))
H2_BUILD_DIR := $(patsubst %/install,%/build/libs/h2,$(INSTALLPATH))
POSIX_BUILD_DIR := $(patsubst %/install,%/build/libs/posix,$(INSTALLPATH))
BUILD_DIR := $(INSTALLPATH)/../build/libs/h2_compat
H2_BUILD_DIR := $(INSTALLPATH)/../build/libs/h2
POSIX_BUILD_DIR := $(INSTALLPATH)/../build/libs/posix
CFLAGS += -I$(BUILD_DIR)/include -I$(H2_BUILD_DIR)/include -I$(POSIX_BUILD_DIR)/include

MKINCLUDES := $(shell find . -name make.inc)
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
21 changes: 16 additions & 5 deletions libs/locks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,27 @@ endif

CFLAGS += $(LIB_CFLAGS) $(H2_EXTRA_CFLAGS)

BUILD_DIR := $(INSTALLPATH)/../build/libs/locks

ASM_FILES =
C_FILES = $(wildcard src/*.c)

O_FILES = $(ASM_FILES:.S=.o) $(C_FILES:.c=.o)
O_FILES = $(addprefix $(BUILD_DIR)/,$(ASM_FILES:.S=.o) $(C_FILES:.c=.o))

all: liblocks.a
all: $(BUILD_DIR)/liblocks.a

clean:
rm -f liblocks.a src/*.o
clean:
rm -rf $(BUILD_DIR)

liblocks.a: $(O_FILES)
$(BUILD_DIR)/liblocks.a: $(O_FILES)
mkdir -p $(dir $@)
$(AR) cru $@ $(sort $(O_FILES))

$(BUILD_DIR)/%.o: %.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c -o $@ $<

$(BUILD_DIR)/%.o: %.S
mkdir -p $(dir $@)
$(CC) $(ASFLAGS) -c -o $@ $<

Loading
Loading