Mistake on this page? Email us
pal_macros.h File Reference

PAL macros. This file contains macros defined by PAL for constant values and network purposes. More...

#include "pal.h"
#include "mbed-trace/mbed_trace.h"
#include "assert.h"
#include <limits.h>

Go to the source code of this file.

Macros

#define PAL_MAX_UINT8   0xFFU
 
#define PAL_MAX_UINT16   0xFFFFU
 
#define PAL_MAX_UINT32   0xFFFFFFFFUL
 
#define PAL_MAX_INT32   0x7FFFFFFFL
 
#define PAL_MIN_INT32   0x80000000L
 
#define PAL_MAX_UINT64   0xFFFFFFFFFFFFFFFFULL
 
#define PAL_MAX_INT64   0x7FFFFFFFFFFFFFFFLL
 
#define PAL_MAX(a, b)    ((a) > (b) ? (a) : (b))
 
#define PAL_MIN(a, b)    ((a) < (b) ? (a) : (b))
 
#define PAL_DIVIDE_ROUND_UP(num, divider)    (((num) + (divider) - 1) / (divider))
 
#define LITTLE__ENDIAN   1
 
#define PAL_HTONS(x)
 
#define PAL_NTOHS(x)
 
#define PAL_HTONL(x)
 
#define PAL_NTOHL(x)
 
#define PAL_GET_LOWER_8BITS(x)   (x & 0xFF)
 
#define PAL_INVERSE_UINT16_BYTES(val)   ( ((val) << 8) | (((val) & 0x0000FF00) >> 8))
 
#define PAL_INVERSE_UINT32_BYTES(val)   ( ((val) >> 24) | (((val) & 0x00FF0000) >> 8) | (((val) & 0x0000FF00) << 8) | (((val) & 0x000000FF) << 24) )
 
#define PAL_INVERSE_UINT64_BYTES(val)   ((PAL_INVERSE_UINT32_BYTES( ((val >> 16) >> 16)) &0xffffffff) | ((((uint64_t)PAL_INVERSE_UINT32_BYTES(val & 0xffffffff))<<16)<<16))
 
#define PAL_LITTLE_ENDIAN_TO_HOST_16BIT(x)   (x)
 
#define PAL_LITTLE_ENDIAN_TO_HOST_32BIT(x)   (x)
 
#define PAL_LITTLE_ENDIAN_TO_HOST_64BIT(x)   (x)
 
#define PAL_HOST_TO_LITTLE_ENDIAN_16BIT(x)   (x)
 
#define PAL_HOST_TO_LITTLE_ENDIAN_32BIT(x)   (x)
 
#define PAL_HOST_TO_LITTLE_ENDIAN_64BIT(x)   (x)
 
#define PAL_MODULE_INIT(INIT)   INIT= 1
 
#define PAL_MODULE_DEINIT(INIT)   INIT= 0
 Time utility values. More...
 
#define PAL_MILISEC_TO_SEC(milisec)   (milisec/1000)
 
#define PAL_ONE_SEC   1
 
#define PAL_SECONDS_PER_MIN   60
 
#define PAL_MINUTES_PER_HOUR   60
 
#define PAL_HOURS_PER_DAY   24
 
#define PAL_SECONDS_PER_HOUR   PAL_MINUTES_PER_HOUR * PAL_SECONDS_PER_MIN
 
#define PAL_SECONDS_PER_DAY   PAL_HOURS_PER_DAY * PAL_SECONDS_PER_HOUR
 
#define PAL_DAYS_IN_A_YEAR   (365U)
 
#define PAL_RATIO_SECONDS_PER_DAY   480
 
#define PAL_MINIMUM_RTC_LATENCY_SEC   100
 
#define PAL_MINIMUM_STORAGE_LATENCY_SEC   500000
 
#define PAL_MINIMUM_FORWARD_LATENCY_SEC   100000
 
#define PAL_MINIMUM_BACKWARD_LATENCY_SEC   100
 
#define PAL_FEB_MONTH   2
 
#define PAL_MILLI_PER_SECOND   1000
 
#define PAL_NANO_PER_MILLI   1000000L
 
#define PAL_NANO_PER_SECOND   1000000000L
 
#define PAL_MILLI_TO_NANO(x)   (((x) % PAL_MILLI_PER_SECOND) * PAL_NANO_PER_MILLI)
 
#define PAL_MILISEC_TO_SEC(milisec)   (milisec/1000)
 
#define PAL_MIN_SEC_FROM_EPOCH   1483264800
 
#define PAL_MIN_RTC_SET_TIME   PAL_MIN_SEC_FROM_EPOCH
 
#define PAL_LAST_SAVED_TIME_LATENCY_SEC   2500000
 
#define PAL_INLINE
 Define static function and inline function. More...
 
#define PAL_PRIVATE   static
 
#define PAL_PRAGMA(x)   _Pragma (#x)
 
