Skip to content

Commit

Permalink
[style] format code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Azure-stars committed Nov 24, 2024
1 parent 3d4855c commit 0ff99a4
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 46 deletions.
10 changes: 6 additions & 4 deletions apps/libc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ ifeq ($(TARGET),musl)
CFLAGS := -static -no-pie
ifeq ($(ARCH),x86_64)
RUST_TARGET := x86_64-unknown-linux-musl
RUSTFLAGS := ""
RUSTFLAGS :=
else ifeq ($(ARCH),aarch64)
RUST_TARGET := aarch64-unknown-linux-musl
RUSTFLAGS := "-C linker=aarch64-linux-musl-ld"
RUSTFLAGS := -C linker=aarch64-linux-musl-ld
else ifeq ($(ARCH),riscv64)
$(warning "Warn: Rust musl target not supported for riscv64")
RUST_TARGET := ""
RUSTFLAGS := ""
RUSTFLAGS :=
else
$(error "Unknown ARCH")
endif
Expand All @@ -38,6 +38,9 @@ else
$(error "Unknown TARGET")
endif

$(info RUSTFLAGS: "$(RUSTFLAGS)")
export RUSTFLAGS

all: build

build: build_dir build_c build_rust
Expand All @@ -58,7 +61,6 @@ build_rust:
for app in $(shell find rust -name Cargo.toml); do \
echo "Building $$(dirname $${app})"; \
app_name=$$(basename $$(dirname $${app})); \
export RUSTFLAGS=$(RUSTFLAGS); \
cargo build --release --target $(RUST_TARGET) --manifest-path $${app} ; \
cp $$(dirname $${app})/target/$(RUST_TARGET)/release/$${app_name} build/$(ARCH)/$${app_name}_rust ; \
done \
Expand Down
22 changes: 6 additions & 16 deletions apps/nimbos/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,9 @@ foreach(PATH ${SRCS})
)
endforeach()

# If arch is not x86_64, we need to use different syscall ids
if (NOT ${ARCH} STREQUAL x86_64)
add_custom_command(
OUTPUT syscall_ids.h
COMMAND sed ARGS -n -e s/__NR_/SYS_/p
< ${CMAKE_SOURCE_DIR}/lib/syscall_ids.h.no_x86.in
> ${CMAKE_SOURCE_DIR}/lib/syscall_ids.h
)
else()
add_custom_command(
OUTPUT syscall_ids.h
COMMAND sed ARGS -n -e s/__NR_/SYS_/p
< ${CMAKE_SOURCE_DIR}/lib/syscall_ids.h.in
> ${CMAKE_SOURCE_DIR}/lib/syscall_ids.h
)
endif()
add_custom_command(
OUTPUT syscall_ids.h
COMMAND sed ARGS -n -e s/__NR_/SYS_/p
< ${CMAKE_SOURCE_DIR}/${ARCH_DIR}/syscall_ids.h.in
> ${CMAKE_SOURCE_DIR}/lib/syscall_ids.h
)
File renamed without changes.
11 changes: 11 additions & 0 deletions apps/nimbos/c/lib/arch/riscv/syscall_ids.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#define __NR_read 63
#define __NR_write 64
#define __NR_exit 93
#define __NR_yield 124
#define __NR_getpid 172
#define __NR_clone 220
#define __NR_fork 220
#define __NR_exec 221
#define __NR_waitpid 260
#define __NR_clock_gettime 403
#define __NR_clock_nanosleep 407
11 changes: 11 additions & 0 deletions apps/nimbos/c/lib/arch/x86_64/syscall_ids.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#define __NR_read 0
#define __NR_write 1
#define __NR_yield 24
#define __NR_getpid 39
#define __NR_clone 56
#define __NR_fork 57
#define __NR_exec 59
#define __NR_exit 60
#define __NR_waitpid 61
#define __NR_clock_gettime 228
#define __NR_clock_nanosleep 230
11 changes: 0 additions & 11 deletions apps/nimbos/c/lib/syscall_ids.h.in

This file was deleted.

17 changes: 3 additions & 14 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,29 +95,18 @@ fn gen_kernel_config(arch: &str) -> Result<()> {

let mut f = File::create(out_path)?;
writeln!(f, "// Automatically generated by build.rs\n")?;
writeln!(f, "#![allow(dead_code)]")?;
for (key, item) in config_content.iter() {
let comments = get_comments(&config_content, key).replace('#', "///");
writeln!(f, "{}", comments)?;
if let Item::Value(value) = item {
let key_name = key.to_uppercase().replace('-', "_");
match value {
toml_edit::Value::Integer(i) => {
writeln!(
f,
"
#[allow(dead_code)]\n
pub const {}: usize = {};",
key_name, i
)?;
writeln!(f, "pub const {}: usize = {};", key_name, i)?;
}
toml_edit::Value::String(s) => {
writeln!(
f,
"
#[allow(dead_code)]\n
pub const {}: &str = \"{}\";",
key_name, s
)?;
writeln!(f, "pub const {}: &str = \"{}\";", key_name, s)?;
}
_ => {
panic!("Unsupported value type");
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn main() {
.split(',')
.filter(|&x| !x.is_empty());
for testcase in testcases {
log::info!("Running testcase: {}", testcase);
info!("Running testcase: {}", testcase);
let (entry_vaddr, ustack_top, uspace) = mm::load_user_app(testcase).unwrap();
let user_task = task::spawn_user_task(
Arc::new(Mutex::new(uspace)),
Expand Down

0 comments on commit 0ff99a4

Please sign in to comment.