Loading...
Searching...
No Matches
common_defs.h File Reference

Cross-platform compiler macros and common definitions. More...

`#include <version>`

Go to the source code of this file.

## Namespaces

namespace | ada

## Macros

#define | ADA_BEGIN_DEBUG_BLOCK(name)
#define | ADA_END_DEBUG_BLOCK(name)
#define | ADA_DEBUG_BLOCK(name, block)
#define | ADA_ROUNDUP_N(a, n)
#define | ADA_ROUNDDOWN_N(a, n)
#define | ADA_ISALIGNED_N(ptr, n)
#define | ada_really_inline inline __attribute__((always_inline))
#define | ada_never_inline inline __attribute__((noinline))
#define | ada_unused __attribute__((unused))
#define | ada_warn_unused __attribute__((warn_unused_result))
#define | ADA_PUSH_DISABLE_WARNINGS _Pragma("GCC diagnostic push")
#define | ADA_PUSH_DISABLE_ALL_WARNINGS
#define | ADA_PRAGMA(P)
#define | ADA_DISABLE_GCC_WARNING(WARNING)
#define | ADA_DISABLE_UNDESIRED_WARNINGS
#define | ADA_DISABLE_DEPRECATED_WARNING ADA_DISABLE_GCC_WARNING("-Wdeprecated-declarations")
#define | ADA_DISABLE_STRICT_OVERFLOW_WARNING ADA_DISABLE_GCC_WARNING("-Wstrict-overflow")
#define | ADA_POP_DISABLE_WARNINGS _Pragma("GCC diagnostic pop")
#define | ADA_DLLIMPORTEXPORT
#define | ADA_TRY(EXPR)
| If EXPR is an error, returns it.
#define | __has_cpp_attribute(x)
#define | ADA_ATTRIBUTE_NOINLINE
#define | ADA_DEVELOPMENT_CHECKS 1
#define | ADA_STR(x)
#define | ADA_REQUIRE(EXPR)
#define | ADA_FAIL(MESSAGE)
#define | ADA_ASSERT_EQUAL(LHS, RHS, MESSAGE)
#define | ADA_ASSERT_TRUE(COND)
#define | ADA_ASSUME(COND)
#define | ada_lifetime_bound
#define | ADA_INCLUDE_URL_PATTERN 1

## Functions

void | ada::unreachable ()

## Detailed Description

Cross-platform compiler macros and common definitions.

This header provides compiler-specific macros for optimization hints, platform detection, SIMD support detection, and development/debug utilities. It ensures consistent behavior across different compilers (GCC, Clang, MSVC).

Definition in file common_defs.h.

## Macro Definition Documentation

## __has_cpp_attribute

#define __has_cpp_attribute | ( |  | x | ) |

Value:
0

Definition at line 151 of file common_defs.h.

## ADA_ASSERT_EQUAL

#define ADA_ASSERT_EQUAL | ( |  | LHS,
|  |  | RHS,
|  |  | MESSAGE )

Value:
do { \
if (LHS != RHS) { \
std::cerr << "Mismatch: '" << LHS << "' - '" << RHS << "'" << std::endl; \
ADA_FAIL(MESSAGE); \
} \
} while (0);

Definition at line 208 of file common_defs.h.

Referenced by ada::url_aggregator::clear_hash(), and ada::url_aggregator::clear_search().

## ADA_ASSERT_TRUE

#define ADA_ASSERT_TRUE | ( |  | COND | ) |

Value:
do { \
if (!(COND)) { \
std::cerr << "Assert at line " << __LINE__ << " of file " << __FILE__ \
<< std::endl; \
ADA_FAIL(ADA_STR(COND)); \
} \
} while (0);
ADA_STR
#define ADA_STR(x)
Definition common_defs.h:196

Definition at line 215 of file common_defs.h.

