diff --git a/include/ircd/ircd.h b/include/ircd/ircd.h index fbd4fb2e5..aaf7ecef6 100644 --- a/include/ircd/ircd.h +++ b/include/ircd/ircd.h @@ -8,173 +8,11 @@ // copyright notice and this permission notice is present in all copies. The // full license for this software is available in the LICENSE file. -/////////////////////////////////////////////////////////////////////////////// -// -// Standard includes -// -// This header includes almost everything we use out of the standard library. -// This is a pre-compiled header. Project build time is significantly reduced -// by doing things this way and C++ std headers have very little namespace -// pollution and risk of conflicts. -// -// * If any project header file requires standard library symbols we try to -// list it here, not in our header files. -// -// * Rare one-off's #includes isolated to a specific .cc file may not always be -// listed here but can be. -// -// * Third party / dependency / non-std includes, are NEVER listed here. -// Instead we include those in .cc files, and use forward declarations if -// we require a symbol in our API to them. -// - #define HAVE_IRCD_IRCD_H // Generated by ./configure #include "config.h" - -extern "C" -{ - #include -// -// Pollution -// -// This section lists all of the items introduced outside of our namespace -// which may conflict with your project. -// - -// Common branch prediction macros -#define likely(x) __builtin_expect(!!(x), 1) -#define unlikely(x) __builtin_expect(!!(x), 0) - -// Legacy attribute format printf macros -#define AFP(a, b) __attribute__((format(printf, a, b))) -#define AFGP(a, b) __attribute__((format(gnu_printf, a, b))) - -// Experimental std::string_view -#if !defined(__cpp_lib_string_view) && defined(__cpp_lib_experimental_string_view) -namespace std -{ - using experimental::string_view; -} -#endif - -// Experimental std::optional -#if !defined(__cpp_lib_optional) && defined(__cpp_lib_experimental_optional) -namespace std -{ - using experimental::optional; -} -#endif - -// OpenSSL -// Additional forward declarations in the extern namespace are introduced -// by ircd/openssl.h - -/////////////////////////////////////////////////////////////////////////////// -// -// libircd API -// - -// Some items imported into our namespace. -namespace ircd -{ - using int128_t = signed __int128; - using uint128_t = unsigned __int128; - - 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::seconds; - using std::chrono::milliseconds; - using std::chrono::microseconds; - using std::chrono::nanoseconds; - 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::literals::chrono_literals; - using namespace std::string_literals; - - namespace ph = std::placeholders; - - template using ilist = std::initializer_list; -} +#include "stdinc.h" namespace ircd { @@ -235,7 +73,6 @@ namespace ircd /// \brief Internet Relay Chat daemon. This is the principal namespace for IRCd. /// -/// namespace ircd { struct init; diff --git a/include/ircd/stdinc.h b/include/ircd/stdinc.h new file mode 100644 index 000000000..34c0da9c8 --- /dev/null +++ b/include/ircd/stdinc.h @@ -0,0 +1,174 @@ +// Matrix Construct +// +// Copyright (C) Matrix Construct Developers, Authors & Contributors +// Copyright (C) 2016-2018 Jason Volk +// +// 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. + +/////////////////////////////////////////////////////////////////////////////// +// +// Standard includes +// +// This header includes almost everything we use out of the standard library. +// This is a pre-compiled header. Project build time is significantly reduced +// by doing things this way and C++ std headers have very little namespace +// pollution and risk of conflicts. +// +// * If any project header file requires standard library symbols we try to +// list it here, not in our header files. +// +// * Rare one-off's #includes isolated to a specific .cc file may not always be +// listed here but can be. +// +// * Third party / dependency / non-std includes, are NEVER listed here. +// Instead we include those in .cc files, and use forward declarations if +// we require a symbol in our API to them. +// + +#define HAVE_IRCD_STDINC_H + +extern "C" +{ + #include +// +// Pollution +// +// This section lists all of the items introduced outside of our namespace +// which may conflict with your project. +// + +// Common branch prediction macros +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) + +// Legacy attribute format printf macros +#define AFP(a, b) __attribute__((format(printf, a, b))) +#define AFGP(a, b) __attribute__((format(gnu_printf, a, b))) + +// Experimental std::string_view +#if !defined(__cpp_lib_string_view) && defined(__cpp_lib_experimental_string_view) +namespace std +{ + using experimental::string_view; +} +#endif + +// Experimental std::optional +#if !defined(__cpp_lib_optional) && defined(__cpp_lib_experimental_optional) +namespace std +{ + using experimental::optional; +} +#endif + +// OpenSSL +// Additional forward declarations in the extern namespace are introduced +// by ircd/openssl.h + +/////////////////////////////////////////////////////////////////////////////// +// +// libircd API +// + +// Some items imported into our namespace. +namespace ircd +{ + using int128_t = signed __int128; + using uint128_t = unsigned __int128; + + 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::seconds; + using std::chrono::milliseconds; + using std::chrono::microseconds; + using std::chrono::nanoseconds; + 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::literals::chrono_literals; + using namespace std::string_literals; + + namespace ph = std::placeholders; + + template using ilist = std::initializer_list; +}