#define PAL_DEPRECATED(x)   PAL_PRAGMA(message ("!!! PAL DEPRECATED CODE- " #x))
 
#define PAL_MODULE_IS_INIT(INIT)   (void)INIT
 
#define PAL_ASSERT_STATIC(e)
 
#define PAL_UNUSED_ARG(x)   (void)(x)
 
#define PAL_LOG_ASSERT(ARGS...)
 
#define PAL_LOG_ERR_FUNC   tr_err
 
#define PAL_LOG_WARN_FUNC   tr_warn
 
#define PAL_LOG_INFO_FUNC   tr_info
 
#define PAL_LOG_DBG_FUNC   tr_debug
 
#define PAL_LOG_ARRAY_FUNC   tr_array
 
#define PAL_LOG_LEVEL_ERR   TRACE_LEVEL_ERROR
 
#define PAL_LOG_LEVEL_WARN   TRACE_LEVEL_WARN
 
#define PAL_LOG_LEVEL_INFO   TRACE_LEVEL_INFO
 
#define PAL_LOG_LEVEL_DBG   TRACE_LEVEL_DEBUG
 
#define PAL_LOG_ERR(ARGS...)    PAL_LOG_ERR_FUNC(ARGS);
 
#define PAL_LOG_WARN(ARGS...)   PAL_LOG_WARN_FUNC(ARGS);
 
#define PAL_LOG_INFO(ARGS...)   PAL_LOG_INFO_FUNC(ARGS);
 
#define PAL_LOG_DBG(ARGS...)    PAL_LOG_DBG_FUNC(ARGS);
 
#define PAL_PRINTF(ARGS...)
 
#define DEBUG_PRINT(ARGS...)   PAL_PRINTF(ARGS)
 
#define PAL_PTR_ADDR_ALIGN_UINT8_TO_UINT32   __attribute__((aligned(4)))
 
#define PAL_INT32_BITS   (sizeof(int32_t) * CHAR_BIT)
 
#define PAL_VALIDATE_ARGUMENTS(condition)
 
#define PAL_VALIDATE_CONDITION_WITH_ERROR(condition, error)
 
#define PAL_VALIDATE_ARG_RLZ(condition, error)
 

Detailed Description

PAL macros. This file contains macros defined by PAL for constant values and network purposes.

Macro Definition Documentation

#define DEBUG_PRINT (   ARGS...)    PAL_PRINTF(ARGS)
#define LITTLE__ENDIAN   1
#define PAL_ASSERT_STATIC (   e)
Value:
do { \
enum { assert_static__ = 1/(e) }; \
} while (0)
#define PAL_DAYS_IN_A_YEAR   (365U)
#define PAL_DEPRECATED (   x)    PAL_PRAGMA(message ("!!! PAL DEPRECATED CODE- " #x))
#define PAL_DIVIDE_ROUND_UP (   num,
  divider 
)    (((num) + (divider) - 1) / (divider))
#define PAL_FEB_MONTH   2
#define PAL_GET_LOWER_8BITS (   x)    (x & 0xFF)
#define PAL_HOST_TO_LITTLE_ENDIAN_16BIT (   x)    (x)
#define PAL_HOST_TO_LITTLE_ENDIAN_32BIT (   x)    (x)
#define PAL_HOST_TO_LITTLE_ENDIAN_64BIT (   x)    (x)
#define PAL_HOURS_PER_DAY   24
#define PAL_HTONL (   x)
Value:
((((x)>>24) & 0xffL) | (((x)>>8) & 0xff00L) | \
(((x)<<8) & 0xff0000L) | (((x)<<24) & 0xff000000L))
#define PAL_HTONS (   x)
Value:
(((((unsigned short)(x)) >> 8) & 0xff) | \
((((unsigned short)(x)) & 0xff) << 8))
#define PAL_INLINE

Define static function and inline function.

User should provide the compiler inline function command.

