mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests: 64 bit compatibility
Fixed compilation errors. Mostly DEBUG/printf formatting and void pointer casting. Other changes are: * net/gnrc_sixlowpan_frag_*: Generalized packet size calculation * cpu/native_backtrace: Reduced required backtrace size to 3 for 64-bit * periph/flashpage: Simplified test * unittests/tests-pktbuf: Generalized alignment * sys/architecture: Extended test for 64-bit
This commit is contained in:
parent
55cbb7bdfa
commit
7a1c099e7b
@ -35,9 +35,9 @@ int main(void)
|
||||
msg_init_queue(msg_queue, QUEUE_SIZE);
|
||||
msg_queue_print();
|
||||
|
||||
for (int i = 0; i < QUEUE_SIZE; i++) {
|
||||
for (uintptr_t i = 0; i < QUEUE_SIZE; i++) {
|
||||
messages[i].type = i;
|
||||
messages[i].content.value = i;
|
||||
messages[i].content.ptr = (void *) i;
|
||||
msg_send_to_self(&messages[i]);
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,8 @@ static char t4_stack[TEST_THREAD_STACKSIZE];
|
||||
/* function for testing threads */
|
||||
void *second_thread(void *arg)
|
||||
{
|
||||
printf("Thread: %d is starting\n", (int)arg);
|
||||
printf("Thread: %d calls zombify\n", (int)arg);
|
||||
printf("Thread: %" PRIdPTR " is starting\n", (intptr_t)arg);
|
||||
printf("Thread: %" PRIdPTR " calls zombify\n", (intptr_t)arg);
|
||||
thread_zombify();
|
||||
puts("ERROR zombie runs again!");
|
||||
return NULL;
|
||||
|
@ -4,4 +4,11 @@ USEMODULE += backtrace
|
||||
|
||||
BOARD_WHITELIST := native
|
||||
|
||||
# Tests if native returns a backtrace of size three.
|
||||
# The following function should be included in the backtrace:
|
||||
# `main`/`main_trampoline`/ return to a user context function (e.g. `makecontext`)
|
||||
# Depending on the implementation of the ucontext functions, the backtrace size
|
||||
# may be longer, but this test only checks if it is at least three.
|
||||
CFLAGS += -DBACKTRACE_SIZE=3
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
@ -191,7 +191,7 @@ int netdev_ieee802154_minimal_init_devs(netdev_event_cb_t cb) {
|
||||
at86rf215_t *at86rf215_subghz = NULL;
|
||||
at86rf215_t *at86rf215_24ghz = NULL;
|
||||
|
||||
printf("%d out of %d\n", i + 1, AT86RF215_NUM);
|
||||
printf("%d out of %u\n", i + 1, (unsigned)AT86RF215_NUM);
|
||||
|
||||
if (IS_USED(MODULE_AT86RF215_SUBGHZ)) {
|
||||
puts("Sub-GHz");
|
||||
|
@ -73,7 +73,7 @@ int netdev_ieee802154_minimal_init_devs(netdev_event_cb_t cb) {
|
||||
puts("Initializing AT86RF2XX devices");
|
||||
|
||||
for (unsigned i = 0; i < AT86RF2XX_NUM; i++) {
|
||||
printf("%d out of %d\n", i + 1, AT86RF2XX_NUM);
|
||||
printf("%d out of %u\n", i + 1, (unsigned)AT86RF2XX_NUM);
|
||||
/* setup the specific driver */
|
||||
at86rf2xx_setup(&at86rf2xx[i], &at86rf2xx_params[i], i);
|
||||
|
||||
|
@ -31,7 +31,7 @@ int netdev_ieee802154_minimal_init_devs(netdev_event_cb_t cb) {
|
||||
puts("Initializing CC2420 devices");
|
||||
|
||||
for (unsigned i = 0; i < CC2420_NUM; i++) {
|
||||
printf("%d out of %d\n", i + 1, CC2420_NUM);
|
||||
printf("%d out of %u\n", i + 1, (unsigned)CC2420_NUM);
|
||||
netdev_t *netdev = &cc2420[i].netdev.netdev;
|
||||
|
||||
/* setup the specific driver */
|
||||
|
@ -47,7 +47,7 @@ int netdev_ieee802154_minimal_init_devs(netdev_event_cb_t cb) {
|
||||
ieee802154_hal_test_init_devs(_reg_callback, &c);
|
||||
|
||||
for (unsigned i = 0; i < MRF24J40_NUM; i++) {
|
||||
printf("%d out of %d\n", i + 1, MRF24J40_NUM);
|
||||
printf("%d out of %u\n", i + 1, (unsigned)MRF24J40_NUM);
|
||||
netdev_register(&mrf24j40_netdev[i].dev.netdev, NETDEV_MRF24J40, 0);
|
||||
netdev_ieee802154_submac_init(&mrf24j40_netdev[i]);
|
||||
|
||||
|
@ -279,7 +279,7 @@ static void _print_info(mtd_dev_t *dev)
|
||||
static int cmd_info(int argc, char **argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
printf("mtd devices: %d\n", MTD_NUMOF);
|
||||
printf("mtd devices: %d\n", (unsigned)MTD_NUMOF);
|
||||
|
||||
for (unsigned i = 0; i < MTD_NUMOF; ++i) {
|
||||
printf(" -=[ MTD_%d ]=-\n", i);
|
||||
|
@ -76,7 +76,7 @@ static void _print_measurement(sds011_data_t *data)
|
||||
void measure_cb(sds011_data_t *data, void *ctx)
|
||||
{
|
||||
msg_t msg = { .content.value = (((uint32_t)data->pm_10) << 16 | data->pm_2_5) };
|
||||
kernel_pid_t target_pid = (int)ctx;
|
||||
kernel_pid_t target_pid = (intptr_t)ctx;
|
||||
msg_send(&msg, target_pid);
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ int main(void)
|
||||
}
|
||||
}
|
||||
|
||||
sds011_register_callback(&dev, measure_cb, (void*)(int)thread_getpid());
|
||||
sds011_register_callback(&dev, measure_cb, (void*)(intptr_t)thread_getpid());
|
||||
|
||||
printf("switching to active reporting mode for %u measurements...\n",
|
||||
ACTIVE_REPORTING_TEST_CNT);
|
||||
|
@ -72,7 +72,7 @@ static int parse_dev(char *arg)
|
||||
|
||||
static void rx_cb(void *arg, uint8_t data)
|
||||
{
|
||||
uart_t dev = (soft_uart_t)arg;
|
||||
uart_t dev = (soft_uart_t)(intptr_t)arg;
|
||||
|
||||
ringbuffer_add_one(&(ctx[dev].rx_buf), data);
|
||||
if (data == '\n' || ringbuffer_full(&(ctx[dev].rx_buf))) {
|
||||
@ -139,7 +139,7 @@ static int cmd_init(int argc, char **argv)
|
||||
baud = strtol(argv[2], NULL, 0);
|
||||
|
||||
/* initialize UART */
|
||||
res = soft_uart_init(dev, baud, rx_cb, (void *)dev);
|
||||
res = soft_uart_init(dev, baud, rx_cb, (void *)(intptr_t)dev);
|
||||
if (res == UART_NOBAUD) {
|
||||
printf("Error: Given baudrate (%u) not possible\n", (unsigned int)baud);
|
||||
return 1;
|
||||
@ -269,7 +269,7 @@ int main(void)
|
||||
"NOTE: all strings need to be '\\n' terminated!\n");
|
||||
|
||||
puts("\nUART INFO:");
|
||||
printf("Available devices: %i\n", SOFT_UART_NUMOF);
|
||||
printf("Available devices: %u\n", (unsigned)SOFT_UART_NUMOF);
|
||||
|
||||
/* initialize ringbuffers */
|
||||
for (unsigned i = 0; i < SOFT_UART_NUMOF; i++) {
|
||||
|
@ -11,6 +11,8 @@ USEMODULE += netdev_test
|
||||
|
||||
CFLAGS += -DTEST_SUITES
|
||||
|
||||
INCLUDES += -I$(RIOTBASE)/sys/net/gnrc/pktbuf_static/include
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
ifndef CONFIG_GNRC_IPV6_NIB_NO_RTR_SOL
|
||||
|
@ -41,6 +41,8 @@
|
||||
#include "utlist.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
#include "pktbuf_static.h"
|
||||
|
||||
#define SEND_PACKET_TIMEOUT (500U)
|
||||
|
||||
#define LOC_L2 { _LL0, _LL1, _LL2, _LL3, _LL4, _LL5, _LL6, _LL7 }
|
||||
@ -624,12 +626,19 @@ static void test_minfwd_forward__ENOMEM__netif_hdr_build_fail(void)
|
||||
gnrc_pktsnip_t *pkt, *frag, *filled_space;
|
||||
|
||||
vrbe->super.arrival = xtimer_now_usec();
|
||||
TEST_ASSERT_NOT_NULL((filled_space = gnrc_pktbuf_add(
|
||||
NULL, NULL,
|
||||
/* 115U == 2 * sizeof(gnrc_pktsnip_t) + movement due to mark */
|
||||
CONFIG_GNRC_PKTBUF_SIZE - sizeof(_test_nth_frag) - 115U,
|
||||
GNRC_NETTYPE_UNDEF
|
||||
)));
|
||||
|
||||
size_t test_pkt_size = _align(sizeof(gnrc_pktsnip_t)) + _align(sizeof(_test_nth_frag));
|
||||
size_t marked_pkt_size = _align(sizeof(gnrc_pktsnip_t)) + _align(sizeof(sixlowpan_frag_n_t))
|
||||
+ _align(sizeof(_test_nth_frag) - sizeof(sixlowpan_frag_n_t));
|
||||
|
||||
/* Calculate the maximum payload size to fill the buffer with the following three packets */
|
||||
size_t dummy_pkt_payload_size = CONFIG_GNRC_PKTBUF_SIZE - _align(sizeof(gnrc_pktsnip_t))
|
||||
- test_pkt_size - marked_pkt_size;
|
||||
|
||||
TEST_ASSERT_NOT_NULL((filled_space = gnrc_pktbuf_add(NULL, NULL,
|
||||
dummy_pkt_payload_size,
|
||||
GNRC_NETTYPE_UNDEF)));
|
||||
|
||||
TEST_ASSERT_NOT_NULL((pkt = gnrc_pktbuf_add(NULL, _test_nth_frag,
|
||||
sizeof(_test_nth_frag),
|
||||
GNRC_NETTYPE_SIXLOWPAN)));
|
||||
|
@ -11,6 +11,8 @@ USEMODULE += netdev_test
|
||||
|
||||
CFLAGS += -DTEST_SUITES
|
||||
|
||||
INCLUDES += -I$(RIOTBASE)/sys/net/gnrc/pktbuf_static/include
|
||||
|
||||
# microbit qemu failing currently
|
||||
TEST_ON_CI_BLACKLIST += microbit
|
||||
|
||||
|
@ -43,6 +43,8 @@
|
||||
#include "utlist.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
#include "pktbuf_static.h"
|
||||
|
||||
#define SEND_PACKET_TIMEOUT (500U)
|
||||
|
||||
#define LOC_L2 { _LL0, _LL1, _LL2, _LL3, _LL4, _LL5, _LL6, _LL7 }
|
||||
@ -540,12 +542,18 @@ static void test_sfr_forward__ENOMEM__netif_hdr_build_fail(void)
|
||||
);
|
||||
gnrc_pktsnip_t *pkt, *frag, *filled_space;
|
||||
|
||||
TEST_ASSERT_NOT_NULL((filled_space = gnrc_pktbuf_add(
|
||||
NULL, NULL,
|
||||
/* 115U == 2 * sizeof(gnrc_pktsnip_t) + movement due to mark */
|
||||
CONFIG_GNRC_PKTBUF_SIZE - sizeof(_test_nth_frag) - 115U,
|
||||
GNRC_NETTYPE_UNDEF
|
||||
)));
|
||||
size_t test_pkt_size = _align(sizeof(gnrc_pktsnip_t)) + _align(sizeof(_test_nth_frag));
|
||||
size_t marked_pkt_size = _align(sizeof(gnrc_pktsnip_t)) + _align(sizeof(sixlowpan_frag_n_t))
|
||||
+ _align(sizeof(_test_nth_frag) - sizeof(sixlowpan_frag_n_t));
|
||||
|
||||
/* Calculate the maximum payload size to fill the buffer with the following three packets */
|
||||
size_t dummy_pkt_payload_size = CONFIG_GNRC_PKTBUF_SIZE - _align(sizeof(gnrc_pktsnip_t))
|
||||
- test_pkt_size - marked_pkt_size;
|
||||
|
||||
TEST_ASSERT_NOT_NULL((filled_space = gnrc_pktbuf_add(NULL, NULL,
|
||||
dummy_pkt_payload_size,
|
||||
GNRC_NETTYPE_UNDEF)));
|
||||
|
||||
TEST_ASSERT_NOT_NULL((pkt = gnrc_pktbuf_add(NULL, _test_nth_frag,
|
||||
sizeof(_test_nth_frag),
|
||||
GNRC_NETTYPE_SIXLOWPAN)));
|
||||
|
@ -204,42 +204,29 @@ static int cmd_write(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
static uint32_t getaddr(const char *str)
|
||||
static uintptr_t getaddr(const char *str)
|
||||
{
|
||||
uint32_t addr = strtol(str, NULL, 16);
|
||||
uintptr_t addr = (uintptr_t)strtol(str, NULL, 16);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
static int cmd_write_raw(int argc, char **argv)
|
||||
{
|
||||
#if (__SIZEOF_POINTER__ == 2)
|
||||
uint16_t addr;
|
||||
#else
|
||||
uint32_t addr;
|
||||
#endif
|
||||
uintptr_t addr;
|
||||
|
||||
if (argc < 3) {
|
||||
printf("usage: %s <addr> <data>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if (__SIZEOF_POINTER__ == 2)
|
||||
addr = (uint16_t) getaddr(argv[1]);
|
||||
#else
|
||||
addr = getaddr(argv[1]);
|
||||
#endif
|
||||
/* try to align */
|
||||
memcpy(raw_buf, argv[2], strlen(argv[2]));
|
||||
|
||||
flashpage_write((void*)addr, raw_buf, strlen(raw_buf));
|
||||
#if (__SIZEOF_POINTER__ == 2)
|
||||
printf("wrote local data to flash address %#" PRIx16 " of len %" PRIuSIZE "\n",
|
||||
flashpage_write((void*)(uintptr_t)addr, raw_buf, strlen(raw_buf));
|
||||
printf("wrote local data to flash address %#" PRIxPTR " of len %" PRIuSIZE "\n",
|
||||
addr, strlen(raw_buf));
|
||||
#else
|
||||
printf("wrote local data to flash address %#" PRIx32 " of len %" PRIuSIZE "\n",
|
||||
addr, strlen(raw_buf));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -47,12 +47,12 @@ static void test_flashbase_addr(void)
|
||||
void *addr;
|
||||
|
||||
addr = flashpage_addr(0);
|
||||
TEST_ASSERT_EQUAL_INT((unsigned int)CPU_FLASH_BASE, (unsigned int)addr);
|
||||
TEST_ASSERT_EQUAL_INT((unsigned int)CPU_FLASH_BASE, (uintptr_t)addr);
|
||||
addr = flashpage_addr(FLASHPAGE_NUMOF - 1);
|
||||
TEST_ASSERT_EQUAL_INT((long)CPU_FLASH_BASE + (((unsigned)FLASHPAGE_NUMOF - 1) * FLASHPAGE_SIZE),
|
||||
(unsigned int)addr);
|
||||
(uintptr_t)addr);
|
||||
addr = flashpage_addr(12);
|
||||
TEST_ASSERT_EQUAL_INT((unsigned int)CPU_FLASH_BASE + (12 * FLASHPAGE_SIZE), (unsigned int)addr);
|
||||
TEST_ASSERT_EQUAL_INT((unsigned int)CPU_FLASH_BASE + (12 * FLASHPAGE_SIZE), (uintptr_t)addr);
|
||||
}
|
||||
|
||||
static void test_flashbase_page(void)
|
||||
|
@ -33,7 +33,7 @@
|
||||
#ifdef MODULE_PERIPH_GPIO_IRQ
|
||||
static void cb(void *arg)
|
||||
{
|
||||
printf("INT: external interrupt from pin %i\n", (int)arg);
|
||||
printf("INT: external interrupt from pin %" PRIiPTR "\n", (intptr_t)arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -145,7 +145,7 @@ static int init_int(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (gpio_init_int(GPIO_PIN(po, pi), mode, flank, cb, (void *)pi) < 0) {
|
||||
if (gpio_init_int(GPIO_PIN(po, pi), mode, flank, cb, (void *)(intptr_t)pi) < 0) {
|
||||
printf("error: init_int of GPIO_PIN(%i, %i) failed\n", po, pi);
|
||||
return 1;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ static unsigned args[TIMER_CHANNEL_NUMOF];
|
||||
static void cb(void *arg, int chan)
|
||||
{
|
||||
timeouts[chan] = sw_count;
|
||||
args[chan] = (unsigned)arg + chan;
|
||||
args[chan] = (uintptr_t)arg + chan;
|
||||
fired++;
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ static int test_timer(unsigned num, uint32_t timer_freq)
|
||||
printf(" - Calling timer_init(%u, %" PRIu32 ")\n ",
|
||||
num, timer_freq);
|
||||
/* initialize and halt timer */
|
||||
if (timer_init(TIMER_DEV(num), timer_freq, cb, (void *)(COOKIE * num)) != 0) {
|
||||
if (timer_init(TIMER_DEV(num), timer_freq, cb, (void *)(uintptr_t)(COOKIE * num)) != 0) {
|
||||
printf("ERROR: timer_init() failed\n\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ static int cmd_init(int argc, char **argv)
|
||||
baud = strtol(argv[2], NULL, 0);
|
||||
|
||||
/* initialize UART */
|
||||
res = uart_init(UART_DEV(dev), baud, rx_cb, (void *)dev);
|
||||
res = uart_init(UART_DEV(dev), baud, rx_cb, (void *)(intptr_t)dev);
|
||||
if (res == UART_NOBAUD) {
|
||||
printf("Error: Given baudrate (%u) not possible\n", (unsigned int)baud);
|
||||
return 1;
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "cayenne_lpp.h"
|
||||
|
||||
#define TEST_BUFFER1 { 0x03, 0x67, 0x01, 0x10, 0x05, 0x67, 0x00, 0xff }
|
||||
#if defined(BOARD_NATIVE)
|
||||
#if defined(BOARD_NATIVE) && !(__SIZEOF_POINTER__ == 8)
|
||||
#define TEST_BUFFER2 { 0x01, 0x67, 0xFF, 0xD8, \
|
||||
0x06, 0x71, 0x04, 0xD1, 0xFB, 0x2F, 0x00, 0x00 }
|
||||
#else
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <stdio.h>
|
||||
#include "lora_serialization.h"
|
||||
|
||||
#if defined(BOARD_NATIVE)
|
||||
#if defined(BOARD_NATIVE) && !(__SIZEOF_POINTER__ == 8)
|
||||
#define TEST_01_EXPECTED { 0x1f, 0x4c, 0x0e, 0x27 }
|
||||
#define TEST_02_EXPECTED { 0x65, 0xa6, 0xfa, 0xfd, \
|
||||
0x6a, 0x24, 0x04, 0x09, \
|
||||
|
@ -3,6 +3,10 @@ include ../Makefile.sys_common
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
ifneq (,$(filter arch_64bit,$(FEATURES_USED)))
|
||||
CFLAGS += -DCORRECT_WORD_BITS=64
|
||||
endif
|
||||
|
||||
ifneq (,$(filter arch_32bit,$(FEATURES_USED)))
|
||||
CFLAGS += -DCORRECT_WORD_BITS=32
|
||||
endif
|
||||
|
@ -53,7 +53,7 @@ int main(void)
|
||||
|
||||
for (num = 0; num < 5; num++) {
|
||||
entries[num].cb = cb;
|
||||
entries[num].arg = (void *)num;
|
||||
entries[num].arg = (void *)(uintptr_t)num;
|
||||
entries[num].cbid = num;
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ int main(void)
|
||||
while (num < 5) {
|
||||
cb_mux_add(&cb_mux_head, &(entries[num]));
|
||||
|
||||
printf("Added entry %i\n", num);
|
||||
printf("Added entry %u\n", (unsigned)num);
|
||||
|
||||
num = cb_mux_find_free_id(cb_mux_head);
|
||||
}
|
||||
@ -125,7 +125,7 @@ int main(void)
|
||||
|
||||
for (num = 0; num < 5; num++) {
|
||||
if ((uintptr_t)entries[num].info & (1 << ITER_TEST)) {
|
||||
printf("Entry %i was updated correctly\n", num);
|
||||
printf("Entry %u was updated correctly\n", (unsigned)num);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -592,7 +592,7 @@ static int _can_handler(int argc, char **argv)
|
||||
|
||||
static void *_receive_thread(void *args)
|
||||
{
|
||||
int thread_nb = (int)args;
|
||||
int thread_nb = (intptr_t)args;
|
||||
struct can_frame frame;
|
||||
msg_t msg, msg_queue[RECEIVE_THREAD_MSG_QUEUE_SIZE];
|
||||
|
||||
@ -729,7 +729,7 @@ static const shell_command_t _commands[] = {
|
||||
|
||||
int main(void)
|
||||
{
|
||||
for (int i = 0; i < RCV_THREAD_NUMOF; i++) {
|
||||
for (intptr_t i = 0; i < RCV_THREAD_NUMOF; i++) {
|
||||
receive_pid[i] = thread_create(thread_stack[i], THREAD_STACKSIZE,
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
THREAD_CREATE_STACKTEST, _receive_thread,
|
||||
|
@ -62,7 +62,7 @@ static void callback(event_t *arg)
|
||||
order++;
|
||||
expect(order == 4);
|
||||
expect(arg == &event);
|
||||
printf("triggered 0x%08x\n", (unsigned)arg);
|
||||
printf("triggered 0x%08" PRIxPTR "\n", (uintptr_t)arg);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
@ -94,7 +94,8 @@ static void timed_callback(void *arg)
|
||||
uint32_t now = xtimer_now_usec();
|
||||
#endif
|
||||
expect((now - before >= 100000LU));
|
||||
printf("triggered timed callback with arg 0x%08x after %" PRIu32 "us\n", (unsigned)arg, now - before);
|
||||
printf("triggered timed callback with arg 0x%08" PRIxPTR " after %" PRIu32 "us\n",
|
||||
(uintptr_t)arg, now - before);
|
||||
puts("[SUCCESS]");
|
||||
}
|
||||
|
||||
@ -176,12 +177,12 @@ int main(void)
|
||||
/* test posting different kind of events in order to a statically
|
||||
* initialized queue */
|
||||
event_queue_t queue = EVENT_QUEUE_INIT;
|
||||
printf("posting 0x%08x\n", (unsigned)&event);
|
||||
printf("posting 0x%08" PRIxPTR "\n", (uintptr_t)&event);
|
||||
event_post(&queue, &event);
|
||||
|
||||
printf("posting 0x%08x\n", (unsigned)&event2);
|
||||
printf("posting 0x%08" PRIxPTR "\n", (uintptr_t)&event2);
|
||||
event_post(&queue, &event2);
|
||||
printf("canceling 0x%08x\n", (unsigned)&event2);
|
||||
printf("canceling 0x%08" PRIxPTR "\n", (uintptr_t)&event2);
|
||||
event_cancel(&queue, &event2);
|
||||
|
||||
puts("posting custom event");
|
||||
|
@ -41,7 +41,7 @@ static int free_cmd(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int p = strtoul(argv[1], NULL, 16);
|
||||
uintptr_t p = strtoul(argv[1], NULL, 16);
|
||||
void *ptr = (void *)p;
|
||||
printf("freeing %p\n", ptr);
|
||||
free(ptr);
|
||||
|
@ -36,9 +36,9 @@ static kernel_pid_t pids[NB_THREADS];
|
||||
|
||||
static void *_thread_fn(void *arg)
|
||||
{
|
||||
int next = ((int)arg + 1) % NB_THREADS;
|
||||
int next = ((uintptr_t)arg + 1) % NB_THREADS;
|
||||
|
||||
printf("Creating thread #%d, next=%d\n", (int)arg, next);
|
||||
printf("Creating thread #%" PRIuPTR ", next=%d\n", (uintptr_t)arg, next);
|
||||
|
||||
while (1) {
|
||||
msg_t m1, m2;
|
||||
@ -59,7 +59,7 @@ int main(void)
|
||||
{
|
||||
test_utils_interactive_sync();
|
||||
|
||||
for (unsigned i = 0; i < NB_THREADS; ++i) {
|
||||
for (uintptr_t i = 0; i < NB_THREADS; ++i) {
|
||||
pids[i] = thread_create(stacks[i], sizeof(stacks[i]),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
|
@ -32,7 +32,7 @@ volatile uint32_t storage = 1;
|
||||
|
||||
void *run(void *parameter)
|
||||
{
|
||||
int arg = (int) parameter;
|
||||
int arg = (intptr_t) parameter;
|
||||
printf("My arg: %d\n", arg);
|
||||
|
||||
int err = pthread_mutex_lock(&mtx);
|
||||
@ -56,8 +56,8 @@ int main(void)
|
||||
pthread_attr_init(&th_attr);
|
||||
pthread_mutex_init(&mtx, NULL);
|
||||
|
||||
for (int i = 0; i < NUM_THREADS; ++i) {
|
||||
printf("Creating thread with arg %d\n", (i + 1));
|
||||
for (intptr_t i = 0; i < NUM_THREADS; ++i) {
|
||||
printf("Creating thread with arg %" PRIdPTR "\n", (i + 1));
|
||||
pthread_create(&ths[i], &th_attr, run, (void *)(i + 1));
|
||||
}
|
||||
|
||||
|
@ -45,8 +45,8 @@ void *run(void *parameter)
|
||||
aTLS_values[i]++;
|
||||
}
|
||||
|
||||
printf("pick deliberate storage (key[3]:%d) and change the value\n",
|
||||
(int)aKeys[3]);
|
||||
printf("pick deliberate storage (key[3]:%" PRIuPTR ") and change the value\n",
|
||||
(uintptr_t)aKeys[3]);
|
||||
void *val = pthread_getspecific(aKeys[3]);
|
||||
*((int *)val) = 42;
|
||||
|
||||
@ -55,11 +55,11 @@ void *run(void *parameter)
|
||||
for (int i = 0; i < NUMBER_OF_TLS; ++i) {
|
||||
void *val = pthread_getspecific(aKeys[i]);
|
||||
int x = *(int *)val;
|
||||
printf("key[%d]: %d, val: %d\n",i, (int)aKeys[i], x);
|
||||
printf("key[%d]: %" PRIuPTR ", val: %d\n", i, (uintptr_t)aKeys[i], x);
|
||||
}
|
||||
|
||||
printf("\n -= TEST 2 - delete deliberate key (key[5]:%d) =-\n",
|
||||
(int)aKeys[5]);
|
||||
printf("\n -= TEST 2 - delete deliberate key (key[5]:%" PRIuPTR ") =-\n",
|
||||
(uintptr_t)aKeys[5]);
|
||||
pthread_key_delete(aKeys[5]);
|
||||
|
||||
puts("show tls values:");
|
||||
@ -69,7 +69,7 @@ void *run(void *parameter)
|
||||
|
||||
if (val != NULL) {
|
||||
int x = *(int *)val;
|
||||
printf("key[%d]: %d, val: %d\n",i, (int)aKeys[i], x);
|
||||
printf("key[%d]: %" PRIuPTR ", val: %d\n", i, (uintptr_t)aKeys[i], x);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ void *run(void *parameter)
|
||||
pthread_key_create(&new_key, NULL);
|
||||
pthread_setspecific(new_key, &new_val);
|
||||
|
||||
printf("added new tls, key: %d, val: %d\n", (int)new_key, new_val);
|
||||
printf("added new tls, key: %" PRIuPTR ", val: %d\n", (uintptr_t)new_key, new_val);
|
||||
printf("show tls values:\n");
|
||||
|
||||
for (int i = 0; i < NUMBER_OF_TLS; ++i) {
|
||||
@ -88,7 +88,7 @@ void *run(void *parameter)
|
||||
|
||||
if (val != NULL) {
|
||||
int x = *(int *)val;
|
||||
printf("key[%d]: %d, val: %d\n",i, (int)aKeys[i], x);
|
||||
printf("key[%d]: %" PRIuPTR ", val: %d\n", i, (uintptr_t)aKeys[i], x);
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ void *run(void *parameter)
|
||||
|
||||
if (val != NULL) {
|
||||
int x = *(int *)val;
|
||||
printf("key[%d]: %d, val: %d\n",i, (int)aKeys[i], x);
|
||||
printf("key[%d]: %" PRIuPTR ", val: %d\n", i, (uintptr_t)aKeys[i], x);
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,13 +119,13 @@ void *run(void *parameter)
|
||||
puts("-= TEST 6 - add key and delete without a tls =-");
|
||||
|
||||
pthread_key_create(&new_key, NULL);
|
||||
printf("created key: %d\n", (int)new_key);
|
||||
printf("created key: %" PRIuPTR "\n", (uintptr_t)new_key);
|
||||
printf("try to delete returns: %d\n", pthread_key_delete(new_key));
|
||||
|
||||
puts("");
|
||||
puts("-= TEST 7 - add key without tls =-");
|
||||
pthread_key_create(&new_key, NULL);
|
||||
printf("created key: %d\n", (int)new_key);
|
||||
printf("created key: %" PRIuPTR "\n", (uintptr_t)new_key);
|
||||
void* test_7_val = pthread_getspecific(new_key);
|
||||
printf("test_7_val: %p\n", test_7_val);
|
||||
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "unittests-constants.h"
|
||||
#include "tests-pktbuf.h"
|
||||
|
||||
#define ALIGNMENT_SIZE (2 * sizeof(uintptr_t))
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
uint8_t u8;
|
||||
uint16_t u16;
|
||||
@ -250,14 +252,14 @@ static void test_pktbuf_add__packed_struct(void)
|
||||
#ifndef MODULE_GNRC_PKTBUF_MALLOC /* alignment-handling left to malloc, so no certainty here */
|
||||
static void test_pktbuf_add__unaligned_in_aligned_hole(void)
|
||||
{
|
||||
gnrc_pktsnip_t *pkt1 = gnrc_pktbuf_add(NULL, NULL, 8, GNRC_NETTYPE_TEST);
|
||||
gnrc_pktsnip_t *pkt2 = gnrc_pktbuf_add(NULL, NULL, 8, GNRC_NETTYPE_TEST);
|
||||
gnrc_pktsnip_t *pkt3 = gnrc_pktbuf_add(NULL, NULL, 8, GNRC_NETTYPE_TEST);
|
||||
gnrc_pktsnip_t *pkt1 = gnrc_pktbuf_add(NULL, NULL, ALIGNMENT_SIZE, GNRC_NETTYPE_TEST);
|
||||
gnrc_pktsnip_t *pkt2 = gnrc_pktbuf_add(NULL, NULL, ALIGNMENT_SIZE, GNRC_NETTYPE_TEST);
|
||||
gnrc_pktsnip_t *pkt3 = gnrc_pktbuf_add(NULL, NULL, ALIGNMENT_SIZE, GNRC_NETTYPE_TEST);
|
||||
gnrc_pktsnip_t *pkt4;
|
||||
void *tmp_data2 = pkt2->data;
|
||||
|
||||
gnrc_pktbuf_release(pkt2);
|
||||
pkt4 = gnrc_pktbuf_add(NULL, TEST_STRING12, 9, GNRC_NETTYPE_TEST);
|
||||
pkt4 = gnrc_pktbuf_add(NULL, TEST_STRING64, ALIGNMENT_SIZE + 1, GNRC_NETTYPE_TEST);
|
||||
|
||||
TEST_ASSERT(tmp_data2 != pkt4->data);
|
||||
|
||||
@ -820,14 +822,14 @@ static void test_pktbuf_start_write__pkt_users_2(void)
|
||||
static void test_pktbuf_reverse_snips__too_full(void)
|
||||
{
|
||||
gnrc_pktsnip_t *pkt, *pkt_next, *pkt_huge;
|
||||
const size_t pkt_huge_size = CONFIG_GNRC_PKTBUF_SIZE - (3 * 8) -
|
||||
const size_t pkt_huge_size = CONFIG_GNRC_PKTBUF_SIZE - (3 * ALIGNMENT_SIZE) -
|
||||
(3 * sizeof(gnrc_pktsnip_t)) - 4;
|
||||
|
||||
pkt_next = gnrc_pktbuf_add(NULL, TEST_STRING8, 8, GNRC_NETTYPE_TEST);
|
||||
pkt_next = gnrc_pktbuf_add(NULL, TEST_STRING16, ALIGNMENT_SIZE, GNRC_NETTYPE_TEST);
|
||||
TEST_ASSERT_NOT_NULL(pkt_next);
|
||||
/* hold to enforce duplication */
|
||||
gnrc_pktbuf_hold(pkt_next, 1);
|
||||
pkt = gnrc_pktbuf_add(pkt_next, TEST_STRING8, 8, GNRC_NETTYPE_TEST);
|
||||
pkt = gnrc_pktbuf_add(pkt_next, TEST_STRING16, 8, GNRC_NETTYPE_TEST);
|
||||
TEST_ASSERT_NOT_NULL(pkt);
|
||||
/* filling up rest of packet buffer */
|
||||
pkt_huge = gnrc_pktbuf_add(NULL, NULL, pkt_huge_size, GNRC_NETTYPE_UNDEF);
|
||||
|
Loading…
Reference in New Issue
Block a user