libhatchet
Loading...
Searching...
No Matches
hxsettings.h File Reference

Go to the source code of this file.

Classes

struct  hxsettings

Macros

#define HX_CPLUSPLUS   202302L
#define HX_USE_INLINING_ATTR   1
#define HX_USE_THREADS   11
#define HX_USE_LIBCXX   1
#define hxbreakpoint()
#define hxrestrict
#define hxattr_allocator(...)
#define hxattr_assume(...)
#define hxattr_cold
#define hxattr_flatten
#define hxattr_hot
#define hxattr_nodiscard
#define hxattr_noexcept
#define hxattr_nonnull(...)
#define hxattr_noinline
#define hxattr_noreturn
#define hxattr_printf(...)
#define hxattr_weak
#define hxattr_scanf(...)
#define hxinline   inline
#define hxconstexpr   constexpr
#define hxinline_constexpr   inline constexpr
#define hxif_constexpr   if constexpr
#define HX_USE_MACROS_WITH_MODULE   0
#define HX_USE_CONSOLE   ((HX_CPLUSPLUS >= 202002L) ? 1 : 0)
#define HX_USE_LOGGING   2
#define HX_USE_FILE_IO   1
#define HX_USE_PROFILER   0
#define HX_CYCLES_PER_SECOND   3.0e+9
#define HX_PROFILER_MAX_RECORDS   4096
#define HX_USE_MEMORY_MANAGER   1
#define HX_PROVIDE_NEW_DELETE   !(HX_USE_LIBCXX)
#define HX_KIB   (1 << 10)
#define HX_MIB   (1 << 20)
#define HX_GIB   (1 << 30)
#define HX_MEMORY_BUDGET_PERMANENT   (4u * HX_KIB)
#define HX_MEMORY_MAX_STACKS   3u
#define HX_RADIX_SORT_MIN_SIZE   32
#define HX_MAX_LINE   (2 * HX_KIB)
#define HX_USE_GOOGLE_TEST   0
#define HX_USE_FLOATING_POINT_TRAPS   0
#define HX_QUOTE(x_)

Functions

void hxsettings_construct_ (void)

Variables

struct hxsettings hxg_settings

Detailed Description

Compiler detection and target specific C++ feature polyfill.

Use #if HX_... instead of #ifdef HX_... for all HX_* macros. HX_USE_NAMESPACE can be used to wrap the library in a namespace.

Macro Definition Documentation

◆ HX_CPLUSPLUS

#define HX_CPLUSPLUS   202302L

HX_CPLUSPLUS - A version of __cplusplus that is defined to 0 when __cplusplus is undefined.

Allows use in C preprocessor statements without warnings when the compiler is configured to warn about undefined macros.

  • C++11: 201103L
  • C++14: 201402L
  • C++17: 201703L
  • C++20: 202002L
  • C++23: 202302L

◆ HX_CYCLES_PER_SECOND

#define HX_CYCLES_PER_SECOND   3.0e+9

HX_CYCLES_PER_SECOND - Configures the CPU cycles per second.

This is hardcoded to avoid an OS dependency. WARNING: Processors may change speed.

◆ HX_GIB

#define HX_GIB   (1 << 30)

HX_GIB - A GiB, 2^30.

◆ HX_KIB

#define HX_KIB   (1 << 10)

HX_KIB - A KiB, 2^10.

◆ HX_MAX_LINE

#define HX_MAX_LINE   (2 * HX_KIB)

HX_MAX_LINE - Set to 2 KiB.

Line buffer size for formatted messages printed with this platform. Only allocated on the stack.

◆ HX_MEMORY_BUDGET_PERMANENT

#define HX_MEMORY_BUDGET_PERMANENT   (4u * HX_KIB)

HX_MEMORY_BUDGET_PERMANENT - Pool sizes.

Defaults to 4 KiB if not defined. Set to 0 to disable.

◆ HX_MEMORY_MAX_STACKS

#define HX_MEMORY_MAX_STACKS   3u

HX_MEMORY_MAX_STACKS - The maximum number of temporary stacks that hxmemory_manager_allocate_stacks may allocate.

Set to 3 for triple buffering if not defined.

◆ HX_MIB

#define HX_MIB   (1 << 20)

HX_MIB - A MiB, 2^20.

◆ HX_PROFILER_MAX_RECORDS

#define HX_PROFILER_MAX_RECORDS   4096

HX_PROFILER_MAX_RECORDS - Set to 4096 if not defined.

The profiler doesn't reallocate. This is the maximum.

◆ HX_PROVIDE_NEW_DELETE

#define HX_PROVIDE_NEW_DELETE   !(HX_USE_LIBCXX)

HX_PROVIDE_NEW_DELETE - Provides a new/delete implementation when the std library is absent unless overridden.

Use HX_PROVIDE_NEW_DELETE=-1 when compiling a module to prevent declaration.

◆ HX_QUOTE

#define HX_QUOTE ( x_)
Value:
#x_

Converts its arg into a string.

◆ HX_RADIX_SORT_MIN_SIZE

#define HX_RADIX_SORT_MIN_SIZE   32

HX_RADIX_SORT_MIN_SIZE - Radix sort switches to hxinsertion_sort below this size.

Set to 32 if not defined.

◆ HX_USE_CONSOLE

#define HX_USE_CONSOLE   ((HX_CPLUSPLUS >= 202002L) ? 1 : 0)

HX_USE_CONSOLE - Control whether the console is included in the build.

C++20 is required to use the console. 0 - Disables the console. 1 - Enables the console. 2 - Enables the debug console. This allows executing files and modifying memory.

◆ HX_USE_FILE_IO

#define HX_USE_FILE_IO   1

HX_USE_FILE_IO - Select if hxfile exists and if it uses C file I/O or POSIX I/O.

stdout is used for logging even when hxfile is disabled. 0

  • Disables hxfile. 1 - C file I/O. 2 - POSIX file I/O.

◆ HX_USE_FLOATING_POINT_TRAPS

#define HX_USE_FLOATING_POINT_TRAPS   0

◆ HX_USE_GOOGLE_TEST

#define HX_USE_GOOGLE_TEST   0

HX_USE_GOOGLE_TEST - Switch to using the real Google Test. Defaults to 0.

◆ HX_USE_INLINING_ATTR

#define HX_USE_INLINING_ATTR   1

HX_USE_INLINING_ATTR - Controls whether hxinline, hxattr_flatten, and hxattr_hot are enabled.

◆ HX_USE_LIBCXX

#define HX_USE_LIBCXX   1

HX_USE_LIBCXX: Indicates whether libstdc++/libc++ are present.

Set -DHX_USE_LIBCXX=0 to signal the C++ standard library is not in use. The C++ standard library is not detected automatically because that depends on header include order.

◆ HX_USE_LOGGING

#define HX_USE_LOGGING   2

HX_USE_LOGGING - Control whether logging statements are included in the build.

Note: hxlog_handler is always available and is used by the asserts. 0 - Disables the logging macros. 1 - All logging except hxlog. 2 - All logging including hxlog. This is the default.

◆ HX_USE_MACROS_WITH_MODULE

#define HX_USE_MACROS_WITH_MODULE   0

HX_USE_MACROS_WITH_MODULE - Setting -DHX_USE_MACROS_WITH_MODULE=1 when using modules (e.g.

import hx;) will allow the macros in <hx/libhatchet.h>, <hx/hxconsole.hpp>, <hx/hxprofiler.hpp> and <hx/hxtest.hpp> to be textually included alongside import hx;. See src/hxmodule.cppm.

◆ HX_USE_MEMORY_MANAGER

#define HX_USE_MEMORY_MANAGER   1

HX_USE_MEMORY_MANAGER - Used to disable memory management for debugging and for platforms like wasm where extra system allocations are probably cheaper than code size.

  • 0 : normal target operation - 1 : remove code entirely