#define PAL_INT32_BITS   (sizeof(int32_t) * CHAR_BIT)
#define PAL_INVERSE_UINT16_BYTES (   val)    ( ((val) << 8) | (((val) & 0x0000FF00) >> 8))
#define PAL_INVERSE_UINT32_BYTES (   val)    ( ((val) >> 24) | (((val) & 0x00FF0000) >> 8) | (((val) & 0x0000FF00) << 8) | (((val) & 0x000000FF) << 24) )
#define PAL_INVERSE_UINT64_BYTES (   val)    ((PAL_INVERSE_UINT32_BYTES( ((val >> 16) >> 16)) &0xffffffff) | ((((uint64_t)PAL_INVERSE_UINT32_BYTES(val & 0xffffffff))<<16)<<16))
#define PAL_LAST_SAVED_TIME_LATENCY_SEC   2500000
#define PAL_LITTLE_ENDIAN_TO_HOST_16BIT (   x)    (x)
#define PAL_LITTLE_ENDIAN_TO_HOST_32BIT (   x)    (x)
#define PAL_LITTLE_ENDIAN_TO_HOST_64BIT (   x)    (x)
#define PAL_LOG_ARRAY_FUNC   tr_array
#define PAL_LOG_ASSERT (   ARGS...)
Value:
{ \
tr_err(ARGS); \
assert(0);\
}
#define PAL_LOG_DBG (   ARGS...)    PAL_LOG_DBG_FUNC(ARGS);
#define PAL_LOG_DBG_FUNC   tr_debug
#define PAL_LOG_ERR (   ARGS...)    PAL_LOG_ERR_FUNC(ARGS);
#define PAL_LOG_ERR_FUNC   tr_err
#define PAL_LOG_INFO (   ARGS...)    PAL_LOG_INFO_FUNC(ARGS);
#define PAL_LOG_INFO_FUNC   tr_info
#define PAL_LOG_LEVEL_DBG   TRACE_LEVEL_DEBUG
#define PAL_LOG_LEVEL_ERR   TRACE_LEVEL_ERROR
#define PAL_LOG_LEVEL_INFO   TRACE_LEVEL_INFO
#define PAL_LOG_LEVEL_WARN   TRACE_LEVEL_WARN
#define PAL_LOG_WARN (   ARGS...)    PAL_LOG_WARN_FUNC(ARGS);
#define PAL_LOG_WARN_FUNC   tr_warn
#define PAL_MAX (   a,
 
)    ((a) > (b) ? (a) : (b))
#define PAL_MAX_INT32   0x7FFFFFFFL
#define PAL_MAX_INT64   0x7FFFFFFFFFFFFFFFLL
#define PAL_MAX_UINT16   0xFFFFU
#define PAL_MAX_UINT32   0xFFFFFFFFUL
#define PAL_MAX_UINT64   0xFFFFFFFFFFFFFFFFULL
#define PAL_MAX_UINT8   0xFFU
#define PAL_MILISEC_TO_SEC (   milisec)    (milisec/1000)
#define PAL_MILISEC_TO_SEC (   milisec)    (milisec/1000)
#define PAL_MILLI_PER_SECOND   1000
#define PAL_MILLI_TO_NANO (   x)    (((x) % PAL_MILLI_PER_SECOND) * PAL_NANO_PER_MILLI)
#define PAL_MIN (   a,
 
)    ((a) < (b) ? (a) : (b))
#define PAL_MIN_INT32   0x80000000L
#define PAL_MIN_RTC_SET_TIME   PAL_MIN_SEC_FROM_EPOCH
#define PAL_MIN_SEC_FROM_EPOCH   1483264800
#define PAL_MINIMUM_BACKWARD_LATENCY_SEC   100
#define PAL_MINIMUM_FORWARD_LATENCY_SEC   100000
#define PAL_MINIMUM_RTC_LATENCY_SEC   100
#define PAL_MINIMUM_STORAGE_LATENCY_SEC   500000
#define PAL_MINUTES_PER_HOUR   60
#define PAL_MODULE_DEINIT (   INIT)    INIT= 0

Time utility values.

#define PAL_MODULE_INIT (   INIT)    INIT= 1
#define PAL_MODULE_IS_INIT (   INIT)    (void)INIT
#define PAL_NANO_PER_MILLI   1000000L
#define PAL_NANO_PER_SECOND   1000000000L
#define PAL_NTOHL (   x)
Value:
((((x)>>24) & 0xffL) | (((x)>>8) & 0xff00L) | \
(((x)<<8) & 0xff0000L) | (((x)<<24) & 0xff000000L))
#define PAL_NTOHS (   x)
Value:
(((((unsigned short)(x)) >> 8) & 0xff) | \
((((unsigned short)(x)) & 0xff) << 8) )
#define PAL_ONE_SEC   1
#define PAL_PRAGMA (   x)    _Pragma (#x)
#define PAL_PRINTF (   ARGS...)
#define PAL_PRIVATE   static
#define PAL_PTR_ADDR_ALIGN_UINT8_TO_UINT32   __attribute__((aligned(4)))
#define PAL_RATIO_SECONDS_PER_DAY   480
#define PAL_SECONDS_PER_DAY   PAL_HOURS_PER_DAY * PAL_SECONDS_PER_HOUR
#define PAL_SECONDS_PER_HOUR   PAL_MINUTES_PER_HOUR * PAL_SECONDS_PER_MIN
#define PAL_SECONDS_PER_MIN   60
#define PAL_UNUSED_ARG (   x)    (void)(x)
#define PAL_VALIDATE_ARG_RLZ (   condition,
  error 
)
Value:
{\
if ((condition)) \
{ \
return error; \
} \
}
#define PAL_VALIDATE_ARGUMENTS (   condition)
#define PAL_VALIDATE_CONDITION_WITH_ERROR (   condition,
  error 
)