-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test util library extracted to global tinylibc library
- Loading branch information
Showing
16 changed files
with
56 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cmake_minimum_required(VERSION 3.22.1) | ||
|
||
add_subdirectory(tinylibc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cmake_minimum_required(VERSION 3.22.1) | ||
|
||
set(TINYLIBC_CFLAGS -O2 -Wall -Wextra -g -fno-stack-protector) | ||
set(TINYLIBC_ASFLAGS -x assembler-with-cpp ${TINYLIBC_CFLAGS}) | ||
|
||
add_library(tinylibc STATIC) | ||
|
||
target_compile_options(tinylibc PRIVATE | ||
$<$<COMPILE_LANGUAGE:C>:${TINYLIBC_CFLAGS}> | ||
$<$<COMPILE_LANGUAGE:ASM>:${TINYLIBC_ASFLAGS}> | ||
) | ||
|
||
target_include_directories(tinylibc PUBLIC include) | ||
|
||
file(GLOB TINYLIBC_SRC "./*.[cs]") | ||
|
||
target_sources(tinylibc PRIVATE ${TINYLIBC_SRC}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
#include <syscall.h> | ||
#include <asm/unistd.h> | ||
|
||
.section .text, "ax", @progbits | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../third_party/printf/printf.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef MY1STLD_LIB_TINYLIBC_H | ||
#define MY1STLD_LIB_TINYLIBC_H | ||
|
||
#include "printf.h" | ||
|
||
void exit(int exit_code); | ||
|
||
#define ASSERT_EXIT_CODE 666 | ||
#define assert(condition) \ | ||
do { \ | ||
if(!condition) { \ | ||
printf("assetion %s failed at %s:%i\n", \ | ||
#condition, __FILE__, __LINE__); \ | ||
exit(ASSERT_EXIT_CODE); \ | ||
} \ | ||
} while(0) \ | ||
|
||
#endif /* MY1STLD_LIB_TINYLIBC_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../third_party/printf/printf.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
|
||
int so_variable = 0; | ||
int so_variable = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#include "util.h" | ||
#include "lib.h" | ||
#include "tinylibc.h" | ||
|
||
void _start() { | ||
so_variable++; | ||
assert(so_variable == 1); | ||
exit(0); | ||
} |
This file was deleted.
Oops, something went wrong.