◆ HX_USE_PROFILER

#define HX_USE_PROFILER   0

HX_USE_PROFILER - Enable this to use the profiler.

  • 0 Disables code for capturing profiling data. - 1 Compiles in code. See hxprofile_scope.

◆ HX_USE_THREADS

#define HX_USE_THREADS   11

HX_USE_THREADS - 11 indicates C11 threads are in use.

1 is for pthreads and 0 is for no threading.

◆ hxattr_allocator

#define hxattr_allocator ( ...)

hxattr_allocator - Mark allocator/deallocator pairs for static analysis.

See the gcc manual. Must return non-null as well.

◆ hxattr_assume

#define hxattr_assume ( ...)
Value:
(void)0

hxattr_assume - Tell the optimizer that condition is always true.

Similar to C++23 [[assume(condition)]];.

◆ hxattr_cold

#define hxattr_cold

hxattr_cold - Optimize a function for size.

◆ hxattr_flatten

#define hxattr_flatten

hxattr_flatten - Inline every call inside a function's body into it, recursively, regardless of the cost heuristic used for those calls.

◆ hxattr_hot

#define hxattr_hot

hxattr_hot - Optimize a function more aggressively.

Significantly increases code utilization. Adjust implementation according to needs.

◆ hxattr_nodiscard

#define hxattr_nodiscard

hxattr_nodiscard - Indicates the caller should not discard the return value.

◆ hxattr_noexcept

#define hxattr_noexcept

hxattr_noexcept - Use gcc/clang nothrow attribute.

Unlike noexcept this is undefined when violated.

◆ hxattr_noinline

#define hxattr_noinline

hxattr_noinline - Prevents a function from being inlined.

◆ hxattr_nonnull

#define hxattr_nonnull ( ...)

hxattr_nonnull - Indicates that a function has args that should not be null.

Checked by UBSan.

◆ hxattr_noreturn

#define hxattr_noreturn

hxattr_noreturn - Indicates that a function will never return.

E.g., by calling _Exit.

◆ hxattr_printf

#define hxattr_printf ( ...)

hxattr_printf - Indicates to gcc that a function uses printf-style formatting so it can type-check the format string.

◆ hxattr_scanf

#define hxattr_scanf ( ...)

hxattr_scanf - Indicates to gcc that a function uses scanf-style formatting so it can type-check the format string.

◆ hxattr_weak

#define hxattr_weak

hxattr_weak - Allow calling code to override static library code.

Note: MSVC treats all static library symbols as weak.

◆ hxbreakpoint

#define hxbreakpoint ( )
Value:
true

hxbreakpoint - Can be conditionally evaluated with the && and || operators.

Uses intrinsics when available. (E.g., Clang's.) Raises SIGTRAP when __builtin_debugtrap is not available.

◆ hxconstexpr

#define hxconstexpr   constexpr

hxconstexpr - Enables C++23 compatable constexpr usage for functions as that has support for destructors.

Falls back to not using constexpr below C++23.

◆ hxif_constexpr

#define hxif_constexpr   if constexpr

hxif_constexpr - if constexpr on C++17 and later, plain if otherwise.

◆ hxinline

#define hxinline   inline

hxinline - Force a function to be inlined into its callers.

Also includes the inline keyword.

◆ hxinline_constexpr

#define hxinline_constexpr   inline constexpr

hxinline_constexpr - Enables C++17 compatable "inline constexpr" usage for variables so they can be exported from modules.

Falls back to not using inline below C++17.

◆ hxrestrict

#define hxrestrict

hxrestrict - A pointer attribute indicating that for the lifetime of that pointer, it will be the sole means of accessing the object(s) it points to.

Prevents a write iterator from interfering with a read iterator.

Function Documentation

◆ hxsettings_construct_()

void hxsettings_construct_ ( void )

hxsettings_construct - Internal. Used to reset settings at startup.

Variable Documentation

◆ hxg_settings

struct hxsettings hxg_settings
extern

hxg_settings - Global class constructed by hxinit.