mirror of
https://github.com/matrix-construct/construct
synced 2024-06-02 10:08:56 +02:00
ircd: Split stdinc into additional macros header.
This commit is contained in:
parent
992fc10be5
commit
4bef7dca7b
|
@ -1,7 +1,7 @@
|
|||
// Matrix Construct
|
||||
// The Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
||||
// Copyright (C) Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2020 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -11,10 +11,35 @@
|
|||
#ifndef HAVE_IRCD_IRCD_H
|
||||
#define HAVE_IRCD_IRCD_H
|
||||
|
||||
// Generated by ./configure
|
||||
#include "config.h"
|
||||
#include "assert.h"
|
||||
//////////////////////////////////////////////////////////////////////////////>
|
||||
//
|
||||
// This is an aggregate header which ties together the general public
|
||||
// interfaces for IRCd. Include this header to operate and embed the library in
|
||||
// your application; no other includes from the project should be required.
|
||||
//
|
||||
// This header only includes standard library headers; we may forward declare
|
||||
// third-party symbols, but only if their headers are not required.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////>
|
||||
|
||||
//
|
||||
// Project configuration
|
||||
//
|
||||
|
||||
#include "config.h" // Generated by ./configure; do not edit
|
||||
#include "assert.h" // Custom assert (during debug builds)
|
||||
#include "portable.h" // Additional developer config; editable
|
||||
|
||||
//
|
||||
// Standard library includes
|
||||
//
|
||||
|
||||
#include "stdinc.h"
|
||||
|
||||
//
|
||||
// Project library interfaces
|
||||
//
|
||||
|
||||
#include "string_view.h"
|
||||
#include "vector_view.h"
|
||||
#include "byte_view.h"
|
||||
|
|
68
include/ircd/portable.h
Normal file
68
include/ircd/portable.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Matrix Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice is present in all copies. The
|
||||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
//
|
||||
// Portability Macros & Developer Tools
|
||||
//
|
||||
|
||||
#define HAVE_IRCD_PORTABLE_H
|
||||
|
||||
//
|
||||
// Common branch prediction macros
|
||||
//
|
||||
|
||||
#ifndef likely
|
||||
#define likely(x) __builtin_expect(!!(x), 1)
|
||||
#endif
|
||||
|
||||
#ifndef unlikely
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
#endif
|
||||
|
||||
//
|
||||
// 128 bit integer support
|
||||
//
|
||||
|
||||
#if !defined(HAVE_INT128_T) || !defined(HAVE_UINT128_T)
|
||||
namespace ircd
|
||||
{
|
||||
#if defined(HAVE___INT128_T) && defined(HAVE__UINT128_T)
|
||||
using int128_t = __int128_t;
|
||||
using uint128_t = __uint128_t;
|
||||
#elif defined(HAVE___INT128)
|
||||
using int128_t = signed __int128;
|
||||
using uint128_t = unsigned __int128;
|
||||
#else
|
||||
#error "Missing 128 bit integer types on this platform."
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Trouble; FreeBSD unsigned long ctype
|
||||
//
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(ulong)
|
||||
typedef u_long ulong;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Trouble; clang w/ our custom assert
|
||||
//
|
||||
|
||||
#if defined(__clang__) && !defined(assert)
|
||||
#ifdef NDEBUG
|
||||
#define assert(expr) \
|
||||
(static_cast<void>(0))
|
||||
#else
|
||||
#define assert(expr) \
|
||||
(static_cast<bool>(expr)? void(0): __assert_fail(#expr, __FILE__, __LINE__, __FUNCTION__))
|
||||
#endif
|
||||
#endif
|
|
@ -94,11 +94,6 @@ extern "C"
|
|||
#include <RB_INC_EXPERIMENTAL_STRING_VIEW
|
||||
#include <RB_INC_EXPERIMENTAL_OPTIONAL
|
||||
|
||||
// FreeBSD unsigned long ctype
|
||||
#if defined(__FreeBSD__) && !defined(ulong)
|
||||
typedef u_long ulong;
|
||||
#endif
|
||||
|
||||
// These are #defined in stdio.h. If the system includes it indirectly we have
|
||||
// to undef those here or there will be trouble.
|
||||
#undef stdin
|
||||
|
@ -109,17 +104,6 @@ extern "C"
|
|||
#undef major
|
||||
#undef minor
|
||||
|
||||
// Trouble; clang.
|
||||
#if defined(__clang__) && !defined(assert)
|
||||
#ifdef NDEBUG
|
||||
#define assert(expr) \
|
||||
(static_cast<void>(0))
|
||||
#else
|
||||
#define assert(expr) \
|
||||
(static_cast<bool>(expr)? void(0): __assert_fail(#expr, __FILE__, __LINE__, __FUNCTION__))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////>
|
||||
//
|
||||
// Pollution
|
||||
|
@ -128,10 +112,6 @@ extern "C"
|
|||
// which may conflict with your project.
|
||||
//
|
||||
|
||||
// Common branch prediction macros
|
||||
#define likely(x) __builtin_expect(!!(x), 1)
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
|
||||
// Experimental std::string_view
|
||||
#if !defined(__cpp_lib_string_view) && defined(__cpp_lib_experimental_string_view)
|
||||
namespace std
|
||||
|
@ -166,22 +146,6 @@ namespace std
|
|||
// Some items imported into our namespace.
|
||||
//
|
||||
|
||||
// 128 bit integer support
|
||||
#if !defined(HAVE_INT128_T) || !defined(HAVE_UINT128_T)
|
||||
namespace ircd
|
||||
{
|
||||
#if defined(HAVE___INT128_T) && defined(HAVE__UINT128_T)
|
||||
using int128_t = __int128_t;
|
||||
using uint128_t = __uint128_t;
|
||||
#elif defined(HAVE___INT128)
|
||||
using int128_t = signed __int128;
|
||||
using uint128_t = unsigned __int128;
|
||||
#else
|
||||
#error "Missing 128 bit integer types on this platform."
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace ircd
|
||||
{
|
||||
using std::get;
|
||||
|
|
Loading…
Reference in a new issue