Merge pull request #5166 from kaspar030/syntax_check_debug_code
core: debug: rely on optimizer to kick out unused debug code
This commit is contained in:
commit
eb89954f13
@ -67,7 +67,9 @@ extern "C" {
|
|||||||
* @name Debugging defines
|
* @name Debugging defines
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#if ENABLE_DEBUG
|
#ifndef ENABLE_DEBUG
|
||||||
|
#define ENABLE_DEBUG (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def DEBUG_FUNC
|
* @def DEBUG_FUNC
|
||||||
@ -92,10 +94,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* @note Another name for ::DEBUG_PRINT
|
* @note Another name for ::DEBUG_PRINT
|
||||||
*/
|
*/
|
||||||
#define DEBUG(...) DEBUG_PRINT(__VA_ARGS__)
|
#define DEBUG(...) if (ENABLE_DEBUG) DEBUG_PRINT(__VA_ARGS__)
|
||||||
#else
|
|
||||||
#define DEBUG(...)
|
|
||||||
#endif
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -447,10 +447,11 @@ char *thread_stack_init(thread_task_func_t task_func, void *arg, void *stack_sta
|
|||||||
*/
|
*/
|
||||||
void thread_add_to_list(list_node_t *list, thread_t *thread);
|
void thread_add_to_list(list_node_t *list, thread_t *thread);
|
||||||
|
|
||||||
#ifdef DEVELHELP
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the name of a process
|
* @brief Returns the name of a process
|
||||||
*
|
*
|
||||||
|
* @note when compiling without DEVELHELP, this *always* returns NULL!
|
||||||
|
*
|
||||||
* @param[in] pid the PID of the thread to get the name from
|
* @param[in] pid the PID of the thread to get the name from
|
||||||
*
|
*
|
||||||
* @return the threads name
|
* @return the threads name
|
||||||
@ -458,6 +459,7 @@ void thread_add_to_list(list_node_t *list, thread_t *thread);
|
|||||||
*/
|
*/
|
||||||
const char *thread_getname(kernel_pid_t pid);
|
const char *thread_getname(kernel_pid_t pid);
|
||||||
|
|
||||||
|
#ifdef DEVELHELP
|
||||||
/**
|
/**
|
||||||
* @brief Measures the stack usage of a stack
|
* @brief Measures the stack usage of a stack
|
||||||
*
|
*
|
||||||
|
|||||||
@ -44,13 +44,16 @@ int thread_getstatus(kernel_pid_t pid)
|
|||||||
return t ? (int) t->status : STATUS_NOT_FOUND;
|
return t ? (int) t->status : STATUS_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEVELHELP
|
|
||||||
const char *thread_getname(kernel_pid_t pid)
|
const char *thread_getname(kernel_pid_t pid)
|
||||||
{
|
{
|
||||||
|
#ifdef DEVELHELP
|
||||||
volatile thread_t *t = thread_get(pid);
|
volatile thread_t *t = thread_get(pid);
|
||||||
return t ? t->name : NULL;
|
return t ? t->name : NULL;
|
||||||
}
|
#else
|
||||||
|
(void)pid;
|
||||||
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void thread_sleep(void)
|
void thread_sleep(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -132,7 +132,8 @@ int timer_init(tim_t tim, unsigned long freq, timer_cb_t cb, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (freq != sys_clock_freq()) {
|
if (freq != sys_clock_freq()) {
|
||||||
DEBUG("In 32-bit mode, the GPTimer frequency must equal the system clock frequency (%u).", sys_clock_freq());
|
DEBUG("In 32-bit mode, the GPTimer frequency must equal the system clock frequency (%u).\n",
|
||||||
|
(unsigned)sys_clock_freq());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -164,14 +164,14 @@ void uart_write(uart_t uart, const uint8_t *data, size_t len)
|
|||||||
{
|
{
|
||||||
DEBUG("writing to serial port ");
|
DEBUG("writing to serial port ");
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
if (ENABLE_DEBUG) {
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
DEBUG("%02x ", (unsigned char) data[i]);
|
DEBUG("%02x ", (unsigned char) data[i]);
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < len; i++) {
|
||||||
|
DEBUG("%c", (char) data[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < len; i++) {
|
|
||||||
DEBUG("%c", (char) data[i]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DEBUG("\n");
|
DEBUG("\n");
|
||||||
|
|
||||||
|
|||||||
@ -70,8 +70,8 @@ int kw2xrf_spi_init(kw2xrf_t *dev)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (res != SPI_OK) {
|
if (res != SPI_OK) {
|
||||||
LOG_ERROR("[kw2xrf_spi] failed to init SPI_%i device (code %i)\n",
|
LOG_ERROR("[kw2xrf_spi] failed to init SPI_%u device (code %i)\n",
|
||||||
SPIDEV, res);
|
(unsigned)SPIDEV, res);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* verify SPI params */
|
/* verify SPI params */
|
||||||
@ -90,8 +90,8 @@ int kw2xrf_spi_init(kw2xrf_t *dev)
|
|||||||
}
|
}
|
||||||
spi_release(SPIDEV);
|
spi_release(SPIDEV);
|
||||||
|
|
||||||
DEBUG("[kw2xrf_spi] SPI_DEV(%i) initialized: mode: %i, clk: %i, cs_pin: %i\n",
|
DEBUG("[kw2xrf_spi] SPI_DEV(%u) initialized: mode: %u, clk: %u, cs_pin: %u\n",
|
||||||
SPIDEV, SPIMODE, SPICLK, CSPIN);
|
(unsigned)SPIDEV, (unsigned)SPIMODE, (unsigned)SPICLK, (unsigned)CSPIN);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -689,16 +689,16 @@ static int xbee_recv(netdev_t *dev, void *buf, size_t len, void *info)
|
|||||||
size = (size_t)(xbee->rx_limit - 1);
|
size = (size_t)(xbee->rx_limit - 1);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
DEBUG("[xbee] recv: reading size and dropping: %i\n", size);
|
DEBUG("[xbee] recv: reading size and dropping: %u\n", (unsigned)size);
|
||||||
xbee->rx_count = 0;
|
xbee->rx_count = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEBUG("[xbee] recv: reading size without dropping: %i\n", size);
|
DEBUG("[xbee] recv: reading size without dropping: %u\n", (unsigned)size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
size = (size > len) ? len : size;
|
size = (size > len) ? len : size;
|
||||||
DEBUG("[xbee] recv: consuming packet: reading %i byte\n", size);
|
DEBUG("[xbee] recv: consuming packet: reading %u byte\n", (unsigned)size);
|
||||||
memcpy(buf, xbee->rx_buf, size);
|
memcpy(buf, xbee->rx_buf, size);
|
||||||
xbee->rx_count = 0;
|
xbee->rx_count = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -222,7 +222,7 @@ static int _mkdir(vfs_mount_t *mountp, const char *name, mode_t mode)
|
|||||||
mutex_lock(&fs->lock);
|
mutex_lock(&fs->lock);
|
||||||
|
|
||||||
DEBUG("littlefs: mkdir: mountp=%p, name=%s, mode=%" PRIu32 "\n",
|
DEBUG("littlefs: mkdir: mountp=%p, name=%s, mode=%" PRIu32 "\n",
|
||||||
(void *)mountp, name, mode);
|
(void *)mountp, name, (uint32_t)mode);
|
||||||
|
|
||||||
int ret = lfs_mkdir(&fs->fs, name);
|
int ret = lfs_mkdir(&fs->fs, name);
|
||||||
mutex_unlock(&fs->lock);
|
mutex_unlock(&fs->lock);
|
||||||
|
|||||||
@ -72,10 +72,10 @@ int conn_can_raw_set_filter(conn_can_raw_t *conn, struct can_filter *filter, siz
|
|||||||
assert(conn != NULL);
|
assert(conn != NULL);
|
||||||
assert(filter != NULL || count == 0);
|
assert(filter != NULL || count == 0);
|
||||||
|
|
||||||
DEBUG("conn_can_raw_set_filter: conn=%p, filter=%p, count=%d\n",
|
DEBUG("conn_can_raw_set_filter: conn=%p, filter=%p, count=%u\n",
|
||||||
(void *)conn, (void *)filter, count);
|
(void *)conn, (void *)filter, (unsigned)count);
|
||||||
DEBUG("conn_can_raw_set_filter: conn->filter=%p, conn->count=%d\n",
|
DEBUG("conn_can_raw_set_filter: conn->filter=%p, conn->count=%u\n",
|
||||||
(void *)conn->filter, conn->count);
|
(void *)conn->filter, (unsigned)conn->count);
|
||||||
|
|
||||||
/* unset previous filters */
|
/* unset previous filters */
|
||||||
if (conn->count) {
|
if (conn->count) {
|
||||||
|
|||||||
@ -509,7 +509,7 @@ static void _isotp_fill_dataframe(struct isotp *isotp, struct can_frame *frame,
|
|||||||
frame->can_id = isotp->opt.tx_id;
|
frame->can_id = isotp->opt.tx_id;
|
||||||
frame->can_dlc = num_bytes + pci_len;
|
frame->can_dlc = num_bytes + pci_len;
|
||||||
|
|
||||||
DEBUG("_isotp_fill_dataframe: num_bytes=%d, pci_len=%d\n", num_bytes, pci_len);
|
DEBUG("_isotp_fill_dataframe: num_bytes=%d, pci_len=%d\n", (unsigned)num_bytes, (unsigned)pci_len);
|
||||||
|
|
||||||
if (num_bytes < space) {
|
if (num_bytes < space) {
|
||||||
if (isotp->opt.flags & CAN_ISOTP_TX_PADDING) {
|
if (isotp->opt.flags & CAN_ISOTP_TX_PADDING) {
|
||||||
|
|||||||
@ -960,7 +960,7 @@ static size_t cbor_stream_decode_at(cbor_stream_t *stream, size_t offset, int in
|
|||||||
offset += inner_read_bytes = cbor_stream_decode_at(stream, offset, indent + 2);
|
offset += inner_read_bytes = cbor_stream_decode_at(stream, offset, indent + 2);
|
||||||
|
|
||||||
if (inner_read_bytes == 0) {
|
if (inner_read_bytes == 0) {
|
||||||
DEBUG("Failed to read array item at position %d\n", i);
|
DEBUG("Failed to read array item at position %u\n", (unsigned)i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -994,7 +994,7 @@ static size_t cbor_stream_decode_at(cbor_stream_t *stream, size_t offset, int in
|
|||||||
offset += value_read_bytes = cbor_stream_decode_at(stream, offset, indent + 2); /* value */
|
offset += value_read_bytes = cbor_stream_decode_at(stream, offset, indent + 2); /* value */
|
||||||
|
|
||||||
if (key_read_bytes == 0 || value_read_bytes == 0) {
|
if (key_read_bytes == 0 || value_read_bytes == 0) {
|
||||||
DEBUG("Failed to read key-value pair at position %d\n", i);
|
DEBUG("Failed to read key-value pair at position %u\n", (unsigned)i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1073,7 +1073,7 @@ void cbor_stream_decode(cbor_stream_t *stream)
|
|||||||
size_t read_bytes = cbor_stream_decode_at(stream, offset, 0);
|
size_t read_bytes = cbor_stream_decode_at(stream, offset, 0);
|
||||||
|
|
||||||
if (read_bytes == 0) {
|
if (read_bytes == 0) {
|
||||||
DEBUG("Failed to read from stream at offset %d, start byte 0x%02X\n", offset, stream->data[offset]);
|
DEBUG("Failed to read from stream at offset %u, start byte 0x%02X\n", (unsigned)offset, stream->data[offset]);
|
||||||
cbor_stream_print(stream);
|
cbor_stream_print(stream);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -241,7 +241,7 @@ static ssize_t constfs_read(vfs_file_t *filp, void *dest, size_t nbytes)
|
|||||||
nbytes = fp->size - filp->pos;
|
nbytes = fp->size - filp->pos;
|
||||||
}
|
}
|
||||||
memcpy(dest, fp->data + filp->pos, nbytes);
|
memcpy(dest, fp->data + filp->pos, nbytes);
|
||||||
DEBUG("constfs_read: read %d bytes\n", nbytes);
|
DEBUG("constfs_read: read %lu bytes\n", (long unsigned)nbytes);
|
||||||
filp->pos += nbytes;
|
filp->pos += nbytes;
|
||||||
return nbytes;
|
return nbytes;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -131,7 +131,7 @@ static void _listen(sock_udp_t *sock)
|
|||||||
|
|
||||||
res = coap_parse(&pdu, buf, res);
|
res = coap_parse(&pdu, buf, res);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
DEBUG("gcoap: parse failure: %d\n", res);
|
DEBUG("gcoap: parse failure: %d\n", (int)res);
|
||||||
/* If a response, can't clear memo, but it will timeout later. */
|
/* If a response, can't clear memo, but it will timeout later. */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -723,7 +723,7 @@ size_t gcoap_req_send2(const uint8_t *buf, size_t len,
|
|||||||
}
|
}
|
||||||
else if (!res) {
|
else if (!res) {
|
||||||
memo->state = GCOAP_MEMO_UNUSED;
|
memo->state = GCOAP_MEMO_UNUSED;
|
||||||
DEBUG("gcoap: sock send failed: %d\n", res);
|
DEBUG("gcoap: sock send failed: %d\n", (int)res);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -229,7 +229,7 @@ bool gnrc_mac_queue_rx_packet(gnrc_mac_rx_t *rx, uint32_t priority, gnrc_pktsnip
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG("[gnrc_mac] Can't push RX packet @ %p, no entries left\n", pkt);
|
DEBUG("[gnrc_mac] Can't push RX packet @ %p, no entries left\n", (void*)pkt);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif /* GNRC_MAC_RX_QUEUE_SIZE != 0 */
|
#endif /* GNRC_MAC_RX_QUEUE_SIZE != 0 */
|
||||||
@ -268,7 +268,7 @@ void gnrc_mac_dispatch(gnrc_mac_rx_t *rx)
|
|||||||
if (!gnrc_netapi_dispatch_receive(rx->dispatch_buffer[i]->type,
|
if (!gnrc_netapi_dispatch_receive(rx->dispatch_buffer[i]->type,
|
||||||
GNRC_NETREG_DEMUX_CTX_ALL,
|
GNRC_NETREG_DEMUX_CTX_ALL,
|
||||||
rx->dispatch_buffer[i])) {
|
rx->dispatch_buffer[i])) {
|
||||||
DEBUG("Unable to forward packet of type %i\n", buffer[i]->type);
|
DEBUG("Unable to forward packet of type %i\n", rx->dispatch_buffer[i]->type);
|
||||||
gnrc_pktbuf_release(rx->dispatch_buffer[i]);
|
gnrc_pktbuf_release(rx->dispatch_buffer[i]);
|
||||||
}
|
}
|
||||||
rx->dispatch_buffer[i] = NULL;
|
rx->dispatch_buffer[i] = NULL;
|
||||||
|
|||||||
@ -26,8 +26,7 @@
|
|||||||
#define ENABLE_DEBUG (0)
|
#define ENABLE_DEBUG (0)
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
static const char *lwmac_timeout_names[] = {
|
||||||
char *lwmac_timeout_names[] = {
|
|
||||||
[GNRC_LWMAC_TIMEOUT_DISABLED] = "DISABLED",
|
[GNRC_LWMAC_TIMEOUT_DISABLED] = "DISABLED",
|
||||||
[GNRC_LWMAC_TIMEOUT_WR] = "WR",
|
[GNRC_LWMAC_TIMEOUT_WR] = "WR",
|
||||||
[GNRC_LWMAC_TIMEOUT_NO_RESPONSE] = "NO_RESPONSE",
|
[GNRC_LWMAC_TIMEOUT_NO_RESPONSE] = "NO_RESPONSE",
|
||||||
@ -35,7 +34,6 @@ char *lwmac_timeout_names[] = {
|
|||||||
[GNRC_LWMAC_TIMEOUT_WAIT_DEST_WAKEUP] = "WAIT_FOR_DEST_WAKEUP",
|
[GNRC_LWMAC_TIMEOUT_WAIT_DEST_WAKEUP] = "WAIT_FOR_DEST_WAKEUP",
|
||||||
[GNRC_LWMAC_TIMEOUT_WAKEUP_PERIOD] = "WAKEUP_PERIOD",
|
[GNRC_LWMAC_TIMEOUT_WAKEUP_PERIOD] = "WAKEUP_PERIOD",
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline void _lwmac_clear_timeout(gnrc_lwmac_timeout_t *timeout)
|
static inline void _lwmac_clear_timeout(gnrc_lwmac_timeout_t *timeout)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -85,7 +85,7 @@ static inline int _snd_rcv_mbox(mbox_t *mbox, uint16_t type, gnrc_pktsnip_t *pkt
|
|||||||
/* send message */
|
/* send message */
|
||||||
int ret = mbox_try_put(mbox, &msg);
|
int ret = mbox_try_put(mbox, &msg);
|
||||||
if (ret < 1) {
|
if (ret < 1) {
|
||||||
DEBUG("gnrc_netapi: dropped message to %p (was full)\n", mbox);
|
DEBUG("gnrc_netapi: dropped message to %p (was full)\n", (void*)mbox);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,10 +34,6 @@
|
|||||||
#define ENABLE_DEBUG (0)
|
#define ENABLE_DEBUG (0)
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
|
||||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define _NETIF_NETAPI_MSG_QUEUE_SIZE (8)
|
#define _NETIF_NETAPI_MSG_QUEUE_SIZE (8)
|
||||||
|
|
||||||
static gnrc_netif_t _netifs[GNRC_NETIF_NUMOF];
|
static gnrc_netif_t _netifs[GNRC_NETIF_NUMOF];
|
||||||
@ -454,6 +450,8 @@ void gnrc_netif_release(gnrc_netif_t *netif)
|
|||||||
static inline bool _addr_anycast(const gnrc_netif_t *netif, unsigned idx);
|
static inline bool _addr_anycast(const gnrc_netif_t *netif, unsigned idx);
|
||||||
static int _addr_idx(const gnrc_netif_t *netif, const ipv6_addr_t *addr);
|
static int _addr_idx(const gnrc_netif_t *netif, const ipv6_addr_t *addr);
|
||||||
|
|
||||||
|
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Matches an address by prefix to an address on the interface
|
* @brief Matches an address by prefix to an address on the interface
|
||||||
*
|
*
|
||||||
@ -568,15 +566,11 @@ int gnrc_netif_ipv6_addr_add_internal(gnrc_netif_t *netif,
|
|||||||
* for SLAAC */
|
* for SLAAC */
|
||||||
ipv6_addr_set_solicited_nodes(&sol_nodes, addr);
|
ipv6_addr_set_solicited_nodes(&sol_nodes, addr);
|
||||||
res = gnrc_netif_ipv6_group_join_internal(netif, &sol_nodes);
|
res = gnrc_netif_ipv6_group_join_internal(netif, &sol_nodes);
|
||||||
#if ENABLE_DEBUG
|
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
DEBUG("nib: Can't join solicited-nodes of %s on interface %u\n",
|
DEBUG("nib: Can't join solicited-nodes of %s on interface %u\n",
|
||||||
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
|
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
|
||||||
netif->pid);
|
netif->pid);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
(void)res;
|
|
||||||
#endif
|
|
||||||
#endif /* GNRC_IPV6_NIB_CONF_ARSM */
|
#endif /* GNRC_IPV6_NIB_CONF_ARSM */
|
||||||
if (_get_state(netif, idx) == GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID) {
|
if (_get_state(netif, idx) == GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID) {
|
||||||
void *state = NULL;
|
void *state = NULL;
|
||||||
@ -880,7 +874,6 @@ static unsigned _match(const gnrc_netif_t *netif, const ipv6_addr_t *addr,
|
|||||||
best_match = match;
|
best_match = match;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if ENABLE_DEBUG
|
|
||||||
if (*idx >= 0) {
|
if (*idx >= 0) {
|
||||||
DEBUG("gnrc_netif: Found %s on interface %" PRIkernel_pid " matching ",
|
DEBUG("gnrc_netif: Found %s on interface %" PRIkernel_pid " matching ",
|
||||||
ipv6_addr_to_str(addr_str, &netif->ipv6.addrs[*idx],
|
ipv6_addr_to_str(addr_str, &netif->ipv6.addrs[*idx],
|
||||||
@ -898,7 +891,6 @@ static unsigned _match(const gnrc_netif_t *netif, const ipv6_addr_t *addr,
|
|||||||
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
|
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
|
||||||
(filter != NULL) ? "true" : "false");
|
(filter != NULL) ? "true" : "false");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return best_match;
|
return best_match;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1249,12 +1241,10 @@ static void *_gnrc_netif_thread(void *args)
|
|||||||
case GNRC_NETAPI_MSG_TYPE_SND:
|
case GNRC_NETAPI_MSG_TYPE_SND:
|
||||||
DEBUG("gnrc_netif: GNRC_NETDEV_MSG_TYPE_SND received\n");
|
DEBUG("gnrc_netif: GNRC_NETDEV_MSG_TYPE_SND received\n");
|
||||||
res = netif->ops->send(netif, msg.content.ptr);
|
res = netif->ops->send(netif, msg.content.ptr);
|
||||||
#if ENABLE_DEBUG
|
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
DEBUG("gnrc_netif: error sending packet %p (code: %u)\n",
|
DEBUG("gnrc_netif: error sending packet %p (code: %u)\n",
|
||||||
msg.content.ptr, res);
|
msg.content.ptr, res);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case GNRC_NETAPI_MSG_TYPE_SET:
|
case GNRC_NETAPI_MSG_TYPE_SET:
|
||||||
opt = msg.content.ptr;
|
opt = msg.content.ptr;
|
||||||
@ -1292,12 +1282,10 @@ static void *_gnrc_netif_thread(void *args)
|
|||||||
"netif->ops->msg_handler()\n", msg.type);
|
"netif->ops->msg_handler()\n", msg.type);
|
||||||
netif->ops->msg_handler(netif, &msg);
|
netif->ops->msg_handler(netif, &msg);
|
||||||
}
|
}
|
||||||
#if ENABLE_DEBUG
|
|
||||||
else {
|
else {
|
||||||
DEBUG("gnrc_netif: unknown message type 0x%04x"
|
DEBUG("gnrc_netif: unknown message type 0x%04x"
|
||||||
"(no message handler defined)\n", msg.type);
|
"(no message handler defined)\n", msg.type);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,9 +59,7 @@ static fib_entry_t _fib_entries[GNRC_IPV6_FIB_TABLE_SIZE];
|
|||||||
fib_table_t gnrc_ipv6_fib_table;
|
fib_table_t gnrc_ipv6_fib_table;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
|
||||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||||
#endif
|
|
||||||
|
|
||||||
kernel_pid_t gnrc_ipv6_pid = KERNEL_PID_UNDEF;
|
kernel_pid_t gnrc_ipv6_pid = KERNEL_PID_UNDEF;
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
#define ENABLE_DEBUG (0)
|
#define ENABLE_DEBUG (0)
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#if ENABLE_DEBUG && defined(MODULE_IPV6_ADDR)
|
#if defined(MODULE_IPV6_ADDR)
|
||||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -24,9 +24,8 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#if GNRC_IPV6_NIB_CONF_6LN
|
#if GNRC_IPV6_NIB_CONF_6LN
|
||||||
#if ENABLE_DEBUG
|
|
||||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||||
#endif
|
|
||||||
|
|
||||||
extern void _handle_search_rtr(gnrc_netif_t *netif);
|
extern void _handle_search_rtr(gnrc_netif_t *netif);
|
||||||
|
|
||||||
|
|||||||
@ -23,9 +23,8 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#if GNRC_IPV6_NIB_CONF_6LR
|
#if GNRC_IPV6_NIB_CONF_6LR
|
||||||
#if ENABLE_DEBUG
|
|
||||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint8_t _update_nce_ar_state(const sixlowpan_nd_opt_ar_t *aro,
|
static uint8_t _update_nce_ar_state(const sixlowpan_nd_opt_ar_t *aro,
|
||||||
_nib_onl_entry_t *nce)
|
_nib_onl_entry_t *nce)
|
||||||
@ -38,12 +37,12 @@ static uint8_t _update_nce_ar_state(const sixlowpan_nd_opt_ar_t *aro,
|
|||||||
_set_ar_state(nce,
|
_set_ar_state(nce,
|
||||||
GNRC_IPV6_NIB_NC_INFO_AR_STATE_REGISTERED);
|
GNRC_IPV6_NIB_NC_INFO_AR_STATE_REGISTERED);
|
||||||
DEBUG("nib: Successfully registered %s\n",
|
DEBUG("nib: Successfully registered %s\n",
|
||||||
ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str)));
|
ipv6_addr_to_str(addr_str, &nce->ipv6, sizeof(addr_str)));
|
||||||
return SIXLOWPAN_ND_STATUS_SUCCESS;
|
return SIXLOWPAN_ND_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEBUG("nib: Could not register %s, neighbor cache was full\n",
|
DEBUG("nib: Could not register %s, neighbor cache was full\n",
|
||||||
ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str)));
|
ipv6_addr_to_str(addr_str, &nce->ipv6, sizeof(addr_str)));
|
||||||
return SIXLOWPAN_ND_STATUS_NC_FULL;
|
return SIXLOWPAN_ND_STATUS_NC_FULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,9 +28,7 @@
|
|||||||
#define ENABLE_DEBUG (0)
|
#define ENABLE_DEBUG (0)
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
|
||||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Determines supposed link-layer address from interface and option
|
* @brief Determines supposed link-layer address from interface and option
|
||||||
|
|||||||
@ -42,9 +42,7 @@ static _nib_dr_entry_t _def_routers[GNRC_IPV6_NIB_DEFAULT_ROUTER_NUMOF];
|
|||||||
static _nib_abr_entry_t _abrs[GNRC_IPV6_NIB_ABR_NUMOF];
|
static _nib_abr_entry_t _abrs[GNRC_IPV6_NIB_ABR_NUMOF];
|
||||||
#endif /* GNRC_IPV6_NIB_CONF_MULTIHOP_P6C */
|
#endif /* GNRC_IPV6_NIB_CONF_MULTIHOP_P6C */
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
|
||||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||||
#endif
|
|
||||||
|
|
||||||
mutex_t _nib_mutex = MUTEX_INIT;
|
mutex_t _nib_mutex = MUTEX_INIT;
|
||||||
evtimer_msg_t _nib_evtimer;
|
evtimer_msg_t _nib_evtimer;
|
||||||
|
|||||||
@ -27,9 +27,7 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#if GNRC_IPV6_NIB_CONF_ROUTER
|
#if GNRC_IPV6_NIB_CONF_ROUTER
|
||||||
#if ENABLE_DEBUG
|
|
||||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||||
#endif
|
|
||||||
|
|
||||||
static void _snd_ra(gnrc_netif_t *netif, const ipv6_addr_t *dst,
|
static void _snd_ra(gnrc_netif_t *netif, const ipv6_addr_t *dst,
|
||||||
bool final, _nib_abr_entry_t *abr);
|
bool final, _nib_abr_entry_t *abr);
|
||||||
|
|||||||
@ -39,9 +39,7 @@
|
|||||||
#include "xtimer.h"
|
#include "xtimer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
|
||||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||||
#endif
|
|
||||||
|
|
||||||
#if GNRC_IPV6_NIB_CONF_QUEUE_PKT
|
#if GNRC_IPV6_NIB_CONF_QUEUE_PKT
|
||||||
static gnrc_pktqueue_t _queue_pool[GNRC_IPV6_NIB_NUMOF];
|
static gnrc_pktqueue_t _queue_pool[GNRC_IPV6_NIB_NUMOF];
|
||||||
@ -418,8 +416,8 @@ static void _handle_rtr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
|
|||||||
netif->pid);
|
netif->pid);
|
||||||
DEBUG(" - IP Hop Limit: %u (should be 255)\n", ipv6->hl);
|
DEBUG(" - IP Hop Limit: %u (should be 255)\n", ipv6->hl);
|
||||||
DEBUG(" - ICMP code: %u (should be 0)\n", rtr_sol->code);
|
DEBUG(" - ICMP code: %u (should be 0)\n", rtr_sol->code);
|
||||||
DEBUG(" - ICMP length: %u (should > %u)\n", icmpv6_len,
|
DEBUG(" - ICMP length: %u (should > %u)\n", (unsigned)icmpv6_len,
|
||||||
sizeof(ndp_rtr_sol_t));
|
(unsigned)sizeof(ndp_rtr_sol_t));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* pre-check option length */
|
/* pre-check option length */
|
||||||
@ -529,7 +527,7 @@ static void _handle_rtr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
|
|||||||
DEBUG(" - IP Hop Limit: %u (should be 255)\n", ipv6->hl);
|
DEBUG(" - IP Hop Limit: %u (should be 255)\n", ipv6->hl);
|
||||||
DEBUG(" - ICMP code: %u (should be 0)\n", rtr_adv->code);
|
DEBUG(" - ICMP code: %u (should be 0)\n", rtr_adv->code);
|
||||||
DEBUG(" - ICMP length: %u (should > %u)\n", (unsigned)icmpv6_len,
|
DEBUG(" - ICMP length: %u (should > %u)\n", (unsigned)icmpv6_len,
|
||||||
sizeof(ndp_rtr_adv_t));
|
(unsigned)sizeof(ndp_rtr_adv_t));
|
||||||
DEBUG(" - Source address: %s (should be link-local)\n",
|
DEBUG(" - Source address: %s (should be link-local)\n",
|
||||||
ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str)));
|
ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str)));
|
||||||
DEBUG(" - Router lifetime: %u (should be <= 9000 on non-6LN)\n",
|
DEBUG(" - Router lifetime: %u (should be <= 9000 on non-6LN)\n",
|
||||||
@ -793,8 +791,8 @@ static void _handle_nbr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
|
|||||||
DEBUG("nib: Received neighbor solicitation is invalid. Discarding silently\n");
|
DEBUG("nib: Received neighbor solicitation is invalid. Discarding silently\n");
|
||||||
DEBUG(" - IP Hop Limit: %u (should be 255)\n", ipv6->hl);
|
DEBUG(" - IP Hop Limit: %u (should be 255)\n", ipv6->hl);
|
||||||
DEBUG(" - ICMP code: %u (should be 0)\n", nbr_sol->code);
|
DEBUG(" - ICMP code: %u (should be 0)\n", nbr_sol->code);
|
||||||
DEBUG(" - ICMP length: %u (should > %u)\n", icmpv6_len,
|
DEBUG(" - ICMP length: %u (should > %u)\n", (unsigned)icmpv6_len,
|
||||||
sizeof(ndp_nbr_sol_t));
|
(unsigned)sizeof(ndp_nbr_sol_t));
|
||||||
DEBUG(" - Target address: %s (should not be multicast)\n",
|
DEBUG(" - Target address: %s (should not be multicast)\n",
|
||||||
ipv6_addr_to_str(addr_str, &nbr_sol->tgt, sizeof(addr_str)));
|
ipv6_addr_to_str(addr_str, &nbr_sol->tgt, sizeof(addr_str)));
|
||||||
DEBUG(" - Source address: %s\n",
|
DEBUG(" - Source address: %s\n",
|
||||||
@ -905,8 +903,8 @@ static void _handle_nbr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
|
|||||||
DEBUG("nib: Received neighbor advertisement is invalid. Discarding silently\n");
|
DEBUG("nib: Received neighbor advertisement is invalid. Discarding silently\n");
|
||||||
DEBUG(" - IP Hop Limit: %u (should be 255)\n", ipv6->hl);
|
DEBUG(" - IP Hop Limit: %u (should be 255)\n", ipv6->hl);
|
||||||
DEBUG(" - ICMP code: %u (should be 0)\n", nbr_adv->code);
|
DEBUG(" - ICMP code: %u (should be 0)\n", nbr_adv->code);
|
||||||
DEBUG(" - ICMP length: %u (should > %u)\n", icmpv6_len,
|
DEBUG(" - ICMP length: %u (should > %u)\n", (unsigned)icmpv6_len,
|
||||||
sizeof(ndp_nbr_adv_t));
|
(unsigned)sizeof(ndp_nbr_adv_t));
|
||||||
DEBUG(" - Target address: %s (should not be multicast)\n",
|
DEBUG(" - Target address: %s (should not be multicast)\n",
|
||||||
ipv6_addr_to_str(addr_str, &nbr_adv->tgt, sizeof(addr_str)));
|
ipv6_addr_to_str(addr_str, &nbr_adv->tgt, sizeof(addr_str)));
|
||||||
DEBUG(" - Destination address: %s\n",
|
DEBUG(" - Destination address: %s\n",
|
||||||
|
|||||||
@ -24,9 +24,7 @@
|
|||||||
ipv6_addr_t gnrc_ipv6_whitelist[GNRC_IPV6_WHITELIST_SIZE];
|
ipv6_addr_t gnrc_ipv6_whitelist[GNRC_IPV6_WHITELIST_SIZE];
|
||||||
BITFIELD(gnrc_ipv6_whitelist_set, GNRC_IPV6_WHITELIST_SIZE);
|
BITFIELD(gnrc_ipv6_whitelist_set, GNRC_IPV6_WHITELIST_SIZE);
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
|
||||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||||
#endif
|
|
||||||
|
|
||||||
int gnrc_ipv6_whitelist_add(const ipv6_addr_t *addr)
|
int gnrc_ipv6_whitelist_add(const ipv6_addr_t *addr)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -26,9 +26,10 @@
|
|||||||
#define ENABLE_DEBUG (0)
|
#define ENABLE_DEBUG (0)
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
/* For PRIu8 etc. */
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||||
#endif
|
|
||||||
|
|
||||||
gnrc_pktsnip_t *gnrc_ndp_nbr_sol_build(const ipv6_addr_t *tgt,
|
gnrc_pktsnip_t *gnrc_ndp_nbr_sol_build(const ipv6_addr_t *tgt,
|
||||||
gnrc_pktsnip_t *options)
|
gnrc_pktsnip_t *options)
|
||||||
|
|||||||
@ -29,9 +29,7 @@ static mutex_t _ctx_mutex = MUTEX_INIT;
|
|||||||
static uint32_t _current_minute(void);
|
static uint32_t _current_minute(void);
|
||||||
static void _update_lifetime(uint8_t id);
|
static void _update_lifetime(uint8_t id);
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
|
||||||
static char ipv6str[IPV6_ADDR_MAX_STR_LEN];
|
static char ipv6str[IPV6_ADDR_MAX_STR_LEN];
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline bool _valid(uint8_t id)
|
static inline bool _valid(uint8_t id)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -225,7 +225,7 @@ void gnrc_sixlowpan_frag_send(gnrc_sixlowpan_msg_frag_t *fragment_msg)
|
|||||||
size_t payload_len = gnrc_pkt_len(fragment_msg->pkt->next);
|
size_t payload_len = gnrc_pkt_len(fragment_msg->pkt->next);
|
||||||
msg_t msg;
|
msg_t msg;
|
||||||
|
|
||||||
#if defined(DEVELHELP) && defined(ENABLE_DEBUG)
|
#if defined(DEVELHELP) && ENABLE_DEBUG
|
||||||
if (iface == NULL) {
|
if (iface == NULL) {
|
||||||
DEBUG("6lo frag: iface == NULL, expect segmentation fault.\n");
|
DEBUG("6lo frag: iface == NULL, expect segmentation fault.\n");
|
||||||
/* remove original packet from packet buffer */
|
/* remove original packet from packet buffer */
|
||||||
|
|||||||
@ -46,9 +46,7 @@ static rbuf_int_t rbuf_int[RBUF_INT_SIZE];
|
|||||||
|
|
||||||
static rbuf_t rbuf[RBUF_SIZE];
|
static rbuf_t rbuf[RBUF_SIZE];
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
|
||||||
static char l2addr_str[3 * RBUF_L2ADDR_MAX_LEN];
|
static char l2addr_str[3 * RBUF_L2ADDR_MAX_LEN];
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ------------------------------------
|
/* ------------------------------------
|
||||||
* internal function definitions
|
* internal function definitions
|
||||||
|
|||||||
@ -279,7 +279,7 @@ static void _send(gnrc_pktsnip_t *pkt)
|
|||||||
}
|
}
|
||||||
else if (datagram_size <= SIXLOWPAN_FRAG_MAX_LEN) {
|
else if (datagram_size <= SIXLOWPAN_FRAG_MAX_LEN) {
|
||||||
DEBUG("6lo: Send fragmented (%u > %" PRIu16 ")\n",
|
DEBUG("6lo: Send fragmented (%u > %" PRIu16 ")\n",
|
||||||
(unsigned int)datagram_size, iface->max_frag_size);
|
(unsigned int)datagram_size, iface->sixlo.max_frag_size);
|
||||||
msg_t msg;
|
msg_t msg;
|
||||||
|
|
||||||
fragment_msg.pid = hdr->if_pid;
|
fragment_msg.pid = hdr->if_pid;
|
||||||
@ -302,7 +302,7 @@ static void _send(gnrc_pktsnip_t *pkt)
|
|||||||
#else
|
#else
|
||||||
(void) datagram_size;
|
(void) datagram_size;
|
||||||
DEBUG("6lo: packet too big (%u > %" PRIu16 ")\n",
|
DEBUG("6lo: packet too big (%u > %" PRIu16 ")\n",
|
||||||
(unsigned int)datagram_size, iface->max_frag_size);
|
(unsigned int)datagram_size, iface->sixlo.max_frag_size);
|
||||||
gnrc_pktbuf_release(pkt2);
|
gnrc_pktbuf_release(pkt2);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,9 +42,7 @@
|
|||||||
#define ENABLE_DEBUG (0)
|
#define ENABLE_DEBUG (0)
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
|
||||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||||
#endif
|
|
||||||
|
|
||||||
#define GNRC_RPL_GROUNDED_SHIFT (7)
|
#define GNRC_RPL_GROUNDED_SHIFT (7)
|
||||||
#define GNRC_RPL_MOP_SHIFT (3)
|
#define GNRC_RPL_MOP_SHIFT (3)
|
||||||
@ -465,8 +463,8 @@ bool _parse_options(int msg_type, gnrc_rpl_instance_t *inst, gnrc_rpl_opt_t *opt
|
|||||||
first_target = target;
|
first_target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG("RPL: adding FT entry %s/%d 0x%" PRIx32 "\n",
|
DEBUG("RPL: adding FT entry %s/%d\n",
|
||||||
ipv6_addr_to_str(addr_str, &(target->target), sizeof(addr_str)),
|
ipv6_addr_to_str(addr_str, &(target->target), (unsigned)sizeof(addr_str)),
|
||||||
target->prefix_length);
|
target->prefix_length);
|
||||||
|
|
||||||
gnrc_ipv6_nib_ft_add(&(target->target), target->prefix_length, src,
|
gnrc_ipv6_nib_ft_add(&(target->target), target->prefix_length, src,
|
||||||
|
|||||||
@ -32,9 +32,7 @@
|
|||||||
#define ENABLE_DEBUG (0)
|
#define ENABLE_DEBUG (0)
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
|
||||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||||
#endif
|
|
||||||
|
|
||||||
static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *dodag);
|
static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *dodag);
|
||||||
|
|
||||||
|
|||||||
@ -20,9 +20,7 @@
|
|||||||
#define ENABLE_DEBUG (0)
|
#define ENABLE_DEBUG (0)
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#if ENABLE_DEBUG
|
|
||||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||||
#endif
|
|
||||||
|
|
||||||
#define GNRC_RPL_SRH_PADDING(X) ((X & 0xF0) >> 4)
|
#define GNRC_RPL_SRH_PADDING(X) ((X & 0xF0) >> 4)
|
||||||
#define GNRC_RPL_SRH_COMPRE(X) (X & 0x0F)
|
#define GNRC_RPL_SRH_COMPRE(X) (X & 0x0F)
|
||||||
|
|||||||
@ -56,7 +56,7 @@ int pthread_barrier_wait(pthread_barrier_t *barrier)
|
|||||||
|
|
||||||
mutex_lock(&barrier->mutex);
|
mutex_lock(&barrier->mutex);
|
||||||
DEBUG("%s: hit a synchronization barrier. pid=%" PRIkernel_pid"\n",
|
DEBUG("%s: hit a synchronization barrier. pid=%" PRIkernel_pid"\n",
|
||||||
sched_active_thread->name, sched_active_pid);
|
thread_getname(sched_active_pid), sched_active_pid);
|
||||||
|
|
||||||
int switch_prio = -1;
|
int switch_prio = -1;
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ int pthread_barrier_wait(pthread_barrier_t *barrier)
|
|||||||
/* need to wait for further threads */
|
/* need to wait for further threads */
|
||||||
|
|
||||||
DEBUG("%s: waiting for %u threads. pid=%" PRIkernel_pid "\n",
|
DEBUG("%s: waiting for %u threads. pid=%" PRIkernel_pid "\n",
|
||||||
sched_active_thread->name, barrier->count, sched_active_pid);
|
thread_getname(sched_active_pid), barrier->count, sched_active_pid);
|
||||||
|
|
||||||
pthread_barrier_waiting_node_t node;
|
pthread_barrier_waiting_node_t node;
|
||||||
node.pid = sched_active_pid;
|
node.pid = sched_active_pid;
|
||||||
@ -90,7 +90,7 @@ int pthread_barrier_wait(pthread_barrier_t *barrier)
|
|||||||
/* all threads have arrived, wake everybody up */
|
/* all threads have arrived, wake everybody up */
|
||||||
|
|
||||||
DEBUG("%s: waking every other thread up. pid=%" PRIkernel_pid "\n",
|
DEBUG("%s: waking every other thread up. pid=%" PRIkernel_pid "\n",
|
||||||
sched_active_thread->name, sched_active_pid);
|
thread_getname(sched_active_pid), sched_active_pid);
|
||||||
|
|
||||||
int count = 1; /* Count number of woken up threads.
|
int count = 1; /* Count number of woken up threads.
|
||||||
* The first thread is the current thread. */
|
* The first thread is the current thread. */
|
||||||
|
|||||||
@ -28,12 +28,14 @@
|
|||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "pthread.h"
|
#include "pthread.h"
|
||||||
#include "sched.h"
|
#include "sched.h"
|
||||||
#include "xtimer.h"
|
#include "xtimer.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include "thread.h"
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define ENABLE_DEBUG (0)
|
#define ENABLE_DEBUG (0)
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
@ -43,7 +45,7 @@ int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *at
|
|||||||
(void) attr;
|
(void) attr;
|
||||||
|
|
||||||
if (rwlock == NULL) {
|
if (rwlock == NULL) {
|
||||||
DEBUG("Thread %" PRIkernel_pid " pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_pid, "init");
|
DEBUG("Thread %" PRIkernel_pid " pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_getpid(), "init");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +56,7 @@ int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *at
|
|||||||
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
|
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
|
||||||
{
|
{
|
||||||
if (rwlock == NULL) {
|
if (rwlock == NULL) {
|
||||||
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_pid, "destroy");
|
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_getpid(), "destroy");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,19 +107,19 @@ static int pthread_rwlock_lock(pthread_rwlock_t *rwlock,
|
|||||||
{
|
{
|
||||||
if (rwlock == NULL) {
|
if (rwlock == NULL) {
|
||||||
DEBUG("Thread %" PRIkernel_pid": pthread_rwlock_%s(): is_writer=%u, allow_spurious=%u %s\n",
|
DEBUG("Thread %" PRIkernel_pid": pthread_rwlock_%s(): is_writer=%u, allow_spurious=%u %s\n",
|
||||||
thread_pid, "lock", is_writer, allow_spurious, "rwlock=NULL");
|
thread_getpid(), "lock", is_writer, allow_spurious, "rwlock=NULL");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&rwlock->mutex);
|
mutex_lock(&rwlock->mutex);
|
||||||
if (!is_blocked(rwlock)) {
|
if (!is_blocked(rwlock)) {
|
||||||
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): is_writer=%u, allow_spurious=%u %s\n",
|
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): is_writer=%u, allow_spurious=%u %s\n",
|
||||||
thread_pid, "lock", is_writer, allow_spurious, "is open");
|
thread_getpid(), "lock", is_writer, allow_spurious, "is open");
|
||||||
rwlock->readers += incr_when_held;
|
rwlock->readers += incr_when_held;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): is_writer=%u, allow_spurious=%u %s\n",
|
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): is_writer=%u, allow_spurious=%u %s\n",
|
||||||
thread_pid, "lock", is_writer, allow_spurious, "is locked");
|
thread_getpid(), "lock", is_writer, allow_spurious, "is locked");
|
||||||
|
|
||||||
/* queue for the lock */
|
/* queue for the lock */
|
||||||
__pthread_rwlock_waiter_node_t waiting_node = {
|
__pthread_rwlock_waiter_node_t waiting_node = {
|
||||||
@ -140,12 +142,12 @@ static int pthread_rwlock_lock(pthread_rwlock_t *rwlock,
|
|||||||
if (waiting_node.continue_) {
|
if (waiting_node.continue_) {
|
||||||
/* pthread_rwlock_unlock() already set rwlock->readers */
|
/* pthread_rwlock_unlock() already set rwlock->readers */
|
||||||
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): is_writer=%u, allow_spurious=%u %s\n",
|
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): is_writer=%u, allow_spurious=%u %s\n",
|
||||||
thread_pid, "lock", is_writer, allow_spurious, "continued");
|
thread_getpid(), "lock", is_writer, allow_spurious, "continued");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (allow_spurious) {
|
else if (allow_spurious) {
|
||||||
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): is_writer=%u, allow_spurious=%u %s\n",
|
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): is_writer=%u, allow_spurious=%u %s\n",
|
||||||
thread_pid, "lock", is_writer, allow_spurious, "is timed out");
|
thread_getpid(), "lock", is_writer, allow_spurious, "is timed out");
|
||||||
priority_queue_remove(&rwlock->queue, &waiting_node.qnode);
|
priority_queue_remove(&rwlock->queue, &waiting_node.qnode);
|
||||||
mutex_unlock(&rwlock->mutex);
|
mutex_unlock(&rwlock->mutex);
|
||||||
return ETIMEDOUT;
|
return ETIMEDOUT;
|
||||||
@ -162,7 +164,7 @@ static int pthread_rwlock_trylock(pthread_rwlock_t *rwlock,
|
|||||||
int incr_when_held)
|
int incr_when_held)
|
||||||
{
|
{
|
||||||
if (rwlock == NULL) {
|
if (rwlock == NULL) {
|
||||||
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_pid, "trylock");
|
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_getpid(), "trylock");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
else if (mutex_trylock(&rwlock->mutex) == 0) {
|
else if (mutex_trylock(&rwlock->mutex) == 0) {
|
||||||
@ -237,30 +239,30 @@ int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *
|
|||||||
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
|
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
|
||||||
{
|
{
|
||||||
if (rwlock == NULL) {
|
if (rwlock == NULL) {
|
||||||
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_pid, "unlock");
|
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_getpid(), "unlock");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&rwlock->mutex);
|
mutex_lock(&rwlock->mutex);
|
||||||
if (rwlock->readers == 0) {
|
if (rwlock->readers == 0) {
|
||||||
/* the lock is open */
|
/* the lock is open */
|
||||||
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): lock is open\n", thread_pid, "unlock");
|
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): lock is open\n", thread_getpid(), "unlock");
|
||||||
mutex_unlock(&rwlock->mutex);
|
mutex_unlock(&rwlock->mutex);
|
||||||
return EPERM;
|
return EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rwlock->readers > 0) {
|
if (rwlock->readers > 0) {
|
||||||
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): release %s lock\n", thread_pid, "unlock", "read");
|
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): release %s lock\n", thread_getpid(), "unlock", "read");
|
||||||
--rwlock->readers;
|
--rwlock->readers;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): release %s lock\n", thread_pid, "unlock", "write");
|
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): release %s lock\n", thread_getpid(), "unlock", "write");
|
||||||
rwlock->readers = 0;
|
rwlock->readers = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rwlock->readers != 0 || rwlock->queue.first == NULL) {
|
if (rwlock->readers != 0 || rwlock->queue.first == NULL) {
|
||||||
/* this thread was not the last reader, or no one is waiting to aquire the lock */
|
/* this thread was not the last reader, or no one is waiting to aquire the lock */
|
||||||
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): no one is waiting\n", thread_pid, "unlock");
|
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): no one is waiting\n", thread_getpid(), "unlock");
|
||||||
mutex_unlock(&rwlock->mutex);
|
mutex_unlock(&rwlock->mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -274,12 +276,12 @@ int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
|
|||||||
|
|
||||||
if (waiting_node->is_writer) {
|
if (waiting_node->is_writer) {
|
||||||
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): continue %s %" PRIkernel_pid "\n",
|
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): continue %s %" PRIkernel_pid "\n",
|
||||||
thread_pid, "unlock", "writer", waiting_node->thread->pid);
|
thread_getpid(), "unlock", "writer", waiting_node->thread->pid);
|
||||||
--rwlock->readers;
|
--rwlock->readers;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): continue %s %" PRIkernel_pid "\n",
|
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): continue %s %" PRIkernel_pid "\n",
|
||||||
thread_pid, "unlock", "reader", waiting_node->thread->pid);
|
thread_getpid(), "unlock", "reader", waiting_node->thread->pid);
|
||||||
++rwlock->readers;
|
++rwlock->readers;
|
||||||
|
|
||||||
/* wake up further readers */
|
/* wake up further readers */
|
||||||
@ -288,12 +290,12 @@ int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
|
|||||||
if (waiting_node->is_writer) {
|
if (waiting_node->is_writer) {
|
||||||
/* Not to be unfair to writers, we don't try to wake up readers that came after the first writer. */
|
/* Not to be unfair to writers, we don't try to wake up readers that came after the first writer. */
|
||||||
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): continuing readers blocked by writer %" PRIkernel_pid "\n",
|
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): continuing readers blocked by writer %" PRIkernel_pid "\n",
|
||||||
thread_pid, "unlock", waiting_node->thread->pid);
|
thread_getpid(), "unlock", waiting_node->thread->pid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
waiting_node->continue_ = true;
|
waiting_node->continue_ = true;
|
||||||
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): continue %s %" PRIkernel_pid "\n",
|
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): continue %s %" PRIkernel_pid "\n",
|
||||||
thread_pid, "unlock", "reader", waiting_node->thread->pid);
|
thread_getpid(), "unlock", "reader", waiting_node->thread->pid);
|
||||||
|
|
||||||
/* wake up this reader */
|
/* wake up this reader */
|
||||||
qnode = priority_queue_remove_head(&rwlock->queue);
|
qnode = priority_queue_remove_head(&rwlock->queue);
|
||||||
|
|||||||
@ -736,7 +736,7 @@ int vfs_normalize_path(char *buf, const char *path, size_t buflen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while(path <= path_end) {
|
while(path <= path_end) {
|
||||||
DEBUG("vfs_normalize_path: + %d \"%.*s\" <- \"%s\" (%p)\n", npathcomp, len, buf, path, path);
|
DEBUG("vfs_normalize_path: + %d \"%.*s\" <- \"%s\" (%p)\n", npathcomp, (int)len, buf, path, path);
|
||||||
if (path[0] == '\0') {
|
if (path[0] == '\0') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user