subsystems: Rename reserved function names

Rename reserved function names in the subsys/ subdirectory except
for static _mod_pub_set and _mod_unbind functions in bluetooth mesh
cfg_srv.c which clash with the similarly named global functions.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
This commit is contained in:
Patrik Flykt 2019-03-14 19:42:51 -06:00 committed by Anas Nashif
commit 4aa48833d8
30 changed files with 207 additions and 208 deletions

View file

@ -52,7 +52,7 @@ extern __printf_like(3, 4) int snprintk(char *str, size_t size,
extern __printf_like(3, 0) int vsnprintk(char *str, size_t size, extern __printf_like(3, 0) int vsnprintk(char *str, size_t size,
const char *fmt, va_list ap); const char *fmt, va_list ap);
extern __printf_like(3, 0) void _vprintk(int (*out)(int f, void *c), void *ctx, extern __printf_like(3, 0) void z_vprintk(int (*out)(int f, void *c), void *ctx,
const char *fmt, va_list ap); const char *fmt, va_list ap);
#else #else
static inline __printf_like(1, 2) void printk(const char *fmt, ...) static inline __printf_like(1, 2) void printk(const char *fmt, ...)

View file

@ -11,7 +11,7 @@
#define DESC(d) ((void *)d) #define DESC(d) ((void *)d)
extern int _prf(int (*func)(), void *dest, extern int z_prf(int (*func)(), void *dest,
const char *format, va_list vargs); const char *format, va_list vargs);
int fprintf(FILE *_MLIBC_RESTRICT F, const char *_MLIBC_RESTRICT format, ...) int fprintf(FILE *_MLIBC_RESTRICT F, const char *_MLIBC_RESTRICT format, ...)
@ -20,7 +20,7 @@ int fprintf(FILE *_MLIBC_RESTRICT F, const char *_MLIBC_RESTRICT format, ...)
int r; int r;
va_start(vargs, format); va_start(vargs, format);
r = _prf(fputc, DESC(F), format, vargs); r = z_prf(fputc, DESC(F), format, vargs);
va_end(vargs); va_end(vargs);
return r; return r;
@ -31,7 +31,7 @@ int vfprintf(FILE *_MLIBC_RESTRICT F, const char *_MLIBC_RESTRICT format,
{ {
int r; int r;
r = _prf(fputc, DESC(F), format, vargs); r = z_prf(fputc, DESC(F), format, vargs);
return r; return r;
} }
@ -42,7 +42,7 @@ int printf(const char *_MLIBC_RESTRICT format, ...)
int r; int r;
va_start(vargs, format); va_start(vargs, format);
r = _prf(fputc, DESC(stdout), format, vargs); r = z_prf(fputc, DESC(stdout), format, vargs);
va_end(vargs); va_end(vargs);
return r; return r;
@ -52,7 +52,7 @@ int vprintf(const char *_MLIBC_RESTRICT format, va_list vargs)
{ {
int r; int r;
r = _prf(fputc, DESC(stdout), format, vargs); r = z_prf(fputc, DESC(stdout), format, vargs);
return r; return r;
} }

View file

@ -429,7 +429,7 @@ static int _atoi(char **sptr)
return i; return i;
} }
int _prf(int (*func)(), void *dest, char *format, va_list vargs) int z_prf(int (*func)(), void *dest, char *format, va_list vargs)
{ {
/* /*
* Due the fact that buffer is passed to functions in this file, * Due the fact that buffer is passed to functions in this file,

View file

@ -9,7 +9,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
extern int _prf(int (*func)(), void *dest, extern int z_prf(int (*func)(), void *dest,
const char *format, va_list vargs); const char *format, va_list vargs);
struct emitter { struct emitter {
@ -44,7 +44,7 @@ int snprintf(char *_MLIBC_RESTRICT s, size_t len,
p.len = (int) len; p.len = (int) len;
va_start(vargs, format); va_start(vargs, format);
r = _prf(sprintf_out, (void *) (&p), format, vargs); r = z_prf(sprintf_out, (void *) (&p), format, vargs);
va_end(vargs); va_end(vargs);
*(p.ptr) = 0; *(p.ptr) = 0;
@ -62,7 +62,7 @@ int sprintf(char *_MLIBC_RESTRICT s, const char *_MLIBC_RESTRICT format, ...)
p.len = (int) 0x7fffffff; /* allow up to "maxint" characters */ p.len = (int) 0x7fffffff; /* allow up to "maxint" characters */
va_start(vargs, format); va_start(vargs, format);
r = _prf(sprintf_out, (void *) (&p), format, vargs); r = z_prf(sprintf_out, (void *) (&p), format, vargs);
va_end(vargs); va_end(vargs);
*(p.ptr) = 0; *(p.ptr) = 0;
@ -83,7 +83,7 @@ int vsnprintf(char *_MLIBC_RESTRICT s, size_t len,
p.ptr = s; p.ptr = s;
p.len = (int) len; p.len = (int) len;
r = _prf(sprintf_out, (void *) (&p), format, vargs); r = z_prf(sprintf_out, (void *) (&p), format, vargs);
*(p.ptr) = 0; *(p.ptr) = 0;
return r; return r;
@ -98,7 +98,7 @@ int vsprintf(char *_MLIBC_RESTRICT s, const char *_MLIBC_RESTRICT format,
p.ptr = s; p.ptr = s;
p.len = (int) 0x7fffffff; /* allow up to "maxint" characters */ p.len = (int) 0x7fffffff; /* allow up to "maxint" characters */
r = _prf(sprintf_out, (void *) (&p), format, vargs); r = z_prf(sprintf_out, (void *) (&p), format, vargs);
*(p.ptr) = 0; *(p.ptr) = 0;
return r; return r;

View file

@ -98,7 +98,7 @@ static void print_err(out_func_t out, void *ctx)
* *
* @return N/A * @return N/A
*/ */
void _vprintk(out_func_t out, void *ctx, const char *fmt, va_list ap) void z_vprintk(out_func_t out, void *ctx, const char *fmt, va_list ap)
{ {
int might_format = 0; /* 1 if encountered a '%' */ int might_format = 0; /* 1 if encountered a '%' */
enum pad_type padding = PAD_NONE; enum pad_type padding = PAD_NONE;
@ -316,7 +316,7 @@ void vprintk(const char *fmt, va_list ap)
if (_is_user_context()) { if (_is_user_context()) {
struct buf_out_context ctx = { 0 }; struct buf_out_context ctx = { 0 };
_vprintk(buf_char_out, &ctx, fmt, ap); z_vprintk(buf_char_out, &ctx, fmt, ap);
if (ctx.buf_count) { if (ctx.buf_count) {
buf_flush(&ctx); buf_flush(&ctx);
@ -324,7 +324,7 @@ void vprintk(const char *fmt, va_list ap)
} else { } else {
struct out_context ctx = { 0 }; struct out_context ctx = { 0 };
_vprintk(char_out, &ctx, fmt, ap); z_vprintk(char_out, &ctx, fmt, ap);
} }
} }
#else #else
@ -332,7 +332,7 @@ void vprintk(const char *fmt, va_list ap)
{ {
struct out_context ctx = { 0 }; struct out_context ctx = { 0 };
_vprintk(char_out, &ctx, fmt, ap); z_vprintk(char_out, &ctx, fmt, ap);
} }
#endif #endif
@ -510,7 +510,7 @@ int snprintk(char *str, size_t size, const char *fmt, ...)
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
_vprintk((out_func_t)str_out, &ctx, fmt, ap); z_vprintk((out_func_t)str_out, &ctx, fmt, ap);
va_end(ap); va_end(ap);
if (ctx.count < ctx.max) { if (ctx.count < ctx.max) {
@ -524,7 +524,7 @@ int vsnprintk(char *str, size_t size, const char *fmt, va_list ap)
{ {
struct str_context ctx = { str, size, 0 }; struct str_context ctx = { str, size, 0 };
_vprintk((out_func_t)str_out, &ctx, fmt, ap); z_vprintk((out_func_t)str_out, &ctx, fmt, ap);
if (ctx.count < ctx.max) { if (ctx.count < ctx.max) {
str[ctx.count] = '\0'; str[ctx.count] = '\0';

View file

@ -486,7 +486,7 @@ static const struct bt_hci_driver drv = {
.send = hci_driver_send, .send = hci_driver_send,
}; };
static int _hci_driver_init(struct device *unused) static int hci_driver_init(struct device *unused)
{ {
ARG_UNUSED(unused); ARG_UNUSED(unused);
@ -495,4 +495,4 @@ static int _hci_driver_init(struct device *unused)
return 0; return 0;
} }
SYS_INIT(_hci_driver_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE); SYS_INIT(hci_driver_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);

View file

@ -66,7 +66,7 @@ static struct {
atomic_t other; atomic_t other;
} drops; } drops;
extern int _prf(int (*func)(), void *dest, extern int z_prf(int (*func)(), void *dest,
const char *format, va_list vargs); const char *format, va_list vargs);
static void monitor_send(const void *data, size_t len) static void monitor_send(const void *data, size_t len)

View file

@ -2252,7 +2252,7 @@ static u8_t smp_master_ident(struct bt_smp *smp, struct net_buf *buf)
} }
#endif /* !CONFIG_BT_SMP_SC_PAIR_ONLY */ #endif /* !CONFIG_BT_SMP_SC_PAIR_ONLY */
static int _smp_init(struct bt_smp *smp) static int smp_init(struct bt_smp *smp)
{ {
/* Initialize SMP context without clearing L2CAP channel context */ /* Initialize SMP context without clearing L2CAP channel context */
(void)memset((u8_t *)smp + sizeof(smp->chan), 0, (void)memset((u8_t *)smp + sizeof(smp->chan), 0,
@ -2355,7 +2355,7 @@ int bt_smp_send_security_req(struct bt_conn *conn)
return -EINVAL; return -EINVAL;
} }
if (_smp_init(smp) != 0) { if (smp_init(smp) != 0) {
return -ENOBUFS; return -ENOBUFS;
} }
@ -2394,7 +2394,7 @@ static u8_t smp_pairing_req(struct bt_smp *smp, struct net_buf *buf)
* is already initialized. * is already initialized.
*/ */
if (!atomic_test_bit(smp->flags, SMP_FLAG_SEC_REQ)) { if (!atomic_test_bit(smp->flags, SMP_FLAG_SEC_REQ)) {
int ret = _smp_init(smp); int ret = smp_init(smp);
if (ret) { if (ret) {
return ret; return ret;
@ -2533,7 +2533,7 @@ int bt_smp_send_pairing_req(struct bt_conn *conn)
return -EINVAL; return -EINVAL;
} }
if (_smp_init(smp)) { if (smp_init(smp)) {
return -ENOBUFS; return -ENOBUFS;
} }

View file

@ -26,7 +26,7 @@ static inline int is_idle_thread(struct k_thread *thread)
} }
static inline void _sys_trace_thread_switched_in(void) static inline void z_sys_trace_thread_switched_in(void)
{ {
struct k_thread *thread; struct k_thread *thread;
@ -39,7 +39,7 @@ static inline void _sys_trace_thread_switched_in(void)
} }
} }
#define sys_trace_thread_switched_in() _sys_trace_thread_switched_in() #define sys_trace_thread_switched_in() z_sys_trace_thread_switched_in()
#define sys_trace_thread_switched_out() SEGGER_SYSVIEW_OnTaskStopExec() #define sys_trace_thread_switched_out() SEGGER_SYSVIEW_OnTaskStopExec()

View file

@ -7,7 +7,7 @@
#include <SEGGER_SYSVIEW.h> #include <SEGGER_SYSVIEW.h>
#include "SEGGER_SYSVIEW_Zephyr.h" #include "SEGGER_SYSVIEW_Zephyr.h"
static void _cbSendSystemDesc(void) static void cbSendSystemDesc(void)
{ {
SEGGER_SYSVIEW_SendSysDesc("N=ZephyrSysView"); SEGGER_SYSVIEW_SendSysDesc("N=ZephyrSysView");
SEGGER_SYSVIEW_SendSysDesc("D=" CONFIG_BOARD " " SEGGER_SYSVIEW_SendSysDesc("D=" CONFIG_BOARD " "
@ -19,7 +19,7 @@ void SEGGER_SYSVIEW_Conf(void)
{ {
SEGGER_SYSVIEW_Init(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC, SEGGER_SYSVIEW_Init(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC,
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC, CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC,
&SYSVIEW_X_OS_TraceAPI, _cbSendSystemDesc); &SYSVIEW_X_OS_TraceAPI, cbSendSystemDesc);
#if defined(DT_PHYS_RAM_ADDR) /* x86 */ #if defined(DT_PHYS_RAM_ADDR) /* x86 */
SEGGER_SYSVIEW_SetRAMBase(DT_PHYS_RAM_ADDR); SEGGER_SYSVIEW_SetRAMBase(DT_PHYS_RAM_ADDR);

View file

@ -18,8 +18,8 @@ LOG_MODULE_REGISTER(fs_nvs, CONFIG_NVS_LOG_LEVEL);
/* basic routines */ /* basic routines */
/* _nvs_al_size returns size aligned to fs->write_block_size */ /* nvs_al_size returns size aligned to fs->write_block_size */
static inline size_t _nvs_al_size(struct nvs_fs *fs, size_t len) static inline size_t nvs_al_size(struct nvs_fs *fs, size_t len)
{ {
if (fs->write_block_size <= 1U) { if (fs->write_block_size <= 1U) {
return len; return len;
@ -30,7 +30,7 @@ static inline size_t _nvs_al_size(struct nvs_fs *fs, size_t len)
/* flash routines */ /* flash routines */
/* basic aligned flash write to nvs address */ /* basic aligned flash write to nvs address */
static int _nvs_flash_al_wrt(struct nvs_fs *fs, u32_t addr, const void *data, static int nvs_flash_al_wrt(struct nvs_fs *fs, u32_t addr, const void *data,
size_t len) size_t len)
{ {
const u8_t *data8 = (const u8_t *)data; const u8_t *data8 = (const u8_t *)data;
@ -81,7 +81,7 @@ end:
} }
/* basic flash read from nvs address */ /* basic flash read from nvs address */
static int _nvs_flash_rd(struct nvs_fs *fs, u32_t addr, void *data, static int nvs_flash_rd(struct nvs_fs *fs, u32_t addr, void *data,
size_t len) size_t len)
{ {
int rc; int rc;
@ -97,44 +97,44 @@ static int _nvs_flash_rd(struct nvs_fs *fs, u32_t addr, void *data,
} }
/* allocation entry write */ /* allocation entry write */
static int _nvs_flash_ate_wrt(struct nvs_fs *fs, const struct nvs_ate *entry) static int nvs_flash_ate_wrt(struct nvs_fs *fs, const struct nvs_ate *entry)
{ {
int rc; int rc;
rc = _nvs_flash_al_wrt(fs, fs->ate_wra, entry, rc = nvs_flash_al_wrt(fs, fs->ate_wra, entry,
sizeof(struct nvs_ate)); sizeof(struct nvs_ate));
fs->ate_wra -= _nvs_al_size(fs, sizeof(struct nvs_ate)); fs->ate_wra -= nvs_al_size(fs, sizeof(struct nvs_ate));
return rc; return rc;
} }
/* data write */ /* data write */
static int _nvs_flash_data_wrt(struct nvs_fs *fs, const void *data, size_t len) static int nvs_flash_data_wrt(struct nvs_fs *fs, const void *data, size_t len)
{ {
int rc; int rc;
rc = _nvs_flash_al_wrt(fs, fs->data_wra, data, len); rc = nvs_flash_al_wrt(fs, fs->data_wra, data, len);
fs->data_wra += _nvs_al_size(fs, len); fs->data_wra += nvs_al_size(fs, len);
return rc; return rc;
} }
/* flash ate read */ /* flash ate read */
static int _nvs_flash_ate_rd(struct nvs_fs *fs, u32_t addr, static int nvs_flash_ate_rd(struct nvs_fs *fs, u32_t addr,
struct nvs_ate *entry) struct nvs_ate *entry)
{ {
return _nvs_flash_rd(fs, addr, entry, sizeof(struct nvs_ate)); return nvs_flash_rd(fs, addr, entry, sizeof(struct nvs_ate));
} }
/* end of basic flash routines */ /* end of basic flash routines */
/* advanced flash routines */ /* advanced flash routines */
/* _nvs_flash_block_cmp compares the data in flash at addr to data /* nvs_flash_block_cmp compares the data in flash at addr to data
* in blocks of size NVS_BLOCK_SIZE aligned to fs->write_block_size * in blocks of size NVS_BLOCK_SIZE aligned to fs->write_block_size
* returns 0 if equal, 1 if not equal, errcode if error * returns 0 if equal, 1 if not equal, errcode if error
*/ */
static int _nvs_flash_block_cmp(struct nvs_fs *fs, u32_t addr, const void *data, static int nvs_flash_block_cmp(struct nvs_fs *fs, u32_t addr, const void *data,
size_t len) size_t len)
{ {
const u8_t *data8 = (const u8_t *)data; const u8_t *data8 = (const u8_t *)data;
@ -145,7 +145,7 @@ static int _nvs_flash_block_cmp(struct nvs_fs *fs, u32_t addr, const void *data,
block_size = NVS_BLOCK_SIZE & ~(fs->write_block_size - 1U); block_size = NVS_BLOCK_SIZE & ~(fs->write_block_size - 1U);
while (len) { while (len) {
bytes_to_cmp = MIN(block_size, len); bytes_to_cmp = MIN(block_size, len);
rc = _nvs_flash_rd(fs, addr, buf, bytes_to_cmp); rc = nvs_flash_rd(fs, addr, buf, bytes_to_cmp);
if (rc) { if (rc) {
return rc; return rc;
} }
@ -160,11 +160,11 @@ static int _nvs_flash_block_cmp(struct nvs_fs *fs, u32_t addr, const void *data,
return 0; return 0;
} }
/* _nvs_flash_cmp_const compares the data in flash at addr to a constant /* nvs_flash_cmp_const compares the data in flash at addr to a constant
* value. returns 0 if all data in flash is equal to value, 1 if not equal, * value. returns 0 if all data in flash is equal to value, 1 if not equal,
* errcode if error * errcode if error
*/ */
static int _nvs_flash_cmp_const(struct nvs_fs *fs, u32_t addr, u8_t value, static int nvs_flash_cmp_const(struct nvs_fs *fs, u32_t addr, u8_t value,
size_t len) size_t len)
{ {
int rc; int rc;
@ -175,7 +175,7 @@ static int _nvs_flash_cmp_const(struct nvs_fs *fs, u32_t addr, u8_t value,
(void)memset(cmp, value, block_size); (void)memset(cmp, value, block_size);
while (len) { while (len) {
bytes_to_cmp = MIN(block_size, len); bytes_to_cmp = MIN(block_size, len);
rc = _nvs_flash_block_cmp(fs, addr, cmp, bytes_to_cmp); rc = nvs_flash_block_cmp(fs, addr, cmp, bytes_to_cmp);
if (rc) { if (rc) {
return rc; return rc;
} }
@ -188,7 +188,7 @@ static int _nvs_flash_cmp_const(struct nvs_fs *fs, u32_t addr, u8_t value,
/* flash block move: move a block at addr to the current data write location /* flash block move: move a block at addr to the current data write location
* and updates the data write location. * and updates the data write location.
*/ */
static int _nvs_flash_block_move(struct nvs_fs *fs, u32_t addr, size_t len) static int nvs_flash_block_move(struct nvs_fs *fs, u32_t addr, size_t len)
{ {
int rc; int rc;
size_t bytes_to_copy, block_size; size_t bytes_to_copy, block_size;
@ -198,11 +198,11 @@ static int _nvs_flash_block_move(struct nvs_fs *fs, u32_t addr, size_t len)
while (len) { while (len) {
bytes_to_copy = MIN(block_size, len); bytes_to_copy = MIN(block_size, len);
rc = _nvs_flash_rd(fs, addr, buf, bytes_to_copy); rc = nvs_flash_rd(fs, addr, buf, bytes_to_copy);
if (rc) { if (rc) {
return rc; return rc;
} }
rc = _nvs_flash_data_wrt(fs, buf, bytes_to_copy); rc = nvs_flash_data_wrt(fs, buf, bytes_to_copy);
if (rc) { if (rc) {
return rc; return rc;
} }
@ -215,13 +215,13 @@ static int _nvs_flash_block_move(struct nvs_fs *fs, u32_t addr, size_t len)
/* erase a sector by first checking it is used and then erasing if required /* erase a sector by first checking it is used and then erasing if required
* return 0 if OK, errorcode on error. * return 0 if OK, errorcode on error.
*/ */
static int _nvs_flash_erase_sector(struct nvs_fs *fs, u32_t addr) static int nvs_flash_erase_sector(struct nvs_fs *fs, u32_t addr)
{ {
int rc; int rc;
off_t offset; off_t offset;
addr &= ADDR_SECT_MASK; addr &= ADDR_SECT_MASK;
rc = _nvs_flash_cmp_const(fs, addr, 0xff, fs->sector_size); rc = nvs_flash_cmp_const(fs, addr, 0xff, fs->sector_size);
if (rc <= 0) { if (rc <= 0) {
/* flash error or empty sector */ /* flash error or empty sector */
return rc; return rc;
@ -247,7 +247,7 @@ static int _nvs_flash_erase_sector(struct nvs_fs *fs, u32_t addr)
} }
/* crc update on allocation entry */ /* crc update on allocation entry */
static void _nvs_ate_crc8_update(struct nvs_ate *entry) static void nvs_ate_crc8_update(struct nvs_ate *entry)
{ {
u8_t crc8; u8_t crc8;
@ -258,7 +258,7 @@ static void _nvs_ate_crc8_update(struct nvs_ate *entry)
/* crc check on allocation entry /* crc check on allocation entry
* returns 0 if OK, 1 on crc fail * returns 0 if OK, 1 on crc fail
*/ */
static int _nvs_ate_crc8_check(const struct nvs_ate *entry) static int nvs_ate_crc8_check(const struct nvs_ate *entry)
{ {
u8_t crc8; u8_t crc8;
@ -269,11 +269,11 @@ static int _nvs_ate_crc8_check(const struct nvs_ate *entry)
return 1; return 1;
} }
/* _nvs_ate_cmp_const compares an ATE to a constant value. returns 0 if /* nvs_ate_cmp_const compares an ATE to a constant value. returns 0 if
* the whole ATE is equal to value, 1 if not equal. * the whole ATE is equal to value, 1 if not equal.
*/ */
static int _nvs_ate_cmp_const(const struct nvs_ate *entry, u8_t value) static int nvs_ate_cmp_const(const struct nvs_ate *entry, u8_t value)
{ {
const u8_t *data8 = (const u8_t *)entry; const u8_t *data8 = (const u8_t *)entry;
int i; int i;
@ -288,27 +288,27 @@ static int _nvs_ate_cmp_const(const struct nvs_ate *entry, u8_t value)
} }
/* store an entry in flash */ /* store an entry in flash */
static int _nvs_flash_wrt_entry(struct nvs_fs *fs, u16_t id, const void *data, static int nvs_flash_wrt_entry(struct nvs_fs *fs, u16_t id, const void *data,
size_t len) size_t len)
{ {
int rc; int rc;
struct nvs_ate entry; struct nvs_ate entry;
size_t ate_size; size_t ate_size;
ate_size = _nvs_al_size(fs, sizeof(struct nvs_ate)); ate_size = nvs_al_size(fs, sizeof(struct nvs_ate));
entry.id = id; entry.id = id;
entry.offset = (u16_t)(fs->data_wra & ADDR_OFFS_MASK); entry.offset = (u16_t)(fs->data_wra & ADDR_OFFS_MASK);
entry.len = (u16_t)len; entry.len = (u16_t)len;
entry.part = 0xff; entry.part = 0xff;
_nvs_ate_crc8_update(&entry); nvs_ate_crc8_update(&entry);
rc = _nvs_flash_data_wrt(fs, data, len); rc = nvs_flash_data_wrt(fs, data, len);
if (rc) { if (rc) {
return rc; return rc;
} }
rc = _nvs_flash_ate_wrt(fs, &entry); rc = nvs_flash_ate_wrt(fs, &entry);
if (rc) { if (rc) {
return rc; return rc;
} }
@ -320,16 +320,16 @@ static int _nvs_flash_wrt_entry(struct nvs_fs *fs, u16_t id, const void *data,
/* walking through allocation entry list, from newest to oldest entries /* walking through allocation entry list, from newest to oldest entries
* read ate from addr, modify addr to the previous ate * read ate from addr, modify addr to the previous ate
*/ */
static int _nvs_prev_ate(struct nvs_fs *fs, u32_t *addr, struct nvs_ate *ate) static int nvs_prev_ate(struct nvs_fs *fs, u32_t *addr, struct nvs_ate *ate)
{ {
int rc; int rc;
struct nvs_ate close_ate, end_ate; struct nvs_ate close_ate, end_ate;
u32_t data_end_addr, ate_end_addr; u32_t data_end_addr, ate_end_addr;
size_t ate_size; size_t ate_size;
ate_size = _nvs_al_size(fs, sizeof(struct nvs_ate)); ate_size = nvs_al_size(fs, sizeof(struct nvs_ate));
rc = _nvs_flash_ate_rd(fs, *addr, ate); rc = nvs_flash_ate_rd(fs, *addr, ate);
if (rc) { if (rc) {
return rc; return rc;
} }
@ -346,19 +346,19 @@ static int _nvs_prev_ate(struct nvs_fs *fs, u32_t *addr, struct nvs_ate *ate)
*addr -= (1 << ADDR_SECT_SHIFT); *addr -= (1 << ADDR_SECT_SHIFT);
} }
rc = _nvs_flash_ate_rd(fs, *addr, &close_ate); rc = nvs_flash_ate_rd(fs, *addr, &close_ate);
if (rc) { if (rc) {
return rc; return rc;
} }
rc = _nvs_ate_cmp_const(&close_ate, 0xff); rc = nvs_ate_cmp_const(&close_ate, 0xff);
/* at the end of filesystem */ /* at the end of filesystem */
if (!rc) { if (!rc) {
*addr = fs->ate_wra; *addr = fs->ate_wra;
return 0; return 0;
} }
if (!_nvs_ate_crc8_check(&close_ate)) { if (!nvs_ate_crc8_check(&close_ate)) {
(*addr) &= ADDR_SECT_MASK; (*addr) &= ADDR_SECT_MASK;
/* update the address so it points to the last added ate */ /* update the address so it points to the last added ate */
(*addr) += close_ate.offset; (*addr) += close_ate.offset;
@ -371,11 +371,11 @@ static int _nvs_prev_ate(struct nvs_fs *fs, u32_t *addr, struct nvs_ate *ate)
ate_end_addr = *addr; ate_end_addr = *addr;
data_end_addr = *addr & ADDR_SECT_MASK; data_end_addr = *addr & ADDR_SECT_MASK;
while (ate_end_addr > data_end_addr) { while (ate_end_addr > data_end_addr) {
rc = _nvs_flash_ate_rd(fs, ate_end_addr, &end_ate); rc = nvs_flash_ate_rd(fs, ate_end_addr, &end_ate);
if (rc) { if (rc) {
return rc; return rc;
} }
if (!_nvs_ate_crc8_check(&end_ate)) { if (!nvs_ate_crc8_check(&end_ate)) {
/* found a valid ate, update data_end_addr and *addr */ /* found a valid ate, update data_end_addr and *addr */
data_end_addr &= ADDR_SECT_MASK; data_end_addr &= ADDR_SECT_MASK;
data_end_addr += end_ate.offset + end_ate.len; data_end_addr += end_ate.offset + end_ate.len;
@ -390,7 +390,7 @@ static int _nvs_prev_ate(struct nvs_fs *fs, u32_t *addr, struct nvs_ate *ate)
return 0; return 0;
} }
static void _nvs_sector_advance(struct nvs_fs *fs, u32_t *addr) static void nvs_sector_advance(struct nvs_fs *fs, u32_t *addr)
{ {
*addr += (1 << ADDR_SECT_SHIFT); *addr += (1 << ADDR_SECT_SHIFT);
if ((*addr >> ADDR_SECT_SHIFT) == fs->sector_count) { if ((*addr >> ADDR_SECT_SHIFT) == fs->sector_count) {
@ -401,13 +401,13 @@ static void _nvs_sector_advance(struct nvs_fs *fs, u32_t *addr)
/* allocation entry close (this closes the current sector) by writing offset /* allocation entry close (this closes the current sector) by writing offset
* of last ate to the sector end. * of last ate to the sector end.
*/ */
static int _nvs_sector_close(struct nvs_fs *fs) static int nvs_sector_close(struct nvs_fs *fs)
{ {
int rc; int rc;
struct nvs_ate close_ate; struct nvs_ate close_ate;
size_t ate_size; size_t ate_size;
ate_size = _nvs_al_size(fs, sizeof(struct nvs_ate)); ate_size = nvs_al_size(fs, sizeof(struct nvs_ate));
close_ate.id = 0xFFFF; close_ate.id = 0xFFFF;
close_ate.len = 0U; close_ate.len = 0U;
@ -416,11 +416,11 @@ static int _nvs_sector_close(struct nvs_fs *fs)
fs->ate_wra &= ADDR_SECT_MASK; fs->ate_wra &= ADDR_SECT_MASK;
fs->ate_wra += (fs->sector_size - ate_size); fs->ate_wra += (fs->sector_size - ate_size);
_nvs_ate_crc8_update(&close_ate); nvs_ate_crc8_update(&close_ate);
rc = _nvs_flash_ate_wrt(fs, &close_ate); rc = nvs_flash_ate_wrt(fs, &close_ate);
_nvs_sector_advance(fs, &fs->ate_wra); nvs_sector_advance(fs, &fs->ate_wra);
fs->data_wra = fs->ate_wra & ADDR_SECT_MASK; fs->data_wra = fs->ate_wra & ADDR_SECT_MASK;
@ -432,7 +432,7 @@ static int _nvs_sector_close(struct nvs_fs *fs)
* that has just been started. The data to gc is in the sector after this new * that has just been started. The data to gc is in the sector after this new
* sector. * sector.
*/ */
static int _nvs_gc(struct nvs_fs *fs) static int nvs_gc(struct nvs_fs *fs)
{ {
int rc; int rc;
struct nvs_ate close_ate, gc_ate, wlk_ate; struct nvs_ate close_ate, gc_ate, wlk_ate;
@ -440,22 +440,22 @@ static int _nvs_gc(struct nvs_fs *fs)
data_addr, stop_addr; data_addr, stop_addr;
size_t ate_size; size_t ate_size;
ate_size = _nvs_al_size(fs, sizeof(struct nvs_ate)); ate_size = nvs_al_size(fs, sizeof(struct nvs_ate));
sec_addr = (fs->ate_wra & ADDR_SECT_MASK); sec_addr = (fs->ate_wra & ADDR_SECT_MASK);
_nvs_sector_advance(fs, &sec_addr); nvs_sector_advance(fs, &sec_addr);
gc_addr = sec_addr + fs->sector_size - ate_size; gc_addr = sec_addr + fs->sector_size - ate_size;
/* if the sector is not closed don't do gc */ /* if the sector is not closed don't do gc */
rc = _nvs_flash_ate_rd(fs, gc_addr, &close_ate); rc = nvs_flash_ate_rd(fs, gc_addr, &close_ate);
if (rc < 0) { if (rc < 0) {
/* flash error */ /* flash error */
return rc; return rc;
} }
rc = _nvs_ate_cmp_const(&close_ate, 0xff); rc = nvs_ate_cmp_const(&close_ate, 0xff);
if (!rc) { if (!rc) {
rc = _nvs_flash_erase_sector(fs, sec_addr); rc = nvs_flash_erase_sector(fs, sec_addr);
if (rc) { if (rc) {
return rc; return rc;
} }
@ -469,14 +469,14 @@ static int _nvs_gc(struct nvs_fs *fs)
while (1) { while (1) {
gc_prev_addr = gc_addr; gc_prev_addr = gc_addr;
rc = _nvs_prev_ate(fs, &gc_addr, &gc_ate); rc = nvs_prev_ate(fs, &gc_addr, &gc_ate);
if (rc) { if (rc) {
return rc; return rc;
} }
wlk_addr = fs->ate_wra; wlk_addr = fs->ate_wra;
while (1) { while (1) {
wlk_prev_addr = wlk_addr; wlk_prev_addr = wlk_addr;
rc = _nvs_prev_ate(fs, &wlk_addr, &wlk_ate); rc = nvs_prev_ate(fs, &wlk_addr, &wlk_ate);
if (rc) { if (rc) {
return rc; return rc;
} }
@ -486,7 +486,7 @@ static int _nvs_gc(struct nvs_fs *fs)
* invalid, don't consider these as a match. * invalid, don't consider these as a match.
*/ */
if ((wlk_ate.id == gc_ate.id) && if ((wlk_ate.id == gc_ate.id) &&
(!_nvs_ate_crc8_check(&wlk_ate))) { (!nvs_ate_crc8_check(&wlk_ate))) {
break; break;
} }
} }
@ -501,14 +501,14 @@ static int _nvs_gc(struct nvs_fs *fs)
data_addr += gc_ate.offset; data_addr += gc_ate.offset;
gc_ate.offset = (u16_t)(fs->data_wra & ADDR_OFFS_MASK); gc_ate.offset = (u16_t)(fs->data_wra & ADDR_OFFS_MASK);
_nvs_ate_crc8_update(&gc_ate); nvs_ate_crc8_update(&gc_ate);
rc = _nvs_flash_block_move(fs, data_addr, gc_ate.len); rc = nvs_flash_block_move(fs, data_addr, gc_ate.len);
if (rc) { if (rc) {
return rc; return rc;
} }
rc = _nvs_flash_ate_wrt(fs, &gc_ate); rc = nvs_flash_ate_wrt(fs, &gc_ate);
if (rc) { if (rc) {
return rc; return rc;
} }
@ -520,14 +520,14 @@ static int _nvs_gc(struct nvs_fs *fs)
} }
} }
rc = _nvs_flash_erase_sector(fs, sec_addr); rc = nvs_flash_erase_sector(fs, sec_addr);
if (rc) { if (rc) {
return rc; return rc;
} }
return 0; return 0;
} }
static int _nvs_startup(struct nvs_fs *fs) static int nvs_startup(struct nvs_fs *fs)
{ {
int rc; int rc;
struct nvs_ate last_ate; struct nvs_ate last_ate;
@ -541,16 +541,16 @@ static int _nvs_startup(struct nvs_fs *fs)
k_mutex_lock(&fs->nvs_lock, K_FOREVER); k_mutex_lock(&fs->nvs_lock, K_FOREVER);
ate_size = _nvs_al_size(fs, sizeof(struct nvs_ate)); ate_size = nvs_al_size(fs, sizeof(struct nvs_ate));
/* step through the sectors to find the last sector */ /* step through the sectors to find the last sector */
for (u16_t i = 0; i < fs->sector_count; i++) { for (u16_t i = 0; i < fs->sector_count; i++) {
addr = (i << ADDR_SECT_SHIFT) + fs->sector_size - ate_size; addr = (i << ADDR_SECT_SHIFT) + fs->sector_size - ate_size;
rc = _nvs_flash_cmp_const(fs, addr, 0xff, rc = nvs_flash_cmp_const(fs, addr, 0xff,
sizeof(struct nvs_ate)); sizeof(struct nvs_ate));
if (rc) { if (rc) {
/* closed sector */ /* closed sector */
_nvs_sector_advance(fs, &addr); nvs_sector_advance(fs, &addr);
rc = _nvs_flash_cmp_const(fs, addr, 0xff, rc = nvs_flash_cmp_const(fs, addr, 0xff,
sizeof(struct nvs_ate)); sizeof(struct nvs_ate));
if (!rc) { if (!rc) {
/* open sector */ /* open sector */
@ -560,12 +560,12 @@ static int _nvs_startup(struct nvs_fs *fs)
/* none of the sectors where closed, set the address to /* none of the sectors where closed, set the address to
* the first sector * the first sector
*/ */
_nvs_sector_advance(fs, &addr); nvs_sector_advance(fs, &addr);
} }
/* search for the first ate containing all 0xff) */ /* search for the first ate containing all 0xff) */
while (1) { while (1) {
addr -= ate_size; addr -= ate_size;
rc = _nvs_flash_cmp_const(fs, addr, 0xff, rc = nvs_flash_cmp_const(fs, addr, 0xff,
sizeof(struct nvs_ate)); sizeof(struct nvs_ate));
if (!rc) { if (!rc) {
/* found ff empty location */ /* found ff empty location */
@ -582,14 +582,14 @@ static int _nvs_startup(struct nvs_fs *fs)
if ((addr & ADDR_OFFS_MASK) != fs->sector_size - 2 * ate_size) { if ((addr & ADDR_OFFS_MASK) != fs->sector_size - 2 * ate_size) {
addr += ate_size; addr += ate_size;
rc = _nvs_flash_ate_rd(fs, addr, &last_ate); rc = nvs_flash_ate_rd(fs, addr, &last_ate);
if (rc) { if (rc) {
goto end; goto end;
} }
if (!_nvs_ate_crc8_check(&last_ate)) { if (!nvs_ate_crc8_check(&last_ate)) {
/* crc8 is ok, complete write of ate was performed */ /* crc8 is ok, complete write of ate was performed */
fs->data_wra += last_ate.offset; fs->data_wra += last_ate.offset;
fs->data_wra += _nvs_al_size(fs, last_ate.len); fs->data_wra += nvs_al_size(fs, last_ate.len);
} }
} }
@ -599,7 +599,7 @@ static int _nvs_startup(struct nvs_fs *fs)
if (!empty_len) { if (!empty_len) {
break; break;
} }
rc = _nvs_flash_cmp_const(fs, fs->data_wra, 0xff, empty_len); rc = nvs_flash_cmp_const(fs, fs->data_wra, 0xff, empty_len);
if (rc < 0) { if (rc < 0) {
goto end; goto end;
} }
@ -614,21 +614,21 @@ static int _nvs_startup(struct nvs_fs *fs)
* otherwise the data may not fit into the sector. * otherwise the data may not fit into the sector.
*/ */
addr = fs->ate_wra & ADDR_SECT_MASK; addr = fs->ate_wra & ADDR_SECT_MASK;
_nvs_sector_advance(fs, &addr); nvs_sector_advance(fs, &addr);
rc = _nvs_flash_cmp_const(fs, addr, 0xff, fs->sector_size); rc = nvs_flash_cmp_const(fs, addr, 0xff, fs->sector_size);
if (rc < 0) { if (rc < 0) {
goto end; goto end;
} }
if (rc) { if (rc) {
/* the sector after fs->ate_wrt is not empty */ /* the sector after fs->ate_wrt is not empty */
rc = _nvs_flash_erase_sector(fs, fs->ate_wra); rc = nvs_flash_erase_sector(fs, fs->ate_wra);
if (rc) { if (rc) {
goto end; goto end;
} }
fs->ate_wra &= ADDR_SECT_MASK; fs->ate_wra &= ADDR_SECT_MASK;
fs->ate_wra += (fs->sector_size - 2 * ate_size); fs->ate_wra += (fs->sector_size - 2 * ate_size);
fs->data_wra = (fs->ate_wra & ADDR_SECT_MASK); fs->data_wra = (fs->ate_wra & ADDR_SECT_MASK);
rc = _nvs_gc(fs); rc = nvs_gc(fs);
if (rc) { if (rc) {
goto end; goto end;
} }
@ -651,7 +651,7 @@ int nvs_clear(struct nvs_fs *fs)
for (u16_t i = 0; i < fs->sector_count; i++) { for (u16_t i = 0; i < fs->sector_count; i++) {
addr = i << ADDR_SECT_SHIFT; addr = i << ADDR_SECT_SHIFT;
rc = _nvs_flash_erase_sector(fs, addr); rc = nvs_flash_erase_sector(fs, addr);
if (rc) { if (rc) {
return rc; return rc;
} }
@ -698,7 +698,7 @@ int nvs_init(struct nvs_fs *fs, const char *dev_name)
return -EINVAL; return -EINVAL;
} }
rc = _nvs_startup(fs); rc = nvs_startup(fs);
if (rc) { if (rc) {
return rc; return rc;
} }
@ -730,8 +730,8 @@ ssize_t nvs_write(struct nvs_fs *fs, u16_t id, const void *data, size_t len)
return -EACCES; return -EACCES;
} }
ate_size = _nvs_al_size(fs, sizeof(struct nvs_ate)); ate_size = nvs_al_size(fs, sizeof(struct nvs_ate));
data_size = _nvs_al_size(fs, len); data_size = nvs_al_size(fs, len);
/* The maximum data size is sector size - 3 ate /* The maximum data size is sector size - 3 ate
* where: 1 ate for data, 1 ate for sector close * where: 1 ate for data, 1 ate for sector close
@ -748,11 +748,11 @@ ssize_t nvs_write(struct nvs_fs *fs, u16_t id, const void *data, size_t len)
while (1) { while (1) {
rd_addr = wlk_addr; rd_addr = wlk_addr;
rc = _nvs_prev_ate(fs, &wlk_addr, &wlk_ate); rc = nvs_prev_ate(fs, &wlk_addr, &wlk_ate);
if (rc) { if (rc) {
return rc; return rc;
} }
if ((wlk_ate.id == id) && (!_nvs_ate_crc8_check(&wlk_ate))) { if ((wlk_ate.id == id) && (!nvs_ate_crc8_check(&wlk_ate))) {
break; break;
} }
if (wlk_addr == fs->ate_wra) { if (wlk_addr == fs->ate_wra) {
@ -772,7 +772,7 @@ ssize_t nvs_write(struct nvs_fs *fs, u16_t id, const void *data, size_t len)
} }
} else { } else {
/* compare the data and if equal return 0 */ /* compare the data and if equal return 0 */
rc = _nvs_flash_block_cmp(fs, rd_addr, data, len); rc = nvs_flash_block_cmp(fs, rd_addr, data, len);
if (rc <= 0) { if (rc <= 0) {
return rc; return rc;
} }
@ -796,19 +796,19 @@ ssize_t nvs_write(struct nvs_fs *fs, u16_t id, const void *data, size_t len)
/* Leave space for delete ate */ /* Leave space for delete ate */
if (sector_freespace >= data_size + ate_size) { if (sector_freespace >= data_size + ate_size) {
rc = _nvs_flash_wrt_entry(fs, id, data, len); rc = nvs_flash_wrt_entry(fs, id, data, len);
if (rc) { if (rc) {
goto end; goto end;
} }
break; break;
} }
rc = _nvs_sector_close(fs); rc = nvs_sector_close(fs);
if (rc) { if (rc) {
goto end; goto end;
} }
rc = _nvs_gc(fs); rc = nvs_gc(fs);
if (rc) { if (rc) {
goto end; goto end;
} }
@ -839,7 +839,7 @@ ssize_t nvs_read_hist(struct nvs_fs *fs, u16_t id, void *data, size_t len,
return -EACCES; return -EACCES;
} }
ate_size = _nvs_al_size(fs, sizeof(struct nvs_ate)); ate_size = nvs_al_size(fs, sizeof(struct nvs_ate));
if (len > (fs->sector_size - 2 * ate_size)) { if (len > (fs->sector_size - 2 * ate_size)) {
return -EINVAL; return -EINVAL;
@ -852,11 +852,11 @@ ssize_t nvs_read_hist(struct nvs_fs *fs, u16_t id, void *data, size_t len,
while (cnt_his <= cnt) { while (cnt_his <= cnt) {
rd_addr = wlk_addr; rd_addr = wlk_addr;
rc = _nvs_prev_ate(fs, &wlk_addr, &wlk_ate); rc = nvs_prev_ate(fs, &wlk_addr, &wlk_ate);
if (rc) { if (rc) {
goto err; goto err;
} }
if ((wlk_ate.id == id) && (!_nvs_ate_crc8_check(&wlk_ate))) { if ((wlk_ate.id == id) && (!nvs_ate_crc8_check(&wlk_ate))) {
cnt_his++; cnt_his++;
} }
if (wlk_addr == fs->ate_wra) { if (wlk_addr == fs->ate_wra) {
@ -871,7 +871,7 @@ ssize_t nvs_read_hist(struct nvs_fs *fs, u16_t id, void *data, size_t len,
rd_addr &= ADDR_SECT_MASK; rd_addr &= ADDR_SECT_MASK;
rd_addr += wlk_ate.offset; rd_addr += wlk_ate.offset;
rc = _nvs_flash_rd(fs, rd_addr, data, MIN(len, wlk_ate.len)); rc = nvs_flash_rd(fs, rd_addr, data, MIN(len, wlk_ate.len));
if (rc) { if (rc) {
goto err; goto err;
} }
@ -903,7 +903,7 @@ ssize_t nvs_calc_free_space(struct nvs_fs *fs)
return -EACCES; return -EACCES;
} }
ate_size = _nvs_al_size(fs, sizeof(struct nvs_ate)); ate_size = nvs_al_size(fs, sizeof(struct nvs_ate));
free_space = 0; free_space = 0;
for (u16_t i = 1; i < fs->sector_count; i++) { for (u16_t i = 1; i < fs->sector_count; i++) {
@ -913,7 +913,7 @@ ssize_t nvs_calc_free_space(struct nvs_fs *fs)
step_addr = fs->ate_wra; step_addr = fs->ate_wra;
while (1) { while (1) {
rc = _nvs_prev_ate(fs, &step_addr, &step_ate); rc = nvs_prev_ate(fs, &step_addr, &step_ate);
if (rc) { if (rc) {
return rc; return rc;
} }
@ -921,7 +921,7 @@ ssize_t nvs_calc_free_space(struct nvs_fs *fs)
wlk_addr = fs->ate_wra; wlk_addr = fs->ate_wra;
while (1) { while (1) {
rc = _nvs_prev_ate(fs, &wlk_addr, &wlk_ate); rc = nvs_prev_ate(fs, &wlk_addr, &wlk_ate);
if (rc) { if (rc) {
return rc; return rc;
} }
@ -932,9 +932,9 @@ ssize_t nvs_calc_free_space(struct nvs_fs *fs)
} }
if ((wlk_addr == step_addr) && step_ate.len && if ((wlk_addr == step_addr) && step_ate.len &&
(!_nvs_ate_crc8_check(&step_ate))) { (!nvs_ate_crc8_check(&step_ate))) {
/* count needed */ /* count needed */
free_space -= _nvs_al_size(fs, step_ate.len); free_space -= nvs_al_size(fs, step_ate.len);
free_space -= ate_size; free_space -= ate_size;
} }

View file

@ -46,8 +46,8 @@ static u32_t timestamp_div;
typedef int (*out_func_t)(int c, void *ctx); typedef int (*out_func_t)(int c, void *ctx);
extern int _prf(int (*func)(), void *dest, char *format, va_list vargs); extern int z_prf(int (*func)(), void *dest, char *format, va_list vargs);
extern void _vprintk(out_func_t out, void *log_output, extern void z_vprintk(out_func_t out, void *log_output,
const char *fmt, va_list ap); const char *fmt, va_list ap);
/* The RFC 5424 allows very flexible mapping and suggest the value 0 being the /* The RFC 5424 allows very flexible mapping and suggest the value 0 being the
@ -116,9 +116,9 @@ static int print_formatted(const struct log_output *log_output,
va_start(args, fmt); va_start(args, fmt);
#if !defined(CONFIG_NEWLIB_LIBC) && !defined(CONFIG_ARCH_POSIX) && \ #if !defined(CONFIG_NEWLIB_LIBC) && !defined(CONFIG_ARCH_POSIX) && \
defined(CONFIG_LOG_ENABLE_FANCY_OUTPUT_FORMATTING) defined(CONFIG_LOG_ENABLE_FANCY_OUTPUT_FORMATTING)
length = _prf(out_func, (void *)log_output, (char *)fmt, args); length = z_prf(out_func, (void *)log_output, (char *)fmt, args);
#else #else
_vprintk(out_func, (void *)log_output, fmt, args); z_vprintk(out_func, (void *)log_output, fmt, args);
#endif #endif
va_end(args); va_end(args);
@ -554,9 +554,9 @@ void log_output_string(const struct log_output *log_output,
#if !defined(CONFIG_NEWLIB_LIBC) && !defined(CONFIG_ARCH_POSIX) && \ #if !defined(CONFIG_NEWLIB_LIBC) && !defined(CONFIG_ARCH_POSIX) && \
defined(CONFIG_LOG_ENABLE_FANCY_OUTPUT_FORMATTING) defined(CONFIG_LOG_ENABLE_FANCY_OUTPUT_FORMATTING)
length = _prf(out_func, (void *)log_output, (char *)fmt, ap); length = z_prf(out_func, (void *)log_output, (char *)fmt, ap);
#else #else
_vprintk(out_func, (void *)log_output, fmt, ap); z_vprintk(out_func, (void *)log_output, fmt, ap);
#endif #endif
(void)length; (void)length;

View file

@ -493,7 +493,6 @@ static inline struct net_buf_pool *get_data_pool(struct net_context *context)
#define get_data_pool(...) NULL #define get_data_pool(...) NULL
#endif /* CONFIG_NET_CONTEXT_NET_PKT_POOL */ #endif /* CONFIG_NET_CONTEXT_NET_PKT_POOL */
#if NET_LOG_LEVEL >= LOG_LEVEL_DBG #if NET_LOG_LEVEL >= LOG_LEVEL_DBG
void net_pkt_unref_debug(struct net_pkt *pkt, const char *caller, int line) void net_pkt_unref_debug(struct net_pkt *pkt, const char *caller, int line)
{ {

View file

@ -2640,22 +2640,22 @@ static const struct shell *shell_for_ping;
#if defined(CONFIG_NET_IPV6) #if defined(CONFIG_NET_IPV6)
static enum net_verdict _handle_ipv6_echo_reply(struct net_pkt *pkt, static enum net_verdict handle_ipv6_echo_reply(struct net_pkt *pkt,
struct net_ipv6_hdr *ip_hdr, struct net_ipv6_hdr *ip_hdr,
struct net_icmp_hdr *icmp_hdr); struct net_icmp_hdr *icmp_hdr);
static struct net_icmpv6_handler ping6_handler = { static struct net_icmpv6_handler ping6_handler = {
.type = NET_ICMPV6_ECHO_REPLY, .type = NET_ICMPV6_ECHO_REPLY,
.code = 0, .code = 0,
.handler = _handle_ipv6_echo_reply, .handler = handle_ipv6_echo_reply,
}; };
static inline void _remove_ipv6_ping_handler(void) static inline void remove_ipv6_ping_handler(void)
{ {
net_icmpv6_unregister_handler(&ping6_handler); net_icmpv6_unregister_handler(&ping6_handler);
} }
static enum net_verdict _handle_ipv6_echo_reply(struct net_pkt *pkt, static enum net_verdict handle_ipv6_echo_reply(struct net_pkt *pkt,
struct net_ipv6_hdr *ip_hdr, struct net_ipv6_hdr *ip_hdr,
struct net_icmp_hdr *icmp_hdr) struct net_icmp_hdr *icmp_hdr)
{ {
@ -2665,13 +2665,13 @@ static enum net_verdict _handle_ipv6_echo_reply(struct net_pkt *pkt,
net_sprint_ipv6_addr(&ip_hdr->src), net_sprint_ipv6_addr(&ip_hdr->src),
net_sprint_ipv6_addr(&ip_hdr->dst)); net_sprint_ipv6_addr(&ip_hdr->dst));
k_sem_give(&ping_timeout); k_sem_give(&ping_timeout);
_remove_ipv6_ping_handler(); remove_ipv6_ping_handler();
net_pkt_unref(pkt); net_pkt_unref(pkt);
return NET_OK; return NET_OK;
} }
static int _ping_ipv6(const struct shell *shell, char *host) static int ping_ipv6(const struct shell *shell, char *host)
{ {
struct in6_addr ipv6_target; struct in6_addr ipv6_target;
struct net_if *iface = net_if_get_default(); struct net_if *iface = net_if_get_default();
@ -2705,7 +2705,7 @@ static int _ping_ipv6(const struct shell *shell, char *host)
sys_rand32_get(), sys_rand32_get(),
sys_rand32_get()); sys_rand32_get());
if (ret) { if (ret) {
_remove_ipv6_ping_handler(); remove_ipv6_ping_handler();
} else { } else {
PR("Sent a ping to %s\n", host); PR("Sent a ping to %s\n", host);
} }
@ -2713,40 +2713,40 @@ static int _ping_ipv6(const struct shell *shell, char *host)
return ret; return ret;
} }
#else #else
#define _ping_ipv6(...) -ENOTSUP #define ping_ipv6(...) -ENOTSUP
#define _remove_ipv6_ping_handler() #define remove_ipv6_ping_handler()
#endif /* CONFIG_NET_IPV6 */ #endif /* CONFIG_NET_IPV6 */
#if defined(CONFIG_NET_IPV4) #if defined(CONFIG_NET_IPV4)
static enum net_verdict _handle_ipv4_echo_reply(struct net_pkt *pkt, static enum net_verdict handle_ipv4_echo_reply(struct net_pkt *pkt,
struct net_ipv4_hdr *ip_hdr); struct net_ipv4_hdr *ip_hdr);
static struct net_icmpv4_handler ping4_handler = { static struct net_icmpv4_handler ping4_handler = {
.type = NET_ICMPV4_ECHO_REPLY, .type = NET_ICMPV4_ECHO_REPLY,
.code = 0, .code = 0,
.handler = _handle_ipv4_echo_reply, .handler = handle_ipv4_echo_reply,
}; };
static inline void _remove_ipv4_ping_handler(void) static inline void remove_ipv4_ping_handler(void)
{ {
net_icmpv4_unregister_handler(&ping4_handler); net_icmpv4_unregister_handler(&ping4_handler);
} }
static enum net_verdict _handle_ipv4_echo_reply(struct net_pkt *pkt, static enum net_verdict handle_ipv4_echo_reply(struct net_pkt *pkt,
struct net_ipv4_hdr *ip_hdr) struct net_ipv4_hdr *ip_hdr)
{ {
PR_SHELL(shell_for_ping, "Received echo reply from %s to %s\n", PR_SHELL(shell_for_ping, "Received echo reply from %s to %s\n",
net_sprint_ipv4_addr(&ip_hdr->src), net_sprint_ipv4_addr(&ip_hdr->src),
net_sprint_ipv4_addr(&ip_hdr->dst)); net_sprint_ipv4_addr(&ip_hdr->dst));
k_sem_give(&ping_timeout); k_sem_give(&ping_timeout);
_remove_ipv4_ping_handler(); remove_ipv4_ping_handler();
net_pkt_unref(pkt); net_pkt_unref(pkt);
return NET_OK; return NET_OK;
} }
static int _ping_ipv4(const struct shell *shell, char *host) static int ping_ipv4(const struct shell *shell, char *host)
{ {
struct in_addr ipv4_target; struct in_addr ipv4_target;
int ret; int ret;
@ -2763,7 +2763,7 @@ static int _ping_ipv4(const struct shell *shell, char *host)
sys_rand32_get(), sys_rand32_get(),
sys_rand32_get()); sys_rand32_get());
if (ret) { if (ret) {
_remove_ipv4_ping_handler(); remove_ipv4_ping_handler();
} else { } else {
PR("Sent a ping to %s\n", host); PR("Sent a ping to %s\n", host);
} }
@ -2771,8 +2771,8 @@ static int _ping_ipv4(const struct shell *shell, char *host)
return ret; return ret;
} }
#else #else
#define _ping_ipv4(...) -ENOTSUP #define ping_ipv4(...) -ENOTSUP
#define _remove_ipv4_ping_handler() #define remove_ipv4_ping_handler()
#endif /* CONFIG_NET_IPV4 */ #endif /* CONFIG_NET_IPV4 */
#endif /* CONFIG_NET_IPV6 || CONFIG_NET_IPV4 */ #endif /* CONFIG_NET_IPV6 || CONFIG_NET_IPV4 */
@ -2800,7 +2800,7 @@ static int cmd_net_ping(const struct shell *shell, size_t argc, char *argv[])
shell_for_ping = shell; shell_for_ping = shell;
if (IS_ENABLED(CONFIG_NET_IPV6)) { if (IS_ENABLED(CONFIG_NET_IPV6)) {
ret = _ping_ipv6(shell, host); ret = ping_ipv6(shell, host);
if (!ret) { if (!ret) {
goto wait_reply; goto wait_reply;
} else if (ret == -EIO) { } else if (ret == -EIO) {
@ -2810,7 +2810,7 @@ static int cmd_net_ping(const struct shell *shell, size_t argc, char *argv[])
} }
if (IS_ENABLED(CONFIG_NET_IPV4)) { if (IS_ENABLED(CONFIG_NET_IPV4)) {
ret = _ping_ipv4(shell, host); ret = ping_ipv4(shell, host);
if (ret) { if (ret) {
if (ret == -EIO) { if (ret == -EIO) {
PR_WARNING("Cannot send IPv4 ping\n"); PR_WARNING("Cannot send IPv4 ping\n");
@ -2826,8 +2826,8 @@ wait_reply:
ret = k_sem_take(&ping_timeout, K_SECONDS(2)); ret = k_sem_take(&ping_timeout, K_SECONDS(2));
if (ret == -EAGAIN) { if (ret == -EAGAIN) {
PR_INFO("Ping timeout\n"); PR_INFO("Ping timeout\n");
_remove_ipv6_ping_handler(); remove_ipv6_ping_handler();
_remove_ipv4_ping_handler(); remove_ipv4_ping_handler();
return -ETIMEDOUT; return -ETIMEDOUT;
} }

View file

@ -48,7 +48,7 @@ static int wifi_connect(u32_t mgmt_request, struct net_if *iface,
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_CONNECT, wifi_connect); NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_CONNECT, wifi_connect);
static void _scan_result_cb(struct net_if *iface, int status, static void scan_result_cb(struct net_if *iface, int status,
struct wifi_scan_result *entry) struct wifi_scan_result *entry)
{ {
if (!iface) { if (!iface) {
@ -81,7 +81,7 @@ static int wifi_scan(u32_t mgmt_request, struct net_if *iface,
return -ENOTSUP; return -ENOTSUP;
} }
return off_api->scan(dev, _scan_result_cb); return off_api->scan(dev, scan_result_cb);
} }
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_SCAN, wifi_scan); NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_SCAN, wifi_scan);

View file

@ -32,7 +32,7 @@ static struct bt_gatt_attr attrs[] = {
static struct bt_gatt_service ipss_svc = BT_GATT_SERVICE(attrs); static struct bt_gatt_service ipss_svc = BT_GATT_SERVICE(attrs);
#endif #endif
int _net_config_bt_setup(void) int z_net_config_bt_setup(void)
{ {
struct net_if *iface; struct net_if *iface;
struct device *dev; struct device *dev;

View file

@ -7,7 +7,7 @@
*/ */
#if defined(CONFIG_NET_L2_BT) && defined(CONFIG_NET_CONFIG_SETTINGS) #if defined(CONFIG_NET_L2_BT) && defined(CONFIG_NET_CONFIG_SETTINGS)
int _net_config_bt_setup(void); int z_net_config_bt_setup(void);
#else #else
#define _net_config_bt_setup(...) 0 #define z_net_config_bt_setup(...) 0
#endif #endif

View file

@ -17,7 +17,7 @@ LOG_MODULE_DECLARE(net_config, CONFIG_NET_CONFIG_LOG_LEVEL);
#include <net/net_mgmt.h> #include <net/net_mgmt.h>
#include <net/ieee802154_mgmt.h> #include <net/ieee802154_mgmt.h>
int _net_config_ieee802154_setup(void) int z_net_config_ieee802154_setup(void)
{ {
u16_t channel = CONFIG_NET_CONFIG_IEEE802154_CHANNEL; u16_t channel = CONFIG_NET_CONFIG_IEEE802154_CHANNEL;
u16_t pan_id = CONFIG_NET_CONFIG_IEEE802154_PAN_ID; u16_t pan_id = CONFIG_NET_CONFIG_IEEE802154_PAN_ID;

View file

@ -7,7 +7,7 @@
*/ */
#if defined(CONFIG_NET_L2_IEEE802154) && defined(CONFIG_NET_CONFIG_SETTINGS) #if defined(CONFIG_NET_L2_IEEE802154) && defined(CONFIG_NET_CONFIG_SETTINGS)
int _net_config_ieee802154_setup(void); int z_net_config_ieee802154_setup(void);
#else #else
#define _net_config_ieee802154_setup(...) 0 #define z_net_config_ieee802154_setup(...) 0
#endif #endif

View file

@ -350,12 +350,12 @@ static int init_app(struct device *device)
#if defined(CONFIG_NET_IPV6) #if defined(CONFIG_NET_IPV6)
/* IEEE 802.15.4 is only usable if IPv6 is enabled */ /* IEEE 802.15.4 is only usable if IPv6 is enabled */
ret = _net_config_ieee802154_setup(); ret = z_net_config_ieee802154_setup();
if (ret < 0) { if (ret < 0) {
NET_ERR("Cannot setup IEEE 802.15.4 interface (%d)", ret); NET_ERR("Cannot setup IEEE 802.15.4 interface (%d)", ret);
} }
ret = _net_config_bt_setup(); ret = z_net_config_bt_setup();
if (ret < 0) { if (ret < 0) {
NET_ERR("Cannot setup Bluetooth interface (%d)", ret); NET_ERR("Cannot setup Bluetooth interface (%d)", ret);
} }

View file

@ -49,7 +49,7 @@ static void zsock_received_cb(struct net_context *ctx,
int status, int status,
void *user_data); void *user_data);
static inline int _k_fifo_wait_non_empty(struct k_fifo *fifo, int32_t timeout) static inline int k_fifo_wait_non_empty(struct k_fifo *fifo, int32_t timeout)
{ {
struct k_poll_event events[] = { struct k_poll_event events[] = {
K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_FIFO_DATA_AVAILABLE, K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_FIFO_DATA_AVAILABLE,
@ -631,7 +631,7 @@ static inline ssize_t zsock_recv_dgram(struct net_context *ctx,
if (flags & ZSOCK_MSG_PEEK) { if (flags & ZSOCK_MSG_PEEK) {
int res; int res;
res = _k_fifo_wait_non_empty(&ctx->recv_q, timeout); res = k_fifo_wait_non_empty(&ctx->recv_q, timeout);
/* EAGAIN when timeout expired, EINTR when cancelled */ /* EAGAIN when timeout expired, EINTR when cancelled */
if (res && res != -EAGAIN && res != -EINTR) { if (res && res != -EAGAIN && res != -EINTR) {
errno = -res; errno = -res;
@ -719,7 +719,7 @@ static inline ssize_t zsock_recv_stream(struct net_context *ctx,
return 0; return 0;
} }
res = _k_fifo_wait_non_empty(&ctx->recv_q, timeout); res = k_fifo_wait_non_empty(&ctx->recv_q, timeout);
/* EAGAIN when timeout expired, EINTR when cancelled */ /* EAGAIN when timeout expired, EINTR when cancelled */
if (res && res != -EAGAIN && res != -EINTR) { if (res && res != -EAGAIN && res != -EINTR) {
errno = -res; errno = -res;

View file

@ -26,7 +26,7 @@ extern const struct socket_op_vtable sock_fd_op_vtable;
static const struct socket_op_vtable can_sock_fd_op_vtable; static const struct socket_op_vtable can_sock_fd_op_vtable;
static inline int _k_fifo_wait_non_empty(struct k_fifo *fifo, int32_t timeout) static inline int k_fifo_wait_non_empty(struct k_fifo *fifo, int32_t timeout)
{ {
struct k_poll_event events[] = { struct k_poll_event events[] = {
K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_FIFO_DATA_AVAILABLE, K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_FIFO_DATA_AVAILABLE,
@ -211,7 +211,7 @@ static ssize_t zcan_recvfrom_ctx(struct net_context *ctx, void *buf,
if (flags & ZSOCK_MSG_PEEK) { if (flags & ZSOCK_MSG_PEEK) {
int ret; int ret;
ret = _k_fifo_wait_non_empty(&ctx->recv_q, timeout); ret = k_fifo_wait_non_empty(&ctx->recv_q, timeout);
/* EAGAIN when timeout expired, EINTR when cancelled */ /* EAGAIN when timeout expired, EINTR when cancelled */
if (ret && ret != -EAGAIN && ret != -EINTR) { if (ret && ret != -EAGAIN && ret != -EINTR) {
errno = -ret; errno = -ret;

View file

@ -26,7 +26,7 @@ extern const struct socket_op_vtable sock_fd_op_vtable;
static const struct socket_op_vtable packet_sock_fd_op_vtable; static const struct socket_op_vtable packet_sock_fd_op_vtable;
static inline int _k_fifo_wait_non_empty(struct k_fifo *fifo, int32_t timeout) static inline int k_fifo_wait_non_empty(struct k_fifo *fifo, int32_t timeout)
{ {
struct k_poll_event events[] = { struct k_poll_event events[] = {
K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_FIFO_DATA_AVAILABLE, K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_FIFO_DATA_AVAILABLE,
@ -191,7 +191,7 @@ ssize_t zpacket_recvfrom_ctx(struct net_context *ctx, void *buf, size_t max_len,
if (flags & ZSOCK_MSG_PEEK) { if (flags & ZSOCK_MSG_PEEK) {
int res; int res;
res = _k_fifo_wait_non_empty(&ctx->recv_q, timeout); res = k_fifo_wait_non_empty(&ctx->recv_q, timeout);
/* EAGAIN when timeout expired, EINTR when cancelled */ /* EAGAIN when timeout expired, EINTR when cancelled */
if (res && res != -EAGAIN && res != -EINTR) { if (res && res != -EAGAIN && res != -EINTR) {
errno = -res; errno = -res;

View file

@ -9,9 +9,9 @@
#ifdef CONFIG_NEWLIB_LIBC #ifdef CONFIG_NEWLIB_LIBC
typedef int (*out_func_t)(int c, void *ctx); typedef int (*out_func_t)(int c, void *ctx);
extern void _vprintk(out_func_t out, void *ctx, const char *fmt, va_list ap); extern void z_vprintk(out_func_t out, void *ctx, const char *fmt, va_list ap);
#else #else
extern int _prf(int (*func)(), void *dest, char *format, va_list vargs); extern int z_prf(int (*func)(), void *dest, char *format, va_list vargs);
#endif #endif
static int out_func(int c, void *ctx) static int out_func(int c, void *ctx)
@ -40,9 +40,9 @@ void shell_fprintf_fmt(const struct shell_fprintf *sh_fprintf,
const char *fmt, va_list args) const char *fmt, va_list args)
{ {
#if !defined(CONFIG_NEWLIB_LIBC) && !defined(CONFIG_ARCH_POSIX) #if !defined(CONFIG_NEWLIB_LIBC) && !defined(CONFIG_ARCH_POSIX)
(void)_prf(out_func, (void *)sh_fprintf, (char *)fmt, args); (void)z_prf(out_func, (void *)sh_fprintf, (char *)fmt, args);
#else #else
_vprintk(out_func, (void *)sh_fprintf, fmt, args); z_vprintk(out_func, (void *)sh_fprintf, fmt, args);
#endif #endif
if (sh_fprintf->ctrl_blk->autoflush) { if (sh_fprintf->ctrl_blk->autoflush) {

View file

@ -77,13 +77,13 @@ static __unused const char *TC_RESULT_STR[] = {
#define TC_END(result, fmt, ...) PRINT_DATA(fmt, ##__VA_ARGS__) #define TC_END(result, fmt, ...) PRINT_DATA(fmt, ##__VA_ARGS__)
/* prints result and the function name */ /* prints result and the function name */
#define _TC_END_RESULT(result, func) \ #define Z_TC_END_RESULT(result, func) \
do { \ do { \
TC_END(result, "%s - %s\n", TC_RESULT_TO_STR(result), func); \ TC_END(result, "%s - %s\n", TC_RESULT_TO_STR(result), func); \
PRINT_LINE; \ PRINT_LINE; \
} while (0) } while (0)
#define TC_END_RESULT(result) \ #define TC_END_RESULT(result) \
_TC_END_RESULT((result), __func__) Z_TC_END_RESULT((result), __func__)
#if defined(CONFIG_ARCH_POSIX) #if defined(CONFIG_ARCH_POSIX)
#define TC_END_POST(result) posix_exit(result) #define TC_END_POST(result) posix_exit(result)

View file

@ -22,7 +22,7 @@
void ztest_test_fail(void); void ztest_test_fail(void);
#if CONFIG_ZTEST_ASSERT_VERBOSE == 0 #if CONFIG_ZTEST_ASSERT_VERBOSE == 0
static inline void _zassert_(int cond, const char *file, int line) static inline void z_zassert_(int cond, const char *file, int line)
{ {
if (!(cond)) { if (!(cond)) {
PRINT("\n Assertion failed at %s:%d\n", PRINT("\n Assertion failed at %s:%d\n",
@ -31,12 +31,12 @@ static inline void _zassert_(int cond, const char *file, int line)
} }
} }
#define _zassert(cond, default_msg, file, line, func, msg, ...) \ #define z_zassert(cond, default_msg, file, line, func, msg, ...) \
_zassert_(cond, file, line) z_zassert_(cond, file, line)
#else /* CONFIG_ZTEST_ASSERT_VERBOSE != 0 */ #else /* CONFIG_ZTEST_ASSERT_VERBOSE != 0 */
static inline void _zassert(int cond, static inline void z_zassert(int cond,
const char *default_msg, const char *default_msg,
const char *file, const char *file,
int line, const char *func, int line, const char *func,
@ -85,7 +85,7 @@ static inline void _zassert(int cond,
*/ */
#define zassert(cond, default_msg, msg, ...) \ #define zassert(cond, default_msg, msg, ...) \
_zassert(cond, msg ? ("(" default_msg ")") : (default_msg), \ z_zassert(cond, msg ? ("(" default_msg ")") : (default_msg), \
__FILE__, __LINE__, __func__, msg ? msg : "", ##__VA_ARGS__) __FILE__, __LINE__, __func__, msg ? msg : "", ##__VA_ARGS__)
/** /**

View file

@ -34,7 +34,7 @@
* @param value Value for @a param * @param value Value for @a param
*/ */
#define ztest_expect_value(func, param, value) \ #define ztest_expect_value(func, param, value) \
_ztest_expect_value(STRINGIFY(func), STRINGIFY(param), \ z_ztest_expect_value(STRINGIFY(func), STRINGIFY(param), \
(uintptr_t)(value)) (uintptr_t)(value))
/** /**
@ -49,7 +49,7 @@
* @param param Parameter to check * @param param Parameter to check
*/ */
#define ztest_check_expected_value(param) \ #define ztest_check_expected_value(param) \
_ztest_check_expected_value(__func__, STRINGIFY(param), \ z_ztest_check_expected_value(__func__, STRINGIFY(param), \
(uintptr_t)(param)) (uintptr_t)(param))
/** /**
@ -59,7 +59,7 @@
* @param value Value to return from @a func * @param value Value to return from @a func
*/ */
#define ztest_returns_value(func, value) \ #define ztest_returns_value(func, value) \
_ztest_returns_value(STRINGIFY(func), (uintptr_t)(value)) z_ztest_returns_value(STRINGIFY(func), (uintptr_t)(value))
/** /**
* @brief Get the return value for current function * @brief Get the return value for current function
@ -70,7 +70,7 @@
* @returns The value the current function should return * @returns The value the current function should return
*/ */
#define ztest_get_return_value() \ #define ztest_get_return_value() \
_ztest_get_return_value(__func__) z_ztest_get_return_value(__func__)
/** /**
* @brief Get the return value as a pointer for current function * @brief Get the return value as a pointer for current function
@ -81,7 +81,7 @@
* @returns The value the current function should return as a `void *` * @returns The value the current function should return as a `void *`
*/ */
#define ztest_get_return_value_ptr() \ #define ztest_get_return_value_ptr() \
((void *)_ztest_get_return_value(__func__)) ((void *)z_ztest_get_return_value(__func__))
/** /**
* @} * @}
@ -91,20 +91,20 @@
#include <zephyr/types.h> #include <zephyr/types.h>
void _init_mock(void); void z_init_mock(void);
int _cleanup_mock(void); int z_cleanup_mock(void);
void _ztest_expect_value(const char *fn, const char *name, uintptr_t value); void z_ztest_expect_value(const char *fn, const char *name, uintptr_t value);
void _ztest_check_expected_value(const char *fn, const char *param, void z_ztest_check_expected_value(const char *fn, const char *param,
uintptr_t value); uintptr_t value);
void _ztest_returns_value(const char *fn, uintptr_t value); void z_ztest_returns_value(const char *fn, uintptr_t value);
uintptr_t _ztest_get_return_value(const char *fn); uintptr_t z_ztest_get_return_value(const char *fn);
#else /* !CONFIG_ZTEST_MOCKING */ #else /* !CONFIG_ZTEST_MOCKING */
#define _init_mock() #define z_init_mock()
#define _cleanup_mock() 0 #define z_cleanup_mock() 0
#endif /* CONFIG_ZTEST_MOCKING */ #endif /* CONFIG_ZTEST_MOCKING */

View file

@ -23,7 +23,7 @@ struct unit_test {
u32_t thread_options; u32_t thread_options;
}; };
void _ztest_run_test_suite(const char *name, struct unit_test *suite); void z_ztest_run_test_suite(const char *name, struct unit_test *suite);
/** /**
* @defgroup ztest_test Ztest testing macros * @defgroup ztest_test Ztest testing macros
@ -164,7 +164,7 @@ extern struct k_mem_domain ztest_mem_domain;
* @param suite Test suite to run. * @param suite Test suite to run.
*/ */
#define ztest_run_test_suite(suite) \ #define ztest_run_test_suite(suite) \
_ztest_run_test_suite(#suite, _##suite) z_ztest_run_test_suite(#suite, _##suite)
/** /**
* @} * @}

View file

@ -31,7 +31,7 @@ static int cleanup_test(struct unit_test *test)
int ret = TC_PASS; int ret = TC_PASS;
int mock_status; int mock_status;
mock_status = _cleanup_mock(); mock_status = z_cleanup_mock();
#ifdef KERNEL #ifdef KERNEL
/* we need to remove the ztest_thread information from the timeout_q. /* we need to remove the ztest_thread information from the timeout_q.
@ -138,7 +138,7 @@ static int run_test(struct unit_test *test)
run_test_functions(test); run_test_functions(test);
out: out:
ret |= cleanup_test(test); ret |= cleanup_test(test);
_TC_END_RESULT(ret, test->name); Z_TC_END_RESULT(ret, test->name);
return ret; return ret;
} }
@ -234,9 +234,9 @@ static int run_test(struct unit_test *test)
} }
if (test_result == -2) { if (test_result == -2) {
_TC_END_RESULT(TC_SKIP, test->name); Z_TC_END_RESULT(TC_SKIP, test->name);
} else { } else {
_TC_END_RESULT(ret, test->name); Z_TC_END_RESULT(ret, test->name);
} }
return ret; return ret;
@ -244,7 +244,7 @@ static int run_test(struct unit_test *test)
#endif /* !KERNEL */ #endif /* !KERNEL */
void _ztest_run_test_suite(const char *name, struct unit_test *suite) void z_ztest_run_test_suite(const char *name, struct unit_test *suite)
{ {
int fail = 0; int fail = 0;
@ -290,7 +290,7 @@ K_APPMEM_PARTITION_DEFINE(ztest_mem_partition);
#ifndef KERNEL #ifndef KERNEL
int main(void) int main(void)
{ {
_init_mock(); z_init_mock();
test_main(); test_main();
end_report(); end_report();
@ -320,7 +320,7 @@ void main(void)
k_mem_domain_add_thread(&ztest_mem_domain, k_current_get()); k_mem_domain_add_thread(&ztest_mem_domain, k_current_get());
#endif /* CONFIG_USERSPACE */ #endif /* CONFIG_USERSPACE */
_init_mock(); z_init_mock();
test_main(); test_main();
end_report(); end_report();
} }

View file

@ -39,7 +39,7 @@ static struct parameter *alloc_parameter(void)
return param; return param;
} }
void _init_mock(void) void z_init_mock(void)
{ {
} }
@ -126,7 +126,7 @@ struct parameter *alloc_parameter(void)
return param; return param;
} }
void _init_mock(void) void z_init_mock(void)
{ {
} }
@ -176,12 +176,12 @@ static void insert_value(struct parameter *param, const char *fn,
static struct parameter parameter_list = { NULL, "", "", 0 }; static struct parameter parameter_list = { NULL, "", "", 0 };
static struct parameter return_value_list = { NULL, "", "", 0 }; static struct parameter return_value_list = { NULL, "", "", 0 };
void _ztest_expect_value(const char *fn, const char *name, uintptr_t val) void z_ztest_expect_value(const char *fn, const char *name, uintptr_t val)
{ {
insert_value(&parameter_list, fn, name, val); insert_value(&parameter_list, fn, name, val);
} }
void _ztest_check_expected_value(const char *fn, const char *name, void z_ztest_check_expected_value(const char *fn, const char *name,
uintptr_t val) uintptr_t val)
{ {
struct parameter *param; struct parameter *param;
@ -206,13 +206,13 @@ void _ztest_check_expected_value(const char *fn, const char *name,
} }
} }
void _ztest_returns_value(const char *fn, uintptr_t value) void z_ztest_returns_value(const char *fn, uintptr_t value)
{ {
insert_value(&return_value_list, fn, "", value); insert_value(&return_value_list, fn, "", value);
} }
uintptr_t _ztest_get_return_value(const char *fn) uintptr_t z_ztest_get_return_value(const char *fn)
{ {
uintptr_t value; uintptr_t value;
struct parameter *param = find_and_delete_value(&return_value_list, struct parameter *param = find_and_delete_value(&return_value_list,
@ -240,7 +240,7 @@ static void free_param_list(struct parameter *param)
} }
} }
int _cleanup_mock(void) int z_cleanup_mock(void)
{ {
int fail = 0; int fail = 0;