Skip to content

Commit

Permalink
hotplace rev.339 linnux minimal platform tested (Fedora Core 4 - kern…
Browse files Browse the repository at this point in the history
…el 2.6.11, glibc 2.3.5)
  • Loading branch information
princeb612 committed Oct 19, 2023
1 parent e56c10b commit fab232e
Show file tree
Hide file tree
Showing 12 changed files with 352 additions and 206 deletions.
30 changes: 19 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ if (NOT "$ENV{CXXFLAGS}" STREQUAL "")
# specify additional include, lib directories
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $ENV{CXXFLAGS}")
endif ()
if (NOT "$ENV{CMAKE_CXX_COMPILER}" STREQUAL "")
set (CMAKE_CXX_COMPILER "$ENV{CMAKE_CXX_COMPILER}")
endif ()
if (NOT "$ENV{CMAKE_CXX_FLAGS}" STREQUAL "")
set (CMAKE_CXX_FLAGS "$ENV{CMAKE_CXX_FLAGS}")
endif ()
if (NOT "$ENV{SUPPORT_SHARED}" STREQUAL "")
set (SUPPORT_SHARED $ENV{SUPPORT_SHARED})
endif ()
Expand All @@ -41,8 +47,7 @@ endif ()
if (UNIX)
# -std=c++11
# -Wl,-z,noexecstack
# -Wl,--copy-dt-needed-entries # DSO missing from command line
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=${SET_STDCPP} -Wl,-z,noexecstack -Wl,--copy-dt-needed-entries")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=${SET_STDCPP} -Wl,-z,noexecstack")
else (1)
endif ()

Expand Down Expand Up @@ -81,15 +86,18 @@ endif ()

