This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 5b369c5cec3e57d0a6556a6037d21878b666faab Author: ligd <[email protected]> AuthorDate: Wed Dec 8 12:20:35 2021 +0800 libs/lbc: remove CHAR_BIT = 16 support For CEVA platform CHAR_BIT is 16, and will do lots of extra work when use IPC. We will not support this platform anymore, so remove all the b2c operations. Signed-off-by: ligd <[email protected]> --- drivers/addrenv.c | 9 ++- drivers/clk/clk.h | 2 - drivers/rptun/rptun.c | 4 +- drivers/serial/uart_rpmsg.c | 18 +++--- drivers/syslog/syslog_rpmsg.c | 59 +++++++------------- fs/rpmsgfs/rpmsgfs_client.c | 64 +++++++++++----------- include/nuttx/b2c.h | 109 ------------------------------------- include/nuttx/rptun/rptun.h | 2 +- include/string.h | 6 -- libs/libc/string/Make.defs | 2 - libs/libc/string/lib_anbstr2cstr.c | 54 ------------------ libs/libc/string/lib_ancstr2bstr.c | 54 ------------------ libs/libc/string/lib_bmem2cmem.c | 59 -------------------- libs/libc/string/lib_bstrnlen.c | 55 ------------------- libs/libc/string/lib_cmem2bmem.c | 63 --------------------- libs/libc/string/lib_nbstr2cstr.c | 59 -------------------- libs/libc/string/lib_ncstr2bstr.c | 67 ----------------------- mm/mm_heap/mm.h | 18 +++--- 18 files changed, 77 insertions(+), 627 deletions(-) diff --git a/drivers/addrenv.c b/drivers/addrenv.c index dd4d784..82063c4 100644 --- a/drivers/addrenv.c +++ b/drivers/addrenv.c @@ -79,20 +79,19 @@ FAR void *up_addrenv_pa_to_va(uintptr_t pa) { if (pa - addrenv[i].pa < addrenv[i].size) { - return (FAR void *)(addrenv[i].va + - B2C(pa - addrenv[i].pa)); + return (FAR void *)(addrenv[i].va + pa - addrenv[i].pa); } } } - return (FAR void *)B2C(pa); + return (FAR void *)pa; } uintptr_t up_addrenv_va_to_pa(FAR void *va_) { FAR struct simple_addrenv_node_s *node; FAR const struct simple_addrenv_s *addrenv; - uintptr_t va = C2B((uintptr_t)va_); + uintptr_t va = (uintptr_t)va_; uint32_t i; list_for_every_entry(&g_addrenv_list, node, @@ -101,7 +100,7 @@ uintptr_t up_addrenv_va_to_pa(FAR void *va_) addrenv = node->addrenv; for (i = 0; addrenv[i].size; i++) { - uintptr_t tmp = C2B(addrenv[i].va); + uintptr_t tmp = addrenv[i].va; if (va - tmp < addrenv[i].size) { return addrenv[i].pa + (va - tmp); diff --git a/drivers/clk/clk.h b/drivers/clk/clk.h index 680669a..e5ac0a6 100644 --- a/drivers/clk/clk.h +++ b/drivers/clk/clk.h @@ -50,13 +50,11 @@ static inline void clk_write(uint32_t reg, uint32_t value) { - reg = reg / (CHAR_BIT / 8); *((volatile uint32_t *) (reg)) = value; } static inline uint32_t clk_read(uint32_t reg) { - reg = reg / (CHAR_BIT / 8); return *((volatile uint32_t *) (reg)); } diff --git a/drivers/rptun/rptun.c b/drivers/rptun/rptun.c index 0110c96..a450276 100644 --- a/drivers/rptun/rptun.c +++ b/drivers/rptun/rptun.c @@ -538,8 +538,8 @@ static int rptun_dev_start(FAR struct remoteproc *rproc) metal_phys_addr_t pa0; metal_phys_addr_t pa1; - align0 = B2C(rsc->rpmsg_vring0.align); - align1 = B2C(rsc->rpmsg_vring1.align); + align0 = rsc->rpmsg_vring0.align; + align1 = rsc->rpmsg_vring1.align; tbsz = ALIGN_UP(sizeof(struct rptun_rsc_s), MAX(align0, align1)); v0sz = ALIGN_UP(vring_size(rsc->rpmsg_vring0.num, align0), align0); diff --git a/drivers/serial/uart_rpmsg.c b/drivers/serial/uart_rpmsg.c index 35798e6..c00839b 100644 --- a/drivers/serial/uart_rpmsg.c +++ b/drivers/serial/uart_rpmsg.c @@ -245,7 +245,7 @@ static void uart_rpmsg_dmasend(FAR struct uart_dev_s *dev) memset(msg, 0, sizeof(*msg)); - space = C2B(space - sizeof(*msg)); + space = space - sizeof(*msg); if (len > space) { @@ -254,13 +254,12 @@ static void uart_rpmsg_dmasend(FAR struct uart_dev_s *dev) if (len > xfer->length) { - cmem2bmem(msg->data, 0, xfer->buffer, xfer->length); - cmem2bmem(msg->data + B2C_OFF(xfer->length), B2C_REM(xfer->length), - xfer->nbuffer, len - xfer->length); + memcpy(msg->data, xfer->buffer, xfer->length); + memcpy(msg->data, xfer->nbuffer, len - xfer->length); } else { - cmem2bmem(msg->data, 0, xfer->buffer, len); + memcpy(msg->data, xfer->buffer, len); } msg->count = len; @@ -268,7 +267,7 @@ static void uart_rpmsg_dmasend(FAR struct uart_dev_s *dev) msg->header.result = -ENXIO; msg->header.cookie = (uintptr_t)dev; - rpmsg_send_nocopy(&priv->ept, msg, sizeof(*msg) + B2C(len)); + rpmsg_send_nocopy(&priv->ept, msg, sizeof(*msg) + len); } static void uart_rpmsg_dmareceive(FAR struct uart_dev_s *dev) @@ -286,13 +285,12 @@ static void uart_rpmsg_dmareceive(FAR struct uart_dev_s *dev) if (len > xfer->length) { - bmem2cmem(xfer->buffer, msg->data, 0, xfer->length); - bmem2cmem(xfer->nbuffer, msg->data + B2C_OFF(xfer->length), - B2C_REM(xfer->length), len - xfer->length); + memcpy(xfer->buffer, msg->data, xfer->length); + memcpy(xfer->nbuffer, msg->data, len - xfer->length); } else { - bmem2cmem(xfer->buffer, msg->data, 0, len); + memcpy(xfer->buffer, msg->data, len); } xfer->nbytes = len; diff --git a/drivers/syslog/syslog_rpmsg.c b/drivers/syslog/syslog_rpmsg.c index e39e8db..54ce570 100644 --- a/drivers/syslog/syslog_rpmsg.c +++ b/drivers/syslog/syslog_rpmsg.c @@ -44,9 +44,7 @@ #define SYSLOG_RPMSG_WORK_DELAY MSEC2TICK(CONFIG_SYSLOG_RPMSG_WORK_DELAY) -#define SYSLOG_RPMSG_COUNT(h, t, size) ((B2C_OFF(h)>=(t)) ? \ - B2C_OFF(h)-(t) : \ - (size)-((t)-B2C_OFF(h))) +#define SYSLOG_RPMSG_COUNT(h, t, size) (((h)>=(t)) ? (h)-(t) : (size)-((t)-(h))) #define SYSLOG_RPMSG_SPACE(h, t, size) ((size) - 1 - SYSLOG_RPMSG_COUNT(h, t, size)) /**************************************************************************** @@ -117,11 +115,6 @@ static void syslog_rpmsg_work(FAR void *priv_) flags = enter_critical_section(); - if (B2C_REM(priv->head)) - { - priv->head += C2B(1) - B2C_REM(priv->head); - } - space -= sizeof(*msg); len = SYSLOG_RPMSG_COUNT(priv->head, priv->tail, priv->size); len_end = priv->size - priv->tail; @@ -147,30 +140,24 @@ static void syslog_rpmsg_work(FAR void *priv_) leave_critical_section(flags); msg->header.command = SYSLOG_RPMSG_TRANSFER; - msg->count = C2B(len); + msg->count = len; rpmsg_send_nocopy(&priv->ept, msg, sizeof(*msg) + len); } static void syslog_rpmsg_putchar(FAR struct syslog_rpmsg_s *priv, int ch, bool last) { - if (B2C_REM(priv->head) == 0) - { - priv->buffer[B2C_OFF(priv->head)] = 0; - } - - priv->buffer[B2C_OFF(priv->head)] |= (ch & 0xff) << - (8 * B2C_REM(priv->head)); + priv->buffer[priv->head] = ch & 0xff; priv->head += 1; - if (priv->head >= C2B(priv->size)) + if (priv->head >= (priv->size)) { priv->head = 0; } /* Allow overwrite */ - if (priv->head == C2B(priv->tail)) + if (priv->head == (priv->tail)) { priv->buffer[priv->tail] = 0; @@ -350,35 +337,31 @@ void syslog_rpmsg_init_early(FAR void *buffer, size_t size) char prev; char cur; size_t i; - size_t j; priv->buffer = buffer; priv->size = size; - prev = (priv->buffer[size - 1] >> (CHAR_BIT - 8)) & 0xff; + prev = priv->buffer[size - 1]; for (i = 0; i < size; i++) { - for (j = 0; j * 8 < CHAR_BIT; j++) - { - cur = (priv->buffer[i] >> j * 8) & 0xff; - - if (!isascii(cur)) - { - memset(priv->buffer, 0, size); - break; - } - else if (prev && !cur) - { - priv->head = C2B(i) + j; - } - else if (!prev && cur) - { - priv->tail = i; - } + cur = priv->buffer[i]; - prev = cur; + if (!isascii(cur)) + { + memset(priv->buffer, 0, size); + break; } + else if (prev && !cur) + { + priv->head = i; + } + else if (!prev && cur) + { + priv->tail = i; + } + + prev = cur; } if (i != size) diff --git a/fs/rpmsgfs/rpmsgfs_client.c b/fs/rpmsgfs/rpmsgfs_client.c index 430a2f4..e3d1fd6 100644 --- a/fs/rpmsgfs/rpmsgfs_client.c +++ b/fs/rpmsgfs/rpmsgfs_client.c @@ -147,7 +147,7 @@ static int rpmsgfs_read_handler(FAR struct rpmsg_endpoint *ept, cookie->result = header->result; if (cookie->result > 0) { - memcpy(cookie->data, rsp->buf, B2C(cookie->result)); + memcpy(cookie->data, rsp->buf, cookie->result); } nxsem_post(&cookie->sem); @@ -168,7 +168,7 @@ static int rpmsgfs_readdir_handler(FAR struct rpmsg_endpoint *ept, cookie->result = header->result; if (cookie->result >= 0) { - nbstr2cstr(entry->d_name, rsp->name, NAME_MAX); + strncpy(entry->d_name, rsp->name, NAME_MAX); entry->d_name[NAME_MAX] = '\0'; entry->d_type = rsp->type; } @@ -193,7 +193,7 @@ static int rpmsgfs_statfs_handler(FAR struct rpmsg_endpoint *ept, { buf->f_type = rsp->buf.f_type; buf->f_namelen = rsp->buf.f_namelen; - buf->f_bsize = B2C(rsp->buf.f_bsize); + buf->f_bsize = rsp->buf.f_bsize; buf->f_blocks = rsp->buf.f_blocks; buf->f_bfree = rsp->buf.f_bfree; buf->f_bavail = rsp->buf.f_bavail; @@ -226,11 +226,11 @@ static int rpmsgfs_stat_handler(FAR struct rpmsg_endpoint *ept, buf->st_uid = rsp->buf.st_uid; buf->st_gid = rsp->buf.st_gid; buf->st_rdev = rsp->buf.st_rdev; - buf->st_size = B2C(rsp->buf.st_size); + buf->st_size = rsp->buf.st_size; buf->st_atime = rsp->buf.st_atime; buf->st_mtime = rsp->buf.st_mtime; buf->st_ctime = rsp->buf.st_ctime; - buf->st_blksize = B2C(rsp->buf.st_blksize); + buf->st_blksize = rsp->buf.st_blksize; buf->st_blocks = rsp->buf.st_blocks; } @@ -344,7 +344,7 @@ int rpmsgfs_client_open(FAR void *handle, FAR const char *pathname, size_t len; len = sizeof(*msg); - len += B2C(strlen(pathname) + 1); + len += strlen(pathname) + 1; msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); if (!msg) @@ -356,7 +356,7 @@ int rpmsgfs_client_open(FAR void *handle, FAR const char *pathname, msg->flags = flags; msg->mode = mode; - cstr2bstr(msg->pathname, pathname); + strcpy(msg->pathname, pathname); return rpmsgfs_send_recv(priv, RPMSGFS_OPEN, false, (struct rpmsgfs_header_s *)msg, len, NULL); @@ -384,7 +384,7 @@ ssize_t rpmsgfs_client_read(FAR void *handle, int fd, struct rpmsgfs_read_s msg = { .fd = fd, - .count = C2B(count - read), + .count = count - read, }; ret = rpmsgfs_send_recv(handle, RPMSGFS_READ, true, @@ -394,8 +394,8 @@ ssize_t rpmsgfs_client_read(FAR void *handle, int fd, break; } - read += B2C(ret); - buf += B2C(ret); + read += ret; + buf += ret; } return read ? read : ret; @@ -427,7 +427,7 @@ ssize_t rpmsgfs_client_write(FAR void *handle, int fd, } msg->fd = fd; - msg->count = C2B(space); + msg->count = space; memcpy(msg->buf, buf + written, space); ret = rpmsgfs_send_recv(priv, RPMSGFS_WRITE, false, @@ -438,7 +438,7 @@ ssize_t rpmsgfs_client_write(FAR void *handle, int fd, break; } - written += B2C(ret); + written += ret; } return written ? written : ret; @@ -450,7 +450,7 @@ off_t rpmsgfs_client_lseek(FAR void *handle, int fd, struct rpmsgfs_lseek_s msg = { .fd = fd, - .offset = C2B(offset), + .offset = offset, .whence = whence, }; @@ -459,7 +459,7 @@ off_t rpmsgfs_client_lseek(FAR void *handle, int fd, ret = rpmsgfs_send_recv(handle, RPMSGFS_LSEEK, true, (struct rpmsgfs_header_s *)&msg, sizeof(msg), NULL); - return ret < 0 ? ret : B2C(ret); + return ret < 0 ? ret : ret; } int rpmsgfs_client_ioctl(FAR void *handle, int fd, @@ -530,7 +530,7 @@ FAR void *rpmsgfs_client_opendir(FAR void *handle, FAR const char *name) int ret; len = sizeof(*msg); - len += B2C(strlen(name) + 1); + len += strlen(name) + 1; msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); if (!msg) @@ -540,7 +540,7 @@ FAR void *rpmsgfs_client_opendir(FAR void *handle, FAR const char *name) DEBUGASSERT(len <= space); - cstr2bstr(msg->pathname, name); + strcpy(msg->pathname, name); ret = rpmsgfs_send_recv(priv, RPMSGFS_OPENDIR, false, (struct rpmsgfs_header_s *)msg, len, NULL); @@ -636,7 +636,7 @@ int rpmsgfs_client_statfs(FAR void *handle, FAR const char *path, size_t len; len = sizeof(*msg); - len += B2C(strlen(path) + 1); + len += strlen(path) + 1; msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); if (!msg) @@ -646,7 +646,7 @@ int rpmsgfs_client_statfs(FAR void *handle, FAR const char *path, DEBUGASSERT(len <= space); - cstr2bstr(msg->pathname, path); + strcpy(msg->pathname, path); return rpmsgfs_send_recv(priv, RPMSGFS_STATFS, false, (struct rpmsgfs_header_s *)msg, len, buf); @@ -660,7 +660,7 @@ int rpmsgfs_client_unlink(FAR void *handle, FAR const char *pathname) size_t len; len = sizeof(*msg); - len += B2C(strlen(pathname) + 1); + len += strlen(pathname) + 1; msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); if (!msg) @@ -670,7 +670,7 @@ int rpmsgfs_client_unlink(FAR void *handle, FAR const char *pathname) DEBUGASSERT(len <= space); - cstr2bstr(msg->pathname, pathname); + strcpy(msg->pathname, pathname); return rpmsgfs_send_recv(priv, RPMSGFS_UNLINK, false, (struct rpmsgfs_header_s *)msg, len, NULL); @@ -685,7 +685,7 @@ int rpmsgfs_client_mkdir(FAR void *handle, FAR const char *pathname, size_t len; len = sizeof(*msg); - len += B2C(strlen(pathname) + 1); + len += strlen(pathname) + 1; msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); if (!msg) @@ -694,7 +694,7 @@ int rpmsgfs_client_mkdir(FAR void *handle, FAR const char *pathname, } msg->mode = mode; - cstr2bstr(msg->pathname, pathname); + strcpy(msg->pathname, pathname); return rpmsgfs_send_recv(priv, RPMSGFS_MKDIR, false, (struct rpmsgfs_header_s *)msg, len, NULL); @@ -708,7 +708,7 @@ int rpmsgfs_client_rmdir(FAR void *handle, FAR const char *pathname) size_t len; len = sizeof(*msg); - len += B2C(strlen(pathname) + 1); + len += strlen(pathname) + 1; msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); if (!msg) @@ -718,7 +718,7 @@ int rpmsgfs_client_rmdir(FAR void *handle, FAR const char *pathname) DEBUGASSERT(len <= space); - cstr2bstr(msg->pathname, pathname); + strcpy(msg->pathname, pathname); return rpmsgfs_send_recv(priv, RPMSGFS_RMDIR, false, (struct rpmsgfs_header_s *)msg, len, NULL); @@ -734,8 +734,8 @@ int rpmsgfs_client_rename(FAR void *handle, FAR const char *oldpath, uint32_t space; len = sizeof(*msg); - oldlen = B2C((strlen(oldpath) + 1 + 0x7) & ~0x7); - len += oldlen + B2C(strlen(newpath) + 1); + oldlen = (strlen(oldpath) + 1 + 0x7) & ~0x7; + len += oldlen + strlen(newpath) + 1; msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); if (!msg) @@ -745,8 +745,8 @@ int rpmsgfs_client_rename(FAR void *handle, FAR const char *oldpath, DEBUGASSERT(len <= space); - cstr2bstr(msg->pathname, oldpath); - cstr2bstr(msg->pathname + oldlen, newpath); + strcpy(msg->pathname, oldpath); + strcpy(msg->pathname + oldlen, newpath); return rpmsgfs_send_recv(priv, RPMSGFS_RENAME, false, (struct rpmsgfs_header_s *)msg, len, NULL); @@ -761,7 +761,7 @@ int rpmsgfs_client_stat(FAR void *handle, FAR const char *path, size_t len; len = sizeof(*msg); - len += B2C(strlen(path) + 1); + len += strlen(path) + 1; msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); if (!msg) @@ -771,7 +771,7 @@ int rpmsgfs_client_stat(FAR void *handle, FAR const char *path, DEBUGASSERT(len <= space); - cstr2bstr(msg->pathname, path); + strcpy(msg->pathname, path); return rpmsgfs_send_recv(priv, RPMSGFS_STAT, false, (struct rpmsgfs_header_s *)msg, len, buf); @@ -800,7 +800,7 @@ int rpmsgfs_client_chstat(FAR void *handle, FAR const char *path, size_t len; len = sizeof(*msg); - len += B2C(strlen(path) + 1); + len += strlen(path) + 1; msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); if (!msg) @@ -812,7 +812,7 @@ int rpmsgfs_client_chstat(FAR void *handle, FAR const char *path, msg->flags = flags; memcpy(&msg->buf, buf, sizeof(*buf)); - cstr2bstr(msg->pathname, path); + strcpy(msg->pathname, path); return rpmsgfs_send_recv(priv, RPMSGFS_CHSTAT, false, (struct rpmsgfs_header_s *)msg, len, NULL); diff --git a/include/nuttx/b2c.h b/include/nuttx/b2c.h deleted file mode 100644 index bc01c6f..0000000 --- a/include/nuttx/b2c.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** - * include/nuttx/b2c.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __INCLUDE_NUTTX_B2C_H -#define __INCLUDE_NUTTX_B2C_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <sys/types.h> -#include <string.h> -#include <limits.h> - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#if CHAR_BIT == 8 -# define CHAR_BYTE 1 -# define CHAR_SHIFT 0 -#elif CHAR_BIT == 16 -# define CHAR_BYTE 2 -# define CHAR_SHIFT 1 -#elif CHAR_BIT == 32 -# define CHAR_BYTE 4 -# define CHAR_SHIFT 2 -#else -# error unsupported CHAR_BIT value -#endif - -/* Macros convert between chars and bytes */ - -#define B2C(x) (((x) + CHAR_BYTE - 1) >> CHAR_SHIFT) -#define C2B(x) ((x) << CHAR_SHIFT) - -#define B2C_OFF(x) ((x) >> CHAR_SHIFT) -#define C2B_OFF(x) ((x) << CHAR_SHIFT) - -#define B2C_REM(x) ((x) - C2B_OFF(B2C_OFF(x))) - -#define B2C_SHIFT(x) ((x) - CHAR_SHIFT) -#define C2B_SHIFT(x) ((x) + CHAR_SHIFT) - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/* Functions convert between chars and bytes */ - -#if CHAR_BIT != 8 - -size_t bstrnlen(FAR const char *src, size_t maxlen); - -FAR char *ancstr2bstr(FAR const char *src, size_t maxlen); -FAR char *anbstr2cstr(FAR const char *src, size_t maxlen); - -void ncstr2bstr(FAR char *dst, FAR const char *src, size_t maxlen); -void nbstr2cstr(FAR char *dst, FAR const char *src, size_t maxlen); - -void cmem2bmem(FAR void *dst, size_t rem, FAR const void *src, size_t len); -void bmem2cmem(FAR void *dst, FAR const void *src, size_t rem, size_t len); - -# define cstr2bstr(dst, src) ncstr2bstr(dst, src, SIZE_MAX) -# define bstr2cstr(dst, src) nbstr2cstr(dst, src, SIZE_MAX) - -#else - -# define bstrnlen(src, maxlen) strnlen(src, maxlen) - -# define ancstr2bstr(src, maxlen) strndup(src, maxlen) -# define anbstr2cstr(src, maxlen) strndup(src, maxlen) - -# define ncstr2bstr(dst, src, maxlen) strncpy(dst, src, maxlen) -# define nbstr2cstr(dst, src, maxlen) strncpy(dst, src, maxlen) - -# define cmem2bmem(dst, rem, src, len) memcpy((FAR char *)(dst) + rem, src, len) -# define bmem2cmem(dst, src, rem, len) memcpy(dst, (FAR char *)(src) + rem, len) - -# define cstr2bstr(dst, src) strcpy(dst, src) -# define bstr2cstr(dst, src) strcpy(dst, src) - -#endif - -#define bstrlen(src) bstrnlen(src, SIZE_MAX) - -#define acstr2bstr(src) ancstr2bstr(src, SIZE_MAX) -#define abstr2cstr(src) anbstr2cstr(src, SIZE_MAX) - -#endif /* __INCLUDE_NUTTX_B2C_H */ diff --git a/include/nuttx/rptun/rptun.h b/include/nuttx/rptun/rptun.h index 88d2cce..c875643 100644 --- a/include/nuttx/rptun/rptun.h +++ b/include/nuttx/rptun/rptun.h @@ -265,7 +265,7 @@ struct rptun_addrenv_s size_t size; }; -struct aligned_data(B2C(8)) rptun_rsc_s +struct aligned_data(8) rptun_rsc_s { struct resource_table rsc_tbl_hdr; unsigned int offset[2]; diff --git a/include/string.h b/include/string.h index c7ff9d1..268483f 100644 --- a/include/string.h +++ b/include/string.h @@ -29,12 +29,6 @@ #include <stddef.h> -/* Non-standard support for cases where CHAR_BIT != 8 carried in strings.h - * only for convenience. See include/nuttx/b2c.h. - */ - -#include <nuttx/b2c.h> - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ diff --git a/libs/libc/string/Make.defs b/libs/libc/string/Make.defs index aa23791..8955cb7 100644 --- a/libs/libc/string/Make.defs +++ b/libs/libc/string/Make.defs @@ -29,8 +29,6 @@ CSRCS += lib_strerror.c lib_strncasecmp.c lib_strncat.c lib_strncmp.c CSRCS += lib_strndup.c lib_strcasestr.c lib_strpbrk.c lib_strrchr.c CSRCS += lib_strspn.c lib_strstr.c lib_strtok.c lib_strtokr.c CSRCS += lib_strsep.c lib_strerrorr.c lib_explicit_bzero.c lib_strsignal.c -CSRCS += lib_anbstr2cstr.c lib_ancstr2bstr.c lib_bmem2cmem.c -CSRCS += lib_bstrnlen.c lib_cmem2bmem.c lib_nbstr2cstr.c lib_ncstr2bstr.c CSRCS += lib_index.c lib_rindex.c ifneq ($(CONFIG_LIBC_ARCH_MEMCHR),y) diff --git a/libs/libc/string/lib_anbstr2cstr.c b/libs/libc/string/lib_anbstr2cstr.c deleted file mode 100644 index 98b92fa..0000000 --- a/libs/libc/string/lib_anbstr2cstr.c +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** - * libs/libc/string/lib_anbstr2cstr.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdlib.h> -#include <string.h> - -#include "libc.h" - -#if CHAR_BIT != 8 - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -FAR char *anbstr2cstr(FAR const char *src, size_t maxlen) -{ - FAR char *dst; - size_t len; - - len = bstrnlen(src, maxlen); - dst = lib_malloc(C2B(len + 1)); - if (dst) - { - dst[C2B(len + 1) - 1] = 0; - bmem2cmem(dst, src, 0, len); - } - - return dst; -} - -#endif diff --git a/libs/libc/string/lib_ancstr2bstr.c b/libs/libc/string/lib_ancstr2bstr.c deleted file mode 100644 index fe5c1a5..0000000 --- a/libs/libc/string/lib_ancstr2bstr.c +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** - * libs/libc/string/lib_ancstr2bstr.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdlib.h> -#include <string.h> - -#include "libc.h" - -#if CHAR_BIT != 8 - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -FAR char *ancstr2bstr(FAR const char *src, size_t maxlen) -{ - FAR char *dst; - size_t len; - - len = strnlen(src, maxlen); - dst = lib_malloc(B2C(len + 1)); - if (dst) - { - dst[B2C(len + 1) - 1] = 0; - cmem2bmem(dst, 0, src, len); - } - - return dst; -} - -#endif diff --git a/libs/libc/string/lib_bmem2cmem.c b/libs/libc/string/lib_bmem2cmem.c deleted file mode 100644 index 56175f2..0000000 --- a/libs/libc/string/lib_bmem2cmem.c +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** - * libs/libc/string/lib_bmem2cmem.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdlib.h> - -#if !defined(CONFIG_ENDIAN_BIG) && CHAR_BIT != 8 - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -void bmem2cmem(FAR void *dst_, FAR const void *src_, size_t rem, size_t len) -{ - char *dst = dst_; - const char *src = src_; - - while (1) - { - int i; - - for (i = 8 * rem; i < CHAR_BIT; i += 8) - { - if (len-- == 0) - { - return; - } - - *dst++ = (*src >> i) & 0xff; - } - - rem = 0; - src++; - } -} - -#endif diff --git a/libs/libc/string/lib_bstrnlen.c b/libs/libc/string/lib_bstrnlen.c deleted file mode 100644 index 7466628..0000000 --- a/libs/libc/string/lib_bstrnlen.c +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** - * libs/libc/string/lib_bstrnlen.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdlib.h> - -#if !defined(CONFIG_ENDIAN_BIG) && CHAR_BIT != 8 - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -size_t bstrnlen(FAR const char *src, size_t maxlen) -{ - size_t len = 0; - - while (1) - { - int i; - - for (i = 0; i < CHAR_BIT; i += 8, len++) - { - if (maxlen-- == 0 || ((*src >> i) & 0xff) == 0) - { - return len; - } - } - - src++; - } -} - -#endif diff --git a/libs/libc/string/lib_cmem2bmem.c b/libs/libc/string/lib_cmem2bmem.c deleted file mode 100644 index 0efca81..0000000 --- a/libs/libc/string/lib_cmem2bmem.c +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** - * libs/libc/string/lib_cmem2bmem.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdlib.h> - -#if !defined(CONFIG_ENDIAN_BIG) && CHAR_BIT != 8 - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -void cmem2bmem(FAR void *dst_, size_t rem, FAR const void *src_, size_t len) -{ - char *dst = dst_; - const char *src = src_; - - while (1) - { - int i; - - for (i = 8 * rem; i < CHAR_BIT; i += 8) - { - if (len-- == 0) - { - return; - } - else if (i == 8 * rem) - { - *dst = 0; - } - - *dst |= (*src++ & 0xff) << i; - } - - rem = 0; - dst++; - } -} - -#endif diff --git a/libs/libc/string/lib_nbstr2cstr.c b/libs/libc/string/lib_nbstr2cstr.c deleted file mode 100644 index d593f67..0000000 --- a/libs/libc/string/lib_nbstr2cstr.c +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** - * libs/libc/string/lib_nbstr2cstr.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdlib.h> - -#if !defined(CONFIG_ENDIAN_BIG) && CHAR_BIT != 8 - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -void nbstr2cstr(FAR char *dst, FAR const char *src, size_t maxlen) -{ - while (1) - { - int i; - - for (i = 0; i < CHAR_BIT; i += 8) - { - if (maxlen-- == 0) - { - return; - } - - *dst = (*src >> i) & 0xff; - if (*dst++ == 0) - { - return; - } - } - - src++; - } -} - -#endif diff --git a/libs/libc/string/lib_ncstr2bstr.c b/libs/libc/string/lib_ncstr2bstr.c deleted file mode 100644 index 29bcc8a..0000000 --- a/libs/libc/string/lib_ncstr2bstr.c +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** - * libs/libc/string/lib_ncstr2bstr.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdlib.h> - -#if !defined(CONFIG_ENDIAN_BIG) && CHAR_BIT != 8 - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -void ncstr2bstr(FAR char *dst, FAR const char *src, size_t maxlen) -{ - while (1) - { - int i; - - for (i = 0; i < CHAR_BIT; i += 8) - { - char tmp; - - if (maxlen-- == 0) - { - return; - } - else if (i == 0) - { - *dst = 0; - } - - tmp = *src++ & 0xff; - if (tmp == 0) - { - return; - } - - *dst |= tmp << i; - } - - dst++; - } -} - -#endif diff --git a/mm/mm_heap/mm.h b/mm/mm_heap/mm.h index 141920f..a68775e 100644 --- a/mm/mm_heap/mm.h +++ b/mm/mm_heap/mm.h @@ -63,8 +63,8 @@ * REVISIT: We could do better on machines with 16-bit addressing. */ -# define MM_MIN_SHIFT B2C_SHIFT( 4) /* 16 bytes */ -# define MM_MAX_SHIFT B2C_SHIFT(15) /* 32 Kb */ +# define MM_MIN_SHIFT ( 4) /* 16 bytes */ +# define MM_MAX_SHIFT (15) /* 32 Kb */ #elif defined(CONFIG_HAVE_LONG_LONG) /* Four byte offsets; Pointers may be 4 or 8 bytes @@ -72,19 +72,19 @@ */ # if UINTPTR_MAX <= UINT32_MAX -# define MM_MIN_SHIFT B2C_SHIFT( 4) /* 16 bytes */ +# define MM_MIN_SHIFT ( 4) /* 16 bytes */ # elif UINTPTR_MAX <= UINT64_MAX -# define MM_MIN_SHIFT B2C_SHIFT( 5) /* 32 bytes */ +# define MM_MIN_SHIFT ( 5) /* 32 bytes */ # endif -# define MM_MAX_SHIFT B2C_SHIFT(22) /* 4 Mb */ +# define MM_MAX_SHIFT (22) /* 4 Mb */ #else /* Four byte offsets; Pointers must be 4 bytes. * sizeof(struct mm_freenode_s) is 16 bytes. */ -# define MM_MIN_SHIFT B2C_SHIFT( 4) /* 16 bytes */ -# define MM_MAX_SHIFT B2C_SHIFT(22) /* 4 Mb */ +# define MM_MIN_SHIFT ( 4) /* 16 bytes */ +# define MM_MAX_SHIFT (22) /* 4 Mb */ #endif /* All other definitions derive from these two */ @@ -137,9 +137,9 @@ struct mm_allocnode_s /* What is the size of the allocnode? */ #ifdef CONFIG_MM_SMALL -# define SIZEOF_MM_ALLOCNODE B2C(4) +# define SIZEOF_MM_ALLOCNODE (4) #else -# define SIZEOF_MM_ALLOCNODE B2C(8) +# define SIZEOF_MM_ALLOCNODE (8) #endif #define CHECK_ALLOCNODE_SIZE \
