aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.core
diff options
context:
space:
mode:
Diffstat (limited to 'nihil.core')
-rw-r--r--nihil.core/CMakeLists.txt2
-rw-r--r--nihil.core/errc.cc16
-rw-r--r--nihil.core/errc.ccm41
-rw-r--r--nihil.core/features.ccm13
-rw-r--r--nihil.core/nihil.core.ccm8
-rw-r--r--nihil.core/nihil.hh21
6 files changed, 55 insertions, 46 deletions
diff --git a/nihil.core/CMakeLists.txt b/nihil.core/CMakeLists.txt
index 2a7b3e2..cbb1b6b 100644
--- a/nihil.core/CMakeLists.txt
+++ b/nihil.core/CMakeLists.txt
@@ -1,11 +1,13 @@
# This source code is released into the public domain.
add_library(nihil.core STATIC)
+target_link_libraries(nihil.core PRIVATE nihil.std)
target_include_directories(nihil.core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_sources(nihil.core
PUBLIC FILE_SET modules TYPE CXX_MODULES FILES
nihil.core.ccm
errc.ccm
+ features.ccm
PRIVATE
errc.cc
diff --git a/nihil.core/errc.cc b/nihil.core/errc.cc
index 35c9d8f..411ad66 100644
--- a/nihil.core/errc.cc
+++ b/nihil.core/errc.cc
@@ -1,14 +1,8 @@
-/*
- * This source code is released into the public domain.
- */
-
-module;
-
-#include <string>
-#include <system_error>
-
+// This source code is released into the public domain.
module nihil.core;
+import nihil.std;
+
namespace nihil {
struct nihil_error_category final : std::error_category {
@@ -43,6 +37,10 @@ auto nihil_error_category::message(int err) const -> std::string
return "Empty string is not permitted";
case errc::invalid_unit:
return "Invalid unit specifier";
+ case errc::failed_to_create_object:
+ return "Failed to create UCL object";
+ case errc::type_mismatch:
+ return "UCL type does not match expected type";
default:
return "Undefined error";
}
diff --git a/nihil.core/errc.ccm b/nihil.core/errc.ccm
index c597faf..f5aac0b 100644
--- a/nihil.core/errc.ccm
+++ b/nihil.core/errc.ccm
@@ -1,28 +1,29 @@
-/*
- * This source code is released into the public domain.
- */
-
-module;
-
-#include <string>
-#include <system_error>
-
+// This source code is released into the public domain.
export module nihil.core:errc;
+import nihil.std;
+
namespace nihil {
-export enum struct errc {
+export enum struct errc : std::uint8_t {
no_error = 0,
- /*
- * nihil.command
- */
+ //
+ // nihil.command
+ //
incomplete_command,
- /*
- * nihil.util
- */
+ //
+ // nihil.ucl
+ //
+
+ failed_to_create_object,
+ type_mismatch,
+
+ //
+ // nihil.util
+ //
// Empty string is not allowed.
empty_string,
@@ -36,9 +37,5 @@ export [[nodiscard]] auto make_error_condition(errc ec) -> std::error_condition;
} // namespace nihil
-namespace std {
-
-export template<>
-struct is_error_condition_enum<nihil::errc> : true_type {};
-
-} // namespace std
+template<>
+struct std::is_error_condition_enum<nihil::errc> : std::true_type {};
diff --git a/nihil.core/features.ccm b/nihil.core/features.ccm
new file mode 100644
index 0000000..5c6631b
--- /dev/null
+++ b/nihil.core/features.ccm
@@ -0,0 +1,13 @@
+// This source code is released into the public domain.
+module;
+
+#include "nihil.hh"
+
+export module nihil.core:features;
+
+namespace nihil::features {
+
+export inline constexpr bool fexecve = NIHIL_HAVE_FEXECVE;
+export inline constexpr bool getenv_r = NIHIL_HAVE_GETENV_R;
+
+} // namespace nihil::features
diff --git a/nihil.core/nihil.core.ccm b/nihil.core/nihil.core.ccm
index a7a4100..0aa5402 100644
--- a/nihil.core/nihil.core.ccm
+++ b/nihil.core/nihil.core.ccm
@@ -1,9 +1,5 @@
-/*
- * This source code is released into the public domain.
- */
-
-module;
-
+// This source code is released into the public domain.
export module nihil.core;
export import :errc;
+export import :features;
diff --git a/nihil.core/nihil.hh b/nihil.core/nihil.hh
index cd7e789..da37895 100644
--- a/nihil.core/nihil.hh
+++ b/nihil.core/nihil.hh
@@ -1,10 +1,11 @@
-/*
-* This source code is released into the public domain.
- */
+// This source code is released into the public domain.
#ifndef NIHIL_HH_INCLUDED
#define NIHIL_HH_INCLUDED
+#define NIHIL_HAVE_FEXECVE 0
+#define NIHIL_HAVE_GETENV_R 0
+
#if __has_include(<sys/param.h>)
# include <sys/param.h>
#endif
@@ -12,14 +13,16 @@
#if defined(__FreeBSD_version)
/* fexecve() added in FreeBSD 8.0 */
-#if (__FreeBSD_version >= 800000)
-# define NIHIL_HAVE_FEXECVE
-#endif
+# if (__FreeBSD_version >= 800000)
+# undef NIHIL_HAVE_FEXECVE
+# define NIHIL_HAVE_FEXECVE 1
+# endif
/* getenv_r() added in FreeBSD 15.0 */
-#if (__FreeBSD_version >= 1500000)
-# define NIHIL_HAVE_GETENV_R
-#endif
+# if (__FreeBSD_version >= 1500000)
+# undef NIHIL_HAVE_GETENV_R
+# define NIHIL_HAVE_GETENV_R 1
+# endif
#endif // defined(__FreeBSD_version)