# copy header files to destination
function(copy_headers_with_hierarchy SOURCE_DIR DESTINATION_DIR)
file(GLOB_RECURSE HEADER_FILES ${SOURCE_DIR}/*.hpp ${SOURCE_DIR}/*.h)

foreach(HEADER_FILE ${HEADER_FILES})
file(RELATIVE_PATH HEADER_RELATIVE_PATH ${SOURCE_DIR} ${HEADER_FILE})
get_filename_component(HEADER_DESTINATION_PATH "${DESTINATION_DIR}/${HEADER_RELATIVE_PATH}" DIRECTORY)

file(MAKE_DIRECTORY ${HEADER_DESTINATION_PATH})
file(COPY ${HEADER_FILE} DESTINATION ${HEADER_DESTINATION_PATH})
endforeach()
if(CMAKE_VERSION VERSION_LESS 3.0)
else(1)
file(GLOB_RECURSE HEADER_FILES ${SOURCE_DIR}/*.hpp ${SOURCE_DIR}/*.h)

foreach(HEADER_FILE ${HEADER_FILES})
file(RELATIVE_PATH HEADER_RELATIVE_PATH ${SOURCE_DIR} ${HEADER_FILE})
get_filename_component(HEADER_DESTINATION_PATH "${DESTINATION_DIR}/${HEADER_RELATIVE_PATH}" DIRECTORY)

file(MAKE_DIRECTORY ${HEADER_DESTINATION_PATH})
file(COPY ${HEADER_FILE} DESTINATION ${HEADER_DESTINATION_PATH})
endforeach()
endif()
endfunction()

# makelib name type source header library
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,20 @@
* RHEL 7 and newer, (including CentOS, Rockey Linux)
* ubuntu 20.04 and newer
* mingw
* Fedora Core release 4 (Stentz) w/ custom toolchain (GCC 4.8)

# custom toolchain

## openssl

* important
* openssl 1.1.1 or newer
* RSA-OAEP-256
* Ed25519 Ed448 X25519 X448
* sha3
* openssl 3.0, 3.1
* EVP_CIPHER_fetch/EVP_CIPHER_free, EVP_MD_fetch/EVP_MD_free
* truncated sha ("sha2-512/224", "sha2-512/256")
* failed to load PEM file containing private key
* openssl 3.2
* argon2d, argon2i, argon2id
Expand Down Expand Up @@ -148,6 +155,9 @@
* $ make
* no thanks man pages
* $ make install_sw install_ssldirs

## jansson

* build custom jansson (example)
* see https://github.com/akheron/jansson
* aclocal; autoheader; autoconf;
Expand All @@ -158,6 +168,23 @@
* make
* make install

## FC4 custom toolchain

* toolchain dependencies
* cmake (2.8.10.2)
* perl (5.10.0)
* m4 (1.4.13)
* autoconf (2.65)
* automake (1.16.4)
* libtool (1.5.2)
* make (3.80)
* gmp (4.3.2)
* mpfr (2.4.2)
* mpc (1.0.3)
* isl (0.10)
* binutils (2.18)
* gcc (4.8.5)

# link

* https://github.com/princeb612/hotplace
Expand Down
2 changes: 2 additions & 0 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ else
export SUPPORT_ODBC=0
export SUPPORT_PCH=0
export SET_STDCPP=c++11
# -Wl,--copy-dt-needed-entries # DSO missing from command line
export CMAKE_CXX_FLAGS='-Wl,--copy-dt-needed-entries'
true
fi
export CXXFLAGS='-DDEBUG'
Expand Down
31 changes: 29 additions & 2 deletions sdk/base/system/datetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

#include <hotplace/sdk/base/stl.hpp>
#include <hotplace/sdk/base/system/datetime.hpp>
#if defined __linux__
#include <dlfcn.h>
#include <sys/time.h>
#include <unistd.h>
#endif

namespace hotplace {

Expand Down Expand Up @@ -48,7 +53,7 @@ datetime::~datetime() {
// do nothing
}

void datetime::update() { clock_gettime(CLOCK_REALTIME, &_timespec); }
void datetime::update() { system_gettime(CLOCK_REALTIME, _timespec); }

bool datetime::update_if_elapsed(unsigned long msecs) {
bool ret = false;
Expand Down Expand Up @@ -769,7 +774,7 @@ return_t datetime::asn1time_to_timespec(asn1time_t at, struct timespec& ts) {
return ret;
}

void time_monotonic(struct timespec& ts) { clock_gettime(CLOCK_MONOTONIC, &ts); }
void time_monotonic(struct timespec& ts) { system_gettime(CLOCK_MONOTONIC, ts); }

return_t time_diff(struct timespec& ts, struct timespec begin, struct timespec end) {
return_t ret = errorcode_t::success;
Expand Down Expand Up @@ -829,4 +834,26 @@ return_t time_sum(struct timespec& ts, std::list<struct timespec>& slices) {
return ret;
}

void system_gettime(int clockid, struct timespec& ts) {
#if defined __linux__
// to support a minimal platform
#define DLSYMAPI(handle, nameof_api, func_ptr) *(void**)(&func_ptr) = dlsym(handle, nameof_api)
typedef int (*clock_gettime_t)(clockid_t clockid, struct timespec * tp);
clock_gettime_t clock_gettime_ptr = nullptr;
DLSYMAPI(RTLD_DEFAULT, "clock_gettime", clock_gettime_ptr);
if (clock_gettime_ptr) {
// kernel 2.8~ later
(*clock_gettime_ptr)(clockid, &ts);
} else {
// kernel ~2.7 earlier
ts.tv_sec = time(nullptr);
struct timeval tv;
gettimeofday(&tv, nullptr);
ts.tv_nsec = tv.tv_usec * 1000;
}
#else
clock_gettime(CLOCK_REALTIME, &ts);
#endif
}

} // namespace hotplace
7 changes: 7 additions & 0 deletions sdk/base/system/datetime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,13 @@ class datetime {
struct timespec _timespec; /* time_t tv_sec(UTC seconds) + long tv_nsec(nanoseconds) */
};

/**
* @brief clock_gettime (kernel 2.6) replacement
* @param int clockid [in] CLOCK_REALTIME, CLOCK_MONOTONIC
* @param struct timespec& ts [out]
*/
void system_gettime(int clockid, struct timespec& ts);

void time_monotonic(struct timespec& timespec);
/**
* @brief calculate difference
Expand Down
9 changes: 9 additions & 0 deletions sdk/crypto/basic/crypto_advisor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ return_t crypto_advisor::build_if_necessary() {
_blockcipher_map.insert(std::make_pair(item->_alg, item));
}

// openssl-3.0
// - use EVP_CIPHER_fetch/EVP_CIPHER_free, EVP_MD_fetch/EVP_MD_free
// openssl-1.1.1
// - use EVP_get_cipherbyname, EVP_get_digestbyname (run-time)
// EVP_CIPHER* and EVP_MD* at extern const structure return nullptr (constexpr in compile-time)
// - not provided "aes-128-wrap", "aes-192-wrap", "aes-256-wrap"
// [FAIL] const EVP_CIPHER* cipher = EVP_get_cipherbyname("aes-128-wrap");
// [PASS] const EVP_CIPHER* cipher = crypto_advisor::get_instance()->find_evp_cipher("aes-128-wrap");

for (i = 0; i < sizeof_evp_cipher_methods; i++) {
const openssl_evp_cipher_method_t* item = evp_cipher_methods + i;
#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
Expand Down
Loading

0 comments on commit fab232e

Please sign in to comment.