Skip to content

Commit

Permalink
kul -> mkn::kul
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Nov 7, 2021
1 parent 32a81c8 commit ae3d01d
Show file tree
Hide file tree
Showing 125 changed files with 1,230 additions and 1,118 deletions.
13 changes: 3 additions & 10 deletions .github/workflows/build_nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,8 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Get mkn
uses: dawidd6/action-download-artifact@v2
with:
name: mkn
branch: master
workflow: build_nix.yml
repo: mkn/maiken

- name: "Build/Test" # contains slash so use quotes otherwise UB
run: |
chmod +x mkn
KLOG=3 ./mkn clean build run -dtOp test -a "-std=c++17 -fPIC"
wget https://github.com/PhilipDeegan/mkn/releases/download/latest/mkn_nix
chmod +x mkn_nix
KLOG=3 ./mkn_nix clean build run -dtOp test -a "-std=c++17 -fPIC"
13 changes: 3 additions & 10 deletions .github/workflows/build_osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,8 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Get mkn
uses: dawidd6/action-download-artifact@v2
with:
name: mkn
branch: master
workflow: build_osx.yml
repo: mkn/maiken

- name: "Build/Test" # contains slash so use quotes otherwise UB
run: |
chmod +x mkn
KLOG=3 ./mkn clean build run -dtOp test -a "-std=c++17 -fPIC"
wget https://github.com/PhilipDeegan/mkn/releases/download/latest/mkn_osx
chmod +x mkn_osx
KLOG=3 ./mkn_osx clean build run -dtOp test -a "-std=c++17 -fPIC"
9 changes: 1 addition & 8 deletions .github/workflows/build_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,12 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Get mkn
uses: dawidd6/action-download-artifact@v2
with:
name: mkn
branch: master
workflow: build_win.yml
repo: mkn/maiken

- name: "Build/Test" # contains slash so use quotes otherwise UB
shell: cmd
env:
MKN_CL_PREFERRED: 1
run: | # /bin/link interferes with cl/link.exe
bash -c "rm /bin/link"
bash -c "curl -Lo mkn.exe https://github.com/PhilipDeegan/mkn/releases/download/latest/mkn.exe"
call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
bash -c 'KLOG=3 ./mkn clean build run -dtKOp test -a "-EHsc -std:c++17"'
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ script:
eval "${MATRIX_EVAL}"
export CC CXX
make nix -C maiken && cp maiken/mkn .
./mkn build -dtKa "-D_KUL_USE_CBLAS -O2 -std=c++17 -fPIC" -l "-pthread -ldl -lblas" -p test run
./mkn build -dtKa "-D_MKN_KUL_USE_CBLAS -O2 -std=c++17 -fPIC" -l "-pthread -ldl -lblas" -p test run
fi
28 changes: 17 additions & 11 deletions README.noformat
Original file line number Diff line number Diff line change
Expand Up @@ -52,36 +52,42 @@ Description - Add string to svn checkout as arguments

Switches - OSX is considered BSD for swiches unless otherwise noted

Key _KUL_MAX_PATH_
Key _MKN_KUL_DISABLE_KLOG_DEF_
Type bool
Default undefined
OS all
Description if defined, or set to 1, do not register KLOG* macros

Key _MKN_KUL_MAX_PATH_
Type size_t
Default MAX_PATH/PATH_MAX - or 1024 if not found
OS all
Description Max array length for filesystem interactions


Key __KUL_LOG_FRMT__
Key __MKN_KUL_LOG_FRMT__
Type string
Default "[%M]: %T - %D : %F fn(%N)#%L - %S"
OS all
Description
Logging format in format view:
%M = Mode - INF/ERR/DBG
%T = Thread ID
%D = DateTime - uses __KUL_LOG_DATE_FRMT__
%D = DateTime - uses __MKN_KUL_LOG_DATE_FRMT__
%F = File
%N = Function
%L = Line
%S = String

Key __KUL_LOG_DATE_FRMT__
Key __MKN_KUL_LOG_DATE_FRMT__
Type string
Default "%Y-%m-%d-%H:%M:%S:%i"
OS all
Description
Logging DateTime format, reference: http://en.cppreference.com/w/cpp/chrono/c/strftime
"%i" is custom for milliseconds, method strftime is used for all other

Key __KUL_THREAD_SPAWN_WAIT__
Key __MKN_KUL_THREAD_SPAWN_WAIT__
Type number
Default
nix/bsd 5000000
Expand All @@ -90,7 +96,7 @@ OS all
Description
Used in thread queues. The amount of time in nanoseconds waited after launching a thread. Threads launched too quickly can cause issues on nix platforms, bsd assumed similar.

