Merge pull request #6688 from OlegHahm/doxy_cleanup
doc: fix all doxygen warnings and enable doccheck for all files
This commit is contained in:
commit
187a4e63d1
@ -50,27 +50,27 @@ extern "C" {
|
||||
/* *************************************************************************************************
|
||||
* Global Variable section */
|
||||
|
||||
/* Set of display flags */
|
||||
/** Set of display flags */
|
||||
typedef union {
|
||||
struct {
|
||||
/* Line1 + Line2 + Icons*/
|
||||
uint16_t full_update : 1; /* 1 = Redraw all content */
|
||||
uint16_t partial_update : 1; /* 1 = Update changes */
|
||||
uint16_t full_update : 1; /**< 1 = Redraw all content */
|
||||
uint16_t partial_update : 1; /**< 1 = Update changes */
|
||||
|
||||
/* Line only */
|
||||
uint16_t line1_full_update : 1; /* 1 = Redraw Line1 content */
|
||||
uint16_t line2_full_update : 1; /* 1 = Redraw Line2 content */
|
||||
uint16_t line1_full_update : 1; /**< 1 = Redraw Line1 content */
|
||||
uint16_t line2_full_update : 1; /**< 1 = Redraw Line2 content */
|
||||
|
||||
/* Logic module data update flags */
|
||||
uint16_t update_time : 1; /* 1 = Time was updated */
|
||||
uint16_t update_stopwatch : 1; /* 1 = Stopwatch was updated */
|
||||
uint16_t update_temperature : 1; /* 1 = Temperature was updated */
|
||||
uint16_t update_battery_voltage : 1; /* 1 = Battery voltage was updated */
|
||||
uint16_t update_date : 1; /* 1 = Date was updated */
|
||||
uint16_t update_alarm : 1; /* 1 = Alarm time was updated */
|
||||
uint16_t update_acceleration : 1; /* 1 = Acceleration data was updated */
|
||||
} flag;
|
||||
uint16_t all_flags; /* Shortcut to all display flags (for reset) */
|
||||
uint16_t update_time : 1; /**< 1 = Time was updated */
|
||||
uint16_t update_stopwatch : 1; /**< 1 = Stopwatch was updated */
|
||||
uint16_t update_temperature : 1; /**< 1 = Temperature was updated */
|
||||
uint16_t update_battery_voltage : 1; /**< 1 = Battery voltage was updated */
|
||||
uint16_t update_date : 1; /**< 1 = Date was updated */
|
||||
uint16_t update_alarm : 1; /**< 1 = Alarm time was updated */
|
||||
uint16_t update_acceleration : 1; /**< 1 = Acceleration data was updated */
|
||||
} flag; /**< Bitfield for the display flags */
|
||||
uint16_t all_flags; /**< Shortcut to all display flags (for reset) */
|
||||
} s_display_flags_t;
|
||||
|
||||
extern volatile s_display_flags_t display;
|
||||
|
||||
@ -28,8 +28,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define VICIntEnClear VICIntEnClr
|
||||
|
||||
/**
|
||||
* @brief Feed sequence for PLL register
|
||||
*/
|
||||
static inline void pllfeed(void)
|
||||
{
|
||||
PLLFEED = 0xAA;
|
||||
|
||||
@ -16,7 +16,11 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief structure to hold boot partition
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int size;
|
||||
const int *prog;
|
||||
int size; /**< size of partition */
|
||||
const int *prog; /**< partition data */
|
||||
} boot_t;
|
||||
|
||||
@ -18,20 +18,26 @@
|
||||
|
||||
extern char *lpc_return_strings[];
|
||||
|
||||
/**
|
||||
* @brief struct defining sector information
|
||||
*/
|
||||
struct sector_info_struct { /* an array of */
|
||||
int address; /* where each sector is located */
|
||||
int size; /* and how big it is */
|
||||
int address; /**< where each sector is located */
|
||||
int size; /**< and how big it is */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief alksd
|
||||
*/
|
||||
struct chip_info_struct {
|
||||
char *part_number; /* human readable part number */
|
||||
char *id_string; /* id string sent by "J" command */
|
||||
unsigned int ram_addr; /* where to download into RAM */
|
||||
int chunk_size; /* download to ram chunk size */
|
||||
int num_sector; /* number of flash sectors */
|
||||
struct sector_info_struct *layout; /* layout of sectors */
|
||||
const unsigned int *bootprog; /* code that boots into user program
|
||||
(NULL = DTR/RTS only) */
|
||||
char *part_number; /**< human readable part number */
|
||||
char *id_string; /**< id string sent by "J" command */
|
||||
unsigned int ram_addr; /**< where to download into RAM */
|
||||
int chunk_size; /**< download to ram chunk size */
|
||||
int num_sector; /**< number of flash sectors */
|
||||
struct sector_info_struct *layout; /**< layout of sectors */
|
||||
const unsigned int *bootprog; /**< code that boots into user program
|
||||
(NULL = DTR/RTS only) */
|
||||
};
|
||||
|
||||
extern struct chip_info_struct chip_info[];
|
||||
|
||||
@ -36,7 +36,7 @@ extern "C" {
|
||||
#define LED0_ON (GPIOB->BSRR = LED0_MASK)
|
||||
#define LED0_OFF (GPIOB->BRR = LED0_MASK)
|
||||
#define LED0_TOGGLE (GPIOB->ODR ^= LED0_MASK)
|
||||
/** }@ */
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Initialize board specific hardware, including clock, LEDs and std-IO
|
||||
|
||||
@ -160,8 +160,10 @@ extern "C" {
|
||||
PCICR |= (1 << PCIE0); \
|
||||
PCMSK0 |= (1 << PCINT5); \
|
||||
} while (0)
|
||||
/** @cond INTERNAL */
|
||||
#define AVR_CONTEXT_SWAP_INTERRUPT_VECT PCINT0_vect
|
||||
#define AVR_CONTEXT_SWAP_TRIGGER PORTB ^= (1 << PB5)
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief xtimer configuration values
|
||||
|
||||
@ -55,7 +55,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Export errno value
|
||||
* @brief number of last error
|
||||
*/
|
||||
extern int errno;
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup cpu_specific_peripheral_memory_map CC26x0 peripheral memory map
|
||||
* @defgroup cpu_specific_peripheral_memory_map Texas Instruments CC26x0 peripheral memory map
|
||||
* @ingroup cpu
|
||||
*/
|
||||
|
||||
|
||||
@ -50,7 +50,8 @@ typedef union x86_rtc_data {
|
||||
uint8_t second, minute, hour;
|
||||
uint8_t day, month, year, century;
|
||||
};
|
||||
uint64_t timestamp;
|
||||
uint64_t timestamp; /**< The full timestamp as a 64bit integer
|
||||
representation */
|
||||
} x86_rtc_data_t;
|
||||
|
||||
#define RTC_REG_SECOND (0x00)
|
||||
|
||||
45
dist/tools/doccheck/check.sh
vendored
45
dist/tools/doccheck/check.sh
vendored
@ -6,52 +6,11 @@
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
|
||||
TMP_ERR=$(mktemp)
|
||||
TMP_WARN=$(mktemp)
|
||||
TMP_DOC=$(mktemp)
|
||||
ERR_DIFFFILTER="--diff-filter=AC"
|
||||
WARN_DIFFFILTER="--diff-filter=MR"
|
||||
|
||||
# If no branch but an option is given, unset BRANCH.
|
||||
# Otherwise, consume this parameter.
|
||||
BRANCH="${1}"
|
||||
if echo "${BRANCH}" | grep -q '^-'; then
|
||||
if [ $(git rev-parse --abbrev-ref HEAD) != "master" ]; then
|
||||
BRANCH="master"
|
||||
else
|
||||
BRANCH=""
|
||||
fi
|
||||
else
|
||||
if [ -n "${BRANCH}" ]; then
|
||||
shift 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# select files to check
|
||||
if [ -z "${BRANCH}" ]; then
|
||||
git ls-tree -r --full-tree --name-only HEAD | grep -E '\.([sSch]|cpp)$' | sort | uniq > ${TMP_WARN}
|
||||
else
|
||||
git diff ${ERR_DIFFFILTER} --name-only $(git merge-base ${BRANCH} HEAD) | grep -E '\.([sSchp]|cpp)$' | sort | uniq > ${TMP_ERR}
|
||||
git diff ${WARN_DIFFFILTER} --name-only $(git merge-base ${BRANCH} HEAD) | grep -E '\.([sSchp]|cpp)$' | sort | uniq > ${TMP_WARN}
|
||||
fi
|
||||
|
||||
make doc 2>&1 | grep '.*warning' | sed "s#.*${PWD}/\([^:]*\).*#\1#" | sort | uniq > ${TMP_DOC}
|
||||
|
||||
WARNINGS=$(comm -1 -2 ${TMP_WARN} ${TMP_DOC})
|
||||
ERRORS=$(comm -1 -2 ${TMP_ERR} ${TMP_DOC})
|
||||
|
||||
rm ${TMP_ERR} ${TMP_WARN} ${TMP_DOC}
|
||||
|
||||
if [ -n "${WARNINGS}" ]
|
||||
then
|
||||
echo "WARNING: The following modified files generate doxygen warnings:"
|
||||
echo "${WARNINGS}"
|
||||
fi
|
||||
ERRORS=$(make doc 2>&1 | grep '.*warning' | sed "s#.*${PWD}/\([^:]*\).*#\1#" | sort | uniq)
|
||||
|
||||
if [ -n "${ERRORS}" ]
|
||||
then
|
||||
echo "ERROR: The following new files generate doxygen warnings:"
|
||||
echo "ERROR: The following files generate doxygen warnings:"
|
||||
echo "${ERRORS}"
|
||||
exit 2
|
||||
else
|
||||
|
||||
@ -818,6 +818,8 @@ EXCLUDE_SYMLINKS = NO
|
||||
# exclude all test directories for example use the pattern */test/*
|
||||
|
||||
EXCLUDE_PATTERNS = */board/*/tools/* \
|
||||
*_params.h \
|
||||
*/boards/x86-multiboot-common/include/multiboot.h \
|
||||
*/cpu/atmega_common/include/sys/*.h \
|
||||
*/cpu/msp430_common/include/stdatomic.h \
|
||||
*/cpu/msp430_common/include/sys/*.h \
|
||||
@ -827,6 +829,7 @@ EXCLUDE_PATTERNS = */board/*/tools/* \
|
||||
*/drivers/nrf24l01p/include/nrf24l01p_settings.h \
|
||||
*/pkg/*/*/* \
|
||||
*/pkg/tlsf/patch.txt \
|
||||
*/sys/include/embUnit/* \
|
||||
*/sys/random/tinymt32/* \
|
||||
*/toolchain/* \
|
||||
*/vendor/* \
|
||||
@ -2332,7 +2335,7 @@ PLANTUML_JAR_PATH =
|
||||
# Minimum value: 0, maximum value: 10000, default value: 50.
|
||||
# This tag requires that the tag HAVE_DOT is set to YES.
|
||||
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
DOT_GRAPH_MAX_NODES = 100
|
||||
|
||||
# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs
|
||||
# generated by dot. A depth value of 3 means that only nodes reachable from the
|
||||
|
||||
@ -116,7 +116,7 @@ int hdc1000_init(hdc1000_t *dev, const hdc1000_params_t *params);
|
||||
*
|
||||
* After the conversion is triggered, one has to wait
|
||||
* @ref HDC1000_CONVERSION_TIME us until the results can be read using
|
||||
* @ref hdc1000_reg_results().
|
||||
* @ref hdc1000_get_results().
|
||||
*
|
||||
* @param[in] dev device descriptor of sensor
|
||||
*/
|
||||
|
||||
@ -31,9 +31,11 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* @brief The sensors default I2C address
|
||||
* @{
|
||||
*/
|
||||
#define LSM303DLHC_ACC_DEFAULT_ADDRESS (0x19)
|
||||
#define LSM303DLHC_MAG_DEFAULT_ADDRESS (0x1e)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Possible accelerometer sample rates
|
||||
@ -92,9 +94,9 @@ typedef enum {
|
||||
* @brief 3d data container
|
||||
*/
|
||||
typedef struct {
|
||||
int16_t x_axis;
|
||||
int16_t y_axis;
|
||||
int16_t z_axis;
|
||||
int16_t x_axis; /**< holds the x axis value. WOW! */
|
||||
int16_t y_axis; /**< holds the y axis value. Not kidding. */
|
||||
int16_t z_axis; /**< surprise, holds the z axis value */
|
||||
} lsm303dlhc_3d_data_t;
|
||||
|
||||
/**
|
||||
|
||||
@ -27,6 +27,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief maximum unprocessed value fetched form the sensor
|
||||
*/
|
||||
#define MQ3_MAX_RAW_VALUE (1023U)
|
||||
|
||||
/**
|
||||
@ -45,7 +48,7 @@ typedef struct {
|
||||
* can be made.
|
||||
*
|
||||
* @param[out] dev device descriptor of an MQ-3 sensor
|
||||
* @param[in] adc the ADC device the sensor is connected to
|
||||
* @param[in] adc_line the ADC device the sensor is connected to
|
||||
*
|
||||
* @return 0 on success
|
||||
* @return -1 on error
|
||||
|
||||
@ -116,7 +116,7 @@ int adc_init(adc_t line);
|
||||
* for the first to finish before its conversion starts.
|
||||
*
|
||||
* @param[in] line line to sample
|
||||
* @param[in] resolution resolution to use for conversion
|
||||
* @param[in] res resolution to use for conversion
|
||||
*
|
||||
* @return the sampled value on success
|
||||
* @return -1 if resolution is not applicable
|
||||
|
||||
@ -90,7 +90,7 @@ typedef struct {
|
||||
*
|
||||
* @param[in] dev the timer to initialize
|
||||
* @param[in] freq requested number of ticks per second
|
||||
* @param[in] callback this callback is called in interrupt context, the
|
||||
* @param[in] cb this callback is called in interrupt context, the
|
||||
* emitting channel is passed as argument
|
||||
* @param[in] arg argument to the callback
|
||||
*
|
||||
|
||||
@ -36,10 +36,16 @@ typedef struct {
|
||||
kernel_pid_t msg_thread_pid; /**< thread to msg on irq */
|
||||
} pir_t;
|
||||
|
||||
/**
|
||||
* @brief value to configure sensitivity of sensore
|
||||
*/
|
||||
#ifndef PIR_MSG_T_STATUS_START
|
||||
#define PIR_MSG_T_STATUS_START 150
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief event type for a PIR sensor
|
||||
*/
|
||||
typedef enum {
|
||||
PIR_STATUS_HI = PIR_MSG_T_STATUS_START, /**< motion was detected */
|
||||
PIR_STATUS_LO, /**< no motion is detected */
|
||||
|
||||
@ -32,10 +32,10 @@ extern "C" {
|
||||
* @brief Descriptor struct for rgbleds
|
||||
*/
|
||||
typedef struct {
|
||||
pwm_t device;
|
||||
int channel_r;
|
||||
int channel_g;
|
||||
int channel_b;
|
||||
pwm_t device; /**< PWM device to use to control rgbleds */
|
||||
int channel_r; /**< set the R value in RGB */
|
||||
int channel_g; /**< set the G value in RGB */
|
||||
int channel_b; /**< set the B value in RGB */
|
||||
} rgbled_t;
|
||||
|
||||
|
||||
|
||||
@ -27,21 +27,21 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SHT11_NO_ACK (0)
|
||||
#define SHT11_ACK (1)
|
||||
//adr command r/w
|
||||
#define SHT11_STATUS_REG_W (0x06) //000 0011 0
|
||||
#define SHT11_STATUS_REG_R (0x07) //000 0011 1
|
||||
#define SHT11_MEASURE_TEMP (0x03) //000 0001 1
|
||||
#define SHT11_MEASURE_HUMI (0x05) //000 0010 1
|
||||
#define SHT11_RESET (0x1E) //000 1111 0
|
||||
#define SHT11_NO_ACK (0) /**< don't ack read in `read_byte` */
|
||||
#define SHT11_ACK (1) /**< do acknowledge read in `read_byte` */
|
||||
/* adr command r/w */
|
||||
#define SHT11_STATUS_REG_W (0x06) /**< will write to status register */
|
||||
#define SHT11_STATUS_REG_R (0x07) /**< will read from status register */
|
||||
#define SHT11_MEASURE_TEMP (0x03) /**< tell sensor to measure temperature */
|
||||
#define SHT11_MEASURE_HUMI (0x05) /**< tell sensor to measure humidity */
|
||||
#define SHT11_RESET (0x1E) /**< reset the sensor */
|
||||
|
||||
/* time to wait after toggling the data line */
|
||||
/** time to wait after toggling the data line */
|
||||
#define SHT11_DATA_WAIT (1)
|
||||
/* time to wait after toggling the clock line */
|
||||
/** time to wait after toggling the clock line */
|
||||
#define SHT11_CLK_WAIT (1)
|
||||
|
||||
/* set measurement timeout to 1 second */
|
||||
/** set measurement timeout to 1 second */
|
||||
#define SHT11_MEASURE_TIMEOUT (1000)
|
||||
|
||||
/**
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
* @brief C++11 chrono drop in replacement that adds the function now based on
|
||||
* xtimer/timex
|
||||
* @see <a href="http://en.cppreference.com/w/cpp/thread/thread">
|
||||
* std::thread, defined in header <thread>
|
||||
* std::thread, defined in header thread
|
||||
* </a>
|
||||
*
|
||||
* @author Raphael Hiesgen <raphael.hiesgen (at) haw-hamburg.de>
|
||||
@ -38,30 +38,37 @@ constexpr uint32_t microsecs_in_sec = 1000000;
|
||||
} // namespace anaonymous
|
||||
|
||||
/**
|
||||
* @brief time point to use for timed wait, as stdlib clocks are not available
|
||||
* @brief A time point for timed wait, as clocks from the standard are not
|
||||
* available on RIOT.
|
||||
*/
|
||||
class time_point {
|
||||
using native_handle_type = timex_t;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief create a time point with seconds and microseconds set to 0
|
||||
* @brief Creates a time point with seconds and microseconds set to 0.
|
||||
*/
|
||||
inline time_point() : m_handle{0, 0} {}
|
||||
/**
|
||||
* @brief create time point from timex_t struct
|
||||
* @brief Create time point from timex_t struct.
|
||||
*/
|
||||
inline time_point(timex_t&& tp) : m_handle(tp) {}
|
||||
/**
|
||||
* @brief Use default copy constructor.
|
||||
*/
|
||||
constexpr time_point(const time_point& tp) = default;
|
||||
/**
|
||||
* @brief Use default move constructor.
|
||||
*/
|
||||
constexpr time_point(time_point&& tp) = default;
|
||||
|
||||
/**
|
||||
* @brief get access to the handle used to store the time information
|
||||
* @brief Gives access to the native handle that stores the time information.
|
||||
*/
|
||||
inline native_handle_type native_handle() const { return m_handle; }
|
||||
|
||||
/**
|
||||
* @brief add a stdlib chrono::duration to this time point
|
||||
* @brief Add a standard chrono::duration to this time point.
|
||||
*/
|
||||
template <class Rep, class Period>
|
||||
inline time_point& operator+=(const std::chrono::duration<Rep, Period>& d) {
|
||||
@ -74,12 +81,12 @@ class time_point {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief returns seconds member as uint32_t
|
||||
* @brief Returns seconds member as uint32_t.
|
||||
*/
|
||||
inline uint32_t seconds() const { return m_handle.seconds; }
|
||||
|
||||
/**
|
||||
* @brief returns microseconds member as uint32_t
|
||||
* @brief Returns microseconds member as uint32_t.
|
||||
*/
|
||||
inline uint32_t microseconds() const { return m_handle.microseconds; }
|
||||
|
||||
@ -93,9 +100,9 @@ class time_point {
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief get the current time saved in a time point
|
||||
* @brief Returns the current time saved in a time point.
|
||||
*
|
||||
* @return time_point containing the current time
|
||||
* @return time_point containing the current time.
|
||||
*/
|
||||
inline time_point now() {
|
||||
timex_t tp;
|
||||
@ -104,7 +111,7 @@ inline time_point now() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief compare two timepoints
|
||||
* @brief Compares two timepoints.
|
||||
*/
|
||||
inline bool operator<(const time_point& lhs, const time_point& rhs) {
|
||||
return lhs.seconds() < rhs.seconds()
|
||||
@ -113,21 +120,21 @@ inline bool operator<(const time_point& lhs, const time_point& rhs) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief compare two timepoints
|
||||
* @brief Compares two timepoints.
|
||||
*/
|
||||
inline bool operator>(const time_point& lhs, const time_point& rhs) {
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief compare two timepoints
|
||||
* @brief Compares two timepoints.
|
||||
*/
|
||||
inline bool operator<=(const time_point& lhs, const time_point& rhs) {
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief compare two timepoints
|
||||
* @brief Compare two timepoints.
|
||||
*/
|
||||
inline bool operator>=(const time_point& lhs, const time_point& rhs) {
|
||||
return !(lhs < rhs);
|
||||
|
||||
@ -33,49 +33,110 @@
|
||||
|
||||
namespace riot {
|
||||
|
||||
/**
|
||||
* @brief Status for timeout-based calls of the condition variable.
|
||||
*/
|
||||
enum class cv_status {
|
||||
no_timeout,
|
||||
timeout
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief C++11 complient implementation of condition variable, uses the time
|
||||
* point implemented in our chrono replacement instead of the
|
||||
* specified one
|
||||
* @brief C++11 compliant implementation of condition variable, uses the time
|
||||
* point implemented in our chrono replacement instead of the
|
||||
* specified one
|
||||
* @see <a href="http://en.cppreference.com/w/cpp/thread/condition_variable">
|
||||
* std::condition_variable
|
||||
* </a>
|
||||
*/
|
||||
class condition_variable {
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* @brief The native handle type used by the condition variable.
|
||||
*/
|
||||
using native_handle_type = priority_queue_t*;
|
||||
|
||||
inline condition_variable() { m_queue.first = NULL; }
|
||||
~condition_variable();
|
||||
|
||||
/**
|
||||
* @brief Notify one thread waiting on this condition.
|
||||
*/
|
||||
void notify_one() noexcept;
|
||||
/**
|
||||
* @brief Notify all threads waiting on this condition variable.
|
||||
*/
|
||||
void notify_all() noexcept;
|
||||
|
||||
/**
|
||||
* @brief Block until woken up through the condition variable.
|
||||
* @param lock A lock that is locked by the current thread.
|
||||
*/
|
||||
void wait(unique_lock<mutex>& lock) noexcept;
|
||||
/**
|
||||
* @brief Block until woken up through the condition variable and a predicate
|
||||
* is fulfilled.
|
||||
* @param lock A lock that is locked by the current thread.
|
||||
* @param pred A predicate that returns a bool to signify if the thread
|
||||
* should continue to wait when woken up through the cv.
|
||||
*/
|
||||
template <class Predicate>
|
||||
void wait(unique_lock<mutex>& lock, Predicate pred);
|
||||
/**
|
||||
* @brief Block until woken up through the condition variable or a specified
|
||||
* point in time is reached. The lock is reacquired either way.
|
||||
* @param lock A lock that is locked by the current thread.
|
||||
* @param timeout_time Point in time when the thread is woken up
|
||||
* independently of the condition variable.
|
||||
* @return A status to signify if woken up due to a timeout or the cv.
|
||||
*/
|
||||
cv_status wait_until(unique_lock<mutex>& lock,
|
||||
const time_point& timeout_time);
|
||||
/**
|
||||
* @brief Block until woken up through the condition variable and a predicate
|
||||
* is fulfilled or a specified point in time is reached. The lock is
|
||||
* reacquired either way.
|
||||
* @param lock A lock that is locked by the current thread.
|
||||
* @param timeout_time Point in time when the thread is woken up
|
||||
* independently of the condition variable.
|
||||
* @param pred A predicate that returns a bool to signify if the
|
||||
* thread should continue to wait when woken up through
|
||||
* the cv.
|
||||
* @return Result of the pred when the function returns.
|
||||
*/
|
||||
template <class Predicate>
|
||||
bool wait_until(unique_lock<mutex>& lock, const time_point& timeout_time,
|
||||
Predicate pred);
|
||||
|
||||
/**
|
||||
* @brief Blocks until woken up through the condition variable or when the
|
||||
* thread has been blocked for a certain time.
|
||||
* @param lock A lock that is locked by the current thread.
|
||||
* @param rel_time The maximum time spent blocking.
|
||||
* @return A status to signify if woken up due to a timeout or the cv.
|
||||
*/
|
||||
template <class Rep, class Period>
|
||||
cv_status wait_for(unique_lock<mutex>& lock,
|
||||
const std::chrono::duration<Rep, Period>& rel_time);
|
||||
/**
|
||||
* @brief Blocks until woken up through the condition variable and a predicate
|
||||
* is fulfilled or when the thread has been blocked for a certain time.
|
||||
* @param lock A lock that is locked by the current thread.
|
||||
* @param rel_time The maximum time spent blocking.
|
||||
* @param pred A predicate that returns a bool to signify if the thread
|
||||
* should continue to wait when woken up through the cv.
|
||||
* @return Result of the pred when the function returns.
|
||||
*/
|
||||
template <class Rep, class Period, class Predicate>
|
||||
bool wait_for(unique_lock<mutex>& lock,
|
||||
const std::chrono::duration<Rep, Period>& rel_time,
|
||||
Predicate pred);
|
||||
|
||||
/**
|
||||
* @brief Returns the native handle of the condition variable.
|
||||
*/
|
||||
inline native_handle_type native_handle() { return &m_queue; }
|
||||
|
||||
private:
|
||||
private:
|
||||
condition_variable(const condition_variable&);
|
||||
condition_variable& operator=(const condition_variable&);
|
||||
|
||||
|
||||
@ -29,34 +29,49 @@ namespace riot {
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* A list of integers (wraps a long... template parameter pack).
|
||||
* @brief A list of integers (wraps a long... template parameter pack).
|
||||
*/
|
||||
template <long... Is>
|
||||
struct int_list {};
|
||||
|
||||
/**
|
||||
* Creates indices for from `Pos` to `Max`.
|
||||
* @brief Creates indices from `Pos` to `Max`.
|
||||
*/
|
||||
template <long Max, long Pos = 0, typename Indices = int_list<>>
|
||||
struct il_indices;
|
||||
|
||||
/**
|
||||
* @brief End of recursion, `Pos` reached `Max`.
|
||||
*/
|
||||
template <long Pos, long... Is>
|
||||
struct il_indices<Pos, Pos, int_list<Is...>> {
|
||||
/**
|
||||
* @brief Result is the list containing `Is...`.
|
||||
*/
|
||||
using type = int_list<Is...>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Recursion step.
|
||||
*/
|
||||
template <long Max, long Pos, long... Is>
|
||||
struct il_indices<Max, Pos, int_list<Is...>> {
|
||||
/**
|
||||
* @brief Append `Pos` to list and increment for the next step.
|
||||
*/
|
||||
using type = typename il_indices<Max, Pos + 1, int_list<Is..., Pos>>::type;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Function to create a list of indices from `From` to `To`.
|
||||
*/
|
||||
template <long To, long From = 0>
|
||||
typename il_indices<To, From>::type get_indices() {
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* apply arguments to function
|
||||
* @brief Apply arguments in a tuple to function.
|
||||
*/
|
||||
template <class F, long... Is, class Tuple>
|
||||
inline auto apply_args(F& f, detail::int_list<Is...>, Tuple&& tup)
|
||||
@ -64,12 +79,20 @@ inline auto apply_args(F& f, detail::int_list<Is...>, Tuple&& tup)
|
||||
return f(std::get<Is>(tup)...);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Prefix the argument tuple with additonal arguments.
|
||||
* In this case the tuple is empty.
|
||||
*/
|
||||
template <class F, class Tuple, class... Ts>
|
||||
inline auto apply_args_prefixed(F& f, detail::int_list<>, Tuple&, Ts&&... args)
|
||||
-> decltype(f(std::forward<Ts>(args)...)) {
|
||||
return f(std::forward<Ts>(args)...);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Prefix the argument tuple with additonal arguments.
|
||||
* In this case the tuple is contains arguments.
|
||||
*/
|
||||
template <class F, long... Is, class Tuple, class... Ts>
|
||||
inline auto apply_args_prefixed(F& f, detail::int_list<Is...>, Tuple& tup,
|
||||
Ts&&... args)
|
||||
@ -77,6 +100,9 @@ inline auto apply_args_prefixed(F& f, detail::int_list<Is...>, Tuple& tup,
|
||||
return f(std::forward<Ts>(args)..., std::get<Is>(tup)...);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Suffix the tuple with additonal arguments.
|
||||
*/
|
||||
template <class F, long... Is, class Tuple, class... Ts>
|
||||
inline auto apply_args_suffxied(F& f, detail::int_list<Is...>, Tuple& tup,
|
||||
Ts&&... args)
|
||||
|
||||
@ -41,31 +41,66 @@ namespace riot {
|
||||
* </a>
|
||||
*/
|
||||
class mutex {
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* The native handle type used by the mutex.
|
||||
*/
|
||||
using native_handle_type = mutex_t*;
|
||||
|
||||
inline constexpr mutex() noexcept : m_mtx{{0}} {}
|
||||
~mutex();
|
||||
|
||||
/**
|
||||
* @brief Lock the mutex.
|
||||
*/
|
||||
void lock();
|
||||
/**
|
||||
* @brief Try to lock the mutex.
|
||||
* @return `true` if the mutex was locked, `false` otherwise.
|
||||
*/
|
||||
bool try_lock() noexcept;
|
||||
/**
|
||||
* @brief Unlock the mutex.
|
||||
*/
|
||||
void unlock() noexcept;
|
||||
|
||||
/**
|
||||
* @brief Provides access to the native handle.
|
||||
* @return The native handle of the mutex.
|
||||
*/
|
||||
inline native_handle_type native_handle() { return &m_mtx; }
|
||||
|
||||
private:
|
||||
private:
|
||||
mutex(const mutex&);
|
||||
mutex& operator=(const mutex&);
|
||||
|
||||
mutex_t m_mtx;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Tag type for defer lock strategy.
|
||||
*/
|
||||
struct defer_lock_t {};
|
||||
/**
|
||||
* @brief Tag type for try lock strategy.
|
||||
*/
|
||||
struct try_to_lock_t {};
|
||||
/**
|
||||
* @brief Tag type for adopt lock strategy.
|
||||
*/
|
||||
struct adopt_lock_t {};
|
||||
|
||||
/**
|
||||
* @brief Tag constant for defer lock strategy.
|
||||
*/
|
||||
constexpr defer_lock_t defer_lock = defer_lock_t();
|
||||
/**
|
||||
* @brief Tag constant for try lock strategy.
|
||||
*/
|
||||
constexpr try_to_lock_t try_to_lock = try_to_lock_t();
|
||||
/**
|
||||
* @brief Tag constant for adopt lock strategy.
|
||||
*/
|
||||
constexpr adopt_lock_t adopt_lock = adopt_lock_t();
|
||||
|
||||
/**
|
||||
@ -76,15 +111,24 @@ constexpr adopt_lock_t adopt_lock = adopt_lock_t();
|
||||
*/
|
||||
template <class Mutex>
|
||||
class lock_guard {
|
||||
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* The type of Mutex used by the lock_guard.
|
||||
*/
|
||||
using mutex_type = Mutex;
|
||||
|
||||
/**
|
||||
* @brief Constructs a lock_gurad from a Mutex and locks it.
|
||||
*/
|
||||
inline explicit lock_guard(mutex_type& mtx) : m_mtx(mtx) { m_mtx.lock(); }
|
||||
/**
|
||||
* @brief Constructs a lock_guard from a Mutex, acquireing ownership without
|
||||
* locking it.
|
||||
*/
|
||||
inline lock_guard(mutex_type& mtx, adopt_lock_t) : m_mtx{mtx} {}
|
||||
inline ~lock_guard() { m_mtx.unlock(); }
|
||||
|
||||
private:
|
||||
private:
|
||||
mutex_type& m_mtx;
|
||||
};
|
||||
|
||||
@ -96,18 +140,33 @@ class lock_guard {
|
||||
*/
|
||||
template <class Mutex>
|
||||
class unique_lock {
|
||||
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* The type of Mutex used by the lock.
|
||||
*/
|
||||
using mutex_type = Mutex;
|
||||
|
||||
inline unique_lock() noexcept : m_mtx{nullptr}, m_owns{false} {}
|
||||
/**
|
||||
* @brief Constructs a unique_lock from a Mutex and locks it.
|
||||
*/
|
||||
inline explicit unique_lock(mutex_type& mtx) : m_mtx{&mtx}, m_owns{true} {
|
||||
m_mtx->lock();
|
||||
}
|
||||
/**
|
||||
* @brief Constructs a unique_lock from a Mutex but does not lock it.
|
||||
*/
|
||||
inline unique_lock(mutex_type& mtx, defer_lock_t) noexcept : m_mtx{&mtx},
|
||||
m_owns{false} {}
|
||||
/**
|
||||
* @brief Constructs a unique_lock from a Mutex and tries to lock it.
|
||||
*/
|
||||
inline unique_lock(mutex_type& mtx, try_to_lock_t)
|
||||
: m_mtx{&mtx}, m_owns{mtx.try_lock()} {}
|
||||
/**
|
||||
* @brief Constructs a unique_lock from a Mutex that is already owned by the
|
||||
* thread.
|
||||
*/
|
||||
inline unique_lock(mutex_type& mtx, adopt_lock_t)
|
||||
: m_mtx{&mtx}, m_owns{true} {}
|
||||
inline ~unique_lock() {
|
||||
@ -115,11 +174,17 @@ class unique_lock {
|
||||
m_mtx->unlock();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Move constructor.
|
||||
*/
|
||||
inline unique_lock(unique_lock&& lock) noexcept : m_mtx{lock.m_mtx},
|
||||
m_owns{lock.m_owns} {
|
||||
lock.m_mtx = nullptr;
|
||||
lock.m_owns = false;
|
||||
}
|
||||
/**
|
||||
* @brief Move assignment operator.
|
||||
*/
|
||||
inline unique_lock& operator=(unique_lock&& lock) noexcept {
|
||||
if (m_owns) {
|
||||
m_mtx->unlock();
|
||||
@ -131,16 +196,34 @@ class unique_lock {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Locks the associated mutex.
|
||||
*/
|
||||
void lock();
|
||||
/**
|
||||
* @brief Tries to lock the associated mutex.
|
||||
* @return `true` if the mutex has been locked successfully,
|
||||
* `false` otherwise.
|
||||
*/
|
||||
bool try_lock();
|
||||
|
||||
/**
|
||||
* @brief Unlocks the associated mutex.
|
||||
*/
|
||||
void unlock();
|
||||
|
||||
/**
|
||||
* @brief Swap this unique_lock with another unique_lock.
|
||||
*/
|
||||
inline void swap(unique_lock& lock) noexcept {
|
||||
std::swap(m_mtx, lock.m_mtx);
|
||||
std::swap(m_owns, lock.m_owns);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disassociate this lock from its mutex. The caller is responsible to
|
||||
* unlock the mutex if it was locked before.
|
||||
* @return A pointer to the associated mutex or `nullptr` if there was none.
|
||||
*/
|
||||
inline mutex_type* release() noexcept {
|
||||
mutex_type* mtx = m_mtx;
|
||||
m_mtx = nullptr;
|
||||
@ -148,11 +231,25 @@ class unique_lock {
|
||||
return mtx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Query ownership of the associate mutex.
|
||||
* @return `true` if an associated mutex exists and the lock owns it,
|
||||
* `false` otherwise.
|
||||
*/
|
||||
inline bool owns_lock() const noexcept { return m_owns; }
|
||||
/**
|
||||
* @brief Operator to query the ownership of the associated mutex.
|
||||
* @return `true` if an associated mutex exists and the lock owns it,
|
||||
* `false` otherwise.
|
||||
*/
|
||||
inline explicit operator bool() const noexcept { return m_owns; }
|
||||
/**
|
||||
* @brief Provides access to the associated mutex.
|
||||
* @return A pointer to the associated mutex or nullptr it there was none.
|
||||
*/
|
||||
inline mutex_type* mutex() const noexcept { return m_mtx; }
|
||||
|
||||
private:
|
||||
private:
|
||||
unique_lock(unique_lock const&);
|
||||
unique_lock& operator=(unique_lock const&);
|
||||
|
||||
@ -203,6 +300,11 @@ void unique_lock<Mutex>::unlock() {
|
||||
m_owns = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Swaps two mutexes.
|
||||
* @param[inout] lhs Reference to one mutex.
|
||||
* @param[inout] rhs Reference to the other mutex.
|
||||
*/
|
||||
template <class Mutex>
|
||||
inline void swap(unique_lock<Mutex>& lhs, unique_lock<Mutex>& rhs) noexcept {
|
||||
lhs.swap(rhs);
|
||||
|
||||
@ -45,24 +45,39 @@
|
||||
namespace riot {
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @brief Identify uninitialized threads.
|
||||
*/
|
||||
constexpr kernel_pid_t thread_uninitialized = -1;
|
||||
/**
|
||||
* @brief The stack size for new threads.
|
||||
*/
|
||||
constexpr size_t stack_size = THREAD_STACKSIZE_MAIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Holds context data for the thread.
|
||||
*/
|
||||
struct thread_data {
|
||||
thread_data() : ref_count{2}, joining_thread{thread_uninitialized} {
|
||||
// nop
|
||||
}
|
||||
/** @cond INTERNAL */
|
||||
std::atomic<unsigned> ref_count;
|
||||
kernel_pid_t joining_thread;
|
||||
char stack[stack_size];
|
||||
/** @endcond */
|
||||
};
|
||||
|
||||
/**
|
||||
* This deleter prevents our thread data from being destroyed if the thread
|
||||
* object is destroyed before the thread had a chance to run
|
||||
* @brief This deleter prevents our thread data from being destroyed if the
|
||||
* thread object is destroyed before the thread had a chance to run.
|
||||
*/
|
||||
struct thread_data_deleter {
|
||||
/**
|
||||
* @brief Called by the deleter of a thread object to manage the lifetime of
|
||||
* the thread internal management data.
|
||||
*/
|
||||
void operator()(thread_data* ptr) {
|
||||
if (--ptr->ref_count == 0) {
|
||||
delete ptr;
|
||||
@ -83,33 +98,60 @@ class thread_id {
|
||||
thread_id id);
|
||||
friend class thread;
|
||||
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* @brief Creates a uninitialized thread id.
|
||||
*/
|
||||
inline thread_id() noexcept : m_handle{thread_uninitialized} {}
|
||||
/**
|
||||
* @brief Create a thread id from a native handle.
|
||||
*/
|
||||
inline thread_id(kernel_pid_t handle) : m_handle{handle} {}
|
||||
|
||||
/**
|
||||
* @brief Comparison operator for thread ids.
|
||||
*/
|
||||
inline bool operator==(thread_id other) noexcept {
|
||||
return m_handle == other.m_handle;
|
||||
}
|
||||
/**
|
||||
* @brief Comparison operator for thread ids.
|
||||
*/
|
||||
inline bool operator!=(thread_id other) noexcept {
|
||||
return !(m_handle == other.m_handle);
|
||||
}
|
||||
/**
|
||||
* @brief Comparison operator for thread ids.
|
||||
*/
|
||||
inline bool operator<(thread_id other) noexcept {
|
||||
return m_handle < other.m_handle;
|
||||
}
|
||||
/**
|
||||
* @brief Comparison operator for thread ids.
|
||||
*/
|
||||
inline bool operator<=(thread_id other) noexcept {
|
||||
return !(m_handle > other.m_handle);
|
||||
}
|
||||
/**
|
||||
* @brief Comparison operator for thread ids.
|
||||
*/
|
||||
inline bool operator>(thread_id other) noexcept {
|
||||
return m_handle > other.m_handle;
|
||||
}
|
||||
/**
|
||||
* @brief Comparison operator for thread ids.
|
||||
*/
|
||||
inline bool operator>=(thread_id other) noexcept {
|
||||
return !(m_handle < other.m_handle);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
kernel_pid_t m_handle;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Enable printing of thread ids using output streams.
|
||||
*/
|
||||
template <class T, class Traits>
|
||||
inline std::basic_ostream<T, Traits>& operator<<(std::basic_ostream
|
||||
<T, Traits>& out,
|
||||
@ -119,9 +161,23 @@ inline std::basic_ostream<T, Traits>& operator<<(std::basic_ostream
|
||||
|
||||
namespace this_thread {
|
||||
|
||||
/**
|
||||
* @brief Access the id of the currently running thread.
|
||||
*/
|
||||
inline thread_id get_id() noexcept { return thread_getpid(); }
|
||||
/**
|
||||
* @brief Yield the currently running thread.
|
||||
*/
|
||||
inline void yield() noexcept { thread_yield(); }
|
||||
/**
|
||||
* @brief Puts the current thread to sleep.
|
||||
* @param[in] ns Duration to sleep in nanoseconds.
|
||||
*/
|
||||
void sleep_for(const std::chrono::nanoseconds& ns);
|
||||
/**
|
||||
* @brief Puts the current thread to sleep.
|
||||
* @param[in] sleep_duration The duration to sleep.
|
||||
*/
|
||||
template <class Rep, class Period>
|
||||
void sleep_for(const std::chrono::duration<Rep, Period>& sleep_duration) {
|
||||
using namespace std::chrono;
|
||||
@ -139,6 +195,11 @@ void sleep_for(const std::chrono::duration<Rep, Period>& sleep_duration) {
|
||||
sleep_for(ns);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Puts the current thread to sleep.
|
||||
* @param[in] sleep_time A point in time that specifies when the thread
|
||||
* should wake up.
|
||||
*/
|
||||
inline void sleep_until(const riot::time_point& sleep_time) {
|
||||
mutex mtx;
|
||||
condition_variable cv;
|
||||
@ -149,7 +210,7 @@ inline void sleep_until(const riot::time_point& sleep_time) {
|
||||
}
|
||||
} // namespace this_thread
|
||||
|
||||
/*
|
||||
/**
|
||||
* @brief C++11 compliant implementation of thread, however uses the time
|
||||
* point from out chrono header instead of the specified one
|
||||
* @see <a href="http://en.cppreference.com/w/cpp/thread/thread">
|
||||
@ -157,44 +218,100 @@ inline void sleep_until(const riot::time_point& sleep_time) {
|
||||
* </a>
|
||||
*/
|
||||
class thread {
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* @brief The id is of type `thread_id`-
|
||||
*/
|
||||
using id = thread_id;
|
||||
/**
|
||||
* @brief The native handle type is the `kernel_pid_t` of RIOT.
|
||||
*/
|
||||
using native_handle_type = kernel_pid_t;
|
||||
|
||||
/**
|
||||
* @brief Per default, an uninitialized thread is created.
|
||||
*/
|
||||
inline thread() noexcept : m_handle{thread_uninitialized} {}
|
||||
/**
|
||||
* @brief Create a thread from a functor and arguments for it.
|
||||
* @param[in] f Functor to run as a thread.
|
||||
* @param[in] args Arguments passed to the functor.
|
||||
*/
|
||||
template <class F, class... Args>
|
||||
explicit thread(F&& f, Args&&... args);
|
||||
~thread();
|
||||
|
||||
thread(const thread&) = delete;
|
||||
/**
|
||||
* @brief Move constructor.
|
||||
*/
|
||||
inline thread(thread&& t) noexcept : m_handle{t.m_handle} {
|
||||
t.m_handle = thread_uninitialized;
|
||||
std::swap(m_data, t.m_data);
|
||||
}
|
||||
|
||||
~thread();
|
||||
|
||||
thread& operator=(const thread&) = delete;
|
||||
/**
|
||||
* @brief Move assignment operator.
|
||||
*/
|
||||
thread& operator=(thread&&) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Swap threads.
|
||||
* @param[inout] t Thread to swap data with.
|
||||
*/
|
||||
void swap(thread& t) noexcept {
|
||||
std::swap(m_data, t.m_data);
|
||||
std::swap(m_handle, t.m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Query if the thread is joinable.
|
||||
* @return `true` if the thread is joinable, `false` otherwise.
|
||||
*/
|
||||
inline bool joinable() const noexcept {
|
||||
return m_handle != thread_uninitialized;
|
||||
}
|
||||
/**
|
||||
* @brief Block until the thread finishes. Leads to an error if the thread is
|
||||
* not joinable or a thread joins itself.
|
||||
*/
|
||||
void join();
|
||||
/**
|
||||
* @brief Detaches a thread from its handle and allows it to execute
|
||||
* independently. The thread cleans up its resources when it
|
||||
* finishes.
|
||||
*/
|
||||
void detach();
|
||||
/**
|
||||
* @brief Returns the id of a thread.
|
||||
*/
|
||||
inline id get_id() const noexcept { return m_handle; }
|
||||
/**
|
||||
* @brief Returns the native handle to a thread.
|
||||
*/
|
||||
inline native_handle_type native_handle() noexcept { return m_handle; }
|
||||
|
||||
/**
|
||||
* @brief Returns the number of concurrent threads supported by the
|
||||
* underlying hardware. Since there is no RIOT API to query this
|
||||
* information, the function always returns 1;
|
||||
*/
|
||||
static unsigned hardware_concurrency() noexcept;
|
||||
|
||||
private:
|
||||
kernel_pid_t m_handle;
|
||||
std::unique_ptr<thread_data, thread_data_deleter> m_data;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Swaps two threads.
|
||||
* @param[inout] lhs Reference to one thread.
|
||||
* @param[inout] rhs Reference to the other thread.
|
||||
*/
|
||||
void swap(thread& lhs, thread& rhs) noexcept;
|
||||
|
||||
/** @cond INTERNAL */
|
||||
template <class Tuple>
|
||||
void* thread_proxy(void* vp) {
|
||||
{ // without this scope, the objects here are not cleaned up corrctly
|
||||
@ -217,6 +334,7 @@ void* thread_proxy(void* vp) {
|
||||
sched_task_exit();
|
||||
return nullptr;
|
||||
}
|
||||
/** @endcond */
|
||||
|
||||
template <class F, class... Args>
|
||||
thread::thread(F&& f, Args&&... args)
|
||||
@ -224,7 +342,7 @@ thread::thread(F&& f, Args&&... args)
|
||||
using namespace std;
|
||||
using func_and_args = tuple
|
||||
<thread_data*, typename decay<F>::type, typename decay<Args>::type...>;
|
||||
std::unique_ptr<func_and_args> p(
|
||||
unique_ptr<func_and_args> p(
|
||||
new func_and_args(m_data.get(), forward<F>(f), forward<Args>(args)...));
|
||||
m_handle = thread_create(
|
||||
m_data->stack, stack_size, THREAD_PRIORITY_MAIN - 1, 0,
|
||||
|
||||
@ -91,7 +91,7 @@ void color_rgb2hex(const color_rgb_t *rgb, uint32_t *hex);
|
||||
* Expect unexpected behaviour, otherwise.
|
||||
*
|
||||
* @param[in] str Input color encoded as string of the form 'RRGGBB'
|
||||
* @param[out] rgb Output color encoded in RGB space
|
||||
* @param[out] color Output color encoded in RGB space
|
||||
*/
|
||||
void color_str2rgb(const char *str, color_rgb_t *color);
|
||||
|
||||
|
||||
@ -120,17 +120,17 @@ void sha256_final(sha256_context_t *ctx, void *digest);
|
||||
* @brief A wrapper function to simplify the generation of a hash, this is
|
||||
* usefull for generating sha256 for one buffer
|
||||
*
|
||||
* @param data pointer to the buffer to generate hash from
|
||||
* @param len length of the buffer
|
||||
* @param digest optional pointer to an array for the result, length must be
|
||||
* SHA256_DIGEST_LENGTH
|
||||
* if digest == NULL, one static buffer is used
|
||||
* @param[in] data pointer to the buffer to generate hash from
|
||||
* @param[in] len length of the buffer
|
||||
* @param[out] digest optional pointer to an array for the result, length must
|
||||
* be SHA256_DIGEST_LENGTH
|
||||
* if digest == NULL, one static buffer is used
|
||||
*/
|
||||
void *sha256(const void *data, size_t len, void *digest);
|
||||
|
||||
/**
|
||||
* @brief hmac_sha256_init HMAC SHA-256 calculation. Initiate calculation of a HMAC
|
||||
* @param ctx hmac_context_t handle to use
|
||||
* @param[in] ctx hmac_context_t handle to use
|
||||
* @param[in] key key used in the hmac-sha256 computation
|
||||
* @param[in] key_length the size in bytes of the key
|
||||
*/
|
||||
@ -138,15 +138,15 @@ void hmac_sha256_init(hmac_context_t *ctx, const void *key, size_t key_length);
|
||||
|
||||
/**
|
||||
* @brief hmac_sha256_update Add data bytes for HMAC calculation
|
||||
* @param ctx hmac_context_t handle to use
|
||||
* @param data[in] pointer to the buffer to generate hash from
|
||||
* @param len[in] length of the buffer
|
||||
* @param[in] ctx hmac_context_t handle to use
|
||||
* @param[in] data pointer to the buffer to generate hash from
|
||||
* @param[in] len length of the buffer
|
||||
*/
|
||||
void hmac_sha256_update(hmac_context_t *ctx, const void *data, size_t len);
|
||||
|
||||
/**
|
||||
* @brief hmac_sha256_final HMAC SHA-256 finalization. Finish HMAC calculation and export the value
|
||||
* @param ctx hmac_context_t handle to use
|
||||
* @param[in] ctx hmac_context_t handle to use
|
||||
* @param[out] digest the computed hmac-sha256,
|
||||
* length MUST be SHA256_DIGEST_LENGTH
|
||||
* if digest == NULL, a static buffer is used
|
||||
|
||||
@ -38,9 +38,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def GNRC_IPV6_NETIF_ADDR_NUMOF
|
||||
*
|
||||
* @brief Number of IPv6 addresses per interface.
|
||||
* @cond INTERNAL
|
||||
*/
|
||||
#ifdef MODULE_GNRC_RPL
|
||||
/* RPL needs all-RPL-nodes multicast address */
|
||||
@ -54,6 +52,12 @@ extern "C" {
|
||||
#else
|
||||
# define GNRC_IPV6_NETIF_RTR_ADDR (0)
|
||||
#endif
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
/**
|
||||
* @brief Number of IPv6 addresses per interface.
|
||||
*/
|
||||
#ifndef GNRC_IPV6_NETIF_ADDR_NUMOF
|
||||
#define GNRC_IPV6_NETIF_ADDR_NUMOF (6 + GNRC_IPV6_NETIF_RPL_ADDR + GNRC_IPV6_NETIF_RTR_ADDR)
|
||||
#endif
|
||||
|
||||
@ -54,7 +54,7 @@ typedef enum {
|
||||
* state machines.
|
||||
* This structure can be extended to contain more needed
|
||||
* states and parameters. Please guard them by appropriate
|
||||
* #ifdef directives when applicable.
|
||||
* \#ifdef directives when applicable.
|
||||
*/
|
||||
typedef struct {
|
||||
#if (GNRC_MAC_RX_QUEUE_SIZE != 0) || defined(DOXYGEN)
|
||||
@ -137,7 +137,7 @@ typedef struct {
|
||||
* state machines.
|
||||
* This structure can be extended to contain more needed
|
||||
* states and parameters. Please guard them by appropriate
|
||||
* #ifdef directives when applicable.
|
||||
* \#ifdef directives when applicable.
|
||||
*/
|
||||
typedef struct {
|
||||
#if (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN)
|
||||
|
||||
@ -36,6 +36,11 @@ extern "C" {
|
||||
* in bytes.
|
||||
*/
|
||||
#define GNRC_NETIF_HDR_L2ADDR_MAX_LEN (8)
|
||||
|
||||
/**
|
||||
* @brief Maximum length of the string representatiom of l2 addresses of the
|
||||
* generic interface header in bytes.
|
||||
*/
|
||||
#define GNRC_NETIF_HDR_L2ADDR_PRINT_LEN (GNRC_NETIF_HDR_L2ADDR_MAX_LEN * 3)
|
||||
|
||||
/**
|
||||
@ -199,7 +204,8 @@ gnrc_pktsnip_t *gnrc_netif_hdr_build(uint8_t *src, uint8_t src_len, uint8_t *dst
|
||||
*/
|
||||
void gnrc_netif_hdr_print(gnrc_netif_hdr_t *hdr);
|
||||
|
||||
/* @brief Fetch the netif header flags of a gnrc packet
|
||||
/**
|
||||
* @brief Fetch the netif header flags of a gnrc packet
|
||||
*
|
||||
* @param[in] pkt gnrc packet from whom to fetch
|
||||
*
|
||||
@ -208,7 +214,8 @@ void gnrc_netif_hdr_print(gnrc_netif_hdr_t *hdr);
|
||||
*/
|
||||
uint8_t gnrc_netif_hdr_get_flag(gnrc_pktsnip_t* pkt);
|
||||
|
||||
/* @brief Extract the destination address out of a gnrc packet
|
||||
/**
|
||||
* @brief Extract the destination address out of a gnrc packet
|
||||
*
|
||||
* @param[in] pkt gnrc packet from whom to extract
|
||||
* @param[out] pointer_to_addr pointer to address will be stored here
|
||||
@ -219,7 +226,8 @@ uint8_t gnrc_netif_hdr_get_flag(gnrc_pktsnip_t* pkt);
|
||||
*/
|
||||
int gnrc_netif_hdr_get_dstaddr(gnrc_pktsnip_t* pkt, uint8_t** pointer_to_addr);
|
||||
|
||||
/* @brief Extract the source address out of a gnrc packet
|
||||
/**
|
||||
* @brief Extract the source address out of a gnrc packet
|
||||
*
|
||||
* @param[in] pkt gnrc packet from whom to extract
|
||||
* @param[out] pointer_to_addr pointer to address will be stored here
|
||||
|
||||
@ -37,6 +37,11 @@ extern "C" {
|
||||
|
||||
#if defined(MODULE_GNRC_NETAPI_MBOX) || defined(MODULE_GNRC_NETAPI_CALLBACKS) || \
|
||||
defined(DOXYGEN)
|
||||
/**
|
||||
* @brief The type of the netreg entry.
|
||||
*
|
||||
* Different types are availalbe dependent on the used modules.
|
||||
*/
|
||||
typedef enum {
|
||||
GNRC_NETREG_TYPE_DEFAULT = 0,
|
||||
#if defined(MODULE_GNRC_NETAPI_MBOX) || defined(DOXYGEN)
|
||||
@ -95,7 +100,7 @@ typedef enum {
|
||||
*
|
||||
* @param[in] demux_ctx The @ref gnrc_netreg_entry_t::demux_ctx "demux context"
|
||||
* for the netreg entry
|
||||
* @param[in] cb Target callback for the registry entry
|
||||
* @param[in] cbd Target callback for the registry entry
|
||||
*
|
||||
* @note Only available with @ref net_gnrc_netapi_callbacks.
|
||||
*
|
||||
@ -108,7 +113,7 @@ typedef enum {
|
||||
/**
|
||||
* @brief Packet handler callback for netreg entries with callback.
|
||||
*
|
||||
* @pre `cmd` $\in$ { @ref GNRC_NETAPI_MSG_TYPE_RCV, @ref GNRC_NETAPI_MSG_TYPE_SND }
|
||||
* @pre `cmd` ∈ { @ref GNRC_NETAPI_MSG_TYPE_RCV, @ref GNRC_NETAPI_MSG_TYPE_SND }
|
||||
*
|
||||
* @note Only available with @ref net_gnrc_netapi_callbacks.
|
||||
*
|
||||
@ -237,7 +242,7 @@ static inline void gnrc_netreg_entry_init_mbox(gnrc_netreg_entry_t *entry,
|
||||
* @param[out] entry A netreg entry
|
||||
* @param[in] demux_ctx The @ref gnrc_netreg_entry_t::demux_ctx "demux context"
|
||||
* for the netreg entry
|
||||
* @param[in] mbox Target callback for the registry entry
|
||||
* @param[in] cbd Target callback for the registry entry
|
||||
*
|
||||
* @note Only available with @ref net_gnrc_netapi_callbacks.
|
||||
*/
|
||||
|
||||
@ -200,13 +200,23 @@ typedef struct __attribute__((packed)) {
|
||||
ipv6_addr_t prefix; /**< prefix used for Stateless Address Autoconfiguration */
|
||||
} gnrc_rpl_opt_prefix_info_t;
|
||||
|
||||
/**
|
||||
* @brief DODAG representation
|
||||
*/
|
||||
typedef struct gnrc_rpl_dodag gnrc_rpl_dodag_t;
|
||||
typedef struct gnrc_rpl_parent gnrc_rpl_parent_t;
|
||||
typedef struct gnrc_rpl_instance gnrc_rpl_instance_t;
|
||||
|
||||
/**
|
||||
* @brief Parent representation
|
||||
*/
|
||||
typedef struct gnrc_rpl_parent gnrc_rpl_parent_t;
|
||||
|
||||
/**
|
||||
* @brief Instance representation
|
||||
*/
|
||||
typedef struct gnrc_rpl_instance gnrc_rpl_instance_t;
|
||||
|
||||
/**
|
||||
* @cond INTERNAL */
|
||||
struct gnrc_rpl_parent {
|
||||
gnrc_rpl_parent_t *next; /**< pointer to the next parent */
|
||||
uint8_t state; /**< 0 for unsued, 1 for used */
|
||||
@ -218,6 +228,9 @@ struct gnrc_rpl_parent {
|
||||
double link_metric; /**< metric of the link */
|
||||
uint8_t link_metric_type; /**< type of the metric */
|
||||
};
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Objective function representation
|
||||
@ -234,7 +247,7 @@ typedef struct {
|
||||
} gnrc_rpl_of_t;
|
||||
|
||||
/**
|
||||
* @brief DODAG representation
|
||||
* @cond INTERNAL
|
||||
*/
|
||||
struct gnrc_rpl_dodag {
|
||||
ipv6_addr_t dodag_id; /**< id of the DODAG */
|
||||
@ -262,9 +275,6 @@ struct gnrc_rpl_dodag {
|
||||
trickle_t trickle; /**< trickle representation */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Instance representation
|
||||
*/
|
||||
struct gnrc_rpl_instance {
|
||||
uint8_t id; /**< id of the instance */
|
||||
uint8_t state; /**< 0 for unused, 1 for used */
|
||||
@ -275,6 +285,9 @@ struct gnrc_rpl_instance {
|
||||
uint16_t max_rank_inc; /**< max increase in the rank */
|
||||
int8_t cleanup; /**< cleanup time in seconds */
|
||||
};
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@ extern "C" {
|
||||
* @param[in] datagram_size Size of the full uncompressed IPv6 datagram. May be 0, if @p pkt
|
||||
* contains the full (unfragmented) IPv6 datagram.
|
||||
* @param[in] offset Offset of the IPHC dispatch in 6LoWPaN frame.
|
||||
* @param[in, out] nh_len Pointer to next header length
|
||||
*
|
||||
* @return length of the HC dispatches + inline values on success.
|
||||
* @return 0 on error.
|
||||
|
||||
@ -157,7 +157,7 @@ void gnrc_sixlowpan_nd_router_abr_remove(gnrc_sixlowpan_nd_router_abr_t *abr);
|
||||
/**
|
||||
* @brief Makes this node a new border router.
|
||||
*
|
||||
* @per addr != NULL
|
||||
* @pre addr != NULL
|
||||
*
|
||||
* @param[in] addr The local address to use in the ABROs
|
||||
* @param[in] ltime The lifetime to advertise in the ABROs. 0 assumes a default value of
|
||||
@ -174,7 +174,7 @@ gnrc_sixlowpan_nd_router_abr_t *gnrc_sixlowpan_nd_router_abr_create(ipv6_addr_t
|
||||
*
|
||||
* @pre iface != NULL && prefix != NULL
|
||||
*
|
||||
* @param[in] abr The local border router
|
||||
* @param[in] abr The local border router.
|
||||
* @param[in] iface The IPv6 interface the prefix was added to.
|
||||
* @param[in] prefix The prefix.
|
||||
*
|
||||
@ -188,7 +188,7 @@ int gnrc_sixlowpan_nd_router_abr_add_prf(gnrc_sixlowpan_nd_router_abr_t* abr,
|
||||
/**
|
||||
* @brief Removes a prefix from this border router.
|
||||
*
|
||||
* @param[in] abr The local border router
|
||||
* @param[in] abr The local border router.
|
||||
* @param[in] iface The IPv6 interface the prefix was added to.
|
||||
* @param[in] prefix The prefix.
|
||||
*/
|
||||
@ -199,7 +199,7 @@ void gnrc_sixlowpan_nd_router_abr_rem_prf(gnrc_sixlowpan_nd_router_abr_t *abr,
|
||||
* @brief Adds a context for this border router to manage.
|
||||
*
|
||||
* @param[in] abr The local border router
|
||||
* @param[in] ctx The context to be add.
|
||||
* @param[in] cid The context to be add.
|
||||
*
|
||||
* @return 0, on success
|
||||
* @return -EINVAL, if @p ctx is greater than 15.
|
||||
@ -210,8 +210,8 @@ int gnrc_sixlowpan_nd_router_abr_add_ctx(gnrc_sixlowpan_nd_router_abr_t *abr, ui
|
||||
/**
|
||||
* @brief Removes a context from this border router.
|
||||
*
|
||||
* @param[in] abr The local border router
|
||||
* @param[in] ctx The context to be remove.
|
||||
* @param[in] abr The local border router.
|
||||
* @param[in] cid The context to be remove.
|
||||
*/
|
||||
void gnrc_sixlowpan_nd_router_abr_rem_ctx(gnrc_sixlowpan_nd_router_abr_t *abr, uint8_t cid);
|
||||
#else
|
||||
|
||||
@ -61,7 +61,7 @@ typedef struct __attribute__((packed)) {
|
||||
* @brief Process the routing header of an IPv6 packet.
|
||||
*
|
||||
* @param[in, out] ipv6 An IPv6 packet.
|
||||
* @param[in] ext A routing header of @ipv6.
|
||||
* @param[in] ext A routing header of @p ipv6.
|
||||
*
|
||||
* @return EXT_RH_CODE_ERROR
|
||||
* @return EXT_RH_CODE_FORWARD
|
||||
|
||||
@ -32,6 +32,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables support for floating point random number generation
|
||||
*/
|
||||
#ifndef PRNG_FLOAT
|
||||
# define PRNG_FLOAT (0)
|
||||
#endif
|
||||
|
||||
@ -47,7 +47,7 @@ extern "C" {
|
||||
* @note This is a struct in order to make the xtimer API type strict
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t ticks64;
|
||||
uint64_t ticks64; /**< Tick count */
|
||||
} xtimer_ticks64_t;
|
||||
|
||||
/**
|
||||
@ -56,7 +56,7 @@ typedef struct {
|
||||
* @note This is a struct in order to make the xtimer API type strict
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t ticks32;
|
||||
uint32_t ticks32; /**< Tick count */
|
||||
} xtimer_ticks32_t;
|
||||
|
||||
/**
|
||||
@ -68,12 +68,12 @@ typedef void (*xtimer_callback_t)(void*);
|
||||
* @brief xtimer timer structure
|
||||
*/
|
||||
typedef struct xtimer {
|
||||
struct xtimer *next; /**< reference to next timer in timer lists */
|
||||
uint32_t target; /**< lower 32bit absolute target time */
|
||||
uint32_t long_target; /**< upper 32bit absolute target time */
|
||||
struct xtimer *next; /**< reference to next timer in timer lists */
|
||||
uint32_t target; /**< lower 32bit absolute target time */
|
||||
uint32_t long_target; /**< upper 32bit absolute target time */
|
||||
xtimer_callback_t callback; /**< callback function to call when timer
|
||||
expires */
|
||||
void *arg; /**< argument to pass to callback function */
|
||||
void *arg; /**< argument to pass to callback function */
|
||||
} xtimer_t;
|
||||
|
||||
/**
|
||||
|
||||
@ -38,11 +38,23 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default port range for dynamic source port allocation
|
||||
* @brief Minimum port number in the dynamic portrange
|
||||
*/
|
||||
#define GNRC_SOCK_DYN_PORTRANGE_MIN (IANA_DYNAMIC_PORTRANGE_MIN)
|
||||
/**
|
||||
* @brief Maximum port number in the dynamic portrange
|
||||
*/
|
||||
#define GNRC_SOCK_DYN_PORTRANGE_MAX (IANA_DYNAMIC_PORTRANGE_MAX)
|
||||
|
||||
/**
|
||||
* @brief Available ports in the range for dynamic source port allocation
|
||||
*/
|
||||
#define GNRC_SOCK_DYN_PORTRANGE_NUM (GNRC_SOCK_DYN_PORTRANGE_MAX - GNRC_SOCK_DYN_PORTRANGE_MIN + 1)
|
||||
|
||||
/**
|
||||
* @brief Error value indicating that no free port could be found in the
|
||||
* dynamic port range
|
||||
*/
|
||||
#define GNRC_SOCK_DYN_PORTRANGE_ERR (0)
|
||||
|
||||
/**
|
||||
|
||||
@ -34,6 +34,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief POSIX-specific semaphore type
|
||||
*/
|
||||
typedef sema_t sem_t;
|
||||
|
||||
/**
|
||||
|
||||
@ -22,9 +22,15 @@
|
||||
|
||||
#include <time.h>
|
||||
|
||||
/**
|
||||
* @cond INTERNAL
|
||||
*/
|
||||
#ifndef __WITH_AVRLIBC__
|
||||
#define HAVE_MALLOC_H 1
|
||||
#endif
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
#include "mutex.h"
|
||||
#include "sched.h"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user