Few comments about this patch.
> diff --git a/bbque/utils/CMakeLists.txt b/bbque/utils/CMakeLists.txt
> index b99d7bb..038ab0a 100644
> --- a/bbque/utils/CMakeLists.txt
> +++ b/bbque/utils/CMakeLists.txt
> @@ -6,6 +6,7 @@ add_subdirectory(logging)
> set (BBQUE_UTILS_SRC timer deferrable worker)
> set (BBQUE_UTILS_SRC ${BBQUE_UTILS_SRC} metrics_collector)
> set (BBQUE_UTILS_SRC ${BBQUE_UTILS_SRC} extra_data_container)
> +set (BBQUE_UTILS_SRC ${BBQUE_UTILS_SRC} assert)
AFAIU, you want to use assert functions only for BBQUE_DEBUG configured
builds. Thus, the compilation of "assert" should be better guarded by a:
if (CONFIG_BBQUE_DEBUG)
set (BBQUE_UTILS_SRC ${BBQUE_UTILS_SRC} assert)
endif (CONFIG_BBQUE_DEBUG)
> if (CONFIG_BBQUE_RTLIB_PERF_SUPPORT)
> set (BBQUE_UTILS_SRC ${BBQUE_UTILS_SRC} perf)
> endif (CONFIG_BBQUE_RTLIB_PERF_SUPPORT)
> diff --git a/bbque/utils/assert.cc b/bbque/utils/assert.cc
> new file mode 100644
> index 0000000..c0ba510
> --- /dev/null
> +++ b/bbque/utils/assert.cc
> @@ -0,0 +1,62 @@
> +/*
> + * Copyright (C) 2016 Politecnico di Milano
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + */
> +
> +#include "bbque/utils/logging/logger.h"
> +#include "bbque/utils/assert.h"
> +
> +#include <cassert>
> +#include <cstdlib>
> +#include <iostream>
> +
> +#define BBQUE_ASSERT_NAMESPACE "bq.crash"
> +
> +#ifdef BBQUE_DEBUG
If you don't want these functions defined that it's better to avoid the module
compilation on !BBQUE_DEBUG and these guards can be removed.
> +
> +namespace bu=bbque::utils;
> +
> +void _bbque_assert(const char *msg, const char *file, int line) {
> +
> + // First of all print into the standard output. Maybe we will not able
> + // to open a log, so we have to print the error into the stdout
> + std::cout << "Barbeque ASSERTION FAILED." << std::endl;
> + std::cout << "Assert: " << msg << std::endl;
> + std::cout << "File: " << file << ":" << line << std::endl;
> +
> + // Flush the stream just to be sure before continue (and maybe crash)
> + std::cout << std::flush;
> +
> + // Get a logger
> + std::unique_ptr<bu::Logger> logger =
^
Should remove white spaces at end of line
> + bu::Logger::GetLogger(BBQUE_ASSERT_NAMESPACE);
> +
> + //If we do not have a logger, we cannot log the problem, so, stdout
> + // and std assert
> + if (logger) {
> + logger->Fatal("Barbeque ASSERTION FAILED.");
> + logger->Fatal("Assert: %s", msg);
> + logger->Fatal("File: %s:%d", file, line);
> + }
> +
> + // Reset the logger to be sure it is flushed
> + logger.reset(nullptr);
> +
> + // And then, abort
> + std::abort();
> +
> + // Unreachable code
^
Unnecessary comment, also because there is not code here in that function ;-)
> +}
> +#endif
> diff --git a/include/bbque/utils/assert.h b/include/bbque/utils/assert.h
> new file mode 100644
> index 0000000..d8ae432
> --- /dev/null
> +++ b/include/bbque/utils/assert.h
> @@ -0,0 +1,39 @@
> +/*
> + * Copyright (C) 2016 Politecnico di Milano
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + */
> +
> +#ifndef BBQUE_ASSERT_H_
> +#define BBQUE_ASSERT_H_
> +
> +#include "bbque/config.h"
> +
> +#include <cassert>
> +
> +#ifdef BBQUE_DEBUG
> + // The following macro respect the C++ specification for assert
> + #define bbque_assert(EX) (void)((EX) || (_bbque_assert (#EX, __FILE__, __LINE__),0))
> +#else
> + #define bbque_assert(EX)
> +#endif
> +
> +/**
> + * @brief This is the custom assert logging function. You should not use
> + * directly this function, but instead use the bbque_assert macro,
> + * that works exactly as the std::assert one.
> + */
> +void _bbque_assert(const char *msg, const char *file, int line);
But still you are exposing that function to all modules including this header.
Thus, if you should use "_bbque_assert" in other modules, you will get linking
errors in !BBQUE_DEBUG configured builds.
Perhaps it's better to move this forward declaration in the previous #ifdef and
add an empty definition in the #else case, e.g. something like:
#ifdef BBQUE_DEBUG
void _bbque_assert(const char *msg, const char *file, int line);
#define bbque_assert(EX) (void)((EX) || (_bbque_assert (#EX, __FILE__, __LINE__),0))
#else
void _bbque_assert(const char *msg, const char *file, int line) {};
#define bbque_assert(EX)
#endif
> +
> +#endif // BBQUE_ASSERT_H_
--
#include <best/regards.h>
Patrick Bellasi