libs: nxstyle fixes

nxstyle fixes to pass the CI checks

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
This commit is contained in:
Alin Jerpelea 2021-03-02 14:33:27 +01:00 committed by Xiang Xiao
parent 796ef13b20
commit d6b50a1d3f
93 changed files with 475 additions and 348 deletions

View File

@ -33,6 +33,7 @@
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Configuration ************************************************************/ /* Configuration ************************************************************/
/**************************************************************************** /****************************************************************************

View File

@ -33,6 +33,7 @@
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Configuration ************************************************************/ /* Configuration ************************************************************/
/**************************************************************************** /****************************************************************************

View File

@ -78,19 +78,20 @@ int readdir_r(FAR DIR *dirp, FAR struct dirent *entry,
tmp = readdir(dirp); tmp = readdir(dirp);
if (!tmp) if (!tmp)
{ {
int error = get_errno(); int error = get_errno();
if (!error) if (!error)
{ {
if (result) if (result)
{ {
*result = NULL; *result = NULL;
} }
return 0;
} return 0;
else }
{ else
return error; {
} return error;
}
} }
if (entry) if (entry)
@ -102,5 +103,6 @@ int readdir_r(FAR DIR *dirp, FAR struct dirent *entry,
{ {
*result = entry; *result = entry;
} }
return 0; return 0;
} }

View File

@ -32,9 +32,9 @@
#ifndef __SWAP_UINT32_ISMACRO #ifndef __SWAP_UINT32_ISMACRO
uint32_t __swap_uint32(uint32_t n) uint32_t __swap_uint32(uint32_t n)
{ {
return (uint32_t)(((((uint32_t)(n)) & 0x000000ffUL) << 24) | return (uint32_t)(((((uint32_t)(n)) & 0x000000fful) << 24) |
((((uint32_t)(n)) & 0x0000ff00UL) << 8) | ((((uint32_t)(n)) & 0x0000ff00ul) << 8) |
((((uint32_t)(n)) & 0x00ff0000UL) >> 8) | ((((uint32_t)(n)) & 0x00ff0000ul) >> 8) |
((((uint32_t)(n)) & 0xff000000UL) >> 24)); ((((uint32_t)(n)) & 0xff000000ul) >> 24));
} }
#endif #endif

View File

@ -34,13 +34,13 @@
#ifdef CONFIG_HAVE_LONG_LONG #ifdef CONFIG_HAVE_LONG_LONG
uint64_t __swap_uint64(uint64_t n) uint64_t __swap_uint64(uint64_t n)
{ {
return (uint64_t)(((((uint64_t)(n)) & 0x00000000000000ffULL) << 56) | return (uint64_t)(((((uint64_t)(n)) & 0x00000000000000ffull) << 56) |
((((uint64_t)(n)) & 0x000000000000ff00ULL) << 40) | ((((uint64_t)(n)) & 0x000000000000ff00ull) << 40) |
((((uint64_t)(n)) & 0x0000000000ff0000ULL) << 24) | ((((uint64_t)(n)) & 0x0000000000ff0000ull) << 24) |
((((uint64_t)(n)) & 0x00000000ff000000ULL) << 8) | ((((uint64_t)(n)) & 0x00000000ff000000ull) << 8) |
((((uint64_t)(n)) & 0x000000ff00000000ULL) >> 8) | ((((uint64_t)(n)) & 0x000000ff00000000ull) >> 8) |
((((uint64_t)(n)) & 0x0000ff0000000000ULL) >> 24) | ((((uint64_t)(n)) & 0x0000ff0000000000ull) >> 24) |
((((uint64_t)(n)) & 0x00ff000000000000ULL) >> 40) | ((((uint64_t)(n)) & 0x00ff000000000000ull) >> 40) |
((((uint64_t)(n)) & 0xff00000000000000ULL) >> 56)); ((((uint64_t)(n)) & 0xff00000000000000ull) >> 56));
} }
#endif #endif

View File

@ -45,5 +45,6 @@ b16_t b16cos(b16_t rad)
{ {
rad -= b16TWOPI; rad -= b16TWOPI;
} }
return b16sin(rad); return b16sin(rad);
} }

View File

@ -38,7 +38,8 @@
/**************************************************************************** /****************************************************************************
* Name: b16sin * Name: b16sin
* Ref: http://lab.polygonal.de/2007/07/18/fast-and-accurate-sinecosine-approximation/ * Ref:
* lab.polygonal.de/2007/07/18/fast-and-accurate-sinecosine-approximation/
****************************************************************************/ ****************************************************************************/
b16_t b16sin(b16_t rad) b16_t b16sin(b16_t rad)
@ -54,29 +55,28 @@ b16_t b16sin(b16_t rad)
rad += b16TWOPI; rad += b16TWOPI;
} }
else if (rad > b16PI) else if (rad > b16PI)
{ {
rad -= b16TWOPI; rad -= b16TWOPI;
} }
/* tmp1 = 1.27323954 * rad /* tmp1 = 1.27323954 * rad
* tmp2 = .405284735 * rad * rad * tmp2 = .405284735 * rad * rad
*/ */
tmp1 = b16mulb16(b16_1P27323954, rad); tmp1 = b16mulb16(b16_1P27323954, rad);
tmp2 = b16mulb16(b16_P405284735, b16sqr(rad)); tmp2 = b16mulb16(b16_P405284735, b16sqr(rad));
if (rad < 0) if (rad < 0)
{ {
/* tmp3 = 1.27323954 * rad + .405284735 * rad * rad */ /* tmp3 = 1.27323954 * rad + .405284735 * rad * rad */
tmp3 = tmp1 + tmp2; tmp3 = tmp1 + tmp2;
} }
else else
{ {
/* tmp3 = 1.27323954 * rad - 0.405284735 * rad * rad */ /* tmp3 = 1.27323954 * rad - 0.405284735 * rad * rad */
tmp3 = tmp1 - tmp2; tmp3 = tmp1 - tmp2;
} }
/* tmp1 = tmp3*tmp3 */ /* tmp1 = tmp3*tmp3 */

View File

@ -171,6 +171,7 @@ b16_t b16sqr(b16_t a)
{ {
sq = b16MAX; sq = b16MAX;
} }
return sq; return sq;
} }
@ -236,7 +237,7 @@ ub16_t ub16divub16(ub16_t num, ub16_t denom)
term1 = ((uint32_t)num & 0xffff0000) / denom; term1 = ((uint32_t)num & 0xffff0000) / denom;
if (term1 >= 0x00010000) if (term1 >= 0x00010000)
{ {
return ub16MAX; /* Will overflow */ return ub16MAX; /* Will overflow */
} }
/* Finish the division */ /* Finish the division */
@ -249,8 +250,9 @@ ub16_t ub16divub16(ub16_t num, ub16_t denom)
if (product < term1) if (product < term1)
{ {
return ub16MAX; /* Overflowed */ return ub16MAX; /* Overflowed */
} }
return product; return product;
} }

View File

@ -37,4 +37,8 @@
struct group g_group; struct group g_group;
char g_group_buffer[GRPBUF_RESERVE_SIZE]; char g_group_buffer[GRPBUF_RESERVE_SIZE];
/****************************************************************************
* Public Functions
****************************************************************************/
#endif /* CONFIG_LIBC_GROUP_FILE */ #endif /* CONFIG_LIBC_GROUP_FILE */

View File

