0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd: Split stduse.h from stdinc.h.

This commit is contained in:
Jason Volk 2022-07-08 10:22:29 -07:00
parent 18b3b58709
commit 6c7a978a60
3 changed files with 105 additions and 117 deletions

View file

@ -28,13 +28,9 @@
#include "config.h" // Generated by ./configure; do not edit #include "config.h" // Generated by ./configure; do not edit
#include "assert.h" // Custom assert (during debug builds) #include "assert.h" // Custom assert (during debug builds)
#include "portable.h" // Additional developer config; editable #include "portable.h" // Additional developer config pre-std
#include "stdinc.h" // Standard library includes.
// #include "stduse.h" // Additional developer config post-std
// Standard library includes
//
#include "stdinc.h"
// //
// Project library interfaces // Project library interfaces

View file

@ -8,9 +8,10 @@
// copyright notice and this permission notice is present in all copies. The // copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file. // full license for this software is available in the LICENSE file.
#pragma once
#define HAVE_IRCD_STDINC_H #define HAVE_IRCD_STDINC_H
#pragma GCC visibility push(default)
///////////////////////////////////////////////////////////////////////////////
// //
// Standard includes // Standard includes
// //
@ -20,10 +21,6 @@
// pollution and risk of conflicts. // pollution and risk of conflicts.
// //
// This pragma overrides any -fvisibility option on any unit to maintain
// consistent default visibility of these items.
#pragma GCC visibility push(default)
// Windows Specific // Windows Specific
#ifdef _WIN32 #ifdef _WIN32
#define WIN32_LEAN_AND_MEAN 1 #define WIN32_LEAN_AND_MEAN 1
@ -134,14 +131,6 @@ extern "C"
#undef major #undef major
#undef minor #undef minor
//////////////////////////////////////////////////////////////////////////////>
//
// Pollution
//
// This section lists all of the items introduced outside of our namespace
// which may conflict with your project.
//
// Experimental std::string_view // Experimental std::string_view
#if !defined(__cpp_lib_string_view) && defined(__cpp_lib_experimental_string_view) #if !defined(__cpp_lib_string_view) && defined(__cpp_lib_experimental_string_view)
namespace std namespace std
@ -169,100 +158,4 @@ namespace std
extern ostream cerr; extern ostream cerr;
} }
/////////////////////////////////////////////////////////////////////////////// #pragma GCC visibility pop
//
// libircd API
//
// Convenience short-hands for POD-types available in ircd::
namespace ircd
{
// 128-bit
using u128 = uint128_t;
using i128 = int128_t;
using f128 = long double;
// 64-bit
using u64 = uint64_t;
using i64 = int64_t;
using f64 = double;
// 32-bit
using u32 = uint32_t;
using i32 = int32_t;
using c32 = char32_t;
using f32 = float;
// 16-bit
using u16 = uint16_t;
using i16 = int16_t;
using c16 = char16_t;
#if defined(HAVE__FLOAT16)
#define HAVE_FP16
using f16 = _Float16;
#elif defined(HAVE___FP16)
#define HAVE_FP16
using f16 = __fp16;
#elif defined(__clang__)
#warning "Missing half-precision floating point support."
#endif
// 8-bit
using u8 = uint8_t;
using i8 = int8_t;
#ifdef HAVE_CHAR8_T
using c8 = char8_t;
#endif
#if defined(HAVE___FP8)
#define HAVE_FP8
using f8 = __fp8;
#endif
}
// Various standard library items imported into our namespace.
namespace ircd
{
using std::get;
using std::end;
using std::begin;
using std::nullptr_t;
using std::nothrow_t;
using std::const_pointer_cast;
using std::static_pointer_cast;
using std::dynamic_pointer_cast;
using std::chrono::hours;
using std::chrono::minutes;
using std::chrono::seconds;
using std::chrono::milliseconds;
using std::chrono::microseconds;
using std::chrono::nanoseconds;
using std::chrono::duration;
using std::chrono::duration_cast;
using std::chrono::system_clock;
using std::chrono::steady_clock;
using std::chrono::high_resolution_clock;
using std::chrono::time_point;
using namespace std::string_literals;
using namespace std::chrono_literals;
using namespace std::literals::chrono_literals;
using std::string_literals::operator""s;
using std::chrono_literals::operator""s;
namespace ph = std::placeholders;
template<class... T> using ilist = std::initializer_list<T...>;
using std::error_code;
/// Simple gimmick to allow shorter declarations when both elements
/// of a pair are the same.
template<class A,
class B = A>
using pair = std::pair<A, B>;
}
#pragma GCC visibility pop // default

99
include/ircd/stduse.h Normal file
View file

@ -0,0 +1,99 @@
// Matrix Construct
//
// Copyright (C) Matrix Construct Developers, Authors & Contributors
// Copyright (C) 2016-2022 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.
#pragma once
#define HAVE_IRCD_STDUSE_H
namespace ircd
{
// 128-bit
using u128 = uint128_t;
using i128 = int128_t;
using f128 = long double;
// 64-bit
using u64 = uint64_t;
using i64 = int64_t;
using f64 = double;
// 32-bit
using u32 = uint32_t;
using i32 = int32_t;
using c32 = char32_t;
using f32 = float;
// 16-bit
using u16 = uint16_t;
using i16 = int16_t;
using c16 = char16_t;
#if defined(HAVE__FLOAT16)
#define HAVE_FP16
using f16 = _Float16;
#elif defined(HAVE___FP16)
#define HAVE_FP16
using f16 = __fp16;
#elif defined(__clang__)
#warning "Missing half-precision floating point support."
#endif
// 8-bit
using u8 = uint8_t;
using i8 = int8_t;
#ifdef HAVE_CHAR8_T
using c8 = char8_t;
#endif
#if defined(HAVE___FP8)
#define HAVE_FP8
using f8 = __fp8;
#endif
using std::get;
using std::end;
using std::begin;
using std::nullptr_t;
using std::nothrow_t;
using std::const_pointer_cast;
using std::static_pointer_cast;
using std::dynamic_pointer_cast;
using std::chrono::hours;
using std::chrono::minutes;
using std::chrono::seconds;
using std::chrono::milliseconds;
using std::chrono::microseconds;
using std::chrono::nanoseconds;
using std::chrono::duration;
using std::chrono::duration_cast;
using std::chrono::system_clock;
using std::chrono::steady_clock;
using std::chrono::high_resolution_clock;
using std::chrono::time_point;
using namespace std::string_literals;
using namespace std::chrono_literals;
using namespace std::literals::chrono_literals;
using std::string_literals::operator""s;
using std::chrono_literals::operator""s;
namespace ph = std::placeholders;
template<class... T>
using ilist = std::initializer_list<T...>;
using std::error_code;
/// Simple gimmick to allow shorter declarations when both elements
/// of a pair are the same.
template<class A,
class B = A>
using pair = std::pair<A, B>;
}