|
VLink 2.0.0
A high-performance communication middleware
|
Platform-independent macro definitions for the VLink library. More...
Go to the source code of this file.
Macros | |
| #define | VLINK_EXPORT __attribute__((visibility("default"))) |
| #define | VLINK_EXPORT_AND_ALIGNED(align_num) |
| Marks a class or variable as both exported and aligned to the given byte boundary. | |
| #define | __has_builtin(x) |
| #define | VLINK_LIKELY(x) |
| #define | VLINK_UNLIKELY(x) |
| #define | VLINK_DISALLOW_COPY_AND_ASSIGN(classname) |
Deletes the copy constructor and copy-assignment operator of classname. | |
| #define | VLINK_SINGLETON_CHECK(classname) |
| Injects a compile-time and run-time singleton enforcement guard. | |
| #define | VLINK_SINGLETON_DECLARE(classname) |
Declares a complete Meyer's-singleton get() method with safety guards. | |
| #define | VLINK_MACRO_STRING_IFY(name) |
Converts name to a C string literal using the preprocessor stringification operator. | |
| #define | VLINK_MACRO_STRING_GET(name) |
Stringifies the expanded value of macro name (two-level expansion). | |
| #define | VLINK_ASSERT_CONSTANT(msg) |
| #define | VLIKELY(...) |
| Shorthand alias for VLINK_LIKELY. Hints that the expression is likely true. | |
| #define | VUNLIKELY(...) |
| Shorthand alias for VLINK_UNLIKELY. Hints that the expression is unlikely true. | |
Platform-independent macro definitions for the VLink library.
This header provides a unified set of macros used throughout VLink to handle platform differences, visibility control, branch prediction hints, and common class-level utilities such as singleton enforcement and copy-prevention.
The macros are grouped as follows:
| Group | Macros | Purpose |
|---|---|---|
| Symbol visibility | VLINK_EXPORT, VLINK_EXPORT_AND_ALIGNED | DLL export / visibility control |
| Branch hints | VLINK_LIKELY, VLINK_UNLIKELY, VLIKELY, ... | Branch prediction optimization |
| Copy prevention | VLINK_DISALLOW_COPY_AND_ASSIGN | Disable copy constructor/operator |
| Singleton guard | VLINK_SINGLETON_CHECK, VLINK_SINGLETON_DECLARE | Enforce single-instance classes |
| String utilities | VLINK_MACRO_STRING_IFY, VLINK_MACRO_STRING_GET | Stringify macro tokens |
| Constant check | VLINK_ASSERT_CONSTANT | Static-assert constant string args |
| #define __has_builtin | ( | x | ) |
| #define VLIKELY | ( | ... | ) |
Shorthand alias for VLINK_LIKELY. Hints that the expression is likely true.
| #define VLINK_ASSERT_CONSTANT | ( | msg | ) |
| #define VLINK_DISALLOW_COPY_AND_ASSIGN | ( | classname | ) |
Deletes the copy constructor and copy-assignment operator of classname.
Place this macro in the private section of a class to prevent accidental copying. It expands to:
| classname | The unqualified name of the enclosing class. |
| #define VLINK_EXPORT __attribute__((visibility("default"))) |
| #define VLINK_EXPORT_AND_ALIGNED | ( | align_num | ) |
Marks a class or variable as both exported and aligned to the given byte boundary.
On MSVC this expands to __declspec(align(align_num)); on GCC/Clang it expands to __attribute__((aligned(align_num))).
| align_num | The required alignment in bytes (must be a power of two). |
| #define VLINK_LIKELY | ( | x | ) |
| #define VLINK_MACRO_STRING_GET | ( | name | ) |
Stringifies the expanded value of macro name (two-level expansion).
This two-step macro ensures that name is fully expanded before stringification. Use this instead of VLINK_MACRO_STRING_IFY when name is itself a macro that should be expanded first.
| name | A macro whose expansion will be converted to a string literal. |
| #define VLINK_MACRO_STRING_IFY | ( | name | ) |
Converts name to a C string literal using the preprocessor stringification operator.
| name | A macro token (not a string literal) to stringify. |
| #define VLINK_SINGLETON_CHECK | ( | classname | ) |
Injects a compile-time and run-time singleton enforcement guard.
This macro:
static_assert to verify that classname is final and has a private (non-default-constructible-from-outside) constructor.std::atomic_flag to guarantee that the constructor is only invoked once per process. A second instantiation throws std::runtime_error.private section of the class body.| classname | The unqualified name of the class being protected. |
| #define VLINK_SINGLETON_DECLARE | ( | classname | ) |
Declares a complete Meyer's-singleton get() method with safety guards.
Combines VLINK_SINGLETON_CHECK with a public static get() accessor that returns a reference to the single static instance. The constructor must be private and final, otherwise the embedded static_assert will fail.
| classname | The unqualified name of the singleton class. |
| #define VLINK_UNLIKELY | ( | x | ) |
| #define VUNLIKELY | ( | ... | ) |
Shorthand alias for VLINK_UNLIKELY. Hints that the expression is unlikely true.