@ -80,12 +80,13 @@ FAR char *basename(FAR char *path)
/* Check for trailing slash characters */ /* Check for trailing slash characters */
len = strlen(path); len = strlen(path);
while (path[len-1] == '/') while (path[len - 1] == '/')
{ {
/* Remove trailing '/' UNLESS this would make a zero length string */ /* Remove trailing '/' UNLESS this would make a zero length string */
if (len > 1) if (len > 1)
{ {
path[len-1] = '\0'; path[len - 1] = '\0';
len--; len--;
} }
else else

View File

@ -80,12 +80,13 @@ FAR char *dirname(FAR char *path)
/* Check for trailing slash characters */ /* Check for trailing slash characters */
len = strlen(path); len = strlen(path);
while (path[len-1] == '/') while (path[len - 1] == '/')
{ {
/* Remove trailing '/' UNLESS this would make a zero length string */ /* Remove trailing '/' UNLESS this would make a zero length string */
if (len > 1) if (len > 1)
{ {
path[len-1] = '\0'; path[len - 1] = '\0';
len--; len--;
} }
else else
@ -102,8 +103,8 @@ FAR char *dirname(FAR char *path)
p = strrchr(path, '/'); p = strrchr(path, '/');
if (p) if (p)
{ {
/* Handle the case where the only '/' in the string is the at the beginning /* Handle the case where the only '/' in the string is the at the
* of the path. * beginning of the path.
*/ */
if (p == path) if (p == path)

View File

@ -49,6 +49,7 @@
FAR char *setlocale(int category, FAR const char *locale) FAR char *setlocale(int category, FAR const char *locale)
{ {
return ((locale == NULL || strcmp(locale, "POSIX") == 0 || return ((locale == NULL || strcmp(locale, "POSIX") == 0 ||
strcmp(locale, "C") == 0 || strcmp(locale, "") == 0) ? "C" : NULL); strcmp(locale, "C") == 0 || strcmp(locale, "") ==
0) ? "C" : NULL);
} }
#endif #endif

View File

@ -1,28 +1,30 @@
/**************************************************************************** /****************************************************************************
* libs/libc/lzf/lzf.h * libs/libc/lzf/lzf.h
* *
* Copyright (c) 2000-2007 Marc Alexander Lehmann <schmorp@schmorp.de> * Copyright (c) 2000-2007
* Author: Marc Alexander Lehmann <schmorp@schmorp.de>
* *
* Redistribution and use in source and binary forms, with or without modifica- * Redistribution and use in source and binary forms, with or without
* tion, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are
* met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright
* this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* OF THE POSSIBILITY OF SUCH DAMAGE. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
****************************************************************************/ ****************************************************************************/
@ -80,7 +82,7 @@ using namespace std;
* and might also be slower. Default is to autodetect. * and might also be slower. Default is to autodetect.
*/ */
/*#define LZF_USER_OFFSETS autodetect */ /* #define LZF_USER_OFFSETS autodetect */
#ifndef LZF_USE_OFFSETS #ifndef LZF_USE_OFFSETS
# define LZF_USE_OFFSETS (UINTPTR_MAX > 0xffffffffU) # define LZF_USE_OFFSETS (UINTPTR_MAX > 0xffffffffU)

View File

@ -3,26 +3,27 @@
* *
* Copyright (c) 2000-2010 Marc Alexander Lehmann <schmorp@schmorp.de> * Copyright (c) 2000-2010 Marc Alexander Lehmann <schmorp@schmorp.de>
* *
* Redistribution and use in source and binary forms, with or without modifica- * Redistribution and use in source and binary forms, with or without
* tion, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions
* are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright
* this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * INCIDENTAL, SPE- CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* OF THE POSSIBILITY OF SUCH DAMAGE. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
****************************************************************************/ ****************************************************************************/
@ -208,10 +209,10 @@ size_t lzf_compress(FAR const void *const in_data,
} }
} }
op[- lit - 1] = lit - 1; /* Stop run */ op[(- lit) - 1] = lit - 1; /* Stop run */
op -= !lit; /* Undo run if length is zero */ op -= !lit; /* Undo run if length is zero */
for (;;) for (; ; )
{ {
if (expect_true(maxlen > 16)) if (expect_true(maxlen > 16))
{ {
@ -330,7 +331,7 @@ size_t lzf_compress(FAR const void *const in_data,
} }
else else
{ {
*op++ = (off >> 8) + ( 7 << 5); *op++ = (off >> 8) + (7 << 5);
*op++ = len - 7; *op++ = len - 7;
} }
@ -388,8 +389,8 @@ size_t lzf_compress(FAR const void *const in_data,
if (expect_false(lit == MAX_LIT)) if (expect_false(lit == MAX_LIT))
{ {
op[- lit - 1] = lit - 1; /* Stop run */ op[(- lit) - 1] = lit - 1; /* Stop run */
lit = 0; /* Start run */ lit = 0; /* Start run */
op++; op++;
} }
} }
@ -409,14 +410,14 @@ size_t lzf_compress(FAR const void *const in_data,
if (expect_false(lit == MAX_LIT)) if (expect_false(lit == MAX_LIT))
{ {
op[- lit - 1] = lit - 1; /* Stop run */ op[(- lit) - 1] = lit - 1; /* Stop run */
lit = 0; /* Start run */ lit = 0; /* Start run */
op++; op++;
} }
} }
op[- lit - 1] = lit - 1; /* End run */ op[(- lit) - 1] = lit - 1; /* End run */
op -= !lit; /* Undo run if length is zero */ op -= !lit; /* Undo run if length is zero */
cs = op - (uint8_t *)out_data; cs = op - (uint8_t *)out_data;

View File

@ -1,28 +1,30 @@
/**************************************************************************** /****************************************************************************
* libs/libc/lzf/lzf_c.c * libs/libc/lzf/lzf_c.c
* *
* Copyright (c) 2000-2010 Marc Alexander Lehmann <schmorp@schmorp.de> * Copyright (c) 2000-2010
* Author: Marc Alexander Lehmann <schmorp@schmorp.de>
* *
* Redistribution and use in source and binary forms, with or without modifica- * Redistribution and use in source and binary forms, with or without
* tion, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are
* met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright
* this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * OF MER CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * (INCLUDING NEGLIGENCE OR OTH- ERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* OF THE POSSIBILITY OF SUCH DAMAGE. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
****************************************************************************/ ****************************************************************************/
@ -204,6 +206,7 @@ unsigned int lzf_decompress (FAR const void *const in_data,
set_errno(EINVAL); set_errno(EINVAL);
return 0; return 0;
} }
#endif #endif
if (len == 7) if (len == 7)
{ {
@ -288,6 +291,7 @@ unsigned int lzf_decompress (FAR const void *const in_data,
*op++ = *ref++; *op++ = *ref++;
case 0: case 0:
/* Two octets more */ /* Two octets more */
*op++ = *ref++; *op++ = *ref++;

View File

@ -77,7 +77,8 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
if (ehdr->e_ident[EI_CLASS] != ELFCLASS32) if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
{ {
berr("ERROR: Need 32-bit objects: e_ident[EI_CLASS]=%02x\n", ehdr->e_ident[EI_CLASS]); berr("ERROR: Need 32-bit objects: e_ident[EI_CLASS]=%02x\n",
ehdr->e_ident[EI_CLASS]);
return false; return false;
} }
@ -89,7 +90,8 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB)
#endif #endif
{ {
berr("ERROR: Wrong endian-ness: e_ident[EI_DATA]=%02x\n", ehdr->e_ident[EI_DATA]); berr("ERROR: Wrong endian-ness: e_ident[EI_DATA]=%02x\n",
ehdr->e_ident[EI_DATA]);
return false; return false;
} }
@ -97,11 +99,13 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
if ((ehdr->e_entry & 3) != 0) if ((ehdr->e_entry & 3) != 0)
{ {
berr("ERROR: Entry point is not properly aligned: %08x\n", ehdr->e_entry); berr("ERROR: Entry point is not properly aligned: %08x\n",
ehdr->e_entry);
return false; return false;
} }
/* TODO: Check ABI here. */ /* TODO: Check ABI here. */
return true; return true;
} }
@ -155,9 +159,12 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
case R_ARM_CALL: case R_ARM_CALL:
case R_ARM_JUMP24: case R_ARM_JUMP24:
{ {
binfo("Performing PC24 [%d] link at addr %08lx [%08lx] to sym '%p' st_value=%08lx\n", binfo("Performing PC24 [%d] link", ELF32_R_TYPE(rel->r_info),
ELF32_R_TYPE(rel->r_info), (long)addr, (long)(*(uint32_t *)addr), binfo(" at addr %08lx [%08lx] to sym '%p' st_value=%08lx\n",
sym, (long)sym->st_value); (long)addr,
(long)(*(uint32_t *)addr),
sym,
(long)sym->st_value);
offset = (*(uint32_t *)addr & 0x00ffffff) << 2; offset = (*(uint32_t *)addr & 0x00ffffff) << 2;
if (offset & 0x02000000) if (offset & 0x02000000)
@ -166,7 +173,9 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
} }
offset += sym->st_value - addr; offset += sym->st_value - addr;
if (offset & 3 || offset < (int32_t) 0xfe000000 || offset >= (int32_t) 0x02000000) if (offset & 3 || offset <
(int32_t) 0xfe000000 || offset >=
(int32_t) 0x02000000)
{ {
berr("ERROR: PC24 [%d] relocation out of range, offset=%08lx\n", berr("ERROR: PC24 [%d] relocation out of range, offset=%08lx\n",
ELF32_R_TYPE(rel->r_info), offset); ELF32_R_TYPE(rel->r_info), offset);
@ -184,8 +193,13 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
case R_ARM_ABS32: case R_ARM_ABS32:
case R_ARM_TARGET1: /* New ABI: TARGET1 always treated as ABS32 */ case R_ARM_TARGET1: /* New ABI: TARGET1 always treated as ABS32 */
{ {
binfo("Performing ABS32 link at addr=%08lx [%08lx] to sym=%p st_value=%08lx\n", binfo("Performing ABS32 link");
(long)addr, (long)(*(uint32_t *)addr), sym, (long)sym->st_value); binfo(" at addr=%08lx [%08lx]
to sym=%p st_value=%08lx\n",
(long)addr,
(long)(*(uint32_t *)addr),
sym,
(long)sym->st_value);
*(uint32_t *)addr += sym->st_value; *(uint32_t *)addr += sym->st_value;
} }
@ -208,8 +222,12 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
case R_ARM_PREL31: case R_ARM_PREL31:
{ {
binfo("Performing PREL31 link at addr=%08lx [%08lx] to sym=%p st_value=%08lx\n", binfo("Performing PREL31 link at");
(long)addr, (long)(*(uint32_t *)addr), sym, (long)sym->st_value); binfo(" addr=%08lx [%08lx] to sym=%p st_value=%08lx\n",
(long)addr,
(long)(*(uint32_t *)addr),
sym,
(long)sym->st_value);
offset = *(uint32_t *)addr + sym->st_value - addr; offset = *(uint32_t *)addr + sym->st_value - addr;
*(uint32_t *)addr = offset & 0x7fffffff; *(uint32_t *)addr = offset & 0x7fffffff;
@ -219,9 +237,11 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
case R_ARM_MOVW_ABS_NC: case R_ARM_MOVW_ABS_NC:
case R_ARM_MOVT_ABS: case R_ARM_MOVT_ABS:
{ {
binfo("Performing MOVx_ABS [%d] link at addr=%08lx [%08lx] to sym=%p st_value=%08lx\n", binfo("Performing MOVx_ABS [%d] link", ELF32_R_TYPE(rel->r_info));
ELF32_R_TYPE(rel->r_info), (long)addr, (long)(*(uint32_t *)addr), binfo(" at addr=%08lx [%08lx] to sym=%p st_value=%08lx\n",
sym, (long)sym->st_value); (long)addr, (long)(*(uint32_t *)addr),
sym,
(long)sym->st_value);
offset = *(uint32_t *)addr; offset = *(uint32_t *)addr;
offset = ((offset & 0xf0000) >> 4) | (offset & 0xfff); offset = ((offset & 0xf0000) >> 4) | (offset & 0xfff);

View File

@ -208,22 +208,22 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
* upper_insn: * upper_insn:
* *
* 1 1 1 1 1 1 * 1 1 1 1 1 1
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 * 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 Instructions
* +----------+---+-------------------------------+--------------+ * +----------+---+--------------------------+----------+
* |1 1 1 |OP1| OP2 | | 32-Bit Instructions * |1 1 1 |OP1| OP2 | | 32-Bit
* +----------+---+--+-----+----------------------+--------------+ * +----------+---+--+-----+-----------------+----------+
* |1 1 1 | 1 0| S | imm10 | BL Instruction * |1 1 1 | 1 0| S | imm10 | BL
* +----------+------+-----+-------------------------------------+ * +----------+------+-----+----------------------------+
* *
* lower_insn: * lower_insn:
* *
* 1 1 1 1 1 1 * 1 1 1 1 1 1
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 * 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 Instructions
* +---+---------------------------------------------------------+ * +---+------------------------------------------------+
* |OP | | 32-Bit Instructions * |OP | | 32-Bit
* +---+--+---+---+---+------------------------------------------+ * +---+--+---+---+---+---------------------------------+
* |1 1 |J1 | 1 |J2 | imm11 | BL Instruction * |1 1 |J1 | 1 |J2 | imm11 | BL
* +------+---+---+---+------------------------------------------+ * +------+---+---+---+---------------------------------+
* *
* The branch target is encoded in these bits: * The branch target is encoded in these bits:
* *
@ -381,22 +381,22 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
* upper_insn: * upper_insn:
* *
* 1 1 1 1 1 1 * 1 1 1 1 1 1
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 * 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 Instructions
* +----------+---+-------------------------------+--------------+ * +----------+---+--------------------------+----------+
* |1 1 1 |OP1| OP2 | | 32-Bit Instructions * |1 1 1 |OP1| OP2 | | 32-Bit
* +----------+---+--+-----+----------------------+--------------+ * +----------+---+--+-----+-----------------+----------+
* |1 1 1 | 1 0| i | 1 0 1 1 0 0 | imm4 | MOVT Instruction * |1 1 1 | 1 0| i |1 0 1 1 0 0 | imm4 | MOVT
* +----------+------+-----+----------------------+--------------+ * +----------+------+-----+-----------------+----------+
* *
* lower_insn: * lower_insn:
* *
* 1 1 1 1 1 1 * 1 1 1 1 1 1
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 * 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 Instructions
* +---+---------------------------------------------------------+ * +---+-----------------------------------------------+
* |OP | | 32-Bit Instructions * |OP | | 32-Bit
* +---+----------+--------------+-------------------------------+ * +---+----------+-----------+------------------------+
* |0 | imm3 | Rd | imm8 | MOVT Instruction * |0 | imm3 | Rd | imm8 | MOVT
* +---+----------+--------------+-------------------------------+ * +---+----------+-----------+------------------------+
* *
* The 16-bit immediate value is encoded in these bits: * The 16-bit immediate value is encoded in these bits:
* *

View File

@ -211,22 +211,22 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
* upper_insn: * upper_insn:
* *
* 1 1 1 1 1 1 * 1 1 1 1 1 1
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 * 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 Instructions
* +----------+---+-------------------------------+--------------+ * +----------+---+--------------------------+----------+
* |1 1 1 |OP1| OP2 | | 32-Bit Instructions * |1 1 1 |OP1| OP2 | | 32-Bit
* +----------+---+--+-----+----------------------+--------------+ * +----------+---+--+-----+-----------------+----------+
* |1 1 1 | 1 0| S | imm10 | BL Instruction * |1 1 1 | 1 0| S | imm10 | BL
* +----------+------+-----+-------------------------------------+ * +----------+------+-----+----------------------------+
* *
* lower_insn: * lower_insn:
* *
* 1 1 1 1 1 1 * 1 1 1 1 1 1
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 * 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 Instructions
* +---+---------------------------------------------------------+ * +---+------------------------------------------------+
* |OP | | 32-Bit Instructions * |OP | | 32-Bit
* +---+--+---+---+---+------------------------------------------+ * +---+--+---+---+---+---------------------------------+
* |1 1 |J1 | 1 |J2 | imm11 | BL Instruction * |1 1 |J1 | 1 |J2 | imm11 | BL
* +------+---+---+---+------------------------------------------+ * +------+---+---+---+--------------------------------+
* *
* The branch target is encoded in these bits: * The branch target is encoded in these bits:
* *
@ -386,22 +386,22 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
* upper_insn: * upper_insn:
* *
* 1 1 1 1 1 1 * 1 1 1 1 1 1
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 * 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 Instruction
* +----------+---+-------------------------------+--------------+ * +----------+---+--------------------------+----------+
* |1 1 1 |OP1| OP2 | | 32-Bit Instructions * |1 1 1 |OP1| OP2 | | 32-Bit
* +----------+---+--+-----+----------------------+--------------+ * +----------+---+--+-----+-----------------+----------+
* |1 1 1 | 1 0| i | 1 0 1 1 0 0 | imm4 | MOVT Instruction * |1 1 1 | 1 0| i |1 0 1 1 0 0 | imm4 | MOVT
* +----------+------+-----+----------------------+--------------+ * +----------+------+-----+-----------------+----------+
* *
* lower_insn: * lower_insn:
* *
* 1 1 1 1 1 1 * 1 1 1 1 1 1
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 * 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 Instructions
* +---+---------------------------------------------------------+ * +---+-------------------------------------------------+
* |OP | | 32-Bit Instructions * |OP | | 32-Bit
* +---+----------+--------------+-------------------------------+ * +---+----------+--------+-----------------------------+
* |0 | imm3 | Rd | imm8 | MOVT Instruction * |0 | imm3 | Rd | imm8 | MOVT
* +---+----------+--------------+-------------------------------+ * +---+----------+--------+-----------------------------+
* *
* The 16-bit immediate value is encoded in these bits: * The 16-bit immediate value is encoded in these bits:
* *

View File

@ -77,7 +77,8 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
if (ehdr->e_ident[EI_CLASS] != ELFCLASS32) if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
{ {
berr("ERROR: Need 32-bit objects: e_ident[EI_CLASS]=%02x\n", ehdr->e_ident[EI_CLASS]); berr("ERROR: Need 32-bit objects: e_ident[EI_CLASS]=%02x\n",
ehdr->e_ident[EI_CLASS]);
return false; return false;
} }
@ -89,7 +90,8 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB)
#endif #endif
{ {
berr("ERROR: Wrong endian-ness: e_ident[EI_DATA]=%02x\n", ehdr->e_ident[EI_DATA]); berr("ERROR: Wrong endian-ness: e_ident[EI_DATA]=%02x\n",
ehdr->e_ident[EI_DATA]);
return false; return false;
} }
@ -97,11 +99,13 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
if ((ehdr->e_entry & 3) != 0) if ((ehdr->e_entry & 3) != 0)
{ {
berr("ERROR: Entry point is not properly aligned: %08x\n", ehdr->e_entry); berr("ERROR: Entry point is not properly aligned: %08x\n",
ehdr->e_entry);
return false; return false;
} }
/* TODO: Check ABI here. */ /* TODO: Check ABI here. */
return true; return true;
} }
@ -157,8 +161,9 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
case R_ARM_CALL: case R_ARM_CALL:
case R_ARM_JUMP24: case R_ARM_JUMP24:
{ {
binfo("Performing PC24 [%d] link at addr %08lx [%08lx] to sym '%p' st_value=%08lx\n", binfo("Performing PC24 [%d] link at", ELF32_R_TYPE(rel->r_info));
ELF32_R_TYPE(rel->r_info), (long)addr, (long)(*(uint32_t *)addr), binfo(" addr %08lx [%08lx] to sym '%p' st_value=%08lx\n",
(long)addr, (long)(*(uint32_t *)addr),
sym, (long)sym->st_value); sym, (long)sym->st_value);
offset = (*(uint32_t *)addr & 0x00ffffff) << 2; offset = (*(uint32_t *)addr & 0x00ffffff) << 2;
@ -168,9 +173,10 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
} }
offset += sym->st_value - addr; offset += sym->st_value - addr;
if (offset & 3 || offset < (int32_t) 0xfe000000 || offset >= (int32_t) 0x02000000) if (offset & 3 || offset < (int32_t) 0xfe000000 ||
offset >= (int32_t) 0x02000000)
{ {
berr("ERROR: ERROR: PC24 [%d] relocation out of range, offset=%08lx\n", berr("ERROR: PC24 [%d] relocation out of range, offset=%08lx\n",
ELF32_R_TYPE(rel->r_info), offset); ELF32_R_TYPE(rel->r_info), offset);
return -EINVAL; return -EINVAL;
@ -186,8 +192,10 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
case R_ARM_ABS32: case R_ARM_ABS32:
case R_ARM_TARGET1: /* New ABI: TARGET1 always treated as ABS32 */ case R_ARM_TARGET1: /* New ABI: TARGET1 always treated as ABS32 */
{ {
binfo("Performing ABS32 link at addr=%08lx [%08lx] to sym=%p st_value=%08lx\n", binfo("Performing ABS32 link at");
(long)addr, (long)(*(uint32_t *)addr), sym, (long)sym->st_value); binfo(" addr=%08lx [%08lx] to sym=%p st_value=%08lx\n",
(long)addr, (long)(*(uint32_t *)addr), sym,
(long)sym->st_value);
*(uint32_t *)addr += sym->st_value; *(uint32_t *)addr += sym->st_value;
} }
@ -210,8 +218,10 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
case R_ARM_PREL31: case R_ARM_PREL31:
{ {
binfo("Performing PREL31 link at addr=%08lx [%08lx] to sym=%p st_value=%08lx\n", binfo("Performing PREL31 link at");
(long)addr, (long)(*(uint32_t *)addr), sym, (long)sym->st_value); binfo(" addr=%08lx [%08lx] to sym=%p st_value=%08lx\n",
(long)addr, (long)(*(uint32_t *)addr), sym,
(long)sym->st_value);
offset = *(uint32_t *)addr + sym->st_value - addr; offset = *(uint32_t *)addr + sym->st_value - addr;
*(uint32_t *)addr = offset & 0x7fffffff; *(uint32_t *)addr = offset & 0x7fffffff;
@ -221,8 +231,9 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
case R_ARM_MOVW_ABS_NC: case R_ARM_MOVW_ABS_NC:
case R_ARM_MOVT_ABS: case R_ARM_MOVT_ABS:
{ {
binfo("Performing MOVx_ABS [%d] link at addr=%08lx [%08lx] to sym=%p st_value=%08lx\n", binfo("Performing MOVx_ABS [%d] link at", ELF32_R_TYPE(rel->r_info));
ELF32_R_TYPE(rel->r_info), (long)addr, (long)(*(uint32_t *)addr), binfo(" addr=%08lx [%08lx] to sym=%p st_value=%08lx\n",
(long)addr, (long)(*(uint32_t *)addr),
sym, (long)sym->st_value); sym, (long)sym->st_value);
offset = *(uint32_t *)addr; offset = *(uint32_t *)addr;

View File

@ -36,10 +36,10 @@ uint32_t htonl(uint32_t hl)
#ifdef CONFIG_ENDIAN_BIG #ifdef CONFIG_ENDIAN_BIG
return hl; return hl;
#else #else
return (( (hl) >> 24) | return (((hl) >> 24) |
(((hl) >> 8) & 0x0000ff00) | (((hl) >> 8) & 0x0000ff00) |
(((hl) << 8) & 0x00ff0000) | (((hl) << 8) & 0x00ff0000) |
( (hl) << 24)); ((hl) << 24));
#endif #endif
} }

View File

@ -51,9 +51,11 @@
int pthread_attr_getaffinity_np(FAR const pthread_attr_t *attr, int pthread_attr_getaffinity_np(FAR const pthread_attr_t *attr,
size_t cpusetsize, cpu_set_t *cpuset) size_t cpusetsize, cpu_set_t *cpuset)
{ {
linfo("attr=0x%p cpusetsize=%d cpuset=0x%p\n", attr, (int)cpusetsize, cpuset); linfo("attr=0x%p cpusetsize=%d cpuset=0x%p\n",
attr, (int)cpusetsize, cpuset);
DEBUGASSERT(attr != NULL && cpusetsize == sizeof(cpu_set_t) && cpuset != NULL); DEBUGASSERT(attr != NULL && cpusetsize == sizeof(cpu_set_t) &&
cpuset != NULL);
*cpuset = attr->affinity; *cpuset = attr->affinity;
return OK; return OK;

View File

@ -53,7 +53,8 @@ int pthread_attr_setaffinity_np(FAR pthread_attr_t *attr,
size_t cpusetsize, size_t cpusetsize,
FAR const cpu_set_t *cpuset) FAR const cpu_set_t *cpuset)
{ {
linfo("attr=0x%p cpusetsize=%d cpuset=0x%p\n", attr, (int)cpusetsize, cpuset); linfo("attr=0x%p cpusetsize=%d cpuset=0x%p\n",
attr, (int)cpusetsize, cpuset);
DEBUGASSERT(attr != NULL && cpusetsize == sizeof(cpu_set_t) && DEBUGASSERT(attr != NULL && cpusetsize == sizeof(cpu_set_t) &&
cpuset != NULL && *cpuset != 0); cpuset != NULL && *cpuset != 0);

View File

@ -63,5 +63,6 @@ int pthread_barrierattr_destroy(FAR pthread_barrierattr_t *attr)
{ {
attr->pshared = PTHREAD_PROCESS_PRIVATE; attr->pshared = PTHREAD_PROCESS_PRIVATE;
} }
return ret; return ret;
} }

View File

@ -50,7 +50,8 @@
* *
********************************************************************************/ ********************************************************************************/
int pthread_barrierattr_getpshared(FAR const pthread_barrierattr_t *attr, FAR int *pshared) int pthread_barrierattr_getpshared(FAR const pthread_barrierattr_t *attr,
FAR int *pshared)
{ {
int ret = OK; int ret = OK;
@ -62,5 +63,6 @@ int pthread_barrierattr_getpshared(FAR const pthread_barrierattr_t *attr, FAR in
{ {
*pshared = attr->pshared; *pshared = attr->pshared;
} }
return ret; return ret;
} }

View File

@ -62,5 +62,6 @@ int pthread_barrierattr_init(FAR pthread_barrierattr_t *attr)
{ {
attr->pshared = PTHREAD_PROCESS_PRIVATE; attr->pshared = PTHREAD_PROCESS_PRIVATE;
} }
return ret; return ret;
} }

View File

@ -56,25 +56,26 @@
* Name: pthread_barrierattr_setpshared * Name: pthread_barrierattr_setpshared
* *
* Description: * Description:
* The process-shared attribute is set to PTHREAD_PROCESS_SHARED to permit a * The process-shared attribute is set to PTHREAD_PROCESS_SHARED to permit
* barrier to be operated upon by any thread that has access to the memory where * a barrier to be operated upon by any thread that has access to the
* the barrier is allocated. If the process-shared attribute is * memory where the barrier is allocated. If the process-shared attribute
* PTHREAD_PROCESS_PRIVATE, the barrier can only be operated upon by threads * is PTHREAD_PROCESS_PRIVATE, the barrier can only be operated upon by
* created within the same process as the thread that initialized the barrier. * threads created within the same process as the thread that initialized
* If threads of different processes attempt to operate on such a barrier, the * the barrier.
* behavior is undefined. The default value of the attribute is * If threads of different processes attempt to operate on such a barrier,
* the behavior is undefined. The default value of the attribute is
* PTHREAD_PROCESS_PRIVATE. * PTHREAD_PROCESS_PRIVATE.
* *
* Both constants PTHREAD_PROCESS_SHARED and PTHREAD_PROCESS_PRIVATE are defined * Both constants PTHREAD_PROCESS_SHARED and PTHREAD_PROCESS_PRIVATE are
* in pthread.h. * defined in pthread.h.
* *
* Input Parameters: * Input Parameters:
* attr - barrier attributes to be modified. * attr - barrier attributes to be modified.
* pshared - the new value of the pshared attribute. * pshared - the new value of the pshared attribute.
* *
* Returned Value: * Returned Value:
* 0 (OK) on success or EINVAL if either attr is invalid or pshared is not one * 0 (OK) on success or EINVAL if either attr is invalid or pshared is not
* of PTHREAD_PROCESS_SHARED or PTHREAD_PROCESS_PRIVATE. * one of PTHREAD_PROCESS_SHARED or PTHREAD_PROCESS_PRIVATE.
* *
* Assumptions: * Assumptions:
* *
@ -84,7 +85,8 @@ int pthread_barrierattr_setpshared(FAR pthread_barrierattr_t *attr, int pshared)
{ {
int ret = OK; int ret = OK;
if (!attr || (pshared != PTHREAD_PROCESS_SHARED && pshared != PTHREAD_PROCESS_PRIVATE)) if (!attr || (pshared != PTHREAD_PROCESS_SHARED &&
pshared != PTHREAD_PROCESS_PRIVATE))
{ {
ret = EINVAL; ret = EINVAL;
} }
@ -92,5 +94,6 @@ int pthread_barrierattr_setpshared(FAR pthread_barrierattr_t *attr, int pshared)
{ {
attr->pshared = pshared; attr->pshared = pshared;
} }
return ret; return ret;
} }

View File

@ -70,7 +70,8 @@
****************************************************************************/ ****************************************************************************/
int pthread_barrier_init(FAR pthread_barrier_t *barrier, int pthread_barrier_init(FAR pthread_barrier_t *barrier,
FAR const pthread_barrierattr_t *attr, unsigned int count) FAR const pthread_barrierattr_t *attr,
unsigned int count)
{ {
int ret = OK; int ret = OK;

View File

@ -36,9 +36,9 @@
* Description: * Description:
* The mutex object referenced by mutex is locked by calling * The mutex object referenced by mutex is locked by calling
* pthread_mutex_lock(). If the mutex is already locked, the calling thread * pthread_mutex_lock(). If the mutex is already locked, the calling thread
* blocks until the mutex becomes available. This operation returns with the * blocks until the mutex becomes available. This operation returns with
* mutex object referenced by mutex in the locked state with the calling * the mutex object referenced by mutex in the locked state with the
* thread as its owner. * calling thread as its owner.
* *
* If the mutex type is PTHREAD_MUTEX_NORMAL, deadlock detection is not * If the mutex type is PTHREAD_MUTEX_NORMAL, deadlock detection is not
* provided. Attempting to relock the mutex causes deadlock. If a thread * provided. Attempting to relock the mutex causes deadlock. If a thread
@ -56,9 +56,9 @@
* for the first time, the lock count is set to one. Every time a thread * for the first time, the lock count is set to one. Every time a thread
* relocks this mutex, the lock count is incremented by one. Each time the * relocks this mutex, the lock count is incremented by one. Each time the
* thread unlocks the mutex, the lock count is decremented by one. When the * thread unlocks the mutex, the lock count is decremented by one. When the
* lock count reaches zero, the mutex becomes available for other threads to * lock count reaches zero, the mutex becomes available for other threads
* acquire. If a thread attempts to unlock a mutex that it has not locked or * to acquire. If a thread attempts to unlock a mutex that it has not
* a mutex which is unlocked, an error will be returned. * locked or a mutex which is unlocked, an error will be returned.
* *
* If a signal is delivered to a thread waiting for a mutex, upon return * If a signal is delivered to a thread waiting for a mutex, upon return
* from the signal handler the thread resumes waiting for the mutex as if * from the signal handler the thread resumes waiting for the mutex as if

View File

@ -49,7 +49,8 @@
* *
****************************************************************************/ ****************************************************************************/
int pthread_mutexattr_getpshared(FAR const pthread_mutexattr_t *attr, FAR int *pshared) int pthread_mutexattr_getpshared(FAR const pthread_mutexattr_t *attr,
FAR int *pshared)
{ {
int ret = OK; int ret = OK;

View File

@ -61,7 +61,8 @@ int pthread_mutexattr_setrobust(pthread_mutexattr_t *attr, int robust)
#elif defined(CONFIG_PTHREAD_MUTEX_BOTH) #elif defined(CONFIG_PTHREAD_MUTEX_BOTH)
if (attr != NULL && (robust == PTHREAD_MUTEX_STALLED || robust == _PTHREAD_MFLAGS_ROBUST)) if (attr != NULL && (robust == PTHREAD_MUTEX_STALLED ||
robust == _PTHREAD_MFLAGS_ROBUST))
{ {
attr->robust = robust; attr->robust = robust;
return OK; return OK;

View File

@ -81,7 +81,9 @@ int pthread_once(FAR pthread_once_t *once_control,
return OK; return OK;
} }
/* The init_routine has already been called. Restore pre-emption and return */ /* The init_routine has already been called.
* Restore pre-emption and return
*/
sched_unlock(); sched_unlock();
return OK; return OK;

View File

@ -31,7 +31,10 @@
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
/* These are defined in different header files but must have the same values. */
/* These are defined in different header files but must have the same
* values.
*/
#if PTHREAD_CANCEL_ENABLE != TASK_CANCEL_ENABLE #if PTHREAD_CANCEL_ENABLE != TASK_CANCEL_ENABLE
# error We must have PTHREAD_CANCEL_ENABLE == TASK_CANCEL_ENABLE # error We must have PTHREAD_CANCEL_ENABLE == TASK_CANCEL_ENABLE

View File

@ -29,6 +29,7 @@
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* The following are defined in different header files but must have the /* The following are defined in different header files but must have the
* same values. * same values.
*/ */

View File

@ -181,9 +181,10 @@ int pthread_spin_lock(pthread_spinlock_t *lock)
} }
/* Loop until we successfully take the spinlock (i.e., until the previous /* Loop until we successfully take the spinlock (i.e., until the previous
* state of the spinlock was SP_UNLOCKED). NOTE that the test/set operaion * state of the spinlock was SP_UNLOCKED).
* is performed via boardctl() to avoid a variety of issues. An option * NOTE that the test/set operaion is performed via boardctl() to avoid a
* might be to move the implementation of up_testset() to libs/libc/machine. * variety of issues. An option might be to move the implementation of
* up_testset() to libs/libc/machine.
*/ */
do do

View File

@ -37,4 +37,8 @@
struct passwd g_passwd; struct passwd g_passwd;
char g_passwd_buffer[CONFIG_LIBC_PASSWD_LINESIZE]; char g_passwd_buffer[CONFIG_LIBC_PASSWD_LINESIZE];
/****************************************************************************
* Public Functions
****************************************************************************/
#endif /* CONFIG_LIBC_GROUP_FILE */ #endif /* CONFIG_LIBC_GROUP_FILE */

View File

@ -25,7 +25,7 @@
#include <queue.h> #include <queue.h>
/**************************************************************************** /****************************************************************************
* public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************

View File

@ -100,9 +100,9 @@ _sa_handler_t signal(int signo, _sa_handler_t func)
*/ */
if (ret == OK) if (ret == OK)
{ {
return oact.sa_handler; return oact.sa_handler;
} }
return (_sa_handler_t)SIG_ERR; return (_sa_handler_t)SIG_ERR;
} }

View File

@ -98,7 +98,6 @@ int posix_spawnattr_init(posix_spawnattr_t *attr)
attr->budget.tv_nsec = param.sched_ss_init_budget.tv_nsec; attr->budget.tv_nsec = param.sched_ss_init_budget.tv_nsec;
#endif #endif
#ifndef CONFIG_ARCH_ADDRENV #ifndef CONFIG_ARCH_ADDRENV
/* Default stack size */ /* Default stack size */

View File

@ -52,7 +52,8 @@
* *
****************************************************************************/ ****************************************************************************/
int task_spawnattr_setstacksize(FAR posix_spawnattr_t *attr, size_t stacksize) int task_spawnattr_setstacksize(FAR posix_spawnattr_t *attr,
size_t stacksize)
{ {
DEBUGASSERT(attr); DEBUGASSERT(attr);
attr->stacksize = stacksize; attr->stacksize = stacksize;

View File

@ -55,7 +55,8 @@ void add_file_action(FAR posix_spawn_file_actions_t *file_actions,
/* Find the end of the list */ /* Find the end of the list */
for (prev = NULL, next = (FAR struct spawn_general_file_action_s *)*file_actions; for (prev = NULL,
next = (FAR struct spawn_general_file_action_s *)*file_actions;
next; next;
prev = next, next = next->flink); prev = next, next = next->flink);

View File

@ -58,8 +58,9 @@
* *
****************************************************************************/ ****************************************************************************/
int posix_spawn_file_actions_addclose(FAR posix_spawn_file_actions_t *file_actions, int posix_spawn_file_actions_addclose(
int fd) FAR posix_spawn_file_actions_t *file_actions,
int fd)
{ {
FAR struct spawn_close_file_action_s *entry; FAR struct spawn_close_file_action_s *entry;
@ -82,6 +83,7 @@ int posix_spawn_file_actions_addclose(FAR posix_spawn_file_actions_t *file_actio
/* And add it to the file action list */ /* And add it to the file action list */
add_file_action(file_actions, (FAR struct spawn_general_file_action_s *)entry); add_file_action(file_actions,
(FAR struct spawn_general_file_action_s *)entry);
return OK; return OK;
} }

View File

@ -59,8 +59,9 @@
* *
****************************************************************************/ ****************************************************************************/
int posix_spawn_file_actions_adddup2(FAR posix_spawn_file_actions_t *file_actions, int posix_spawn_file_actions_adddup2(
int fd1, int fd2) FAR posix_spawn_file_actions_t *file_actions,
int fd1, int fd2)
{ {
FAR struct spawn_dup2_file_action_s *entry; FAR struct spawn_dup2_file_action_s *entry;
@ -86,6 +87,7 @@ int posix_spawn_file_actions_adddup2(FAR posix_spawn_file_actions_t *file_action
/* And add it to the file action list */ /* And add it to the file action list */
add_file_action(file_actions, (FAR struct spawn_general_file_action_s *)entry); add_file_action(file_actions,
(FAR struct spawn_general_file_action_s *)entry);
return OK; return OK;
} }

View File

@ -57,7 +57,8 @@
* *
****************************************************************************/ ****************************************************************************/
int posix_spawn_file_actions_destroy(FAR posix_spawn_file_actions_t *file_actions) int posix_spawn_file_actions_destroy(
FAR posix_spawn_file_actions_t *file_actions)
{ {
FAR struct spawn_general_file_action_s *curr; FAR struct spawn_general_file_action_s *curr;
FAR struct spawn_general_file_action_s *next; FAR struct spawn_general_file_action_s *next;
@ -70,7 +71,9 @@ int posix_spawn_file_actions_destroy(FAR posix_spawn_file_actions_t *file_action
curr; curr;
curr = next) curr = next)
{ {
/* Get the pointer to the next element before destroying the current one */ /* Get the pointer to the next element before destroying the current
* one
*/
next = curr->flink; next = curr->flink;
lib_free(curr); lib_free(curr);

View File

@ -59,7 +59,8 @@
* *
****************************************************************************/ ****************************************************************************/
void posix_spawn_file_actions_dump(FAR posix_spawn_file_actions_t *file_actions) void posix_spawn_file_actions_dump(
FAR posix_spawn_file_actions_t *file_actions)
{ {
FAR struct spawn_general_file_action_s *entry; FAR struct spawn_general_file_action_s *entry;

View File

@ -48,7 +48,8 @@
* *
****************************************************************************/ ****************************************************************************/
int posix_spawn_file_actions_init(FAR posix_spawn_file_actions_t *file_actions) int posix_spawn_file_actions_init(
FAR posix_spawn_file_actions_t *file_actions)
{ {
*file_actions = NULL; *file_actions = NULL;
return OK; return OK;

View File

@ -34,6 +34,12 @@
#include "libc.h" #include "libc.h"
/* Include floating point functions */
#ifdef CONFIG_LIBC_FLOATINGPOINT
# include "stdio/lib_libdtoa.c"
#endif
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
@ -193,12 +199,6 @@ static const char g_nullstring[] = "(null)";
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
/* Include floating point functions */
#ifdef CONFIG_LIBC_FLOATINGPOINT
# include "stdio/lib_libdtoa.c"
#endif
/**************************************************************************** /****************************************************************************
* Name: ptohex * Name: ptohex
****************************************************************************/ ****************************************************************************/

View File

@ -39,10 +39,10 @@
* *
* Description: * Description:
* fgetpos() function is an alternate interfaces equivalent to ftell(). * fgetpos() function is an alternate interfaces equivalent to ftell().
* It gets the current value of the file offset and store it in the location * It gets the current value of the file offset and store it in the
* referenced by pos. On some non-UNIX systems an fpos_t object may be a * location referenced by pos. On some non-UNIX systems an fpos_t object
* complex object and fsetpos may be the only way to portably reposition a * may be a complex object and fsetpos may be the only way to portably
* stream. * reposition a stream.
* *
* Returned Value: * Returned Value:
* Zero on succes; -1 on failure with errno set appropriately. * Zero on succes; -1 on failure with errno set appropriately.

View File

@ -46,8 +46,8 @@
* set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is relative to the * set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is relative to the
* start of the file, the current position indicator, or end-of-file, * start of the file, the current position indicator, or end-of-file,
* respectively. A successful call to the fseek() function clears the * respectively. A successful call to the fseek() function clears the
* end-of-file indicator for the stream and undoes any effects of the ungetc(3) * end-of-file indicator for the stream and undoes any effects of the
* function on the same stream. * ungetc(3) function on the same stream.
* *
* Returned Value: * Returned Value:
* Zero on succes; -1 on failure with errno set appropriately. * Zero on succes; -1 on failure with errno set appropriately.

View File

@ -55,10 +55,13 @@ static off_t lib_getrdoffset(FAR FILE *stream)
off_t rdoffset = 0; off_t rdoffset = 0;
lib_take_semaphore(stream); lib_take_semaphore(stream);
if (stream->fs_bufstart != NULL && stream->fs_bufread != stream->fs_bufstart) if (stream->fs_bufstart !=
NULL && stream->fs_bufread !=
stream->fs_bufstart)
{ {
#if CONFIG_NUNGET_CHARS > 0 #if CONFIG_NUNGET_CHARS > 0
rdoffset = stream->fs_bufread - stream->fs_bufpos + stream->fs_nungotten; rdoffset = stream->fs_bufread - stream->fs_bufpos +
stream->fs_nungotten;
#else #else
rdoffset = stream->fs_bufread - stream->fs_bufpos; rdoffset = stream->fs_bufread - stream->fs_bufpos;
#endif #endif

View File

@ -42,8 +42,8 @@
* Name: lib_fflush * Name: lib_fflush
* *
* Description: * Description:
* The function lib_fflush() forces a write of all user-space buffered data for * The function lib_fflush() forces a write of all user-space buffered data
* the given output or update stream via the stream's underlying write * for the given output or update stream via the stream's underlying write
* function. The open status of the stream is unaffected. * function. The open status of the stream is unaffected.
* *
* Input Parameters: * Input Parameters:
@ -83,7 +83,7 @@ ssize_t lib_fflush(FAR FILE *stream, bool bforce)
ret = 0; ret = 0;
goto errout_with_sem; goto errout_with_sem;
} }
/* Make sure that the buffer holds valid data */ /* Make sure that the buffer holds valid data */
@ -146,10 +146,10 @@ ssize_t lib_fflush(FAR FILE *stream, bool bforce)
*/ */
while (nbuffer) while (nbuffer)
{ {
*stream->fs_bufpos++ = *src++; *stream->fs_bufpos++ = *src++;
--nbuffer; --nbuffer;
} }
} }
/* Restore normal access to the stream and return the number of bytes /* Restore normal access to the stream and return the number of bytes

View File

@ -74,9 +74,9 @@
* Name: consume_eol * Name: consume_eol
* *
* Description: * Description:
* If 'consume' is true, then consume_eol() will read and discard bytes from * If 'consume' is true, then consume_eol() will read and discard bytes
* 'stream' until an EOF or a newline encountered or until a read error * from 'stream' until an EOF or a newline encountered or until a read
* occurs. * error occurs.
* *
****************************************************************************/ ****************************************************************************/

View File

@ -36,7 +36,8 @@
static void memoutstream_putc(FAR struct lib_outstream_s *this, int ch) static void memoutstream_putc(FAR struct lib_outstream_s *this, int ch)
{ {
FAR struct lib_memoutstream_s *mthis = (FAR struct lib_memoutstream_s *)this; FAR struct lib_memoutstream_s *mthis =
(FAR struct lib_memoutstream_s *)this;
DEBUGASSERT(this); DEBUGASSERT(this);

View File

@ -42,7 +42,8 @@
static void rawoutstream_putc(FAR struct lib_outstream_s *this, int ch) static void rawoutstream_putc(FAR struct lib_outstream_s *this, int ch)
{ {
FAR struct lib_rawoutstream_s *rthis = (FAR struct lib_rawoutstream_s *)this; FAR struct lib_rawoutstream_s *rthis =
(FAR struct lib_rawoutstream_s *)this;
char buffer = ch; char buffer = ch;
int nwritten; int nwritten;
int errcode; int errcode;

View File

@ -68,30 +68,33 @@ int lib_rdflush(FAR FILE *stream)
lib_take_semaphore(stream); lib_take_semaphore(stream);
/* If the buffer is currently being used for read access, then discard all /* If the buffer is currently being used for read access, then discard all
* of the read-ahead data. We do not support concurrent buffered read/write * of the read-ahead data. We do not support concurrent buffered read/write
* access. * access.
*/ */
if (stream->fs_bufread != stream->fs_bufstart) if (stream->fs_bufread != stream->fs_bufstart)
{ {
/* Now adjust the stream pointer to account for the read-ahead data that /* Now adjust the stream pointer to account for the read-ahead data
* was not actually read by the user. * that was not actually read by the user.
*/ */
#if CONFIG_NUNGET_CHARS > 0 #if CONFIG_NUNGET_CHARS > 0
off_t rdoffset = stream->fs_bufread - stream->fs_bufpos + stream->fs_nungotten; off_t rdoffset = stream->fs_bufread - stream->fs_bufpos +
stream->fs_nungotten;
#else #else
off_t rdoffset = stream->fs_bufread - stream->fs_bufpos; off_t rdoffset = stream->fs_bufread - stream->fs_bufpos;
#endif #endif
/* Mark the buffer as empty (do this before calling fseek() because fseek() /* Mark the buffer as empty (do this before calling fseek() because
* also calls this function). * fseek() also calls this function).
*/ */
stream->fs_bufpos = stream->fs_bufread = stream->fs_bufstart; stream->fs_bufpos = stream->fs_bufread = stream->fs_bufstart;
#if CONFIG_NUNGET_CHARS > 0 #if CONFIG_NUNGET_CHARS > 0
stream->fs_nungotten = 0; stream->fs_nungotten = 0;
#endif #endif
/* Then seek to the position corresponding to the last data read by the user */ /* Then seek to the position corresponding to the last data read by the
* user
*/
if (fseek(stream, -rdoffset, SEEK_CUR) < 0) if (fseek(stream, -rdoffset, SEEK_CUR) < 0)
{ {

View File

@ -51,8 +51,8 @@ int snprintf(FAR char *buf, size_t size, FAR const IPTR char *format, ...)
/* "If the value of [size] is zero on a call to snprintf(), nothing shall /* "If the value of [size] is zero on a call to snprintf(), nothing shall
* be written, the number of bytes that would have been written had [size] * be written, the number of bytes that would have been written had [size]
* been sufficiently large excluding the terminating null shall be returned, * been sufficiently large excluding the terminating null shall be
* and [buf] may be a null pointer." -- opengroup.org * returned, and [buf] may be a null pointer." -- opengroup.org
*/ */
if (size > 0) if (size > 0)

View File

@ -38,7 +38,8 @@
static void stdoutstream_putc(FAR struct lib_outstream_s *this, int ch) static void stdoutstream_putc(FAR struct lib_outstream_s *this, int ch)
{ {
FAR struct lib_stdoutstream_s *sthis = (FAR struct lib_stdoutstream_s *)this; FAR struct lib_stdoutstream_s *sthis =
(FAR struct lib_stdoutstream_s *)this;
int result; int result;
DEBUGASSERT(this && sthis->stream); DEBUGASSERT(this && sthis->stream);
@ -70,7 +71,8 @@ static void stdoutstream_putc(FAR struct lib_outstream_s *this, int ch)
#ifndef CONFIG_STDIO_DISABLE_BUFFERING #ifndef CONFIG_STDIO_DISABLE_BUFFERING
static int stdoutstream_flush(FAR struct lib_outstream_s *this) static int stdoutstream_flush(FAR struct lib_outstream_s *this)
{ {
FAR struct lib_stdoutstream_s *sthis = (FAR struct lib_stdoutstream_s *)this; FAR struct lib_stdoutstream_s *sthis =
(FAR struct lib_stdoutstream_s *)this;
DEBUGASSERT(sthis != NULL && sthis->stream != NULL); DEBUGASSERT(sthis != NULL && sthis->stream != NULL);
return lib_fflush(sthis->stream, true); return lib_fflush(sthis->stream, true);

View File

@ -65,8 +65,9 @@ void abort(void)
* *
* Note that pthread_exit() is called instead of exit(). That is because * Note that pthread_exit() is called instead of exit(). That is because
* we do no know if abort was called from a pthread or a normal thread * we do no know if abort was called from a pthread or a normal thread
* (we could find out, of course). If abort() is called from a non-pthread, * (we could find out, of course). If abort() is called from a
* then pthread_exit() should fail and fall back to call exit() anyway. * non-pthread, then pthread_exit() should fail and fall back to call
* exit() anyway.
* *
* If exit() is called (either below or via pthread_exit()), then exit() * If exit() is called (either below or via pthread_exit()), then exit()
* will flush and close all open files and terminate the thread. If this * will flush and close all open files and terminate the thread. If this

View File

@ -35,5 +35,6 @@ int abs(int j)
{ {
j = -j; j = -j;
} }
return j; return j;
} }

View File

@ -63,7 +63,9 @@ int lib_checkbase(int base, FAR const char **pptr)
base = 10; base = 10;
/* Check for leading '0' - that would signify octal or hex (or binary) */ /* Check for leading '0' - that would signify octal
* or hex (or binary)
*/
if (*ptr == '0') if (*ptr == '0')
{ {
@ -83,7 +85,9 @@ int lib_checkbase(int base, FAR const char **pptr)
} }
} }
/* If it a hexadecimal representation, than discard any leading "0X" or "0x" */ /* If it a hexadecimal representation,
* than discard any leading "0X" or "0x"
*/
else if (base == 16) else if (base == 16)
{ {

View File

@ -35,5 +35,6 @@ long int labs(long int j)
{ {
j = -j; j = -j;
} }
return j; return j;
} }

View File

@ -37,6 +37,7 @@ long long int llabs(long long int j)
{ {
j = -j; j = -j;
} }
return j; return j;
} }
#endif #endif

View File

@ -39,8 +39,8 @@
* Name: ffsl * Name: ffsl
* *
* Description: * Description:
* The ffsl() function will find the first bit set (beginning with the least * The ffsl() function will find the first bit set (beginning with the
* significant bit) in j, and return the index of that bit. Bits are * least significant bit) in j, and return the index of that bit. Bits are
* numbered starting at one (the least significant bit). * numbered starting at one (the least significant bit).
* *
* Returned Value: * Returned Value:

View File

@ -41,8 +41,8 @@
* Name: ffsll * Name: ffsll
* *
* Description: * Description:
* The ffsll() function will find the first bit set (beginning with the least * The ffsll() function will find the first bit set (beginning with the
* significant bit) in i, and return the index of that bit. Bits are * least significant bit) in i, and return the index of that bit. Bits are
* numbered starting at one (the least significant bit). * numbered starting at one (the least significant bit).
* *
* Returned Value: * Returned Value:

View File

@ -84,5 +84,6 @@ bool lib_isbasedigit(int ch, int base, int *value)
{ {
*value = tmp; *value = tmp;
} }
return ret; return ret;
} }

View File

@ -50,6 +50,7 @@ int memcmp(FAR const void *s1, FAR const void *s2, size_t n)
p1++; p1++;
p2++; p2++;
} }
return 0; return 0;
} }
#endif #endif

View File

@ -18,7 +18,6 @@
* *
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
@ -164,7 +163,7 @@ FAR void *memset(FAR void *s, int c, size_t n)
#else #else
/* This version is optimized for size */ /* This version is optimized for size */
FAR unsigned char *p = (FAR unsigned char*)s; FAR unsigned char *p = (FAR unsigned char *)s;
while (n-- > 0) *p++ = c; while (n-- > 0) *p++ = c;
#endif #endif
return s; return s;

View File

@ -46,7 +46,7 @@
void lib_skipspace(const char **pptr) void lib_skipspace(const char **pptr)
{ {
const char *ptr = *pptr; const char *ptr = *pptr;
while (isspace(*ptr)) ptr++; while (isspace(*ptr)) ptr++;
*pptr = ptr; *pptr = ptr;
} }

View File

@ -45,6 +45,7 @@ int strcasecmp(FAR const char *cs, FAR const char *ct)
cs++; cs++;
ct++; ct++;
} }
return result; return result;
} }
#endif #endif

View File

@ -97,7 +97,9 @@ FAR char *strcasestr(FAR const char *str, FAR const char *substr)
return NULL; return NULL;
} }
/* Check if this is the beginning of a matching substring (ignoring case) */ /* Check if this is the beginning of a matching substring
* (ignoring case)
*/
if (strncasecmp(candidate, substr, len) == 0) if (strncasecmp(candidate, substr, len) == 0)
{ {
@ -113,8 +115,8 @@ FAR char *strcasestr(FAR const char *str, FAR const char *substr)
candidate++; candidate++;
} }
/* Won't get here, but some compilers might complain. Others might complain /* Won't get here, but some compilers might complain. Others might
* about this code being unreachable too. * complain about this code being unreachable too.
*/ */
return NULL; return NULL;

View File

@ -40,6 +40,7 @@ char *strcat(char *dest, const char *src)
{ {
*dest++ = *src++; *dest++ = *src++;
} }
*dest = '\0'; *dest = '\0';
return ret; return ret;

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* libs/libc/string//lib_strdup.c * libs/libc/string/lib_strdup.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -46,6 +46,7 @@ int strncasecmp(const char *cs, const char *ct, size_t nb)
cs++; cs++;
ct++; ct++;
} }
return result; return result;
} }
#endif #endif

View File

@ -40,6 +40,7 @@ char *strncat(char *dest, const char *src, size_t n)
{ {
*dest++ = *src++; *dest++ = *src++;
} }
*dest = '\0'; *dest = '\0';
return ret; return ret;

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* libs/libc/string//lib_strndup.c * libs/libc/string/lib_strndup.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -31,6 +31,7 @@
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: strndup * Name: strndup
* *

View File

@ -45,7 +45,9 @@ FAR char *strpbrk(FAR const char *str, FAR const char *charset)
while (*str) while (*str)
{ {
/* Check if the character from the string matches any character in the charset */ /* Check if the character from the string matches any character in the
* charset
*/
if (strchr(charset, *str) != NULL) if (strchr(charset, *str) != NULL)
{ {
@ -54,15 +56,15 @@ FAR char *strpbrk(FAR const char *str, FAR const char *charset)
return (FAR char *)str; return (FAR char *)str;
} }
/* This character from the strings matches none of those in the charset. /* This character from the strings matches none of those in the
* Try the next character from the string. * charset. Try the next character from the string.
*/ */
str++; str++;
} }
/* We have looked at every character in the string, and none of them match any of /* We have looked at every character in the string, and none of them match
* the characters in charset. * any of the characters in charset.
*/ */
return NULL; return NULL;

View File

@ -61,5 +61,6 @@ symtab_findbyname(FAR const struct symtab_s *symtab,
return symtab; return symtab;
} }
} }
return NULL; return NULL;
} }

View File

@ -40,9 +40,9 @@
* *
* Description: * Description:
* Find the symbol in the symbol table whose value closest (but not greater * Find the symbol in the symbol table whose value closest (but not greater
* than), the provided value. This version assumes that table is not ordered * than), the provided value. This version assumes that table is not
* with respect to symbol name and, hence, access time will be linear with * ordered with respect to symbol name and, hence, access time will be
* respect to nsyms. * linear with respect to nsyms.
* *
* Returned Value: * Returned Value:
* A reference to the symbol table entry if an entry with the matching * A reference to the symbol table entry if an entry with the matching
@ -59,7 +59,9 @@ symtab_findbyvalue(FAR const struct symtab_s *symtab,
DEBUGASSERT(symtab != NULL); DEBUGASSERT(symtab != NULL);
for (; nsyms > 0; symtab++, nsyms--) for (; nsyms > 0; symtab++, nsyms--)
{ {
/* Look for symbols of lesser or equal value (probably address) to value */ /* Look for symbols of lesser or equal value (probably address) to
* value
*/
if (symtab->sym_value <= value) if (symtab->sym_value <= value)
{ {
@ -73,8 +75,9 @@ symtab_findbyvalue(FAR const struct symtab_s *symtab,
retval = symtab; retval = symtab;
/* If it is exactly equal to the search 'value', then we might as /* If it is exactly equal to the search 'value', then we might
* well terminate early because we can't do any better than that. * as well terminate early because we can't do any better than
* that.
*/ */
if (retval->sym_value == value) if (retval->sym_value == value)

View File

@ -102,8 +102,8 @@ symtab_findorderedbyname(FAR const struct symtab_s *symtab,
* the final symtab[] name. * the final symtab[] name.
* *
* Example: Only the last pass through loop, suppose low = 1, high = 2, * Example: Only the last pass through loop, suppose low = 1, high = 2,
* mid = 1, and symtab[high].sym_name == name. Then we would get here with * mid = 1, and symtab[high].sym_name == name. Then we would get here
* low = 2, high = 2, but symtab[2].sym_name was never tested. * with low = 2, high = 2, but symtab[2].sym_name was never tested.
*/ */
return strcmp(name, symtab[low].sym_name) == 0 ? &symtab[low] : NULL; return strcmp(name, symtab[low].sym_name) == 0 ? &symtab[low] : NULL;

View File

@ -55,8 +55,8 @@
* intended to cause the terminal device to start * intended to cause the terminal device to start
* transmitting data to the system. * transmitting data to the system.
* *
* The default on the opening of a terminal file is that neither its input nor * The default on the opening of a terminal file is that neither its input
* its output are suspended. * nor its output are suspended.
* *
* Returned Value: * Returned Value:
* Upon successful completion, 0 is returned. Otherwise, -1 is returned and * Upon successful completion, 0 is returned. Otherwise, -1 is returned and

View File

@ -42,7 +42,8 @@
* Function for flushing a terminal/serial device * Function for flushing a terminal/serial device
* *
* Input Parameters: * Input Parameters:
* fd - The 'fd' argument is an open file descriptor associated with a terminal. * fd - The 'fd' argument is an open file descriptor associated with a
* terminal.
* cmd - The TCFLSH ioctl argument. * cmd - The TCFLSH ioctl argument.
* *
* Returned Value: * Returned Value:

View File

@ -44,12 +44,14 @@
* referenced by 'termiosp'. * referenced by 'termiosp'.
* *
* Input Parameters: * Input Parameters:
* fd - The 'fd' argument is an open file descriptor associated with a terminal. * fd - The 'fd' argument is an open file descriptor associated with a
* terminal.
* termiosp - The termiosp argument is a pointer to a termios structure. * termiosp - The termiosp argument is a pointer to a termios structure.
* *
* Returned Value: * Returned Value:
* Upon successful completion, 0 is returned. Otherwise, -1 is returned and * Upon successful completion, 0 is returned. Otherwise, -1 is returned and
* errno is set to indicate the error. The following errors may be reported: * errno is set to indicate the error.
* The following errors may be reported:
* *
* - EBADF: The 'fd' argument is not a valid file descriptor. * - EBADF: The 'fd' argument is not a valid file descriptor.
* - ENOTTY: The file associated with 'fd' is not a terminal. * - ENOTTY: The file associated with 'fd' is not a terminal.

View File

@ -46,8 +46,8 @@
* If 'options' is TCSANOW, the change will occur immediately. * If 'options' is TCSANOW, the change will occur immediately.
* *
* If 'options' is TCSADRAIN, the change will occur after all output * If 'options' is TCSADRAIN, the change will occur after all output
* written to 'fd' is transmitted. This function should be used when changing * written to 'fd' is transmitted. This function should be used when
* parameters that affect output. * changing parameters that affect output.
* *
* If 'options' is TCSAFLUSH, the change will occur after all * If 'options' is TCSAFLUSH, the change will occur after all
* output written to 'fd' is transmitted, and all input so far received but * output written to 'fd' is transmitted, and all input so far received but

View File

@ -54,17 +54,17 @@ static time_t clock_gregorian2utc(int year, int month, int day)
temp = (month <= 2 ? -1:0); temp = (month <= 2 ? -1:0);
return (1461*(year + 4800 + temp))/4 return (1461 * (year + 4800 + temp)) / 4
+ (367*(month - 2 - 12*temp))/12 + (367 * (month - 2 - 12 * temp)) / 12
- (3*((year + 4900 + temp)/100))/4 + day - 32075; - (3 * ((year + 4900 + temp) / 100)) / 4 + day - 32075;
} }
#ifdef CONFIG_JULIAN_TIME #ifdef CONFIG_JULIAN_TIME
static time_t clock_julian2utc(int year, int month, int day) static time_t clock_julian2utc(int year, int month, int day)
{ {
return 367*year return 367 * year
- (7*(year + 5001 + (month-9)/7))/4 - (7 * (year + 5001 + (month - 9) / 7)) / 4
+ (275*month)/9 + (275 * month) / 9
+ day + 1729777; + day + 1729777;
} }
#endif /* CONFIG_JULIAN_TIME */ #endif /* CONFIG_JULIAN_TIME */
@ -95,7 +95,7 @@ time_t clock_calendar2utc(int year, int month, int day)
/* Correct year & month ranges. Shift month into range 1-12 */ /* Correct year & month ranges. Shift month into range 1-12 */
dyear = (month-1) / 12; dyear = (month - 1) / 12;
month -= 12 * dyear; month -= 12 * dyear;
year += dyear; year += dyear;

View File

@ -73,10 +73,10 @@ int gettimeofday(FAR struct timeval *tv, FAR struct timezone *tz)
ret = clock_gettime(CLOCK_REALTIME, &ts); ret = clock_gettime(CLOCK_REALTIME, &ts);
if (ret == OK) if (ret == OK)
{ {
/* Convert the struct timespec to a struct timeval */ /* Convert the struct timespec to a struct timeval */
tv->tv_sec = ts.tv_sec; tv->tv_sec = ts.tv_sec;
tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC; tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
} }
return ret; return ret;

View File

@ -85,8 +85,8 @@ static inline void _trimdir(char *path)
* 'path' argument OR more that SYMLOOP_MAX symbolic links in the * 'path' argument OR more that SYMLOOP_MAX symbolic links in the
* resolution of the 'path' argument. * resolution of the 'path' argument.
* ENAMETOOLONG * ENAMETOOLONG
* The length of the path argument exceeds PATH_MAX or a pathname component * The length of the path argument exceeds PATH_MAX or a pathname
* is longer than NAME_MAX. * component is longer than NAME_MAX.
* ENOENT * ENOENT
* A component of 'path' does not name an existing directory or path is * A component of 'path' does not name an existing directory or path is
* an empty string. * an empty string.
@ -128,7 +128,9 @@ int chdir(FAR const char *path)
goto errout; goto errout;
} }
/* Yes, it is a directory. Remove any trailing '/' characters from the path */ /* Yes, it is a directory.
* Remove any trailing '/' characters from the path
*/
_trimdir(path); _trimdir(path);

View File

@ -35,7 +35,8 @@
* Name: getuid * Name: getuid
* *
* Description: * Description:
* The getuid() function will return the real user ID of the calling process. * The getuid() function will return the real user ID of the calling
* process.
* *
* Input Parameters: * Input Parameters:
* None * None

View File

@ -70,10 +70,10 @@
* unspecified whether the SIGALRM signal is blocked, unless the process' * unspecified whether the SIGALRM signal is blocked, unless the process'
* signal mask is restored as part of the environment. * signal mask is restored as part of the environment.
* *
* Implementations may place limitations on the granularity of timer values. * Implementations may place limitations on the granularity of timer
* For each interval timer, if the requested timer value requires a finer * values. For each interval timer, if the requested timer value requires a
* granularity than the implementation supports, the actual timer value will * finer granularity than the implementation supports, the actual timer
* be rounded up to the next supported value. * value will be rounded up to the next supported value.
* *
* Interactions between sleep() and any of setitimer(), ualarm() or sleep() * Interactions between sleep() and any of setitimer(), ualarm() or sleep()
* are unspecified. * are unspecified.
@ -109,8 +109,8 @@ unsigned int sleep(unsigned int seconds)
ret = clock_nanosleep(CLOCK_REALTIME, 0, &rqtp, &rmtp); ret = clock_nanosleep(CLOCK_REALTIME, 0, &rqtp, &rmtp);
/* clock_nanosleep() should only fail if it was interrupted by a signal, /* clock_nanosleep() should only fail if it was interrupted by a
* but we treat all errors the same, * signal, but we treat all errors the same,
*/ */
if (ret < 0) if (ret < 0)

View File

@ -61,24 +61,24 @@ void swab(FAR const void *src, FAR void *dest, ssize_t nbytes)
*/ */
if (nbytes > 1) if (nbytes > 1)
{ {
/* The end of dest buffer + 1 byte (skipping any odd numbered byte at /* The end of dest buffer + 1 byte (skipping any odd numbered byte at
* the end of the buffer. * the end of the buffer.
*/ */
end8 = dest8 + (nbytes & ~1); end8 = dest8 + (nbytes & ~1);
/* Loop until the destination is equal to the end + 1 address */ /* Loop until the destination is equal to the end + 1 address */
while (dest8 != end8) while (dest8 != end8)
{ {
register uint8_t tmp; register uint8_t tmp;
/* Transfer the bytes, swapping the order */ /* Transfer the bytes, swapping the order */
tmp = *src8++; tmp = *src8++;
*dest8++ = *src8++; *dest8++ = *src8++;
*dest8++ = tmp; *dest8++ = tmp;
} }
} }
} }

View File

@ -58,10 +58,10 @@
* it is unspecified whether that signal has any effect other than causing * it is unspecified whether that signal has any effect other than causing
* usleep() to return. * usleep() to return.
* *
* If a signal-catching function interrupts usleep() and examines or changes * If a signal-catching function interrupts usleep() and examines or
* either the time a SIGALRM is scheduled to be generated, the action * changes either the time a SIGALRM is scheduled to be generated, the
* associated with the SIGALRM signal, or whether the SIGALRM signal is * action associated with the SIGALRM signal, or whether the SIGALRM signal
* blocked from delivery, the results are unspecified. * is blocked from delivery, the results are unspecified.
* *
* If a signal-catching function interrupts usleep() and calls siglongjmp() * If a signal-catching function interrupts usleep() and calls siglongjmp()
* or longjmp() to restore an environment saved prior to the usleep() call, * or longjmp() to restore an environment saved prior to the usleep() call,
@ -70,15 +70,15 @@
* unspecified whether the SIGALRM signal is blocked, unless the process' * unspecified whether the SIGALRM signal is blocked, unless the process'
* signal mask is restored as part of the environment. * signal mask is restored as part of the environment.
* *
* Implementations may place limitations on the granularity of timer values. * Implementations may place limitations on the granularity of timer
* For each interval timer, if the requested timer value requires a finer * values. For each interval timer, if the requested timer value requires a
* granularity than the implementation supports, the actual timer value will * finer granularity than the implementation supports, the actual timer
* be rounded up to the next supported value. * value will be rounded up to the next supported value.
* *
* Interactions between usleep() and any of the following are unspecified: * Interactions between usleep() and any of the following are unspecified:
* *
* nanosleep(), setitimer(), timer_create(), timer_delete(), timer_getoverrun(), * nanosleep(), setitimer(), timer_create(), timer_delete(),
* timer_gettime(), timer_settime(), ualarm(), sleep() * timer_getoverrun(), timer_gettime(), timer_settime(), ualarm(), sleep()
* *
* Input Parameters: * Input Parameters:
* usec - the number of microseconds to wait. * usec - the number of microseconds to wait.

View File

@ -44,8 +44,8 @@
* *
* Description: * Description:
* Cancel previously queued work. This removes work from the work queue. * Cancel previously queued work. This removes work from the work queue.
* After work has been cancelled, it may be re-queue by calling work_queue() * After work has been cancelled, it may be re-queue by calling
* again. * work_queue() again.
* *
* Input Parameters: * Input Parameters:
* qid - The work queue ID * qid - The work queue ID
@ -60,7 +60,8 @@
* *
****************************************************************************/ ****************************************************************************/
static int work_qcancel(FAR struct usr_wqueue_s *wqueue, FAR struct work_s *work) static int work_qcancel(FAR struct usr_wqueue_s *wqueue,
FAR struct work_s *work)
{ {
int ret = -ENOENT; int ret = -ENOENT;

View File

@ -56,6 +56,7 @@
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: work_signal * Name: work_signal
* *

View File

@ -58,7 +58,9 @@ struct usr_wqueue_s
extern struct usr_wqueue_s g_usrwork; extern struct usr_wqueue_s g_usrwork;
/* This semaphore/mutex supports exclusive access to the user-mode work queue */ /* This semaphore/mutex supports exclusive access to the user-mode work
* queue
*/
#ifdef CONFIG_BUILD_PROTECTED #ifdef CONFIG_BUILD_PROTECTED
extern sem_t g_usrsem; extern sem_t g_usrsem;

View File

@ -24,6 +24,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <nuttx/zoneinfo.h> #include <nuttx/zoneinfo.h>
#include "romfs_zoneinfo.h"
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
@ -32,5 +33,3 @@
/**************************************************************************** /****************************************************************************
* Public Data * Public Data
****************************************************************************/ ****************************************************************************/
#include "romfs_zoneinfo.h"