mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
!compiler: drop CONFIG_HAVE_LONG_LONG and require long long support
Every compiler supported by NuttX provides the "long long" types,
so the CONFIG_HAVE_LONG_LONG indirection is no longer useful.
Remove the option from include/nuttx/compiler.h and treat
"long long" as unconditionally available across the OS.
In addition to deleting the guard itself, this commit unconditionally
enables the long-long flavored helpers that used to be gated behind
it:
- libs/libc/fixedmath: drop the soft-emulated b32/ub32 routines
in lib_fixedmath.c (-261 lines) and trim the matching
prototypes, Make.defs and CMakeLists.txt entries; keep only
the long-long backed implementations.
- include/sys/endian.h, include/strings.h, libs/libc/string
/lib_ffsll.c, lib_flsll.c: always expose the 64-bit byte-swap
and ffsll/flsll variants.
- libs/libm/libm/lib_llround{,f,l}.c: drop the empty stubs.
- libs/libc/stdlib (atoll, llabs, lldiv, strtoll/ull, rand48,
strtold), libs/libc/stream (libvsprintf, libvscanf,
libbsprintf, ultoa_invert), libs/libc/misc (crc64, crc64emac),
libs/libc/inttypes/strtoimax, libs/libc/lzf, libs/libc/libc.csv,
libs/libc/string (memset, vikmemcpy): remove the
#ifdef CONFIG_HAVE_LONG_LONG branches.
- include/{stddef.h,stdlib.h,fixedmath.h,sys/epoll.h,cxx/cstdlib,
nuttx/audio/audio.h,nuttx/crc64.h,nuttx/lib/math.h,
nuttx/lib/math32.h,nuttx/lib/stdbit.h}: same guard cleanup.
- drivers/note/note_driver.c, fs/spiffs/src/spiffs.h,
sched/irq/irq_procfs.c: drop their local guards as well.
- Documentation/applications/netutils/ntpclient/index.rst:
refresh the documentation snippet.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
9a84223c1e
commit
c32b683085
46 changed files with 96 additions and 611 deletions
|
|
@ -20,5 +20,4 @@
|
|||
#
|
||||
# ##############################################################################
|
||||
|
||||
target_sources(c PRIVATE lib_fixedmath.c lib_b16sin.c lib_b16cos.c
|
||||
lib_b16atan2.c lib_ubsqrt.c)
|
||||
target_sources(c PRIVATE lib_b16sin.c lib_b16cos.c lib_b16atan2.c lib_ubsqrt.c)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
# Add the fixed precision math C files to the build
|
||||
|
||||
CSRCS += lib_fixedmath.c lib_b16sin.c lib_b16cos.c lib_b16atan2.c
|
||||
CSRCS += lib_b16sin.c lib_b16cos.c lib_b16atan2.c
|
||||
CSRCS += lib_ubsqrt.c
|
||||
|
||||
# Add the fixed precision math directory to the build
|
||||
|
|
|
|||
|
|
@ -1,261 +0,0 @@
|
|||
/****************************************************************************
|
||||
* libs/libc/fixedmath/lib_fixedmath.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* 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 <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <fixedmath.h>
|
||||
|
||||
#ifndef CONFIG_HAVE_LONG_LONG
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: fixsign
|
||||
****************************************************************************/
|
||||
|
||||
static void fixsign(b16_t *parg1, b16_t *parg2, bool *pnegate)
|
||||
{
|
||||
bool negate = false;
|
||||
b16_t arg;
|
||||
|
||||
arg = *parg1;
|
||||
if (arg < 0)
|
||||
{
|
||||
*parg1 = -arg;
|
||||
negate = true;
|
||||
}
|
||||
|
||||
arg = *parg2;
|
||||
if (arg < 0)
|
||||
{
|
||||
*parg2 = -arg;
|
||||
negate ^= true;
|
||||
}
|
||||
|
||||
*pnegate = negate;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: adjustsign
|
||||
****************************************************************************/
|
||||
|
||||
static b16_t adjustsign(b16_t result, bool negate)
|
||||
{
|
||||
/* If the product is negative, then we overflowed */
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
if (result)
|
||||
{
|
||||
return b16MIN;
|
||||
}
|
||||
else
|
||||
{
|
||||
return b16MAX;
|
||||
}
|
||||
}
|
||||
|
||||
/* correct the sign of the result */
|
||||
|
||||
if (negate)
|
||||
{
|
||||
return -result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: b16mulb16
|
||||
****************************************************************************/
|
||||
|
||||
b16_t b16mulb16(b16_t m1, b16_t m2)
|
||||
{
|
||||
bool negate;
|
||||
b16_t product;
|
||||
|
||||
fixsign(&m1, &m2, &negate);
|
||||
product = (b16_t)ub16mulub16((ub16_t)m1, (ub16_t)m2);
|
||||
return adjustsign(product, negate);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ub16mulub16
|
||||
****************************************************************************/
|
||||
|
||||
ub16_t ub16mulub16(ub16_t m1, ub16_t m2)
|
||||
{
|
||||
/* Let:
|
||||
*
|
||||
* m1 = m1i*2**16 + m1f (b16)
|
||||
* m2 = m2i*2**16 + m2f (b16)
|
||||
*
|
||||
* Then:
|
||||
*
|
||||
* m1*m2 = (m1i*m2i)*2**32 + (m1i*m2f + m2i*m1f)*2**16 + m1f*m2f (b32)
|
||||
* = (m1i*m2i)*2**16 + (m1i*m2f + m2i*m1f) + m1f*m2f*2**-16 (b16)
|
||||
* = a*2**16 + b + c*2**-16
|
||||
*/
|
||||
|
||||
uint32_t m1i = ((uint32_t)m1 >> 16);
|
||||
uint32_t m2i = ((uint32_t)m1 >> 16);
|
||||
uint32_t m1f = ((uint32_t)m1 & 0x0000ffff);
|
||||
uint32_t m2f = ((uint32_t)m2 & 0x0000ffff);
|
||||
|
||||
return (m1i*m2i << 16) + m1i*m2f + m2i*m1f + (((m1f*m2f) + b16HALF) >> 16);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: b16sqr
|
||||
****************************************************************************/
|
||||
|
||||
b16_t b16sqr(b16_t a)
|
||||
{
|
||||
b16_t sq;
|
||||
|
||||
/* The result is always positive. Just take the absolute value */
|
||||
|
||||
if (a < 0)
|
||||
{
|
||||
a = -a;
|
||||
}
|
||||
|
||||
/* Overflow occurred if the result is negative */
|
||||
|
||||
sq = (b16_t)ub16sqr(a);
|
||||
if (sq < 0)
|
||||
{
|
||||
sq = b16MAX;
|
||||
}
|
||||
|
||||
return sq;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: b16divb16
|
||||
****************************************************************************/
|
||||
|
||||
ub16_t ub16sqr(ub16_t a)
|
||||
{
|
||||
/* Let:
|
||||
*
|
||||
* m = mi*2**16 + mf (b16)
|
||||
*
|
||||
* Then:
|
||||
*
|
||||
* m*m = (mi*mi)*2**32 + 2*(m1*m2)*2**16 + mf*mf (b32)
|
||||
* = (mi*mi)*2**16 + 2*(mi*mf) + mf*mf*2**-16 (b16)
|
||||
*/
|
||||
|
||||
uint32_t mi = ((uint32_t)a >> 16);
|
||||
uint32_t mf = ((uint32_t)a & 0x0000ffff);
|
||||
|
||||
return (mi*mi << 16) + (mi*mf << 1) + ((mf*mf + b16HALF) >> 16);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: b16divb16
|
||||
****************************************************************************/
|
||||
|
||||
b16_t b16divb16(b16_t num, b16_t denom)
|
||||
{
|
||||
bool negate;
|
||||
b16_t quotient;
|
||||
|
||||
fixsign(&num, &denom, &negate);
|
||||
quotient = (b16_t)ub16divub16((ub16_t)num, (ub16_t)denom);
|
||||
return adjustsign(quotient, negate);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ub16divub16
|
||||
****************************************************************************/
|
||||
|
||||
ub16_t ub16divub16(ub16_t num, ub16_t denom)
|
||||
{
|
||||
uint32_t term1;
|
||||
uint32_t numf;
|
||||
uint32_t product;
|
||||
|
||||
/* Let:
|
||||
*
|
||||
* num = numi*2**16 + numf (b16)
|
||||
* den = deni*2**16 + denf (b16)
|
||||
*
|
||||
* Then:
|
||||
*
|
||||
* num/den = numi*2**16 / den + numf / den (b0)
|
||||
* = numi*2**32 / den + numf*2**16 /den (b16)
|
||||
*/
|
||||
|
||||
/* Check for overflow in the first part of the quotient */
|
||||
|
||||
term1 = ((uint32_t)num & 0xffff0000) / denom;
|
||||
if (term1 >= 0x00010000)
|
||||
{
|
||||
return ub16MAX; /* Will overflow */
|
||||
}
|
||||
|
||||
/* Finish the division */
|
||||
|
||||
numf = num - term1 * denom;
|
||||
term1 <<= 16;
|
||||
product = term1 + (numf + (denom >> 1)) / denom;
|
||||
|
||||
/* Check for overflow */
|
||||
|
||||
if (product < term1)
|
||||
{
|
||||
return ub16MAX; /* Overflowed */
|
||||
}
|
||||
|
||||
return product;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -31,8 +31,6 @@
|
|||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ub32sqrtub16
|
||||
*
|
||||
|
|
@ -76,8 +74,6 @@ ub16_t ub32sqrtub16(ub32_t a)
|
|||
return (ub16_t)xk;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ub16sqrtub8
|
||||
*
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@
|
|||
* available if long long types are supported.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -113,4 +111,3 @@ intmax_t strtoimax(FAR const char *nptr, FAR char **endptr, int base)
|
|||
return (intmax_t)accum;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_HAVE_LONG_LONG */
|
||||
|
|
|
|||
|
|
@ -20,13 +20,9 @@
|
|||
"atof","stdlib.h","defined(CONFIG_HAVE_DOUBLE)","double","FAR const char *"
|
||||
"atoi","stdlib.h","","int","FAR const char *"
|
||||
"atol","stdlib.h","","long","FAR const char *"
|
||||
"atoll","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","long long","FAR const char *"
|
||||
"b16atan2","fixedmath.h","!defined(CONFIG_HAVE_LONG_LONG)","b16_t","b16_t","b16_t"
|
||||
"atoll","stdlib.h","","long long","FAR const char *"
|
||||
"b16cos","fixedmath.h","","b16_t","b16_t"
|
||||
"b16divb16","fixedmath.h","!defined(CONFIG_HAVE_LONG_LONG)","b16_t","b16_t","b16_t"
|
||||
"b16mulb16","fixedmath.h","!defined(CONFIG_HAVE_LONG_LONG)","b16_t","b16_t","b16_t"
|
||||
"b16sin","fixedmath.h","","b16_t","b16_t"
|
||||
"b16sqr","fixedmath.h","!defined(CONFIG_HAVE_LONG_LONG)","b16_t","b16_t"
|
||||
"basename","libgen.h","","FAR char *","FAR char *"
|
||||
"bind_textdomain_codeset","libintl.h","defined(CONFIG_LIBC_LOCALE_GETTEXT)","FAR char *","FAR const char *","FAR const char *"
|
||||
"bindtextdomain","libintl.h","defined(CONFIG_LIBC_LOCALE_GETTEXT)","FAR char *","FAR const char *","FAR const char *"
|
||||
|
|
@ -162,7 +158,7 @@
|
|||
"lib_dumpbuffer","debug.h","","void","FAR const char *","FAR const uint8_t *","unsigned int"
|
||||
"lib_get_stream","nuttx/tls.h","","FAR struct file_struct *","int"
|
||||
"lio_listio","aio.h","defined(CONFIG_FS_AIO)","int","int","FAR struct aiocb * const []|FAR struct aiocb * const *","int","FAR struct sigevent *"
|
||||
"llabs","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","long long int","long long int"
|
||||
"llabs","stdlib.h","","long long int","long long int"
|
||||
"localtime","time.h","","struct tm *","const time_t *"
|
||||
"localtime_r","time.h","","FAR struct tm *","FAR const time_t *","FAR struct tm *"
|
||||
"mallinfo","malloc.h","","struct mallinfo","void"
|
||||
|
|
@ -320,10 +316,10 @@
|
|||
"strtok","string.h","","FAR char *","FAR char *","FAR const char *"
|
||||
"strtok_r","string.h","","FAR char *","FAR char *","FAR const char *","FAR char **"
|
||||
"strtol","stdlib.h","","long","FAR const char *","FAR char **","int"
|
||||
"strtoll","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","long long","FAR const char *","FAR char **","int"
|
||||
"strtoll","stdlib.h","","long long","FAR const char *","FAR char **","int"
|
||||
"strtoul","stdlib.h","","unsigned long","FAR const char *","FAR char **","int"
|
||||
"strtoull","stdlib.h","","unsigned long long int","FAR const char *","FAR char **","int"
|
||||
"strtoull","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","unsigned long long","FAR const char *","FAR char **","int"
|
||||
"strtoull","stdlib.h","","unsigned long long","FAR const char *","FAR char **","int"
|
||||
"strtoumax","inttypes.h","","uintmax_t","FAR const char *","FAR char **","int"
|
||||
"strxfrm","string.h","defined(CONFIG_LIBC_LOCALE)","size_t","FAR char *","FAR const char *","size_t"
|
||||
"swab","unistd.h","","void","FAR const void *","FAR void *","ssize_t"
|
||||
|
|
@ -345,9 +341,6 @@
|
|||
"towlower","wchar.h","","wint_t","wint_t"
|
||||
"towupper","wchar.h","","wint_t","wint_t"
|
||||
"truncate","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char *","off_t"
|
||||
"ub16divub16","fixedmath.h","!defined(CONFIG_HAVE_LONG_LONG)","ub16_t","ub16_t","ub16_t"
|
||||
"ub16mulub16","fixedmath.h","!defined(CONFIG_HAVE_LONG_LONG)","ub16_t","ub16_t","ub16_t"
|
||||
"ub16sqr","fixedmath.h","!defined(CONFIG_HAVE_LONG_LONG)","ub16_t","ub16_t"
|
||||
"uname","sys/utsname.h","","int","FAR struct utsname *"
|
||||
"ungetc","stdio.h","defined(CONFIG_FILE_STREAM)","int","int","FAR FILE *"
|
||||
"ungetwc","wchar.h","defined(CONFIG_FILE_STREAM)","wint_t","wint_t","FAR FILE *"
|
||||
|
|
|
|||
|
Can't render this file because it has a wrong number of fields in line 3.
|
|
|
@ -2,7 +2,8 @@
|
|||
* libs/libc/lzf/lzf_c.c
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
* SPDX-FileCopyrightText: 2000-2010 Marc Alexander Lehmann <schmorp@schmorp.de>
|
||||
* SPDX-FileCopyrightText:
|
||||
* 2000-2010 Marc Alexander Lehmann <schmorp@schmorp.de>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
|
@ -146,11 +147,7 @@ size_t lzf_compress(FAR const void *const in_data,
|
|||
* special workaround for it.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
uint64_t off; /* Workaround for missing POSIX compliance */
|
||||
#else
|
||||
unsigned long off;
|
||||
#endif
|
||||
unsigned int hval;
|
||||
int lit;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,6 @@
|
|||
|
||||
#include <nuttx/crc64.h>
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
|
@ -290,4 +288,3 @@ uint64_t crc64(FAR const uint8_t *src, size_t len)
|
|||
return crc64part(src, len, CRC64_INIT) ^ CRC64_XOROUT;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_HAVE_LONG_LONG */
|
||||
|
|
|
|||
|
|
@ -55,8 +55,6 @@
|
|||
|
||||
#include <nuttx/crc64.h>
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
|
@ -289,4 +287,3 @@ uint64_t crc64emac(FAR const uint8_t *src, size_t len)
|
|||
return crc64emac_part(src, len, 0x0000000000000000ull);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_HAVE_LONG_LONG */
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@
|
|||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
long long atoll(FAR const char *nptr)
|
||||
{
|
||||
return strtoll(nptr, NULL, 10);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
long long int llabs(long long int j)
|
||||
{
|
||||
if (j < 0)
|
||||
|
|
@ -42,4 +41,3 @@ long long int llabs(long long int j)
|
|||
|
||||
return j;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -45,8 +45,6 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(CONFIG_HAVE_LONG_LONG)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -80,4 +78,3 @@ lldiv_t lldiv(long long numer, long long denom)
|
|||
return f;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_HAVE_LONG_LONG */
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ static unsigned short int g_seed48[7] =
|
|||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
static uint64_t rand48_step(FAR unsigned short int *xi,
|
||||
FAR unsigned short int *lc)
|
||||
{
|
||||
|
|
@ -66,7 +65,6 @@ static uint64_t rand48_step(FAR unsigned short int *xi,
|
|||
xi[2] = x >> 32;
|
||||
return x & 0xffffffffffffull;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
|
@ -117,7 +115,6 @@ void lcong48(FAR unsigned short int p[7])
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
long jrand48(FAR unsigned short int s[3])
|
||||
{
|
||||
return (long)(rand48_step(s, g_seed48 + 3) >> 16);
|
||||
|
|
@ -201,4 +198,3 @@ double drand48(void)
|
|||
return erand48(g_seed48);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -76,13 +76,8 @@
|
|||
# define ldbl_min_10_exp FLT_MIN_10_EXP
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
# define long_long long long
|
||||
# define llong_min LLONG_MIN
|
||||
#else
|
||||
# define long_long long
|
||||
# define llong_min LONG_MIN
|
||||
#endif
|
||||
#define long_long long long
|
||||
#define llong_min LLONG_MIN
|
||||
|
||||
#define shgetc(f) (*(f)++)
|
||||
#define shunget(f) ((f)--)
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@
|
|||
|
||||
#include "libc.h"
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -127,4 +125,3 @@ long long strtoll(FAR const char *nptr, FAR char **endptr, int base)
|
|||
return retval;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@
|
|||
|
||||
#include "libc.h"
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -139,4 +137,3 @@ unsigned long long strtoull(FAR const char *nptr,
|
|||
return accum;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -44,9 +44,7 @@ int lib_bsprintf(FAR struct lib_outstream_s *s, FAR const IPTR char *fmt,
|
|||
short int si;
|
||||
int i;
|
||||
long l;
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
long long ll;
|
||||
#endif
|
||||
intmax_t im;
|
||||
size_t sz;
|
||||
ptrdiff_t pd;
|
||||
|
|
@ -97,13 +95,11 @@ int lib_bsprintf(FAR struct lib_outstream_s *s, FAR const IPTR char *fmt,
|
|||
offset += sizeof(var->im);
|
||||
ret += lib_sprintf(s, fmtstr, var->im);
|
||||
}
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
else if (*(fmt - 2) == 'l' && *(fmt - 3) == 'l')
|
||||
{
|
||||
offset += sizeof(var->ll);
|
||||
ret += lib_sprintf(s, fmtstr, var->ll);
|
||||
}
|
||||
#endif
|
||||
else if (*(fmt - 2) == 'l')
|
||||
{
|
||||
offset += sizeof(var->l);
|
||||
|
|
|
|||
|
|
@ -40,10 +40,6 @@
|
|||
* support long long types.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_HAVE_LONG_LONG
|
||||
# undef CONFIG_LIBC_LONG_LONG
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LIBC_SCANSET
|
||||
# define SCANSET_MODS "["
|
||||
#else
|
||||
|
|
@ -245,9 +241,7 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||
int base = 10;
|
||||
char tmp[MAXLN];
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
FAR unsigned long long *plonglong = NULL;
|
||||
#endif
|
||||
FAR unsigned long *plong = NULL;
|
||||
FAR unsigned int *pint = NULL;
|
||||
FAR unsigned short *pshort = NULL;
|
||||
|
|
@ -345,7 +339,7 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||
{
|
||||
modifier = L_MOD;
|
||||
}
|
||||
#if defined(CONFIG_HAVE_LONG_LONG) && ULLONG_MAX != ULONG_MAX
|
||||
#if ULLONG_MAX != ULONG_MAX
|
||||
else if (sizeof(size_t) == sizeof(unsigned long long))
|
||||
{
|
||||
modifier = LL_MOD;
|
||||
|
|
@ -353,13 +347,9 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||
#endif
|
||||
else
|
||||
{
|
||||
/* The only known cases that the default will be hit
|
||||
* are (1) the eZ80 which has sizeof(size_t) = 3 which
|
||||
* is the same as the sizeof(int). And (2) if
|
||||
* CONFIG_HAVE_LONG_LONG
|
||||
* is not enabled and sizeof(size_t) is equal to
|
||||
* sizeof(unsigned long long). This latter case is an
|
||||
* error.
|
||||
/* The only known case that the default will be hit
|
||||
* is the eZ80 which has sizeof(size_t) = 3 which is
|
||||
* the same as the sizeof(int).
|
||||
* Treat as integer with no size qualifier.
|
||||
*/
|
||||
|
||||
|
|
@ -369,11 +359,8 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||
else if (fmt_char(fmt) == 'j')
|
||||
{
|
||||
/* Same as long long if available. Otherwise, long. */
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
|
||||
modifier = LL_MOD;
|
||||
#else
|
||||
modifier = L_MOD;
|
||||
#endif
|
||||
}
|
||||
else if (fmt_char(fmt) == 'h' || fmt_char(fmt) == 'H')
|
||||
{
|
||||
|
|
@ -612,13 +599,11 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||
*plong = 0;
|
||||
break;
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
case LL_MOD:
|
||||
plonglong = next_arg(varg, vabuf,
|
||||
FAR unsigned long long *);
|
||||
*plonglong = 0;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -640,9 +625,8 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||
bool stopconv;
|
||||
int errsave;
|
||||
unsigned long tmplong = 0;
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
unsigned long long tmplonglong = 0;
|
||||
#endif
|
||||
|
||||
/* Copy the real string into a temporary working buffer. */
|
||||
|
||||
if (!width || width > sizeof(tmp) - 1)
|
||||
|
|
@ -858,9 +842,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||
|
||||
switch (modifier)
|
||||
{
|
||||
#ifndef CONFIG_HAVE_LONG_LONG
|
||||
case LL_MOD:
|
||||
#endif
|
||||
case HH_MOD:
|
||||
case H_MOD:
|
||||
case NO_MOD:
|
||||
|
|
@ -875,7 +856,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||
}
|
||||
break;
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
case LL_MOD:
|
||||
if (sign)
|
||||
{
|
||||
|
|
@ -894,7 +874,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||
# endif
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Check if the number was successfully converted */
|
||||
|
|
@ -926,18 +905,13 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||
*pint = (unsigned int)tmplong;
|
||||
break;
|
||||
|
||||
#ifndef CONFIG_HAVE_LONG_LONG
|
||||
case L_MOD:
|
||||
#endif
|
||||
default:
|
||||
*plong = tmplong;
|
||||
break;
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
case LL_MOD:
|
||||
*plonglong = tmplonglong;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
assigncount++;
|
||||
|
|
@ -1191,13 +1165,11 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||
*plong = (unsigned long)nchars;
|
||||
break;
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
case LL_MOD:
|
||||
plonglong = next_arg(varg, vabuf,
|
||||
FAR unsigned long long *);
|
||||
*plonglong = (unsigned long long)nchars;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,10 +61,6 @@
|
|||
* support long long types.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_HAVE_LONG_LONG
|
||||
# undef CONFIG_LIBC_LONG_LONG
|
||||
#endif
|
||||
|
||||
#define stream_putc(c,stream) (total_len++, lib_stream_putc(stream, c))
|
||||
#define stream_puts(buf, len, stream) \
|
||||
(total_len += len, lib_stream_puts(stream, buf, len))
|
||||
|
|
@ -122,9 +118,7 @@ union arg_u
|
|||
{
|
||||
unsigned int u;
|
||||
unsigned long ul;
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
unsigned long long ull;
|
||||
#endif
|
||||
double d;
|
||||
FAR char *cp;
|
||||
};
|
||||
|
|
@ -400,7 +394,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
|
|||
{
|
||||
c = 'l';
|
||||
}
|
||||
#if defined(CONFIG_HAVE_LONG_LONG) && ULLONG_MAX != ULONG_MAX
|
||||
#if ULLONG_MAX != ULONG_MAX
|
||||
else if (sizeof(size_t) == sizeof(unsigned long long))
|
||||
{
|
||||
c = 'l';
|
||||
|
|
@ -410,13 +404,9 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
|
|||
#endif
|
||||
else
|
||||
{
|
||||
/* The only known cases that the default will be hit are
|
||||
* (1) the eZ80 which has sizeof(size_t) = 3 which is the
|
||||
* same as the sizeof(int). And (2) if
|
||||
* CONFIG_HAVE_LONG_LONG
|
||||
* is not enabled and sizeof(size_t) is equal to
|
||||
* sizeof(unsigned long long). This latter case is an
|
||||
* error.
|
||||
/* The only known case that the default will be hit is
|
||||
* the eZ80 which has sizeof(size_t) = 3 which is the
|
||||
* same as the sizeof(int).
|
||||
* Treat as integer with no size qualifier.
|
||||
*/
|
||||
|
||||
|
|
@ -428,9 +418,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
|
|||
{
|
||||
/* Same as long long if available. Otherwise, long. */
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
flags |= FL_REPD_TYPE;
|
||||
#endif
|
||||
flags |= FL_LONG;
|
||||
flags &= ~FL_SHORT;
|
||||
continue;
|
||||
|
|
@ -482,13 +470,11 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
|
|||
|
||||
flags &= ~(FL_LONG | FL_REPD_TYPE);
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
if (sizeof(FAR void *) == sizeof(unsigned long long))
|
||||
{
|
||||
flags |= (FL_LONG | FL_REPD_TYPE);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (sizeof(FAR void *) == sizeof(unsigned long))
|
||||
{
|
||||
flags |= FL_LONG;
|
||||
|
|
@ -951,9 +937,6 @@ str_lpad:
|
|||
|
||||
if (c == 'd' || c == 'i')
|
||||
{
|
||||
#ifndef CONFIG_HAVE_LONG_LONG
|
||||
long x;
|
||||
#else
|
||||
long long x;
|
||||
|
||||
if ((flags & FL_LONG) != 0 && (flags & FL_REPD_TYPE) != 0)
|
||||
|
|
@ -972,7 +955,6 @@ str_lpad:
|
|||
#endif
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if ((flags & FL_LONG) != 0)
|
||||
{
|
||||
#ifdef CONFIG_LIBC_NUMBERED_ARGS
|
||||
|
|
@ -1018,11 +1000,7 @@ str_lpad:
|
|||
flags &= ~(FL_NEGATIVE | FL_ALT);
|
||||
if (x < 0)
|
||||
{
|
||||
#ifndef CONFIG_HAVE_LONG_LONG
|
||||
x = -(unsigned long)x;
|
||||
#else
|
||||
x = -(unsigned long long)x;
|
||||
#endif
|
||||
flags |= FL_NEGATIVE;
|
||||
}
|
||||
|
||||
|
|
@ -1032,7 +1010,7 @@ str_lpad:
|
|||
}
|
||||
else
|
||||
{
|
||||
#if !defined(CONFIG_LIBC_LONG_LONG) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
#if !defined(CONFIG_LIBC_LONG_LONG)
|
||||
DEBUGASSERT(x >= 0 && x <= ULONG_MAX);
|
||||
#endif
|
||||
c = __ultoa_invert(x, buf, 10) - buf;
|
||||
|
|
@ -1041,9 +1019,6 @@ str_lpad:
|
|||
else
|
||||
{
|
||||
int base;
|
||||
#ifndef CONFIG_HAVE_LONG_LONG
|
||||
unsigned long x;
|
||||
#else
|
||||
unsigned long long x;
|
||||
|
||||
if ((flags & FL_LONG) != 0 && (flags & FL_REPD_TYPE) != 0)
|
||||
|
|
@ -1062,7 +1037,6 @@ str_lpad:
|
|||
#endif
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if ((flags & FL_LONG) != 0)
|
||||
{
|
||||
#ifdef CONFIG_LIBC_NUMBERED_ARGS
|
||||
|
|
@ -1218,7 +1192,7 @@ str_lpad:
|
|||
}
|
||||
else
|
||||
{
|
||||
#if !defined(CONFIG_LIBC_LONG_LONG) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
#if !defined(CONFIG_LIBC_LONG_LONG)
|
||||
DEBUGASSERT(x <= ULONG_MAX);
|
||||
#endif
|
||||
c = __ultoa_invert(x, buf, base) - buf;
|
||||
|
|
@ -1355,10 +1329,8 @@ int lib_vsprintf(FAR struct lib_outstream_s *stream,
|
|||
switch (arglist.type[i])
|
||||
{
|
||||
case TYPE_LONG_LONG:
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
arglist.value[i].ull = va_arg(ap, unsigned long long);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case TYPE_LONG:
|
||||
arglist.value[i].ul = va_arg(ap, unsigned long);
|
||||
|
|
|
|||
|
|
@ -50,10 +50,6 @@
|
|||
* support long long types.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_HAVE_LONG_LONG
|
||||
# undef CONFIG_LIBC_LONG_LONG
|
||||
#endif
|
||||
|
||||
/* Next flags are to use with `base'. Unused fields are reserved. */
|
||||
|
||||
#define XTOA_PREFIX 0x0100 /* Put prefix for octal or hex */
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@
|
|||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ffsll
|
||||
*
|
||||
|
|
@ -67,4 +65,3 @@ int ffsll(long long j)
|
|||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@
|
|||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
|
||||
/****************************************************************************
|
||||
* Name: flsll
|
||||
*
|
||||
|
|
@ -67,4 +65,3 @@ int flsll(long long j)
|
|||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -34,18 +34,6 @@
|
|||
|
||||
#include "libc.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Can't support CONFIG_LIBC_MEMSET_64BIT if the platform does not
|
||||
* have 64-bit integer types.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_HAVE_LONG_LONG
|
||||
# undef CONFIG_LIBC_MEMSET_64BIT
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -45,14 +45,6 @@
|
|||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Can't support CONFIG_LIBC_MEMCPY_64BIT if the platform does not have
|
||||
* 64-bit integer types.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_HAVE_LONG_LONG
|
||||
# undef CONFIG_LIBC_MEMCPY_64BIT
|
||||
#endif
|
||||
|
||||
/* Remove definitions when CONFIG_LIBC_MEMCPY_INDEXED_COPY is defined */
|
||||
|
||||
#ifdef CONFIG_LIBC_MEMCPY_INDEXED_COPY
|
||||
|
|
@ -307,15 +299,31 @@ FAR void *memcpy(FAR void *dest, FAR const void *src, size_t count)
|
|||
|
||||
switch ((((uintptr_t)src8) PRE_SWITCH_ADJUST) & (TYPE_WIDTH - 1))
|
||||
{
|
||||
case 0: COPY_NO_SHIFT(); break;
|
||||
case 1: COPY_SHIFT(1); break;
|
||||
case 2: COPY_SHIFT(2); break;
|
||||
case 3: COPY_SHIFT(3); break;
|
||||
case 0:
|
||||
COPY_NO_SHIFT();
|
||||
break;
|
||||
case 1:
|
||||
COPY_SHIFT(1);
|
||||
break;
|
||||
case 2:
|
||||
COPY_SHIFT(2);
|
||||
break;
|
||||
case 3:
|
||||
COPY_SHIFT(3);
|
||||
break;
|
||||
#if TYPE_WIDTH > 4
|
||||
case 4: COPY_SHIFT(4); break;
|
||||
case 5: COPY_SHIFT(5); break;
|
||||
case 6: COPY_SHIFT(6); break;
|
||||
case 7: COPY_SHIFT(7); break;
|
||||
case 4:
|
||||
COPY_SHIFT(4);
|
||||
break;
|
||||
case 5:
|
||||
COPY_SHIFT(5);
|
||||
break;
|
||||
case 6:
|
||||
COPY_SHIFT(6);
|
||||
break;
|
||||
case 7:
|
||||
COPY_SHIFT(7);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,11 +33,9 @@
|
|||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
#ifdef CONFIG_HAVE_DOUBLE
|
||||
long long llround(double x)
|
||||
{
|
||||
return (long long)round(x);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -33,9 +33,7 @@
|
|||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
long long llroundf(float x)
|
||||
{
|
||||
return (long long)roundf(x);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -33,11 +33,9 @@
|
|||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
#ifdef CONFIG_HAVE_LONG_DOUBLE
|
||||
long long llroundl(long double x)
|
||||
{
|
||||
return (long long)roundl(x);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue