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 <liguiding1@xiaomi.com>
This commit is contained in:
ligd
2021-12-08 12:20:35 +08:00
committed by Xiang Xiao
parent db6dd623c6
commit 5b369c5cec
18 changed files with 77 additions and 627 deletions
-2
View File
@@ -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)
-54
View File
@@ -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
-54
View File
@@ -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
-59
View File
@@ -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
-55
View File
@@ -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
-63
View File
@@ -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
-59
View File
@@ -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
-67
View File
@@ -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