From 9c6c0a4d95e215f3836817503167e364fe83362c Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Fri, 15 Jun 2018 13:05:16 +0300 Subject: [PATCH] Add common headers to maxbase To be included first in all headers. Defined and included common ground and provides a place when one can affect all code. --- maxutils/maxbase/include/maxbase/ccdefs.hh | 40 ++++++++++ maxutils/maxbase/include/maxbase/cdefs.h | 74 +++++++++++++++++++ .../maxbase/include/maxbase/eventcount.hh | 1 + maxutils/maxbase/include/maxbase/stopwatch.hh | 1 + 4 files changed, 116 insertions(+) create mode 100644 maxutils/maxbase/include/maxbase/ccdefs.hh create mode 100644 maxutils/maxbase/include/maxbase/cdefs.h diff --git a/maxutils/maxbase/include/maxbase/ccdefs.hh b/maxutils/maxbase/include/maxbase/ccdefs.hh new file mode 100644 index 000000000..33f3ec08c --- /dev/null +++ b/maxutils/maxbase/include/maxbase/ccdefs.hh @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl11. + * + * Change Date: 2020-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ + +#pragma once + +/** + * @file ccdefs.hh + * + * This file is to be included first by all C++ headers. + */ + +#if !defined(__cplusplus) +#error This file is only to be included by C++ code. +#endif + +#include +#include +#include + +/** + * All classes of MaxBase are defined in the namespace @c maxbase. + */ +namespace maxbase +{ +} + +/** + * Shorthand for the @c maxscale namespace. + */ +namespace mxb = maxbase; diff --git a/maxutils/maxbase/include/maxbase/cdefs.h b/maxutils/maxbase/include/maxbase/cdefs.h new file mode 100644 index 000000000..b8cec6d0b --- /dev/null +++ b/maxutils/maxbase/include/maxbase/cdefs.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl11. + * + * Change Date: 2020-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ + +#pragma once + +/** + * @file cdefs.h + * + * This file has several purposes. + * + * - Its purpose is the same as that of x86_64-linux-gnu/sys/cdefs.h, that is, + * it defines things that are dependent upon the compilation environment. + * - Since this *must* be included as the very first header by all other MaxScale + * headers, it allows you to redefine things globally, should that be necessary, + * for instance, when debugging something. + * - Global constants applicable across the line can be defined here. + */ + +#ifdef __cplusplus +# define MXB_BEGIN_DECLS extern "C" { +# define MXB_END_DECLS } +#else +# define MXB_BEGIN_DECLS +# define MXB_END_DECLS +#endif + +#undef _GNU_SOURCE +#define _GNU_SOURCE 1 + +#undef OPENSSL_THREAD_DEFINES +#define OPENSSL_THREAD_DEFINES 1 + +/** + * Fix compile errors for PRId64 + * in Centos 6 + */ +#ifndef __STDC_FORMAT_MACROS +# define __STDC_FORMAT_MACROS +#endif + +/** + * Needs to be defined for INT32_MAX and others + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS +#endif + +/** + * Define function attributes + * + * The function attributes are compiler specific. + */ +#ifdef __GNUC__ +#define mxb_attribute(a) __attribute__(a) +#else +#define mxb_attribute(a) +#endif + +/** + * COMMON INCLUDE FILES + */ +#include +#include +#include diff --git a/maxutils/maxbase/include/maxbase/eventcount.hh b/maxutils/maxbase/include/maxbase/eventcount.hh index de6e5273f..08180e04e 100644 --- a/maxutils/maxbase/include/maxbase/eventcount.hh +++ b/maxutils/maxbase/include/maxbase/eventcount.hh @@ -13,6 +13,7 @@ #pragma once +#include #include #include #include diff --git a/maxutils/maxbase/include/maxbase/stopwatch.hh b/maxutils/maxbase/include/maxbase/stopwatch.hh index 86a20844f..4ae708f8c 100644 --- a/maxutils/maxbase/include/maxbase/stopwatch.hh +++ b/maxutils/maxbase/include/maxbase/stopwatch.hh @@ -12,6 +12,7 @@ */ #pragma once +#include #include #include #include