Referenced by ada::url_aggregator::clear_hash(), ada::url_aggregator::clear_port(), ada::url_aggregator::clear_search(), ada::parser::parse_url_impl(), ada::url_aggregator::set_hash(), ada::url_aggregator::set_host(), ada::url_aggregator::set_hostname(), ada::url_aggregator::set_href(), ada::url_aggregator::set_password(), ada::url_aggregator::set_pathname(), ada::url_aggregator::set_port(), ada::url_aggregator::set_protocol(), ada::url_aggregator::set_search(), and ada::url_aggregator::set_username().

## ADA_ASSUME

#define ADA_ASSUME | ( |  | COND | ) |

Value:
do { \
if (!(COND)) { \
__builtin_unreachable(); \
} \
} while (0)

Definition at line 232 of file common_defs.h.

## ADA_ATTRIBUTE_NOINLINE

#define ADA_ATTRIBUTE_NOINLINE

Definition at line 157 of file common_defs.h.

## ADA_BEGIN_DEBUG_BLOCK

#define ADA_BEGIN_DEBUG_BLOCK | ( |  | name | ) |

Definition at line 41 of file common_defs.h.

## ADA_DEBUG_BLOCK

#define ADA_DEBUG_BLOCK | ( |  | name,
|  |  | block )

Definition at line 43 of file common_defs.h.

## ADA_DEVELOPMENT_CHECKS

#define ADA_DEVELOPMENT_CHECKS 1

Definition at line 191 of file common_defs.h.

## ADA_DISABLE_DEPRECATED_WARNING

#define ADA_DISABLE_DEPRECATED_WARNING ADA_DISABLE_GCC_WARNING("-Wdeprecated-declarations")

Definition at line 117 of file common_defs.h.

## ADA_DISABLE_GCC_WARNING

#define ADA_DISABLE_GCC_WARNING | ( |  | WARNING | ) |

Value:
ADA_PRAGMA(GCC diagnostic ignored WARNING)
ADA_PRAGMA
#define ADA_PRAGMA(P)
Definition common_defs.h:108

Definition at line 109 of file common_defs.h.

## ADA_DISABLE_STRICT_OVERFLOW_WARNING

#define ADA_DISABLE_STRICT_OVERFLOW_WARNING ADA_DISABLE_GCC_WARNING("-Wstrict-overflow")

Definition at line 119 of file common_defs.h.

## ADA_DISABLE_UNDESIRED_WARNINGS

#define ADA_DISABLE_UNDESIRED_WARNINGS

Definition at line 115 of file common_defs.h.

## ADA_DLLIMPORTEXPORT

#define ADA_DLLIMPORTEXPORT

Definition at line 137 of file common_defs.h.

## ADA_END_DEBUG_BLOCK

#define ADA_END_DEBUG_BLOCK | ( |  | name | ) |

Definition at line 42 of file common_defs.h.

## ADA_FAIL

#define ADA_FAIL | ( |  | MESSAGE | ) |

Value:
do { \
std::cerr << "FAIL: " << (MESSAGE) << std::endl; \
abort(); \
} while (0);

Definition at line 203 of file common_defs.h.

## ADA_INCLUDE_URL_PATTERN

#define ADA_INCLUDE_URL_PATTERN 1

Definition at line 283 of file common_defs.h.

## ADA_ISALIGNED_N

#define ADA_ISALIGNED_N | ( |  | ptr,
|  |  | n )

Value:
(((uintptr_t)(ptr) & ((n)-1)) == 0)

Definition at line 50 of file common_defs.h.

## ada_lifetime_bound

#define ada_lifetime_bound

Definition at line 272 of file common_defs.h.

Referenced by ada::url_aggregator::get_hash(), ada::url_aggregator::get_host(), ada::url_aggregator::get_hostname(), ada::url_aggregator::get_href(), ada::url_aggregator::get_password(), ada::url_aggregator::get_pathname(), ada::url_aggregator::get_port(), ada::url_aggregator::get_protocol(), ada::url_aggregator::get_search(), ada::url_aggregator::get_username(), and ada::url_aggregator::~url_aggregator().

## ada_never_inline

#define ada_never_inline inline __attribute__((noinline))

Definition at line 86 of file common_defs.h.

## ADA_POP_DISABLE_WARNINGS

#define ADA_POP_DISABLE_WARNINGS _Pragma("GCC diagnostic pop")

Definition at line 121 of file common_defs.h.

## ADA_PRAGMA

#define ADA_PRAGMA | ( |  | P | ) |

Value:
_Pragma(#P)

Definition at line 108 of file common_defs.h.

## ADA_PUSH_DISABLE_ALL_WARNINGS

#define ADA_PUSH_DISABLE_ALL_WARNINGS

Value:
ADA_PUSH_DISABLE_WARNINGS \
ADA_DISABLE_GCC_WARNING("-Weffc++") \
ADA_DISABLE_GCC_WARNING("-Wall") \
ADA_DISABLE_GCC_WARNING("-Wconversion") \
ADA_DISABLE_GCC_WARNING("-Wextra") \
ADA_DISABLE_GCC_WARNING("-Wattributes") \
ADA_DISABLE_GCC_WARNING("-Wimplicit-fallthrough") \
ADA_DISABLE_GCC_WARNING("-Wnon-virtual-dtor") \
ADA_DISABLE_GCC_WARNING("-Wreturn-type") \
ADA_DISABLE_GCC_WARNING("-Wshadow") \
ADA_DISABLE_GCC_WARNING("-Wunused-parameter") \
ADA_DISABLE_GCC_WARNING("-Wunused-variable") \
ADA_DISABLE_GCC_WARNING("-Wsign-compare")

Definition at line 94 of file common_defs.h.

## ADA_PUSH_DISABLE_WARNINGS

#define ADA_PUSH_DISABLE_WARNINGS _Pragma("GCC diagnostic push")

Definition at line 91 of file common_defs.h.

## ada_really_inline

#define ada_really_inline inline __attribute__((always_inline))

Definition at line 85 of file common_defs.h.

Referenced by ada::character_sets::bit_at(), ada::helpers::find_next_host_delimiter(), ada::helpers::find_next_host_delimiter_special(), ada::url::get_components(), ada::url::get_href(), ada::url::has_credentials(), ada::url::has_port(), ada::url_base::has_valid_domain(), ada::url_base::is_special(), ada::unicode::percent_encode_index(), ada::helpers::trailing_zeroes(), ada::checkers::try_parse_ipv4_fast(), and ada::url_aggregator::~url_aggregator().

## ADA_REQUIRE

#define ADA_REQUIRE | ( |  | EXPR | ) |

Value:
{ \
if (!(EXPR) { abort(); }) }

Definition at line 199 of file common_defs.h.

## ADA_ROUNDDOWN_N

#define ADA_ROUNDDOWN_N | ( |  | a,
|  |  | n )

Value:
((a) & ~((n)-1))

Definition at line 48 of file common_defs.h.

## ADA_ROUNDUP_N

#define ADA_ROUNDUP_N | ( |  | a,
|  |  | n )

Value:
(((a) + ((n)-1)) & ~((n)-1))

Definition at line 47 of file common_defs.h.

## ADA_STR

#define ADA_STR | ( |  | x | ) |

Value:
#x

Definition at line 196 of file common_defs.h.

## ADA_TRY

#define ADA_TRY | ( |  | EXPR | ) |

Value:
{ \
auto _err = (EXPR); \
if (_err) { \
return _err; \
} \
}

If EXPR is an error, returns it.

Definition at line 141 of file common_defs.h.

## ada_unused

#define ada_unused __attribute__((unused))

Definition at line 88 of file common_defs.h.

Referenced by ada::helpers::get_state().

## ada_warn_unused

#define ada_warn_unused __attribute__((warn_unused_result))

Examples
  /build/ada-url-QhggFk/ada-url-3.4.4/include/ada/implementation.h.

Definition at line 89 of file common_defs.h.

Referenced by ada::parse(), ada::parse< url_aggregator >(), ada::to_string(), and ada::to_string().