Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Unam3dd committed Jun 1, 2024
1 parent b3cbba9 commit 947635c
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 133 deletions.
34 changes: 9 additions & 25 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tasks:
- sh: '{{if eq OS "windows"}} powershell.exe -Command Test-Path dist {{else}} test ! -d dist {{end}}'
msg: "Nothing to be done."
cmds:
- meson setup build --buildtype=release --prefix=$(pwd)
- meson setup build --prefix=$(pwd)
- ninja -C build install
silent: true
desc: "Build the project in release build"
Expand All @@ -25,7 +25,7 @@ tasks:
- sh: '{{if eq OS "windows"}} powershell.exe -Command Test-Path dist {{else}} test ! -d dist {{end}}'
msg: "Nothing to be done."
cmds:
- meson setup build --buildtype=release --strip --prefix=$(pwd)
- meson setup build --strip --prefix=$(pwd)
- ninja -C build install
silent: true
desc: "Build the project in release build in stripped mode"
Expand All @@ -35,7 +35,7 @@ tasks:
- sh: '{{if eq OS "windows"}} powershell.exe -Command Test-Path dist {{else}} test ! -d dist {{end}}'
msg: "Nothing to be done."
cmds:
- meson setup build --buildtype=debug --prefix=$(pwd)
- meson setup build --buildtype=debugoptmized --prefix=$(pwd)
- ninja -C build install
silent: true
desc: "Build the project in dev build"
Expand All @@ -45,7 +45,7 @@ tasks:
- sh: '{{if eq OS "windows"}} powershell.exe -Command Test-Path dist {{else}} test ! -d dist {{end}}'
msg: "Nothing to be done."
cmds:
- meson setup --cross {{.CLI_ARGS}} build --buildtype=release --prefix=$(pwd)
- meson setup --cross {{.CLI_ARGS}} build --prefix=$(pwd)
- ninja -C build install
silent: true
desc: "Build the project with the compiler of your choice in release mode"
Expand All @@ -55,55 +55,39 @@ tasks:
- sh: '{{if eq OS "windows"}} powershell.exe -Command Test-Path dist {{else}} test ! -d dist {{end}}'
msg: "Nothing to be done."
cmds:
- meson setup --cross {{.CLI_ARGS}} build --buildtype=debug --prefix=$(pwd)
- meson setup --cross {{.CLI_ARGS}} build --buildtype=debugoptimized --prefix=$(pwd)
- ninja -C build install
silent: true
desc: "Build the project with the compiler of your choice in dev mode"

re:
cmds:
- meson setup build --reconfigure --buildtype=release --prefix=$(pwd)
- meson setup build --reconfigure --prefix=$(pwd)
- ninja -C build install
silent: true
desc: "Re build the project"

re-dev:
cmds:
- meson setup build --reconfigure --buildtype=debug --prefix=$(pwd)
- meson setup build --reconfigure --buildtype=debugoptimized --prefix=$(pwd)
- ninja -C build install
silent: true
desc: "Re build the project in dev mode"

re-strip:
cmds:
- meson setup build --reconfigure --buildtype=release --strip --prefix=$(pwd)
- meson setup build --reconfigure --strip --prefix=$(pwd)
- ninja -C build install
silent: true
desc: "Re build the project with strip"

build-tests:
cmds:
- meson setup build --reconfigure -Dbuild_tests=true -Dno_static=true --buildtype=release --prefix=$(pwd)
- meson setup build --reconfigure -Dbuild_tests=true -Dno_static=true --prefix=$(pwd)
- ninja -C build
silent: true
desc: "Build tests files"

build-bench:
cmds:
- meson setup build --reconfigure -Dbuild_tests=true -Dbuild_bench=true -Dno_static=true --buildtype=release --prefix=$(pwd)
- ninja -C build
silent: true
desc: "Build benchmarks files"

run-bench:
preconditions:
- sh: '{{if eq OS "windows" }} powershell.exe -Command Test-Path build {{else}} test -d build {{end}}'
msg: "Build directory not exist please run build_tests before"
cmds:
- meson test --benchmark -C build
silent: true
desc: "Run benchmarks files"

run-tests:
preconditions:
- sh: '{{if eq OS "windows" }} powershell.exe -Command Test-Path build {{else}} test -d build {{end}}'
Expand Down
55 changes: 0 additions & 55 deletions benchmarks/memory/memcpy_naive/memcpy_naive.c

This file was deleted.

8 changes: 8 additions & 0 deletions inc/eth-memory.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#ifndef ETH_MEMORY_H
#define ETH_MEMORY_H

///////////////////////////////////////
//
// HEADER
//
//////////////////////////////////////

#include "eth-types.h"

///////////////////////////////////////
//
// MEMORY
Expand Down
12 changes: 12 additions & 0 deletions inc/eth-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
#define ETH_NULL (void*)0
#endif

