Remove the remain MIN/MAX like macro

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2023-02-03 21:42:03 +08:00 committed by Xiang Xiao
parent d1162ac58f
commit 7625126c91
17 changed files with 60 additions and 110 deletions

View File

@ -35,6 +35,8 @@
#include <errno.h>
#include <time.h>
#include <sys/param.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/clock.h>
@ -46,14 +48,6 @@
#ifdef CONFIG_SCHED_TICKLESS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef min
# define min(a,b) (a < b ? a : b)
#endif
/****************************************************************************
* 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)
{
calc_time = min(TO_RESET_NEXT, to_set);
calc_time = MIN(TO_RESET_NEXT, to_set);
}
else
{
if (curr < TO_END)
{
calc_time = min(curr + RESET_TICKS, to_set);
calc_time = MIN(curr + RESET_TICKS, to_set);
}
else
{

View File

@ -27,6 +27,8 @@
#include <errno.h>
#include <time.h>
#include <sys/param.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/clock.h>
@ -42,10 +44,6 @@
* Pre-processor Definitions
****************************************************************************/
#ifndef min
# define min(a,b) (a < b ? a : b)
#endif
#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)
{
calc_time = min(g_to_reset_next, to_set);
calc_time = MIN(g_to_reset_next, to_set);
}
else
{
if (curr < g_to_end)
{
calc_time = min(curr + g_reset_ticks, to_set);
calc_time = MIN(curr + g_reset_ticks, to_set);
}
else
{

View File

@ -35,6 +35,8 @@
#include <debug.h>
#include <errno.h>
#include <sys/param.h>
#include <arpa/inet.h>
#include <nuttx/wdog.h>
@ -138,10 +140,6 @@
# warning "You are using an incomplete/untested configuration"
#endif
#ifndef min
# define min(a,b) ((a) < (b) ? (a) : (b))
#endif
/* We need at least one more free buffer than transmit buffers */
#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,
(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",
priv->rxhead, dev->d_buf, dev->d_len);

View File

@ -30,6 +30,8 @@
#include <assert.h>
#include <errno.h>
#include <sys/param.h>
#include "hardware/s32k3xx_pflash.h"
#include "hardware/s32k3xx_xrdc.h"
@ -51,11 +53,6 @@
# error Progmem must be a multiple of 8
#endif
#define min(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })
/****************************************************************************
* Private Functions
****************************************************************************/
@ -392,7 +389,7 @@ ssize_t up_progmem_write(size_t addr, const void *buf, size_t count)
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)
{

View File

@ -29,6 +29,7 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <sys/param.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
@ -75,8 +76,6 @@
#define ALIGN_UP(n) (((n)+ALIGN_MASK) & ~ALIGN_MASK)
#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 */
#define QSPI_LUT_READ 0U /* Quad Output read */
#define QSPI_LUT_WRITE 1U /* Quad write */
@ -683,7 +682,7 @@ static int qspi_receive_blocking(struct s32k3xx_qspidev_s *priv,
uint32_t regval;
int ret = 0;
readlen = min(128, remaining);
readlen = MIN(128, remaining);
/* Copy sequence in LUT registers */
@ -703,7 +702,7 @@ static int qspi_receive_blocking(struct s32k3xx_qspidev_s *priv,
regval |= QSPI_MCR_CLR_RXF;
putreg32(regval, S32K3XX_QSPI_MCR);
readlen = min(128, remaining);
readlen = MIN(128, remaining);
#ifdef CONFIG_S32K3XX_QSPI_INTERRUPTS
/* 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 count = UINT32_MAX;
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;
int ret = 0;

View File

@ -50,6 +50,8 @@
#include <nuttx/config.h>
#include <arch/board/board.h>
#include <sys/param.h>
#include "chip.h"
#include "hardware/stm32_tim.h"
@ -326,15 +328,13 @@
#endif
#define PWM_TIM17_NCHANNELS PWM_TIM17_CHANNEL1
#define PWM_MAX(a, b) ((a) > (b) ? (a) : (b))
#define PWM_NCHANNELS PWM_MAX(PWM_TIM1_NCHANNELS, \
PWM_MAX(PWM_TIM2_NCHANNELS, \
PWM_MAX(PWM_TIM3_NCHANNELS, \
PWM_MAX(PWM_TIM14_NCHANNELS, \
PWM_MAX(PWM_TIM15_NCHANNELS, \
PWM_MAX(PWM_TIM16_NCHANNELS, \
PWM_TIM17_NCHANNELS))))))
#define PWM_NCHANNELS MAX(PWM_TIM1_NCHANNELS, \
MAX(PWM_TIM2_NCHANNELS, \
MAX(PWM_TIM3_NCHANNELS, \
MAX(PWM_TIM14_NCHANNELS, \
MAX(PWM_TIM15_NCHANNELS, \
MAX(PWM_TIM16_NCHANNELS, \
PWM_TIM17_NCHANNELS))))))
#else /* !CONFIG_PWM_MULTICHAN */

View File

@ -33,6 +33,8 @@
#include <debug.h>
#include <errno.h>
#include <sys/param.h>
#include <arpa/inet.h>
#include <nuttx/arch.h>
@ -213,10 +215,6 @@
# define CONFIG_STM32H7_ETH_NTXDESC 4
#endif
#ifndef min
# define min(a,b) ((a) < (b) ? (a) : (b))
#endif
/* We need at least one more free buffer than transmit buffers */
#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,
(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",
priv->rxhead, dev->d_buf, dev->d_len);

View File

@ -27,6 +27,8 @@
#include <stdint.h>
#include <stdbool.h>
#include <sys/param.h>
#include <nuttx/compiler.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
@ -77,14 +79,6 @@
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
****************************************************************************/
@ -680,7 +674,7 @@ int riscv_check_pmp_access(uintptr_t attr, uintptr_t base, uintptr_t size)
{
/* 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
{

View File

@ -32,6 +32,8 @@
#include <stdint.h>
#include <string.h>
#include <sys/param.h>
#include <nuttx/arch.h>
#include <nuttx/cache.h>
#include <nuttx/clock.h>
@ -88,9 +90,6 @@
# define CONFIG_LITEX_SD4BIT_FREQ 50000000 /* 25MHz SD 4-bit, normal clocking */
#endif
#define max(x, y) (((x) > (y)) ? (x) : (y))
#define min(x, y) (((x) < (y)) ? (x) : (y))
/****************************************************************************
* Private Types
****************************************************************************/
@ -626,7 +625,7 @@ static void litex_clock(struct sdio_dev_s *dev, enum sdio_clock_e rate)
uint32_t divider;
divider = clk_freq ? litex_get_hfclk() / clk_freq : MAX_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 */

View File

@ -29,6 +29,7 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <sys/param.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
@ -79,8 +80,6 @@ union xorshift128_state_u
* Private Function Prototypes
****************************************************************************/
#define min(a, b) (((a) < (b)) ? (a) : (b))
static ssize_t devurand_read(FAR struct file *filep, FAR char *buffer,
size_t buflen);
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
unsigned int seed = 0;
len = min(len, sizeof(unsigned int));
len = MIN(len, sizeof(unsigned int));
memcpy(&seed, buffer, len);
srand(seed);
return len;
@ -242,7 +241,7 @@ static ssize_t devurand_write(FAR struct file *filep, FAR const char *buffer,
{
/* 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);
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;
#else
len = min(len, sizeof(g_prng.u));
len = MIN(len, sizeof(g_prng.u));
memcpy(&g_prng.u, buffer, len);
return len;
#endif

View File

@ -37,6 +37,8 @@
#include <errno.h>
#include <debug.h>
#include <sys/param.h>
#include <nuttx/irq.h>
#include <nuttx/kmalloc.h>
#include <nuttx/arch.h>
@ -199,18 +201,6 @@
#define PL2303_RWREQUEST_TYPE (0x40)
#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 *************************************************************/
#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 */
reqlen = max(CONFIG_PL2303_BULKIN_REQLEN, ep->maxpacket);
reqlen = MAX(CONFIG_PL2303_BULKIN_REQLEN, ep->maxpacket);
while (!sq_empty(&priv->reqlist))
{
@ -1809,7 +1799,7 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
{
case PL2303_SETLINEREQUEST:
{
memcpy(priv->linest, ctrlreq->buf, min(len, 7));
memcpy(priv->linest, ctrlreq->buf, MIN(len, 7));
ret = 0;
}
break;
@ -1897,7 +1887,7 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
if (ret >= 0)
{
ctrlreq->len = min(len, ret);
ctrlreq->len = MIN(len, ret);
ctrlreq->flags = USBDEV_REQFLAGS_NULLPKT;
ret = EP_SUBMIT(dev->ep0, ctrlreq);
if (ret < 0)

View File

@ -35,6 +35,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <sys/param.h>
#include <nuttx/queue.h>
#include <nuttx/net/net.h>
#include <nuttx/net/netdev.h>
@ -96,14 +98,6 @@
#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
****************************************************************************/
@ -813,7 +807,7 @@ static uint16_t rndis_fillrequest(FAR struct rndis_dev_s *priv,
req->len = 0;
datalen = min(priv->netdev.d_len,
datalen = MIN(priv->netdev.d_len,
CONFIG_RNDIS_BULKIN_REQLEN - RNDIS_PACKET_HDR_SIZE);
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 -
priv->current_rx_datagram_offset;
size_t copysize = min(reqlen,
size_t copysize = MIN(reqlen,
priv->current_rx_datagram_size - index);
/* 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)
{
ctrlreq->len = min(len, ret);
ctrlreq->len = MIN(len, ret);
ctrlreq->flags = USBDEV_REQFLAGS_NULLPKT;
ret = EP_SUBMIT(dev->ep0, ctrlreq);
if (ret < 0)

View File

@ -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++)
{
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;
}
@ -1045,7 +1045,7 @@ static int bcmf_wl_scan_format_results(FAR struct bcmf_dev_s *priv,
iwe = (FAR struct iw_event *)pointer;
iwe->cmd = SIOCGIWESSID;
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);
memcpy(&iwe->u.essid + 1, info->SSID, iwe->u.essid.length);
iwe->len = IW_EV_LEN(essid) + ((iwe->u.essid.length + 3) & ~3);

View File

@ -26,14 +26,7 @@
****************************************************************************/
#include <stdint.h>
#ifndef min
#define min(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef max
#define max(a,b) ((a) > (b) ? (a) : (b))
#endif
#include <sys/param.h>
/****************************************************************************
* Public Function Prototypes

View File

@ -87,9 +87,6 @@
#define MARK(a) { asm(" .globl M.a"); asm("M.a:"); }
#undef min
#define min(a,b) ((a>b) ? b : a)
#ifndef IBUFSIZ
# define IBUFSIZ BUFSIZ /* Defailt input buffer size */
#endif

View File

@ -47,14 +47,13 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <sys/param.h>
#include <stdlib.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define min(a, b) (a) < (b) ? a : b
#define swapcode(TYPE, parmi, parmj, n) \
{ \
long i = (n) / sizeof (TYPE); \
@ -275,10 +274,10 @@ loop:
}
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);
r = min(pd - pc, pn - pd - width);
r = MIN(pd - pc, pn - pd - width);
vecswap(pb, pn - r, r);
if ((r = pb - pa) > width)

View File

@ -58,6 +58,8 @@
#include <assert.h>
#include <errno.h>
#include <sys/param.h>
#include <nuttx/time.h>
#include <nuttx/init.h>
#include <nuttx/fs/fs.h>
@ -120,7 +122,6 @@
/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
#define is_digit(c) ((unsigned)(c) - '0' <= 9)
#define BIGGEST(a, b) (((a) > (b)) ? (a) : (b))
#define MY_TZNAME_MAX 255
/* Max and min values of the integer type T, of which only the bottom
@ -150,7 +151,7 @@
* 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 DAY_OF_YEAR 1 /* n = day of year */
@ -268,7 +269,7 @@ struct state_s
time_t ats[TZ_MAX_TIMES];
unsigned char types[TZ_MAX_TIMES];
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)))];
struct lsinfo_s lsis[TZ_MAX_LEAPS];