Remove the unnecessary math.h inclusion
or move from header file to source file since math.h doesn't always exist Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
2b46a0fdde
commit
3f9908f7d1
@ -34,7 +34,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/power/battery_gauge.h>
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
#include <semaphore.h>
|
||||
#include <errno.h>
|
||||
@ -1740,7 +1739,7 @@ static uint32_t rspi_setfrequency(FAR struct spi_dev_s *dev,
|
||||
if (frequency != priv->frequency)
|
||||
{
|
||||
/* Below formula used to calculate bit rate
|
||||
* Bit rate f(PCLK)/(2 × (n + 1) × 2^N) .
|
||||
* Bit rate f(PCLK)/(2 * (n + 1) * 2^N) .
|
||||
* n denotes SPBR setting (0,1,2..255) .
|
||||
* N denotes a BRDV[1:0] bit setting (0, 1, 2, 3) .
|
||||
*/
|
||||
|
@ -26,7 +26,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
#include <semaphore.h>
|
||||
#include <errno.h>
|
||||
@ -1375,7 +1374,7 @@ static uint32_t rspi_setfrequency(FAR struct spi_dev_s *dev,
|
||||
if (frequency != priv->frequency)
|
||||
{
|
||||
/* Below formula used to calculate bit rate
|
||||
* Bit rate f(PCLK)/(2 × (n + 1) × 2^N) .
|
||||
* Bit rate f(PCLK)/(2 * (n + 1) * 2^N) .
|
||||
* n denotes SPBR setting (0,1,2..255) .
|
||||
* N denotes a BRDV[1:0] bit setting (0, 1, 2, 3) .
|
||||
*/
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include <nuttx/audio/i2s.h>
|
||||
#include <nuttx/audio/audio.h>
|
||||
#include <nuttx/audio/cs4344.h>
|
||||
#include <nuttx/lib/math.h>
|
||||
|
||||
#include "cs4344.h"
|
||||
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <math.h>
|
||||
#include <queue.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
@ -48,7 +48,6 @@
|
||||
#include <nuttx/audio/i2s.h>
|
||||
#include <nuttx/audio/audio.h>
|
||||
#include <nuttx/audio/wm8994.h>
|
||||
#include <nuttx/lib/math.h>
|
||||
|
||||
#include "wm8994.h"
|
||||
|
||||
|
@ -68,7 +68,6 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "spirit_types.h"
|
||||
|
||||
|
@ -37,6 +37,8 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "lib_dtoa_engine.h"
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -40,7 +40,6 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <float.h>
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <nuttx/lib/lib.h>
|
||||
@ -44,6 +43,12 @@
|
||||
# define CONFIG_LIB_RAND_ORDER 3
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_HAVE_DOUBLE
|
||||
typedef float float_t;
|
||||
#else
|
||||
typedef double float_t;
|
||||
#endif
|
||||
|
||||
/* Values needed by the random number generator */
|
||||
|
||||
#define RND1_CONSTK 470001
|
||||
@ -64,7 +69,7 @@
|
||||
|
||||
static inline unsigned long fgenerate1(void);
|
||||
#if (CONFIG_LIB_RAND_ORDER == 1)
|
||||
static double_t frand1(void);
|
||||
static float_t frand1(void);
|
||||
#endif
|
||||
|
||||
/* Second order congruential generators */
|
||||
@ -72,14 +77,14 @@ static double_t frand1(void);
|
||||
#if (CONFIG_LIB_RAND_ORDER > 1)
|
||||
static inline unsigned long fgenerate2(void);
|
||||
#if (CONFIG_LIB_RAND_ORDER == 2)
|
||||
static double_t frand2(void);
|
||||
static float_t frand2(void);
|
||||
#endif
|
||||
|
||||
/* Third order congruential generators */
|
||||
|
||||
#if (CONFIG_LIB_RAND_ORDER > 2)
|
||||
static inline unsigned long fgenerate3(void);
|
||||
static double_t frand3(void);
|
||||
static float_t frand3(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -116,7 +121,7 @@ static inline unsigned long fgenerate1(void)
|
||||
}
|
||||
|
||||
#if (CONFIG_LIB_RAND_ORDER == 1)
|
||||
static double_t frand1(void)
|
||||
static float_t frand1(void)
|
||||
{
|
||||
/* First order congruential generator. */
|
||||
|
||||
@ -124,7 +129,7 @@ static double_t frand1(void)
|
||||
|
||||
/* Construct an floating point value in the range from 0.0 up to 1.0 */
|
||||
|
||||
return ((double_t)randint) / ((double_t)RND1_CONSTP);
|
||||
return ((float_t)randint) / ((float_t)RND1_CONSTP);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -156,7 +161,7 @@ static inline unsigned long fgenerate2(void)
|
||||
}
|
||||
|
||||
#if (CONFIG_LIB_RAND_ORDER == 2)
|
||||
static double_t frand2(void)
|
||||
static float_t frand2(void)
|
||||
{
|
||||
/* Second order congruential generator */
|
||||
|
||||
@ -164,7 +169,7 @@ static double_t frand2(void)
|
||||
|
||||
/* Construct an floating point value in the range from 0.0 up to 1.0 */
|
||||
|
||||
return ((double_t)randint) / ((double_t)RND2_CONSTP);
|
||||
return ((float_t)randint) / ((float_t)RND2_CONSTP);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -197,7 +202,7 @@ static inline unsigned long fgenerate3(void)
|
||||
return randint;
|
||||
}
|
||||
|
||||
static double_t frand3(void)
|
||||
static float_t frand3(void)
|
||||
{
|
||||
/* Third order congruential generator */
|
||||
|
||||
@ -205,7 +210,7 @@ static double_t frand3(void)
|
||||
|
||||
/* Construct an floating point value in the range from 0.0 up to 1.0 */
|
||||
|
||||
return ((double_t)randint) / ((double_t)RND3_CONSTP);
|
||||
return ((float_t)randint) / ((float_t)RND3_CONSTP);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -246,7 +251,7 @@ void srand(unsigned int seed)
|
||||
unsigned long nrand(unsigned long limit)
|
||||
{
|
||||
unsigned long result;
|
||||
double_t ratio;
|
||||
float_t ratio;
|
||||
|
||||
/* Loop to be sure a legal random number is generated */
|
||||
|
||||
@ -264,7 +269,7 @@ unsigned long nrand(unsigned long limit)
|
||||
|
||||
/* Then, produce the return-able value in the requested range */
|
||||
|
||||
result = (unsigned long)(((double_t)limit) * ratio);
|
||||
result = (unsigned long)(((float_t)limit) * ratio);
|
||||
|
||||
/* Loop because there is an (unlikely) possibility that rounding
|
||||
* could increase the result at the limit value about the limit.
|
||||
|
Loading…
x
Reference in New Issue
Block a user