Key __KUL_PROC_BLOCK_ERR__
Key __MKN_KUL_PROC_BLOCK_ERR__
Type flag
Default disabled
OS nix/bsd
Expand All @@ -99,29 +105,29 @@ Turns on error checking for creating new processes when running -
fcntl(fd, F_SETFL, O_NONBLOCK);
Can be an issue being on when running many processes rapidly.

Key __KUL_PROC_DUP_RETRY__
Key __MKN_KUL_PROC_DUP_RETRY__
Type number
Default 3
OS nix/bsd
Description
Allows N retries for "dup(fileDescriptor") calls in forked process.

Key __KUL_SYS_DLOPEN__
Key __MKN_KUL_SYS_DLOPEN__
Type text
Default RTLD_NOW|RTLD_GLOBAL
OS nix/bsd
Description
Flags for dlopen, see https://linux.die.net/man/3/dlopen

Key _KUL_PROC_LOOP_NSLEEP_
Key _MKN_KUL_PROC_LOOP_NSLEEP_
Type number
Default undefined
OS nix/bsd
Description
Nanosecond sleep while reading running processes pipe output, if defined and greater than 0


Key _KUL_COMPILED_LIB_
Key _MKN_KUL_COMPILED_LIB_
Type flag
Default disabled
OS all
Expand All @@ -141,5 +147,5 @@ With options

1. google.sparsehash

Uses google.sparsehash for kul::hash::set and kul::hash::map classes
Uses google.sparsehash for mkn::kul::hash::set and mkn::kul::hash::map classes

8 changes: 5 additions & 3 deletions inc/kul/all.hpp → inc/mkn/kul/all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _KUL_TUPLE_HPP_
#define _KUL_TUPLE_HPP_
#ifndef _MKN_KUL_TUPLE_HPP_
#define _MKN_KUL_TUPLE_HPP_

#include <tuple>
#include <vector>
#include <numeric>
#include <algorithm>

namespace mkn {
namespace kul {

#define PRINT_LINE() std::cout << __LINE__ << std::endl
Expand Down Expand Up @@ -172,5 +173,6 @@ class All {
};

} // namespace kul
} // namespace mkn

#endif /* _KUL_TUPLE_HPP_ */
#endif /* _MKN_KUL_TUPLE_HPP_ */
58 changes: 30 additions & 28 deletions inc/kul/asio/log.hpp → inc/mkn/kul/asio/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,36 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _KUL_ASIO_LOG_HPP_
#define _KUL_ASIO_LOG_HPP_
#ifndef _MKN_KUL_ASIO_LOG_HPP_
#define _MKN_KUL_ASIO_LOG_HPP_

#include "kul/log.hpp"
#include "kul/threads.hpp"
#include "mkn/kul/log.hpp"
#include "mkn/kul/threads.hpp"

namespace mkn {
namespace kul {
namespace asio {
namespace log {

class Exception : public kul::Exception {
class Exception : public mkn::kul::Exception {
public:
Exception(char const *f, uint16_t const &l, std::string const &s) : kul::Exception(f, l, s) {}
Exception(char const *f, uint16_t const &l, std::string const &s) : mkn::kul::Exception(f, l, s) {}
};
} // namespace log

class LogMan;
class Logger : public kul::Logger {
class Logger : public mkn::kul::Logger {
friend class LogMan;

private:
kul::ChroncurrentThreadPool<> ctp;
mkn::kul::ChroncurrentThreadPool<> ctp;
std::function<void(std::string const &)> defE, defO;

public:
Logger()
: ctp(1, 1),
defE([&](std::string const &s) { kul::Logger::err(s); }),
defO([&](std::string const &s) { kul::Logger::out(s); }) {}
defE([&](std::string const &s) { mkn::kul::Logger::err(s); }),
defO([&](std::string const &s) { mkn::kul::Logger::out(s); }) {}
void err(std::string const &s) override {
if (e)
ctp.async(std::bind(e, s));
Expand All @@ -71,9 +72,9 @@ class Logger : public kul::Logger {
}
};

class LogMan : public kul::ALogMan {
class LogMan : public mkn::kul::ALogMan {
protected:
LogMan() : ALogMan(new kul::asio::Logger()) {}
LogMan() : ALogMan(new mkn::kul::asio::Logger()) {}

public:
static LogMan &INSTANCE() {
Expand All @@ -85,9 +86,9 @@ class LogMan : public kul::ALogMan {
class Message {
protected:
std::stringstream ss;
const kul::log::mode &m;
const mkn::kul::log::mode &m;

Message(const kul::log::mode &_m) : m(_m) {}
Message(const mkn::kul::log::mode &_m) : m(_m) {}

public:
template <class T>
Expand All @@ -99,37 +100,38 @@ class Message {
class LogMessage : public Message {
public:
~LogMessage() { LogMan::INSTANCE().log(f, fn, l, m, ss.str()); }
LogMessage(char const *_f, char const *_fn, uint16_t const &_l, const kul::log::mode &_m)
LogMessage(char const *_f, char const *_fn, uint16_t const &_l, const mkn::kul::log::mode &_m)
: Message(_m), f(_f), fn(_fn), l(_l) {}

private:
char const *f, *fn;
uint16_t const &l;
};
struct OutMessage : public Message {
OutMessage(const kul::log::mode &_m = kul::log::mode::NON) : Message(_m) {}
OutMessage(const mkn::kul::log::mode &_m = mkn::kul::log::mode::NON) : Message(_m) {}
~OutMessage() { LogMan::INSTANCE().out(m, ss.str()); }
};
struct ErrMessage : public Message {
ErrMessage() : Message(kul::log::mode::ERR) {}
ErrMessage() : Message(mkn::kul::log::mode::ERR) {}
~ErrMessage() { LogMan::INSTANCE().err(ss.str()); }
};

#define KASIO_LOG_INF kul::asio::LogMessage(__FILE__, __func__, __LINE__, kul::log::mode::INF)
#define KASIO_LOG_ERR kul::asio::LogMessage(__FILE__, __func__, __LINE__, kul::log::mode::ERR)
#define KASIO_LOG_DBG kul::asio::LogMessage(__FILE__, __func__, __LINE__, kul::log::mode::DBG)
#define KASIO_LOG_TRC kul::asio::LogMessage(__FILE__, __func__, __LINE__, kul::log::mode::TRC)
#define KASIO_LOG_INF mkn::kul::asio::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::INF)
#define KASIO_LOG_ERR mkn::kul::asio::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::ERR)
#define KASIO_LOG_DBG mkn::kul::asio::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::DBG)
#define KASIO_LOG_TRC mkn::kul::asio::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::TRC)
#define KASIO_LOG(sev) KLOG_##sev

#define KASIO_OUT_NON kul::asio::OutMessage()
#define KASIO_OUT_INF kul::asio::OutMessage(kul::log::mode::INF)
#define KASIO_OUT_ERR kul::asio::OutMessage(kul::log::mode::ERR)
#define KASIO_OUT_DBG kul::asio::OutMessage(kul::log::mode::DBG)
#define KASIO_OUT_TRC kul::asio::OutMessage(kul::log::mode::TRC)
#define KASIO_OUT_NON mkn::kul::asio::OutMessage()
#define KASIO_OUT_INF mkn::kul::asio::OutMessage(mkn::kul::log::mode::INF)
#define KASIO_OUT_ERR mkn::kul::asio::OutMessage(mkn::kul::log::mode::ERR)
#define KASIO_OUT_DBG mkn::kul::asio::OutMessage(mkn::kul::log::mode::DBG)
#define KASIO_OUT_TRC mkn::kul::asio::OutMessage(mkn::kul::log::mode::TRC)
#define KASIO_OUT(sev) KASIO_OUT_##sev

#define KASIO_ERR kul::ErrMessage()
#define KASIO_ERR mkn::kul::ErrMessage()

} // namespace asio
} // namespace kul
#endif /* _KUL_LOG_HPP_ */
} // namespace mkn
#endif /* _MKN_KUL_LOG_HPP_ */
16 changes: 9 additions & 7 deletions inc/kul/assert.hpp → inc/mkn/kul/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,32 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _KUL_ASSERT_HPP_
#define _KUL_ASSERT_HPP_
#ifndef _MKN_KUL_ASSERT_HPP_
#define _MKN_KUL_ASSERT_HPP_

#include "kul/signal.hpp"
#include "mkn/kul/signal.hpp"

namespace mkn {
namespace kul {
struct Assert {
template <typename T>
Assert(T t) {
#if !defined(NDEBUG)
if (!(t)) {
auto tid = kul::this_thread::id();
auto tid = mkn::kul::this_thread::id();
KOUT(NON) << tid << " : Stacktrace:";
for (auto const& s : kul::this_thread::stacktrace()) KOUT(NON) << tid << " : " << s;
for (auto const& s : mkn::kul::this_thread::stacktrace()) KOUT(NON) << tid << " : " << s;
exit(111);
}
#endif
}
};
} // namespace kul
} // namespace mkn

#if !defined(KASSERT)
#define KASSERT(b) \
kul::Assert { (b) }
mkn::kul::Assert { (b) }
#endif

#if defined(KASSERT_REPLACE_ASSERT)
Expand All @@ -61,4 +63,4 @@ struct Assert {
#define assert(b) KASSERT(b)
#endif

#endif /* _KUL_ASSERT_HPP_ */
#endif /* _MKN_KUL_ASSERT_HPP_ */
Loading

0 comments on commit ae3d01d

Please sign in to comment.