mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 20:08:15 +08:00
Remove the remain MIN/MAX like macro
Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
@@ -35,6 +35,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
@@ -46,14 +48,6 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_SCHED_TICKLESS
|
#ifdef CONFIG_SCHED_TICKLESS
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef min
|
|
||||||
# define min(a,b) (a < b ? a : b)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -428,13 +422,13 @@ static bool lpc43_tl_set_calc_arm(uint32_t curr, uint32_t to_set, bool arm)
|
|||||||
|
|
||||||
if (curr < TO_RESET_NEXT)
|
if (curr < TO_RESET_NEXT)
|
||||||
{
|
{
|
||||||
calc_time = min(TO_RESET_NEXT, to_set);
|
calc_time = MIN(TO_RESET_NEXT, to_set);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (curr < TO_END)
|
if (curr < TO_END)
|
||||||
{
|
{
|
||||||
calc_time = min(curr + RESET_TICKS, to_set);
|
calc_time = MIN(curr + RESET_TICKS, to_set);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
@@ -42,10 +44,6 @@
|
|||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef min
|
|
||||||
# define min(a,b) (a < b ? a : b)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define COUNTER_MAX 0x0000ffffffffffffllu
|
#define COUNTER_MAX 0x0000ffffffffffffllu
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -468,13 +466,13 @@ static bool lpc54_set_calc_arm(uint64_t curr, uint64_t to_set, bool arm)
|
|||||||
|
|
||||||
if (curr < g_to_reset_next)
|
if (curr < g_to_reset_next)
|
||||||
{
|
{
|
||||||
calc_time = min(g_to_reset_next, to_set);
|
calc_time = MIN(g_to_reset_next, to_set);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (curr < g_to_end)
|
if (curr < g_to_end)
|
||||||
{
|
{
|
||||||
calc_time = min(curr + g_reset_ticks, to_set);
|
calc_time = MIN(curr + g_reset_ticks, to_set);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,6 +35,8 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include <nuttx/wdog.h>
|
#include <nuttx/wdog.h>
|
||||||
@@ -138,10 +140,6 @@
|
|||||||
# warning "You are using an incomplete/untested configuration"
|
# warning "You are using an incomplete/untested configuration"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef min
|
|
||||||
# define min(a,b) ((a) < (b) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* We need at least one more free buffer than transmit buffers */
|
/* We need at least one more free buffer than transmit buffers */
|
||||||
|
|
||||||
#define S32K3XX_EMAC_NFREEBUFFERS (CONFIG_S32K3XX_ENET_NTXBUFFERS+1)
|
#define S32K3XX_EMAC_NFREEBUFFERS (CONFIG_S32K3XX_ENET_NTXBUFFERS+1)
|
||||||
@@ -1319,7 +1317,7 @@ static int s32k3xx_recvframe(struct s32k3xx_driver_s *priv)
|
|||||||
|
|
||||||
up_invalidate_dcache((uintptr_t)dev->d_buf,
|
up_invalidate_dcache((uintptr_t)dev->d_buf,
|
||||||
(uintptr_t)dev->d_buf +
|
(uintptr_t)dev->d_buf +
|
||||||
min(dev->d_len, ALIGNED_BUFSIZE));
|
MIN(dev->d_len, ALIGNED_BUFSIZE));
|
||||||
|
|
||||||
ninfo("rxhead: %p d_buf: %p d_len: %d\n",
|
ninfo("rxhead: %p d_buf: %p d_len: %d\n",
|
||||||
priv->rxhead, dev->d_buf, dev->d_len);
|
priv->rxhead, dev->d_buf, dev->d_len);
|
||||||
|
|||||||
@@ -30,6 +30,8 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include "hardware/s32k3xx_pflash.h"
|
#include "hardware/s32k3xx_pflash.h"
|
||||||
#include "hardware/s32k3xx_xrdc.h"
|
#include "hardware/s32k3xx_xrdc.h"
|
||||||
|
|
||||||
@@ -51,11 +53,6 @@
|
|||||||
# error Progmem must be a multiple of 8
|
# error Progmem must be a multiple of 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define min(a,b) \
|
|
||||||
({ __typeof__ (a) _a = (a); \
|
|
||||||
__typeof__ (b) _b = (b); \
|
|
||||||
_a < _b ? _a : _b; })
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -392,7 +389,7 @@ ssize_t up_progmem_write(size_t addr, const void *buf, size_t count)
|
|||||||
|
|
||||||
execute_init_sequence(dest);
|
execute_init_sequence(dest);
|
||||||
|
|
||||||
for (i = 0; i < min(32, words_to_write); i++)
|
for (i = 0; i < MIN(32, words_to_write); i++)
|
||||||
{
|
{
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -75,8 +76,6 @@
|
|||||||
#define ALIGN_UP(n) (((n)+ALIGN_MASK) & ~ALIGN_MASK)
|
#define ALIGN_UP(n) (((n)+ALIGN_MASK) & ~ALIGN_MASK)
|
||||||
#define IS_ALIGNED(n) (((uint32_t)(n) & ALIGN_MASK) == 0)
|
#define IS_ALIGNED(n) (((uint32_t)(n) & ALIGN_MASK) == 0)
|
||||||
|
|
||||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
|
||||||
|
|
||||||
/* LUT entries used for various command sequences */
|
/* LUT entries used for various command sequences */
|
||||||
#define QSPI_LUT_READ 0U /* Quad Output read */
|
#define QSPI_LUT_READ 0U /* Quad Output read */
|
||||||
#define QSPI_LUT_WRITE 1U /* Quad write */
|
#define QSPI_LUT_WRITE 1U /* Quad write */
|
||||||
@@ -683,7 +682,7 @@ static int qspi_receive_blocking(struct s32k3xx_qspidev_s *priv,
|
|||||||
uint32_t regval;
|
uint32_t regval;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
readlen = min(128, remaining);
|
readlen = MIN(128, remaining);
|
||||||
|
|
||||||
/* Copy sequence in LUT registers */
|
/* Copy sequence in LUT registers */
|
||||||
|
|
||||||
@@ -703,7 +702,7 @@ static int qspi_receive_blocking(struct s32k3xx_qspidev_s *priv,
|
|||||||
regval |= QSPI_MCR_CLR_RXF;
|
regval |= QSPI_MCR_CLR_RXF;
|
||||||
putreg32(regval, S32K3XX_QSPI_MCR);
|
putreg32(regval, S32K3XX_QSPI_MCR);
|
||||||
|
|
||||||
readlen = min(128, remaining);
|
readlen = MIN(128, remaining);
|
||||||
|
|
||||||
#ifdef CONFIG_S32K3XX_QSPI_INTERRUPTS
|
#ifdef CONFIG_S32K3XX_QSPI_INTERRUPTS
|
||||||
/* enable end of transfer interrupt for asynchronous transfers */
|
/* enable end of transfer interrupt for asynchronous transfers */
|
||||||
@@ -886,7 +885,7 @@ static int qspi_transmit_blocking(struct s32k3xx_qspidev_s *priv,
|
|||||||
uint32_t regval;
|
uint32_t regval;
|
||||||
uint32_t count = UINT32_MAX;
|
uint32_t count = UINT32_MAX;
|
||||||
uint32_t *data = (uint32_t *)meminfo->buffer;
|
uint32_t *data = (uint32_t *)meminfo->buffer;
|
||||||
uint32_t write_cycle = min(32, ((uint32_t)remaining) >> 2U);
|
uint32_t write_cycle = MIN(32, ((uint32_t)remaining) >> 2U);
|
||||||
uint32_t timeout = 1000;
|
uint32_t timeout = 1000;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,8 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
#include "hardware/stm32_tim.h"
|
#include "hardware/stm32_tim.h"
|
||||||
|
|
||||||
@@ -326,15 +328,13 @@
|
|||||||
#endif
|
#endif
|
||||||
#define PWM_TIM17_NCHANNELS PWM_TIM17_CHANNEL1
|
#define PWM_TIM17_NCHANNELS PWM_TIM17_CHANNEL1
|
||||||
|
|
||||||
#define PWM_MAX(a, b) ((a) > (b) ? (a) : (b))
|
#define PWM_NCHANNELS MAX(PWM_TIM1_NCHANNELS, \
|
||||||
|
MAX(PWM_TIM2_NCHANNELS, \
|
||||||
#define PWM_NCHANNELS PWM_MAX(PWM_TIM1_NCHANNELS, \
|
MAX(PWM_TIM3_NCHANNELS, \
|
||||||
PWM_MAX(PWM_TIM2_NCHANNELS, \
|
MAX(PWM_TIM14_NCHANNELS, \
|
||||||
PWM_MAX(PWM_TIM3_NCHANNELS, \
|
MAX(PWM_TIM15_NCHANNELS, \
|
||||||
PWM_MAX(PWM_TIM14_NCHANNELS, \
|
MAX(PWM_TIM16_NCHANNELS, \
|
||||||
PWM_MAX(PWM_TIM15_NCHANNELS, \
|
PWM_TIM17_NCHANNELS))))))
|
||||||
PWM_MAX(PWM_TIM16_NCHANNELS, \
|
|
||||||
PWM_TIM17_NCHANNELS))))))
|
|
||||||
|
|
||||||
#else /* !CONFIG_PWM_MULTICHAN */
|
#else /* !CONFIG_PWM_MULTICHAN */
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,8 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
@@ -213,10 +215,6 @@
|
|||||||
# define CONFIG_STM32H7_ETH_NTXDESC 4
|
# define CONFIG_STM32H7_ETH_NTXDESC 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef min
|
|
||||||
# define min(a,b) ((a) < (b) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* We need at least one more free buffer than transmit buffers */
|
/* We need at least one more free buffer than transmit buffers */
|
||||||
|
|
||||||
#define STM32_ETH_NFREEBUFFERS (CONFIG_STM32H7_ETH_NTXDESC+1)
|
#define STM32_ETH_NFREEBUFFERS (CONFIG_STM32H7_ETH_NTXDESC+1)
|
||||||
@@ -1795,7 +1793,7 @@ static int stm32_recvframe(struct stm32_ethmac_s *priv)
|
|||||||
|
|
||||||
up_invalidate_dcache((uintptr_t)dev->d_buf,
|
up_invalidate_dcache((uintptr_t)dev->d_buf,
|
||||||
(uintptr_t)dev->d_buf +
|
(uintptr_t)dev->d_buf +
|
||||||
min(dev->d_len, ALIGNED_BUFSIZE));
|
MIN(dev->d_len, ALIGNED_BUFSIZE));
|
||||||
|
|
||||||
ninfo("rxhead: %p d_buf: %p d_len: %d\n",
|
ninfo("rxhead: %p d_buf: %p d_len: %d\n",
|
||||||
priv->rxhead, dev->d_buf, dev->d_len);
|
priv->rxhead, dev->d_buf, dev->d_len);
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include <nuttx/compiler.h>
|
#include <nuttx/compiler.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
@@ -77,14 +79,6 @@
|
|||||||
region##_val; \
|
region##_val; \
|
||||||
})
|
})
|
||||||
|
|
||||||
#ifndef min
|
|
||||||
#define min(a,b) ((a) < (b) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef max
|
|
||||||
#define max(a,b) ((a) > (b) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -680,7 +674,7 @@ int riscv_check_pmp_access(uintptr_t attr, uintptr_t base, uintptr_t size)
|
|||||||
{
|
{
|
||||||
/* Found matching region that allows access */
|
/* Found matching region that allows access */
|
||||||
|
|
||||||
size -= min(end, entry.end) - max(base, entry.base);
|
size -= MIN(end, entry.end) - MAX(base, entry.base);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/cache.h>
|
#include <nuttx/cache.h>
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
@@ -88,9 +90,6 @@
|
|||||||
# define CONFIG_LITEX_SD4BIT_FREQ 50000000 /* 25MHz SD 4-bit, normal clocking */
|
# define CONFIG_LITEX_SD4BIT_FREQ 50000000 /* 25MHz SD 4-bit, normal clocking */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define max(x, y) (((x) > (y)) ? (x) : (y))
|
|
||||||
#define min(x, y) (((x) < (y)) ? (x) : (y))
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -626,7 +625,7 @@ static void litex_clock(struct sdio_dev_s *dev, enum sdio_clock_e rate)
|
|||||||
uint32_t divider;
|
uint32_t divider;
|
||||||
divider = clk_freq ? litex_get_hfclk() / clk_freq : MAX_DIVIDER;
|
divider = clk_freq ? litex_get_hfclk() / clk_freq : MAX_DIVIDER;
|
||||||
divider = litex_pow2roundup(divider);
|
divider = litex_pow2roundup(divider);
|
||||||
divider = min(max(divider, 2), MAX_DIVIDER);
|
divider = MIN(MAX(divider, 2), MAX_DIVIDER);
|
||||||
|
|
||||||
/* this is the *effective* new clk_freq */
|
/* this is the *effective* new clk_freq */
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -79,8 +80,6 @@ union xorshift128_state_u
|
|||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
|
||||||
|
|
||||||
static ssize_t devurand_read(FAR struct file *filep, FAR char *buffer,
|
static ssize_t devurand_read(FAR struct file *filep, FAR char *buffer,
|
||||||
size_t buflen);
|
size_t buflen);
|
||||||
static ssize_t devurand_write(FAR struct file *filep, FAR const char *buffer,
|
static ssize_t devurand_write(FAR struct file *filep, FAR const char *buffer,
|
||||||
@@ -220,7 +219,7 @@ static ssize_t devurand_write(FAR struct file *filep, FAR const char *buffer,
|
|||||||
#ifdef CONFIG_DEV_URANDOM_CONGRUENTIAL
|
#ifdef CONFIG_DEV_URANDOM_CONGRUENTIAL
|
||||||
unsigned int seed = 0;
|
unsigned int seed = 0;
|
||||||
|
|
||||||
len = min(len, sizeof(unsigned int));
|
len = MIN(len, sizeof(unsigned int));
|
||||||
memcpy(&seed, buffer, len);
|
memcpy(&seed, buffer, len);
|
||||||
srand(seed);
|
srand(seed);
|
||||||
return len;
|
return len;
|
||||||
@@ -242,7 +241,7 @@ static ssize_t devurand_write(FAR struct file *filep, FAR const char *buffer,
|
|||||||
{
|
{
|
||||||
/* Make unaligned input aligned. */
|
/* Make unaligned input aligned. */
|
||||||
|
|
||||||
currlen = min(sizeof(uint32_t) - ((uintptr_t)buffer & alignmask), len);
|
currlen = MIN(sizeof(uint32_t) - ((uintptr_t)buffer & alignmask), len);
|
||||||
memcpy(&tmp, buffer, currlen);
|
memcpy(&tmp, buffer, currlen);
|
||||||
up_rngaddint(RND_SRC_SW, tmp);
|
up_rngaddint(RND_SRC_SW, tmp);
|
||||||
|
|
||||||
@@ -276,7 +275,7 @@ static ssize_t devurand_write(FAR struct file *filep, FAR const char *buffer,
|
|||||||
|
|
||||||
return initlen;
|
return initlen;
|
||||||
#else
|
#else
|
||||||
len = min(len, sizeof(g_prng.u));
|
len = MIN(len, sizeof(g_prng.u));
|
||||||
memcpy(&g_prng.u, buffer, len);
|
memcpy(&g_prng.u, buffer, len);
|
||||||
return len;
|
return len;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+5
-15
@@ -37,6 +37,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
@@ -199,18 +201,6 @@
|
|||||||
#define PL2303_RWREQUEST_TYPE (0x40)
|
#define PL2303_RWREQUEST_TYPE (0x40)
|
||||||
#define PL2303_RWREQUEST (0x01) /* IN/OUT, Recipient device */
|
#define PL2303_RWREQUEST (0x01) /* IN/OUT, Recipient device */
|
||||||
|
|
||||||
/* Misc Macros **************************************************************/
|
|
||||||
|
|
||||||
/* min/max macros */
|
|
||||||
|
|
||||||
#ifndef min
|
|
||||||
# define min(a,b) ((a)<(b)?(a):(b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef max
|
|
||||||
# define max(a,b) ((a)>(b)?(a):(b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Trace values *************************************************************/
|
/* Trace values *************************************************************/
|
||||||
|
|
||||||
#define PL2303_CLASSAPI_SETUP TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_SETUP)
|
#define PL2303_CLASSAPI_SETUP TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_SETUP)
|
||||||
@@ -617,7 +607,7 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv)
|
|||||||
|
|
||||||
/* Get the maximum number of bytes that will fit into one bulk IN request */
|
/* Get the maximum number of bytes that will fit into one bulk IN request */
|
||||||
|
|
||||||
reqlen = max(CONFIG_PL2303_BULKIN_REQLEN, ep->maxpacket);
|
reqlen = MAX(CONFIG_PL2303_BULKIN_REQLEN, ep->maxpacket);
|
||||||
|
|
||||||
while (!sq_empty(&priv->reqlist))
|
while (!sq_empty(&priv->reqlist))
|
||||||
{
|
{
|
||||||
@@ -1809,7 +1799,7 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
|
|||||||
{
|
{
|
||||||
case PL2303_SETLINEREQUEST:
|
case PL2303_SETLINEREQUEST:
|
||||||
{
|
{
|
||||||
memcpy(priv->linest, ctrlreq->buf, min(len, 7));
|
memcpy(priv->linest, ctrlreq->buf, MIN(len, 7));
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1897,7 +1887,7 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
|
|||||||
|
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
ctrlreq->len = min(len, ret);
|
ctrlreq->len = MIN(len, ret);
|
||||||
ctrlreq->flags = USBDEV_REQFLAGS_NULLPKT;
|
ctrlreq->flags = USBDEV_REQFLAGS_NULLPKT;
|
||||||
ret = EP_SUBMIT(dev->ep0, ctrlreq);
|
ret = EP_SUBMIT(dev->ep0, ctrlreq);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|||||||
+5
-11
@@ -35,6 +35,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include <nuttx/queue.h>
|
#include <nuttx/queue.h>
|
||||||
#include <nuttx/net/net.h>
|
#include <nuttx/net/net.h>
|
||||||
#include <nuttx/net/netdev.h>
|
#include <nuttx/net/netdev.h>
|
||||||
@@ -96,14 +98,6 @@
|
|||||||
|
|
||||||
#define ETHWORK LPWORK
|
#define ETHWORK LPWORK
|
||||||
|
|
||||||
#ifndef min
|
|
||||||
# define min(a,b) ((a)<(b)?(a):(b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef max
|
|
||||||
# define max(a,b) ((a)>(b)?(a):(b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -813,7 +807,7 @@ static uint16_t rndis_fillrequest(FAR struct rndis_dev_s *priv,
|
|||||||
|
|
||||||
req->len = 0;
|
req->len = 0;
|
||||||
|
|
||||||
datalen = min(priv->netdev.d_len,
|
datalen = MIN(priv->netdev.d_len,
|
||||||
CONFIG_RNDIS_BULKIN_REQLEN - RNDIS_PACKET_HDR_SIZE);
|
CONFIG_RNDIS_BULKIN_REQLEN - RNDIS_PACKET_HDR_SIZE);
|
||||||
if (datalen > 0)
|
if (datalen > 0)
|
||||||
{
|
{
|
||||||
@@ -1135,7 +1129,7 @@ static inline int rndis_recvpacket(FAR struct rndis_dev_s *priv,
|
|||||||
{
|
{
|
||||||
size_t index = priv->current_rx_received -
|
size_t index = priv->current_rx_received -
|
||||||
priv->current_rx_datagram_offset;
|
priv->current_rx_datagram_offset;
|
||||||
size_t copysize = min(reqlen,
|
size_t copysize = MIN(reqlen,
|
||||||
priv->current_rx_datagram_size - index);
|
priv->current_rx_datagram_size - index);
|
||||||
|
|
||||||
/* Check if the received packet exceeds request buffer */
|
/* Check if the received packet exceeds request buffer */
|
||||||
@@ -2442,7 +2436,7 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
|
|||||||
|
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
ctrlreq->len = min(len, ret);
|
ctrlreq->len = MIN(len, ret);
|
||||||
ctrlreq->flags = USBDEV_REQFLAGS_NULLPKT;
|
ctrlreq->flags = USBDEV_REQFLAGS_NULLPKT;
|
||||||
ret = EP_SUBMIT(dev->ep0, ctrlreq);
|
ret = EP_SUBMIT(dev->ep0, ctrlreq);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|||||||
@@ -997,7 +997,7 @@ static int bcmf_wl_scan_format_results(FAR struct bcmf_dev_s *priv,
|
|||||||
for (i = 0; i < priv->scan_result_entries; i++)
|
for (i = 0; i < priv->scan_result_entries; i++)
|
||||||
{
|
{
|
||||||
scan_result[i] = &priv->scan_result[i];
|
scan_result[i] = &priv->scan_result[i];
|
||||||
len += (min(strlen((FAR const char *)scan_result[i]->SSID),
|
len += (MIN(strlen((FAR const char *)scan_result[i]->SSID),
|
||||||
32) + 3) & ~3;
|
32) + 3) & ~3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1045,7 +1045,7 @@ static int bcmf_wl_scan_format_results(FAR struct bcmf_dev_s *priv,
|
|||||||
iwe = (FAR struct iw_event *)pointer;
|
iwe = (FAR struct iw_event *)pointer;
|
||||||
iwe->cmd = SIOCGIWESSID;
|
iwe->cmd = SIOCGIWESSID;
|
||||||
iwe->u.essid.flags = 0;
|
iwe->u.essid.flags = 0;
|
||||||
iwe->u.essid.length = min(strlen((FAR const char *)info->SSID), 32);
|
iwe->u.essid.length = MIN(strlen((FAR const char *)info->SSID), 32);
|
||||||
iwe->u.essid.pointer = (FAR void *)sizeof(iwe->u.essid);
|
iwe->u.essid.pointer = (FAR void *)sizeof(iwe->u.essid);
|
||||||
memcpy(&iwe->u.essid + 1, info->SSID, iwe->u.essid.length);
|
memcpy(&iwe->u.essid + 1, info->SSID, iwe->u.essid.length);
|
||||||
iwe->len = IW_EV_LEN(essid) + ((iwe->u.essid.length + 3) & ~3);
|
iwe->len = IW_EV_LEN(essid) + ((iwe->u.essid.length + 3) & ~3);
|
||||||
|
|||||||
@@ -26,14 +26,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <sys/param.h>
|
||||||
#ifndef min
|
|
||||||
#define min(a,b) ((a) < (b) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef max
|
|
||||||
#define max(a,b) ((a) > (b) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
|
|||||||
@@ -87,9 +87,6 @@
|
|||||||
|
|
||||||
#define MARK(a) { asm(" .globl M.a"); asm("M.a:"); }
|
#define MARK(a) { asm(" .globl M.a"); asm("M.a:"); }
|
||||||
|
|
||||||
#undef min
|
|
||||||
#define min(a,b) ((a>b) ? b : a)
|
|
||||||
|
|
||||||
#ifndef IBUFSIZ
|
#ifndef IBUFSIZ
|
||||||
# define IBUFSIZ BUFSIZ /* Defailt input buffer size */
|
# define IBUFSIZ BUFSIZ /* Defailt input buffer size */
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -47,14 +47,13 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define min(a, b) (a) < (b) ? a : b
|
|
||||||
|
|
||||||
#define swapcode(TYPE, parmi, parmj, n) \
|
#define swapcode(TYPE, parmi, parmj, n) \
|
||||||
{ \
|
{ \
|
||||||
long i = (n) / sizeof (TYPE); \
|
long i = (n) / sizeof (TYPE); \
|
||||||
@@ -275,10 +274,10 @@ loop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
pn = (FAR char *)base + nel * width;
|
pn = (FAR char *)base + nel * width;
|
||||||
r = min(pa - (FAR char *)base, pb - pa);
|
r = MIN(pa - (FAR char *)base, pb - pa);
|
||||||
vecswap(base, pb - r, r);
|
vecswap(base, pb - r, r);
|
||||||
|
|
||||||
r = min(pd - pc, pn - pd - width);
|
r = MIN(pd - pc, pn - pd - width);
|
||||||
vecswap(pb, pn - r, r);
|
vecswap(pb, pn - r, r);
|
||||||
|
|
||||||
if ((r = pb - pa) > width)
|
if ((r = pb - pa) > width)
|
||||||
|
|||||||
@@ -58,6 +58,8 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include <nuttx/time.h>
|
#include <nuttx/time.h>
|
||||||
#include <nuttx/init.h>
|
#include <nuttx/init.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
@@ -120,7 +122,6 @@
|
|||||||
/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
|
/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
|
||||||
|
|
||||||
#define is_digit(c) ((unsigned)(c) - '0' <= 9)
|
#define is_digit(c) ((unsigned)(c) - '0' <= 9)
|
||||||
#define BIGGEST(a, b) (((a) > (b)) ? (a) : (b))
|
|
||||||
#define MY_TZNAME_MAX 255
|
#define MY_TZNAME_MAX 255
|
||||||
|
|
||||||
/* Max and min values of the integer type T, of which only the bottom
|
/* Max and min values of the integer type T, of which only the bottom
|
||||||
@@ -150,7 +151,7 @@
|
|||||||
* for ttunspecified to work without crashing.
|
* for ttunspecified to work without crashing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CHARS_EXTRA (BIGGEST(sizeof(UNSPEC), 2) - 1)
|
#define CHARS_EXTRA (MAX(sizeof(UNSPEC), 2) - 1)
|
||||||
|
|
||||||
#define JULIAN_DAY 0 /* Jn = Julian day */
|
#define JULIAN_DAY 0 /* Jn = Julian day */
|
||||||
#define DAY_OF_YEAR 1 /* n = day of year */
|
#define DAY_OF_YEAR 1 /* n = day of year */
|
||||||
@@ -268,7 +269,7 @@ struct state_s
|
|||||||
time_t ats[TZ_MAX_TIMES];
|
time_t ats[TZ_MAX_TIMES];
|
||||||
unsigned char types[TZ_MAX_TIMES];
|
unsigned char types[TZ_MAX_TIMES];
|
||||||
struct ttinfo_s ttis[TZ_MAX_TYPES];
|
struct ttinfo_s ttis[TZ_MAX_TYPES];
|
||||||
char chars[BIGGEST(BIGGEST(TZ_MAX_CHARS + CHARS_EXTRA, sizeof("UTC")),
|
char chars[MAX(MAX(TZ_MAX_CHARS + CHARS_EXTRA, sizeof("UTC")),
|
||||||
(2 * (MY_TZNAME_MAX + 1)))];
|
(2 * (MY_TZNAME_MAX + 1)))];
|
||||||
struct lsinfo_s lsis[TZ_MAX_LEAPS];
|
struct lsinfo_s lsis[TZ_MAX_LEAPS];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user