diff --git a/.gitignore b/.gitignore index 7d83821..5c39210 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,7 @@ Makefile build/ lib .gitkey +*.deb +*.gz +*.Z +*Linux.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index cf47e21..2012b0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set (CMAKE_CXX_STANDARD 11) add_subdirectory(src) +add_subdirectory(include) #add_executable(c_time time.cpp) #install(TARGETS cpplab RUNTIME DESTINATION bin) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 0000000..d252c73 --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory(bmath) +add_subdirectory(cpu) +add_subdirectory(dstruct) +add_subdirectory(misc) \ No newline at end of file diff --git a/include/bmath/CMakeLists.txt b/include/bmath/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/bmath/complex.hpp b/include/bmath/complex.hpp similarity index 100% rename from src/bmath/complex.hpp rename to include/bmath/complex.hpp diff --git a/src/bmath/math.hpp b/include/bmath/math.hpp similarity index 100% rename from src/bmath/math.hpp rename to include/bmath/math.hpp diff --git a/include/cpu/CMakeLists.txt b/include/cpu/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/cpu/avx2.hpp b/include/cpu/avx2.hpp similarity index 100% rename from src/cpu/avx2.hpp rename to include/cpu/avx2.hpp diff --git a/src/cpu/naive.hpp b/include/cpu/naive.hpp similarity index 100% rename from src/cpu/naive.hpp rename to include/cpu/naive.hpp diff --git a/src/cpu/sse.hpp b/include/cpu/sse.hpp similarity index 100% rename from src/cpu/sse.hpp rename to include/cpu/sse.hpp diff --git a/src/cpu/types.hpp b/include/cpu/types.hpp similarity index 100% rename from src/cpu/types.hpp rename to include/cpu/types.hpp diff --git a/src/cpu/utils.hpp b/include/cpu/utils.hpp similarity index 100% rename from src/cpu/utils.hpp rename to include/cpu/utils.hpp diff --git a/include/dstruct/CMakeLists.txt b/include/dstruct/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/dtstruct/blist.hpp b/include/dstruct/blist.hpp similarity index 100% rename from src/dtstruct/blist.hpp rename to include/dstruct/blist.hpp diff --git a/include/misc/CMakeLists.txt b/include/misc/CMakeLists.txt new file mode 100644 index 0000000..f70a548 --- /dev/null +++ b/include/misc/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(memory) \ No newline at end of file diff --git a/include/misc/memory/CMakeLists.txt b/include/misc/memory/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/misc/memory/smartpointer.h b/include/misc/memory/smartpointer.h similarity index 100% rename from src/misc/memory/smartpointer.h rename to include/misc/memory/smartpointer.h diff --git a/src/bmath/CMakeLists.txt b/src/bmath/CMakeLists.txt index c2e601e..d1d29cc 100644 --- a/src/bmath/CMakeLists.txt +++ b/src/bmath/CMakeLists.txt @@ -4,6 +4,11 @@ add_library( math.cpp ) +target_include_directories( bmath + PUBLIC + "${CMAKE_SOURCE_DIR}/include" +) + add_executable( complex demos/complex.cpp @@ -14,4 +19,8 @@ add_executable( math demos/math.cpp math.cpp +) + +install(TARGETS bmath + DESTINATION "/usr/lib/bmath" ) \ No newline at end of file diff --git a/src/bmath/complex.cpp b/src/bmath/complex.cpp index 1f1dc85..238ace3 100644 --- a/src/bmath/complex.cpp +++ b/src/bmath/complex.cpp @@ -1,4 +1,4 @@ -#include "complex.hpp" +#include "../../include/bmath/complex.hpp" /** * Constructor implementation diff --git a/src/bmath/demos/complex.cpp b/src/bmath/demos/complex.cpp index e542c17..74c02f3 100644 --- a/src/bmath/demos/complex.cpp +++ b/src/bmath/demos/complex.cpp @@ -1,5 +1,5 @@ #include -#include "../complex.hpp" +#include "../../../include/bmath/complex.hpp" using BMath::Complex; diff --git a/src/bmath/demos/math.cpp b/src/bmath/demos/math.cpp index 77c2e62..d0c77a6 100644 --- a/src/bmath/demos/math.cpp +++ b/src/bmath/demos/math.cpp @@ -1,4 +1,4 @@ -#include "../math.hpp" +#include "../../../include/bmath/math.hpp" #include using namespace BMath; diff --git a/src/bmath/math.cpp b/src/bmath/math.cpp index 86923d3..19d2217 100644 --- a/src/bmath/math.cpp +++ b/src/bmath/math.cpp @@ -1,4 +1,4 @@ -#include "math.hpp" +#include "../../include/bmath/math.hpp" //http://graphics.stanford.edu/~seander/bithacks.html //https://hbfs.wordpress.com/2008/08/05/branchless-equivalents-of-simple-functions/ @@ -6,11 +6,12 @@ #include #include +#define C_API extern "C" /** * This will get the most significant bit of the Int value. If the most significant bit is 1 then the number is * 0x11111111 --> equals to -1 integer */ -inline Int msb(Int value) +Int msb(Int value) { return value >> (CHAR_BIT * sizeof(Int) - 1); }; @@ -23,12 +24,13 @@ inline Int msb(Int value) * More on unions * https://www.geeksforgeeks.org/union-c/ */ -inline Int msb2(Int value) +Int msb2(Int value) { SignedInt sint = {.signed_int = value}; return sint.int_with_msb.signal; }; + /** * */ @@ -55,3 +57,18 @@ Int BMath::Math::max(Int a, Int b) { return a + ((b - a) & ~msb2(b - a)); } + + +/** + * Export as C API + */ + +C_API Int c_msb(Int value) +{ + return msb(value); +}; + +C_API Int c_msb2(Int value) +{ + return msb2(value); +} \ No newline at end of file diff --git a/src/cpu/avx2.cpp b/src/cpu/avx2.cpp index d48cb37..d3058b0 100644 --- a/src/cpu/avx2.cpp +++ b/src/cpu/avx2.cpp @@ -1,4 +1,4 @@ -#include "avx2.hpp" +#include "../../include/cpu/avx2.hpp" #include #include diff --git a/src/cpu/demos/sse.cpp b/src/cpu/demos/sse.cpp index d5c3199..9fb4e69 100644 --- a/src/cpu/demos/sse.cpp +++ b/src/cpu/demos/sse.cpp @@ -1,7 +1,7 @@ #include -#include "../utils.hpp" -#include "../sse.hpp" -#include "../naive.hpp" +#include "../../../include/cpu/utils.hpp" +#include "../../../include/cpu/sse.hpp" +#include "../../../include/cpu/naive.hpp" #include using namespace cpu; diff --git a/src/cpu/naive.cpp b/src/cpu/naive.cpp index 8730b38..1cb2341 100644 --- a/src/cpu/naive.cpp +++ b/src/cpu/naive.cpp @@ -1,5 +1,5 @@ -#include "naive.hpp" -#include "types.hpp" +#include "../../include/cpu/naive.hpp" +#include "../../include/cpu/types.hpp" #include void cpu::Naive::sum_128_long(UInt *a,UInt *b){ diff --git a/src/cpu/sse.cpp b/src/cpu/sse.cpp index 522622d..0cb6c27 100644 --- a/src/cpu/sse.cpp +++ b/src/cpu/sse.cpp @@ -1,4 +1,4 @@ -#include "sse.hpp" +#include "../../include/cpu/sse.hpp" #include //X86 Assembly to add two 128 bit numbers in the form of packed integers 32bit diff --git a/src/misc/memory/smartpointer.cpp b/src/misc/memory/smartpointer.cpp index a31e68c..0816ec4 100644 --- a/src/misc/memory/smartpointer.cpp +++ b/src/misc/memory/smartpointer.cpp @@ -1,4 +1,4 @@ -#include "smartpointer.h" +#include "../../../include/misc/memory/smartpointer.h" #include #define UPtr std::unique_ptr