Move MAX, MIN and ABS to sys/cc.h

This commit is contained in:
Moritz 'Morty' Strübe 2014-12-01 13:58:34 +01:00
parent c9324d133f
commit 0dab6926b3
33 changed files with 41 additions and 93 deletions

View File

@ -36,6 +36,7 @@
* Matthias Kovatsch <kovatsch@inf.ethz.ch>
*/
#include "sys/cc.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -36,6 +36,7 @@
* Matthias Kovatsch <kovatsch@inf.ethz.ch>
*/
#include "sys/cc.h"
#include <stdio.h>
#include <string.h>
#include "er-coap-separate.h"

View File

@ -39,6 +39,7 @@
#include <string.h>
#include <stdio.h>
#include "contiki.h"
#include "sys/cc.h"
#include "contiki-net.h"
#include "er-coap.h"

View File

@ -79,10 +79,6 @@ enum { OPTION_MAP_SIZE = sizeof(uint8_t) * 8 };
#define SET_OPTION(packet, opt) ((packet)->options[opt / OPTION_MAP_SIZE] |= 1 << (opt % OPTION_MAP_SIZE))
#define IS_OPTION(packet, opt) ((packet)->options[opt / OPTION_MAP_SIZE] & (1 << (opt % OPTION_MAP_SIZE)))
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif /* MIN */
/* parsed message struct */
typedef struct {
uint8_t *buffer; /* pointer to CoAP header / incoming packet buffer / memory to serialize packet */

View File

@ -57,13 +57,12 @@
#include "lib/assert.h"
#include "lib/list.h"
#include "sys/cc.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/*---------------------------------------------------------------------------*/
#define MIN(a, b) ((a) < (b) ? (a) : (b))
/*---------------------------------------------------------------------------*/
#define DEBUG 0
#if DEBUG
#define PRINTF(...) PRINTF(__VA_ARGS__)

View File

@ -62,10 +62,6 @@
#define REST_MAX_CHUNK_SIZE 64
#endif
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif /* MIN */
struct resource_s;
struct periodic_resource_s;

View File

@ -42,6 +42,7 @@
#include "sys/energest.h"
#include <stdio.h>
#include "sys/cc.h"
struct power_msg {
uint16_t len;

View File

@ -38,6 +38,7 @@
*/
#include "contiki.h"
#include "sys/cc.h"
#include "shell-sky.h"
#include "dev/watchdog.h"
@ -84,8 +85,6 @@ SHELL_COMMAND(rfchannel_command,
"rfchannel <channel>: change CC2420 radio channel (11 - 26)",
&shell_rfchannel_process);
/*---------------------------------------------------------------------------*/
#define MAX(a, b) ((a) > (b)? (a): (b))
#define MIN(a, b) ((a) < (b)? (a): (b))
struct spectrum {
int channel[16];
};

View File

@ -36,13 +36,10 @@
#include <stddef.h>
#include "contiki.h"
#include "sys/cc.h"
#include "shell.h"
#include "telnet.h"
#ifndef MIN
#define MIN(a, b) ((a) < (b)? (a) : (b))
#endif /* MIN */
/*---------------------------------------------------------------------------*/
PROCESS(shell_tcpsend_process, "tcpsend");
SHELL_COMMAND(tcpsend_command,

View File

@ -38,6 +38,7 @@
*/
#include "contiki.h"
#include "sys/cc.h"
#include "shell-time.h"
#include "sys/clock.h"
@ -51,11 +52,6 @@
#define MAX_COMMANDLENGTH 64
#define PERIOD_INTERVAL 60
#ifndef MIN
#define MIN(a, b) ((a) < (b)? (a) : (b))
#endif /* MIN */
/*---------------------------------------------------------------------------*/
PROCESS(shell_time_process, "time");
SHELL_COMMAND(time_command,

View File

@ -33,6 +33,7 @@
#include <string.h>
#include "sys/cc.h"
#include "contiki-lib.h"
#include "contiki-net.h"
#include "lib/petsciiconv.h"
@ -103,7 +104,6 @@ static uint8_t connected;
#define MAX_SILENCE_TIME (CLOCK_SECOND * 30)
#define MIN(a, b) ((a) < (b)? (a): (b))
/*---------------------------------------------------------------------------*/
static void
buf_init(struct telnetd_buf *buf)

View File

@ -65,10 +65,6 @@
#define SETTINGS_BOTTOM_ADDR (SETTINGS_TOP_ADDR + 1 - SETTINGS_MAX_SIZE)
#endif
#ifndef MIN
#define MIN(a,b) ((a)<(b)?a:b)
#endif
typedef struct {
#if SETTINGS_CONF_SUPPORT_LARGE_VALUES
uint8_t size_extra;

View File

@ -30,6 +30,7 @@
*/
#include "contiki.h"
#include "sys/cc.h"
#include "contiki-net.h"
#include "lib/list.h"
@ -39,7 +40,6 @@
#include <stdio.h>
#include <string.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))
static void relisten(struct tcp_socket *s);

View File

@ -78,6 +78,8 @@
#include "net/ipv4/uip-neighbor.h"
#include <string.h>
#include "sys/cc.h"
/*---------------------------------------------------------------------------*/
/* Variable definitions. */
@ -1953,7 +1955,6 @@ void
uip_send(const void *data, int len)
{
int copylen;
#define MIN(a,b) ((a) < (b)? (a): (b))
copylen = MIN(len, UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN -
(int)((char *)uip_sappdata - (char *)&uip_buf[UIP_LLH_LEN + UIP_TCPIP_HLEN]));
if(copylen > 0) {

View File

@ -71,6 +71,7 @@
* the packet back to the peer.
*/
#include "sys/cc.h"
#include "net/ip/uip.h"
#include "net/ip/uipopt.h"
#include "net/ipv6/uip-icmp6.h"
@ -2332,7 +2333,6 @@ void
uip_send(const void *data, int len)
{
int copylen;
#define MIN(a,b) ((a) < (b)? (a): (b))
if(uip_sappdata != NULL) {
copylen = MIN(len, UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN -

View File

@ -229,10 +229,6 @@ static struct compower_activity current_packet;
#define DEFAULT_STREAM_TIME (4 * CYCLE_TIME)
#ifndef MIN
#define MIN(a, b) ((a) < (b)? (a) : (b))
#endif /* MIN */
#if CONTIKIMAC_CONF_BROADCAST_RATE_LIMIT
static struct timer broadcast_rate_timer;
static int broadcast_rate_counter;

View File

@ -52,6 +52,7 @@
#include "sys/rtimer.h"
#include "contiki-conf.h"
#include "sys/cc.h"
#ifdef EXPERIMENT_SETUP
#include "experiment-setup.h"
@ -215,10 +216,6 @@ static linkaddr_t is_streaming_to, is_streaming_to_too;
static rtimer_clock_t stream_until;
#define DEFAULT_STREAM_TIME (RTIMER_ARCH_SECOND)
#ifndef MIN
#define MIN(a, b) ((a) < (b)? (a) : (b))
#endif /* MIN */
/*---------------------------------------------------------------------------*/
static void
on(void)

View File

@ -92,8 +92,6 @@ static struct broadcast_announcement_state {
#define PRINTF(...)
#endif
#define MIN(a, b) ((a)<(b)?(a):(b))
/*---------------------------------------------------------------------------*/
static void
send_adv(void *ptr)

View File

@ -42,20 +42,13 @@
* @{
*/
#include "sys/cc.h"
#include "net/rime/rime.h"
#include "net/rime/ipolite.h"
#include "lib/random.h"
#include <string.h>
#ifndef MAX
#define MAX(a, b) ((a) > (b)? (a) : (b))
#endif /* MAX */
#ifndef MIN
#define MIN(a, b) ((a) < (b)? (a) : (b))
#endif /* MIN */
#define DEBUG 0
#if DEBUG
#include <stdio.h>

View File

@ -43,7 +43,7 @@
*/
#include "contiki.h"
#include "sys/cc.h"
#include "lib/list.h"
#include "net/rime/rime.h"
#include "net/rime/announcement.h"
@ -90,8 +90,6 @@ static struct polite_announcement_state {
#define PRINTF(...)
#endif
#define MIN(a, b) ((a)<(b)?(a):(b))
/*---------------------------------------------------------------------------*/
static void
send_adv(clock_time_t interval)

View File

@ -42,21 +42,13 @@
* @{
*/
#include "sys/cc.h"
#include "net/rime/rime.h"
#include "net/rime/polite.h"
#include "lib/random.h"
#include <string.h>
#ifndef MAX
#define MAX(a,b) ((a) > (b)? (a) : (b))
#endif /* MAX */
#ifndef MIN
#define MIN(a, b) ((a) < (b)? (a) : (b))
#endif /* MIN */
/*---------------------------------------------------------------------------*/
static void
recv(struct abc_conn *abc)

View File

@ -127,6 +127,19 @@
#define NULL 0
#endif /* NULL */
#ifndef MAX
#define MAX(n, m) (((n) < (m)) ? (m) : (n))
#endif
#ifndef MIN
#define MIN(n, m) (((n) < (m)) ? (n) : (m))
#endif
#ifndef ABS
#define ABS(n) (((n) < 0) ? -(n) : (n))
#endif
#define CC_CONCAT2(s1, s2) s1##s2
/**
* A C preprocessing macro for concatenating to

View File

@ -280,9 +280,6 @@ typedef char r_uart_ptchar;
#define OUT_X(addrx,value) (*addrx = value)
#define IN_X(addrx) (*addrx)
# define Max(a, b) ( (a)>(b) ? (a) : (b) ) // Take the max between a and b
# define Min(a, b) ( (a)<(b) ? (a) : (b) ) // Take the min between a and b
// Align on the upper value <val> on a <n> boundary
// i.e. Upper(0, 4)= 4
// Upper(1, 4)= 4

View File

@ -46,6 +46,7 @@
#include "sys/energest.h"
#include "sys/clock.h"
#include "sys/rtimer.h"
#include "sys/cc.h"
#include "lpm.h"
#include "ti-lib.h"
/*---------------------------------------------------------------------------*/
@ -76,10 +77,6 @@
while(!(cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + (max_time))); \
} while(0)
/*---------------------------------------------------------------------------*/
#ifndef MIN
#define MIN(n, m) (((n) < (m)) ? (n) : (m))
#endif
/*---------------------------------------------------------------------------*/
#ifdef __GNUC__
#define CC_ALIGN_ATTR(n) __attribute__ ((aligned(n)))
#else

View File

@ -45,6 +45,7 @@
#include "sfrs-ext.h"
#include "contiki.h" /* for clock_wait() and CLOCK_SECOND. */
#include "sys/cc.h"
/******************************************************************************/
/*************************** Macros Definitions *******************************/
@ -91,9 +92,6 @@
while(condition) { body; break_loop(); } \
} while(0)
#undef MIN
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
/******************************************************************************/
/************************ Variables Definitions *******************************/
/******************************************************************************/

View File

@ -65,6 +65,7 @@
#include "lpm.h"
#include "net-uart.h"
#include "httpd-simple.h"
#include "sys/cc.h"
#include "ti-lib.h"
@ -86,10 +87,6 @@
#define ADDRESS_CONVERSION_OK 1
#define ADDRESS_CONVERSION_ERROR 0
/*---------------------------------------------------------------------------*/
#ifndef MIN
#define MIN(n, m) (((n) < (m)) ? (n) : (m))
#endif
/*---------------------------------------------------------------------------*/
static struct uip_udp_conn *udp_conn = NULL;
static uint8_t buffer[MAX_MSG_SIZE];

View File

@ -37,6 +37,7 @@
*/
#include <string.h>
#include "sys/cc.h"
#include "rest-engine.h"
#include "er-coap.h"
#include "er-plugtest.h"

View File

@ -38,6 +38,7 @@
*/
#include "contiki.h"
#include "sys/cc.h"
#include "net/netstack.h"
#include "net/rime/rime.h"
#include "net/rime/collect.h"
@ -120,8 +121,6 @@ PROCESS_THREAD(depth_blink_process, ev, data)
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
#define MAX(a, b) ((a) > (b)? (a): (b))
#define MIN(a, b) ((a) < (b)? (a): (b))
struct spectrum {
int channel[16];
};

View File

@ -30,6 +30,7 @@
*/
#include "contiki-net.h"
#include "sys/cc.h"
#include <stdio.h>
#include <stdlib.h>
@ -104,7 +105,6 @@ PROCESS_THREAD(tcp_server_process, ev, data)
while(bytes_to_send > 0) {
PROCESS_PAUSE();
int len, tosend;
#define MIN(a,b) ((a)<(b)?(a):(b))
tosend = MIN(bytes_to_send, sizeof(outputbuf));
len = tcp_socket_send(&socket, (uint8_t *)"", tosend);
bytes_to_send -= len;

View File

@ -411,7 +411,7 @@ lcd_num_putdec(int numb, lcd_padding_t padding)
}
/* Convert to BCD */
bcd = itobcd(abs(numb));
bcd = itobcd(ABS(numb));
/* Print */
return lcd_num_print(bcd, (bool)(numb<0), padding);

View File

@ -48,6 +48,7 @@
#include "contiki.h"
#include "sys/cc.h"
#include "usb_drv.h"
#include "usb_descriptors.h"
#include "usb_specific_request.h"
@ -753,7 +754,7 @@ uint16_t p=(uint16_t)&__bss_end;
radio_get_rssi_value(&RSSI);
RSSI*=3;
#endif
maxRSSI[i-11]=Max(maxRSSI[i-11],RSSI);
maxRSSI[i-11]=MAX(maxRSSI[i-11],RSSI);
accRSSI[i-11]+=RSSI;
}
if(j&(1<<7)) {
@ -774,7 +775,7 @@ uint16_t p=(uint16_t)&__bss_end;
#endif
PRINTF_P(PSTR("\n"));
for(i=11;i<=26;i++) {
uint8_t activity=Min(maxRSSI[i-11],accRSSI[i-11]/(1<<7));
uint8_t activity=MIN(maxRSSI[i-11],accRSSI[i-11]/(1<<7));
PRINTF_P(PSTR(" %d: %02ddB "),i, -91+(maxRSSI[i-11]-1));
for(;activity--;maxRSSI[i-11]--) {
PRINTF_P(PSTR("#"));

View File

@ -40,6 +40,7 @@
#include <string.h>
#include "contiki.h"
#include "sys/cc.h"
#include "sys/clock.h"
#include "sys/etimer.h"
@ -136,8 +137,6 @@ long referenceVar;
static struct cooja_mt_thread rtimer_thread;
static struct cooja_mt_thread process_run_thread;
#define MIN(a, b) ( (a)<(b) ? (a) : (b) )
/*---------------------------------------------------------------------------*/
#if NETSTACK_CONF_WITH_IPV4
static void

View File

@ -37,18 +37,6 @@
#ifndef HAL_LCD_H
#define HAL_LCD_H
#ifndef MIN
# define MIN(n, m) (((n) < (m)) ? (n) : (m))
#endif
#ifndef MAX
# define MAX(n, m) (((n) < (m)) ? (m) : (n))
#endif
#ifndef ABS
# define ABS(n) (((n) < 0) ? -(n) : (n))
#endif
#define LCD_BACKLT_OUT P8OUT
#define LCD_BACKLT_DIR P8DIR
#define LCD_BACKLT_SEL P8SEL