///////////////////////////////////////
//
// STATIC
//
//////////////////////////////////////

#ifndef NO_STATIC
#define STATIC static
#else
#define STATIC
#endif

///////////////////////////////////////
//
// TYPEDEFS SIGNED LEGACY
Expand Down
42 changes: 6 additions & 36 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project('Etheria-std', 'c',
version : '0.1',
default_options : ['warning_level=3', 'werror=true', 'optimization=3'])
default_options : ['warning_level=3', 'werror=true', 'optimization=3', 'buildtype=release'])


######################################
Expand All @@ -26,7 +26,7 @@ endif
#
######################################

criterion_dep = dependency('criterion', required: false)
criterion_dep = dependency('criterion', required: false, allow_fallback: true)

######################################
#
Expand Down Expand Up @@ -71,16 +71,6 @@ memory_memcpy_naive = files('tests/memory/memcpy/memcpy_naive/memcpy_naive.c',

tests = types_tests + memory_memcpy_naive

######################################
#
#
# BENCHMARKS
#
#
######################################

benchmarks = files('./benchmarks/memory/memcpy_naive/memcpy_naive.c')

summary({
'CPU': build_machine.cpu(),
'Endian': build_machine.endian(),
Expand Down Expand Up @@ -124,14 +114,14 @@ if host_machine.system() == 'windows'
else
lib_shared = shared_library('etheria-std',
srcs,
c_args: ['-nostdlib', '-nodefaultlibs', '-Oz', '-fPIC'],
c_args: ['-nostdlib', '-nodefaultlibs', '-Os', '-fPIC'],
install: true,
install_dir: 'dist/shared',
include_directories: incdir)

lib_static = static_library('etheria-std',
srcs,
c_args: ['-nostdlib', '-nodefaultlibs', '-Oz'],
c_args: ['-nostdlib', '-nodefaultlibs', '-Os'],
install: true,
install_dir: 'dist/static',
include_directories: incdir)
Expand All @@ -143,32 +133,12 @@ foreach test_file : tests
test_name = 'test_' + test_file.full_path().split('/')[-1].split('.c')[0]
test_exec = executable(test_name,
test_file,
c_args: ['-g3', '-Oz', '-fPIC'],
c_args: ['-g3', '-Os', '-fPIC'],
dependencies: [criterion_dep],
link_with: lib_static,
include_directories: incdir,
install: false,
pie: true)
test(test_name, test_exec, verbose: true)
test(test_name, test_exec, verbose: false)
endforeach

if get_option('build_bench') and host_machine.system() == 'linux'
foreach bench_file: benchmarks
bench_name = 'bench_' + bench_file.full_path().split('/')[-1].split('.c')[0]

bench_exec = executable(bench_name, bench_file,
c_args: ['-Oz', '-fPIC'],
link_with: lib_static,
include_directories: incdir,
install: true,
install_dir: 'benchmarks/output/',
pie: true)

benchmark(bench_name, bench_exec, args: ['--stack', 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'], verbose: true)
benchmark(bench_name, bench_exec, args: ['--stack', 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'], verbose: true)
benchmark(bench_name, bench_exec, args: ['--stack', 'HELLO'], verbose: true)
benchmark(bench_name, bench_exec, args: ['--stack', 'PWDPWD'], verbose: true)
endforeach
endif

endif
18 changes: 2 additions & 16 deletions src/memory/memcpy/memcpy.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "eth-std.h"
#include "eth-types.h"

///////////////////////////////////////
//
Expand All @@ -8,8 +8,7 @@

#if defined(__linux__)

#ifdef NO_STATIC
void *_eth_memcpy_naive (void *restrict dst, const void *restrict src, size_t size)
STATIC void *_eth_memcpy_naive (void *restrict dst, const void *restrict src, size_t size)
{
if (!dst || !src || !size)
return (dst);
Expand All @@ -20,19 +19,6 @@ void *_eth_memcpy_naive (void *restrict dst, const void *restrict src, size_t si
while (size--) *pd++ = *ps++;
return (dst);
}
#else
static void *_eth_memcpy_naive (void *restrict dst, const void *restrict src, size_t size)
{
if (!dst || !src || !size)
return (dst);

u8_t *ps = (u8_t *) src;
u8_t *pd = (u8_t *) dst;

while (size--) *pd++ = *ps++;
return (dst);
}
#endif

void *(*_eth_memcpy_ifunc (void)) (void *restrict, const void *restrict, size_t)
{
Expand Down
2 changes: 1 addition & 1 deletion subprojects/criterion.wrap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
url = https://github.com/Snaipe/Criterion.git
depth = 1
revision = head
method = cmake
method = meson

[provide]
dependency_names = criterion

0 comments on commit 947635c

Please sign in to comment.