logging: Clean up log.h dependencies
Cleaning up log.h include dependencies to allow log.h including in base headers (e.g. kernel.h). Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
5a39bcae84
commit
fce2692bcc
8 changed files with 43 additions and 32 deletions
|
@ -7,7 +7,9 @@
|
|||
#define ZEPHYR_INCLUDE_LOGGING_LOG_BACKEND_H_
|
||||
|
||||
#include <logging/log_msg.h>
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/__assert.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <sys/util.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#define ZEPHYR_INCLUDE_LOGGING_LOG_CTRL_H_
|
||||
|
||||
#include <logging/log_backend.h>
|
||||
#include <kernel.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
#ifndef ZEPHYR_INCLUDE_LOGGING_LOG_MSG_H_
|
||||
#define ZEPHYR_INCLUDE_LOGGING_LOG_MSG_H_
|
||||
|
||||
#include <kernel.h>
|
||||
#include <sys/atomic.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -88,18 +86,12 @@ struct log_msg_ids {
|
|||
u16_t source_id : 10; /*!< Source ID. */
|
||||
};
|
||||
|
||||
BUILD_ASSERT_MSG((sizeof(struct log_msg_ids) == sizeof(u16_t)),
|
||||
"Structure must fit in 2 bytes");
|
||||
|
||||
/** Part of log message header common to standard and hexdump log message. */
|
||||
struct log_msg_generic_hdr {
|
||||
COMMON_PARAM_HDR();
|
||||
u16_t reserved : 14;
|
||||
};
|
||||
|
||||
BUILD_ASSERT_MSG((sizeof(struct log_msg_generic_hdr) == sizeof(u16_t)),
|
||||
"Structure must fit in 2 bytes");
|
||||
|
||||
/** Part of log message header specific to standard log message. */
|
||||
struct log_msg_std_hdr {
|
||||
COMMON_PARAM_HDR();
|
||||
|
@ -107,18 +99,12 @@ struct log_msg_std_hdr {
|
|||
u16_t nargs : 4;
|
||||
};
|
||||
|
||||
BUILD_ASSERT_MSG((sizeof(struct log_msg_std_hdr) == sizeof(u16_t)),
|
||||
"Structure must fit in 2 bytes");
|
||||
|
||||
/** Part of log message header specific to hexdump log message. */
|
||||
struct log_msg_hexdump_hdr {
|
||||
COMMON_PARAM_HDR();
|
||||
u16_t length : LOG_MSG_HEXDUMP_LENGTH_BITS;
|
||||
};
|
||||
|
||||
BUILD_ASSERT_MSG((sizeof(struct log_msg_hexdump_hdr) == sizeof(u16_t)),
|
||||
"Structure must fit in 2 bytes");
|
||||
|
||||
/** Log message header structure */
|
||||
struct log_msg_hdr {
|
||||
atomic_t ref_cnt; /*!< Reference counter for tracking message users. */
|
||||
|
@ -158,10 +144,6 @@ struct log_msg {
|
|||
} payload; /*!< Message data. */
|
||||
};
|
||||
|
||||
BUILD_ASSERT_MSG((sizeof(union log_msg_head_data) ==
|
||||
sizeof(struct log_msg_ext_head_data)),
|
||||
"Structure must be same size");
|
||||
|
||||
/** @brief Chunks following message head when message is extended. */
|
||||
struct log_msg_cont {
|
||||
struct log_msg_cont *next; /*!< Pointer to the next chunk. */
|
||||
|
@ -177,8 +159,6 @@ union log_msg_chunk {
|
|||
struct log_msg_cont cont;
|
||||
};
|
||||
|
||||
extern struct k_mem_slab log_msg_pool;
|
||||
|
||||
/** @brief Function for initialization of the log message pool. */
|
||||
void log_msg_pool_init(void);
|
||||
|
||||
|
@ -327,17 +307,11 @@ void log_msg_hexdump_data_get(struct log_msg *msg,
|
|||
|
||||
union log_msg_chunk *log_msg_no_space_handle(void);
|
||||
|
||||
static inline union log_msg_chunk *log_msg_chunk_alloc(void)
|
||||
{
|
||||
union log_msg_chunk *msg = NULL;
|
||||
int err = k_mem_slab_alloc(&log_msg_pool, (void **)&msg, K_NO_WAIT);
|
||||
|
||||
if (err != 0) {
|
||||
msg = log_msg_no_space_handle();
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
/** @brief Allocate single chunk from the pool.
|
||||
*
|
||||
* @return Pointer to the allocated chunk or NULL if failed to allocate.
|
||||
*/
|
||||
union log_msg_chunk *log_msg_chunk_alloc(void);
|
||||
|
||||
/** @brief Allocate chunk for standard log message.
|
||||
*
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#define ZEPHYR_INCLUDE_LOGGING_LOG_OUTPUT_H_
|
||||
|
||||
#include <logging/log_msg.h>
|
||||
#include <sys/util.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue