diff --git a/maxutils/maxbase/include/maxbase/string.h b/maxutils/maxbase/include/maxbase/string.h new file mode 100644 index 000000000..efa65cc4f --- /dev/null +++ b/maxutils/maxbase/include/maxbase/string.h @@ -0,0 +1,20 @@ +#pragma once +/* + * 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: 2022-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. + */ + +#include + +/** + * Thread-safe strerror + */ +const char* mxb_strerror(int error); diff --git a/maxutils/maxbase/src/CMakeLists.txt b/maxutils/maxbase/src/CMakeLists.txt index f85b7c2ce..be1f59835 100644 --- a/maxutils/maxbase/src/CMakeLists.txt +++ b/maxutils/maxbase/src/CMakeLists.txt @@ -3,6 +3,7 @@ add_library(maxbase STATIC eventcount.cc logger.cc stopwatch.cc + string.cc stacktrace.cc ) set_target_properties(maxbase PROPERTIES VERSION "1.0.0" LINK_FLAGS -Wl,-z,defs) diff --git a/maxutils/maxbase/src/logger.cc b/maxutils/maxbase/src/logger.cc index 4d74eea66..d784f0a80 100644 --- a/maxutils/maxbase/src/logger.cc +++ b/maxutils/maxbase/src/logger.cc @@ -22,7 +22,7 @@ #include #include -#include +#include // TODO: move into maxbase #define ss_dassert(a) diff --git a/maxutils/maxbase/include/maxbase/error.h b/maxutils/maxbase/src/string.cc similarity index 78% rename from maxutils/maxbase/include/maxbase/error.h rename to maxutils/maxbase/src/string.cc index 8172935e6..673582f95 100644 --- a/maxutils/maxbase/include/maxbase/error.h +++ b/maxutils/maxbase/src/string.cc @@ -1,4 +1,3 @@ -#pragma once /* * Copyright (c) 2016 MariaDB Corporation Ab * @@ -12,14 +11,19 @@ * Public License. */ -#include +#include #include -inline const char* mxb_strerror(int error) +namespace +{ + +thread_local char errbuf[512]; // Enough for all errors + +} + +const char* mxb_strerror(int error) { - // Enough for all errors - static thread_local char errbuf[512]; #ifdef HAVE_GLIBC return strerror_r(error, errbuf, sizeof(errbuf)); #else diff --git a/server/core/log_manager.cc b/server/core/log_manager.cc index ed4bcc7bd..6253b12ff 100644 --- a/server/core/log_manager.cc +++ b/server/core/log_manager.cc @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include