Browse Source

core: remove extra thread_create_arg() function

dev/timer
René Kijewski 9 years ago
parent
commit
ba1a15535b
  1. 4
      core/include/thread.h
  2. 27
      core/kernel_init.c
  3. 22
      core/thread.c
  4. 7
      cpu/x86/x86_hwtimer.c
  5. 10
      drivers/cc110x/cc1100_phy.c
  6. 12
      examples/ccn-lite-client/main.c
  7. 7
      examples/ccn-lite-relay/main.c
  8. 5
      examples/default/main.c
  9. 8
      examples/ipc_pingpong/main.c
  10. 8
      examples/riot_and_cpp/main.cpp
  11. 2
      examples/rpl_udp/demo.h
  12. 6
      examples/rpl_udp/helper.c
  13. 2
      examples/rpl_udp/rpl.c
  14. 10
      examples/rpl_udp/udp.c
  15. 4
      sys/auto_init/auto_init.c
  16. 7
      sys/chardev_thread.c
  17. 1
      sys/include/chardev_thread.h
  18. 3
      sys/net/include/etx_beaconing.h
  19. 4
      sys/net/network_layer/sixlowpan/ip.c
  20. 2
      sys/net/network_layer/sixlowpan/ip.h
  21. 20
      sys/net/network_layer/sixlowpan/lowpan.c
  22. 8
      sys/net/network_layer/sixlowpan/mac.c
  23. 28
      sys/net/routing/etx_beaconing.c
  24. 6
      sys/net/routing/rpl/rpl.c
  25. 4
      sys/net/routing/rpl/rpl.h
  26. 42
      sys/net/routing/rpl/trickle.c
  27. 4
      sys/net/routing/rpl/trickle.h
  28. 6
      sys/net/transport_layer/destiny/destiny.c
  29. 4
      sys/net/transport_layer/destiny/tcp.c
  30. 2
      sys/net/transport_layer/destiny/tcp.h
  31. 4
      sys/net/transport_layer/destiny/tcp_timer.c
  32. 2
      sys/net/transport_layer/destiny/tcp_timer.h
  33. 4
      sys/net/transport_layer/destiny/udp.c
  34. 2
      sys/net/transport_layer/destiny/udp.h
  35. 14
      sys/posix/pthread/pthread.c
  36. 12
      sys/transceiver/transceiver.c
  37. 8
      sys/uart0/uart0.c
  38. 28
      tests/test_ipc_pingpong/main.c
  39. 10
      tests/test_irq/main.c
  40. 5
      tests/test_mutex_unlock_and_sleep/main.c
  41. 6
      tests/test_nativenet/main.c
  42. 12
      tests/test_posix_semaphore/main.c
  43. 5
      tests/test_pthread_condition_variable/main.c
  44. 14
      tests/test_pthread_rwlock/main.c
  45. 5
      tests/test_queue_fairness/main.c
  46. 6
      tests/test_thread_basic/main.c
  47. 18
      tests/test_thread_cooperation/main.c
  48. 15
      tests/test_thread_exit/main.c
  49. 22
      tests/test_thread_msg/main.c
  50. 9
      tests/test_thread_msg_block_w_queue/main.c
  51. 9
      tests/test_thread_msg_block_wo_queue/main.c
  52. 15
      tests/test_thread_msg_seq/main.c
  53. 10
      tests/test_vtimer_msg/main.c
  54. 6
      tests/test_vtimer_msg_diff/main.c

4
core/include/thread.h

@ -67,6 +67,7 @@
* @param[in] priority priority of the new thread, lower mean higher priority
* @param[in] flags optional flags for the creation of the new thread
* @param[in] function pointer to the code that is executed in the new thread
* @param[in] arg the argument to the function
* @param[in] name a human readable descriptor for the thread
*
* @return value ``<0`` on error
@ -76,7 +77,8 @@ int thread_create(char *stack,
int stacksize,
char priority,
int flags,
void (*function) (void),
void *(*function)(void *arg),
void *arg,
const char *name);
int thread_create_arg(char *stack,

27
core/kernel_init.c

@ -46,9 +46,22 @@
volatile int lpm_prevent_sleep = 0;
extern int main(void);
static void *main_trampoline(void *arg)
{
(void) arg;
#ifdef MODULE_AUTO_INIT
auto_init();
#endif
main();
return NULL;
}
static void idle_thread(void)
static void *idle_thread(void *arg)
{
(void) arg;
while (1) {
if (lpm_prevent_sleep) {
lpm_set(LPM_IDLE);
@ -59,6 +72,8 @@ static void idle_thread(void)
/* lpm_set(LPM_POWERDOWN); */
}
}
return NULL;
}
const char *main_name = "main";
@ -67,12 +82,6 @@ const char *idle_name = "idle";
static char main_stack[KERNEL_CONF_STACKSIZE_MAIN];
static char idle_stack[KERNEL_CONF_STACKSIZE_IDLE];
#ifdef MODULE_AUTO_INIT
#define MAIN_FUNC auto_init
#else
#define MAIN_FUNC ((void (*) (void)) main)
#endif
void kernel_init(void)
{
dINT();
@ -80,11 +89,11 @@ void kernel_init(void)
hwtimer_init();
if (thread_create(idle_stack, sizeof(idle_stack), PRIORITY_IDLE, CREATE_WOUT_YIELD | CREATE_STACKTEST, idle_thread, idle_name) < 0) {
if (thread_create(idle_stack, sizeof(idle_stack), PRIORITY_IDLE, CREATE_WOUT_YIELD | CREATE_STACKTEST, idle_thread, NULL, idle_name) < 0) {
printf("kernel_init(): error creating idle task.\n");
}
if (thread_create(main_stack, sizeof(main_stack), PRIORITY_MAIN, CREATE_WOUT_YIELD | CREATE_STACKTEST, MAIN_FUNC, main_name) < 0) {
if (thread_create(main_stack, sizeof(main_stack), PRIORITY_MAIN, CREATE_WOUT_YIELD | CREATE_STACKTEST, main_trampoline, NULL, main_name) < 0) {
printf("kernel_init(): error creating main task.\n");
}

22
core/thread.c

@ -112,27 +112,7 @@ int thread_measure_stack_free(char *stack)
return space_free;
}
typedef union
{
void *ptr;
void (*wo_args)(void);
void (*w_args)(void *arg);
} task_funcs_t;
static void *thread_create_entry(void *function_)
{
task_funcs_t function = { .ptr = function_ };
function.wo_args();
return NULL;
}
int thread_create(char *stack, int stacksize, char priority, int flags, void (*function_)(void), const char *name)
{
task_funcs_t function = { .wo_args = function_ };
return thread_create_arg(stack, stacksize, priority, flags, thread_create_entry, function.ptr, name);
}
int thread_create_arg(char *stack, int stacksize, char priority, int flags, void *(*function)(void *arg), void *arg, const char *name)
int thread_create(char *stack, int stacksize, char priority, int flags, void *(*function)(void *arg), void *arg, const char *name)
{
/* allocate our thread control block at the top of our stackspace */
int total_stacksize = stacksize;

7
cpu/x86/x86_hwtimer.c

@ -206,8 +206,10 @@ static bool timer_unlink(unsigned i)
return do_yield;
}
static void hwtimer_tick_handler(void)
static void *hwtimer_tick_handler(void *arg)
{
(void) arg;
msg_t msg_array[2];
msg_init_queue(msg_array, sizeof (msg_array) / sizeof (*msg_array));
while (1) {
@ -218,6 +220,8 @@ static void hwtimer_tick_handler(void)
set_next_alarm(true);
eINT();
}
return NULL;
}
static void stop_alarms(void)
@ -394,6 +398,7 @@ void hwtimer_arch_init(void (*handler)(int), uint32_t fcpu)
1,
CREATE_STACKTEST,
hwtimer_tick_handler,
NULL,
"x86-hwtimer");
hwtimer_ie = true;
}

10
drivers/cc110x/cc1100_phy.c

@ -88,7 +88,7 @@ static vtimer_t cc1100_watch_dog;
static timex_t cc1100_watch_dog_period;
static uint16_t cc1100_event_handler_pid;
static void cc1100_event_handler_function(void);
static void *cc1100_event_handler_function(void *);
static char event_handler_stack[KERNEL_CONF_STACKSIZE_MAIN];
@ -179,7 +179,7 @@ void cc1100_phy_init(void)
/* Allocate event numbers and start cc1100 event process */
cc1100_event_handler_pid = thread_create(event_handler_stack, sizeof(event_handler_stack), PRIORITY_CC1100, CREATE_STACKTEST,
cc1100_event_handler_function, cc1100_event_handler_name);
cc1100_event_handler_function, NULL, cc1100_event_handler_name);
/* Active watchdog for the first time */
if (radio_mode == CC1100_MODE_CONSTANT_RX) {
@ -622,8 +622,10 @@ int cc1100_set_packet_handler(protocol_t protocol, packet_handler_t handler)
return pm_set_handler(&handler_table, protocol, handler);
}
static void cc1100_event_handler_function(void)
static void *cc1100_event_handler_function(void *arg)
{
(void) arg;
msg_t m;
while (1) {
@ -693,6 +695,8 @@ static void cc1100_event_handler_function(void)
eINT();
}
return NULL;
}
/*---------------------------------------------------------------------------*/

12
examples/ccn-lite-client/main.c

@ -63,9 +63,11 @@ unsigned char big_buf[3 * 1024];
char small_buf[PAYLOAD_SIZE];
#if RIOT_CCN_APPSERVER
static void appserver_thread(void)
static void *appserver_thread(void *arg)
{
(void) arg;
ccnl_riot_appserver_start(relay_pid);
return NULL;
}
static void riot_ccn_appserver(int argc, char **argv)
@ -81,7 +83,7 @@ static void riot_ccn_appserver(int argc, char **argv)
appserver_pid = thread_create(
appserver_stack, sizeof(appserver_stack),
PRIORITY_MAIN - 1, CREATE_STACKTEST,
appserver_thread, "appserver");
appserver_thread, NULL, "appserver");
DEBUG("ccn-lite appserver on thread_id %d...\n", appserver_pid);
}
#endif
@ -133,9 +135,11 @@ static void riot_ccn_register_prefix(int argc, char **argv)
puts("done");
}
static void relay_thread(void)
static void *relay_thread(void *arg)
{
(void) arg;
ccnl_riot_relay_start(shell_max_cache_entries, shell_threshold_prefix, shell_threshold_aggregate);
return NULL;
}
static void riot_ccn_relay_start(int argc, char **argv)
@ -169,7 +173,7 @@ static void riot_ccn_relay_start(int argc, char **argv)
relay_pid = thread_create(
relay_stack, sizeof(relay_stack),
PRIORITY_MAIN - 2, CREATE_STACKTEST,
relay_thread, "relay");
relay_thread, NULL, "relay");
DEBUG("ccn-lite relay on thread_id %d...\n", relay_pid);
}

7
examples/ccn-lite-relay/main.c

@ -65,10 +65,12 @@ void populate_cache(void)
msg_send(&m, relay_pid, 1);
}
void second_thread(void)
void *second_thread(void *arg)
{
(void) arg;
set_address_handler(42);
populate_cache();
return NULL;
}
int main(void)
@ -77,7 +79,8 @@ int main(void)
relay_pid = thread_getpid();
thread_create(t2_stack, KERNEL_CONF_STACKSIZE_MAIN, PRIORITY_MAIN + 1, CREATE_STACKTEST, second_thread, "helper thread");
thread_create(t2_stack, KERNEL_CONF_STACKSIZE_MAIN, PRIORITY_MAIN + 1,
CREATE_STACKTEST, second_thread, NULL, "helper thread");
printf("starting ccn-lite relay...\n");
ccnl_riot_relay_start(CCNL_DEFAULT_MAX_CACHE_ENTRIES,

5
examples/default/main.c

@ -48,8 +48,10 @@
char radio_stack_buffer[RADIO_STACK_SIZE];
msg_t msg_q[RCV_BUFFER_SIZE];
void radio(void)
void *radio(void *arg)
{
(void) arg;
msg_t m;
radio_packet_t *p;
radio_packet_length_t i;
@ -92,6 +94,7 @@ void init_transceiver(void)
PRIORITY_MAIN - 2,
CREATE_STACKTEST,
radio,
NULL,
"radio");
uint16_t transceivers = TRANSCEIVER_DEFAULT;

8
examples/ipc_pingpong/main.c

@ -25,8 +25,10 @@
#include "msg.h"
#include "kernel.h"
void second_thread(void)
void *second_thread(void *arg)
{
(void) arg;
printf("2nd thread started, pid: %i\n", thread_getpid());
msg_t m;
@ -36,6 +38,8 @@ void second_thread(void)
m.content.value++;
msg_reply(&m, &m);
}
return NULL;
}
char second_thread_stack[KERNEL_CONF_STACKSIZE_MAIN];
@ -49,7 +53,7 @@ int main(void)
int pid = thread_create(second_thread_stack, sizeof(second_thread_stack),
PRIORITY_MAIN - 1, CREATE_STACKTEST,
second_thread, "pong");
second_thread, NULL, "pong");
m.content.value = 1;

8
examples/riot_and_cpp/main.cpp

@ -41,7 +41,7 @@ using namespace std;
char threadA_stack [KERNEL_CONF_STACKSIZE_PRINTF];
/* thread's function */
void threadA_func(void);
void *threadA_func(void *arg);
/* main */
int main()
@ -50,7 +50,7 @@ int main()
printf("\n");
/* create thread A */
thread_create(threadA_stack, sizeof(threadA_stack), 0, CREATE_WOUT_YIELD, threadA_func, "thread A");
thread_create(threadA_stack, sizeof(threadA_stack), 0, CREATE_WOUT_YIELD, threadA_func, NULL, "thread A");
printf("******** Hello, you're in thread %s ********\n", thread_getname(thread_getpid()));
printf("We'll test C++ class and methods here!\n");
@ -82,7 +82,7 @@ int main()
}
/* thread A function implemetation */
void threadA_func(void)
void *threadA_func(void *)
{
int day = 13, month = 6, year = 2014;
int ret_day;
@ -104,4 +104,6 @@ void threadA_func(void)
}
printf("\nThis demo ends here, press Ctrl-C to exit (if you're on native)!\n");
return NULL;
}

2
examples/rpl_udp/demo.h

@ -46,7 +46,7 @@ void rpl_udp_ip(int argc, char **argv);
void rpl_udp_ignore(int argc, char **argv);
/* monitoring thread */
void rpl_udp_monitor(void);
void *rpl_udp_monitor(void *arg);
extern radio_address_t id;
extern ipv6_addr_t std_addr;

6
examples/rpl_udp/helper.c

@ -53,8 +53,10 @@ void rpl_udp_set_id(int argc, char **argv)
printf("Set node ID to %u\n", id);
}
void rpl_udp_monitor(void)
void *rpl_udp_monitor(void *arg)
{
(void) arg;
msg_t m;
radio_packet_t *p;
ipv6_hdr_t *ipv6_buf;
@ -111,6 +113,8 @@ void rpl_udp_monitor(void)
printf("Unknown packet received, type %04X\n", m.type);
}
}
return NULL;
}
transceiver_command_t tcmd;

2
examples/rpl_udp/rpl.c

@ -90,7 +90,7 @@ void rpl_udp_init(int argc, char **argv)
int monitor_pid = thread_create(
monitor_stack_buffer, sizeof(monitor_stack_buffer),
PRIORITY_MAIN - 2, CREATE_STACKTEST,
rpl_udp_monitor, "monitor");
rpl_udp_monitor, NULL, "monitor");
DEBUGF("Register at transceiver %02X\n", TRANSCEIVER);
transceiver_register(TRANSCEIVER, monitor_pid);
ipv6_register_packet_handler(monitor_pid);

10
examples/rpl_udp/udp.c

@ -39,7 +39,7 @@
char udp_server_stack_buffer[KERNEL_CONF_STACKSIZE_MAIN];
char addr_str[IPV6_MAX_ADDR_STR_LEN];
void init_udp_server(void);
static void *init_udp_server(void *);
/* UDP server thread */
void udp_server(int argc, char **argv)
@ -50,12 +50,14 @@ void udp_server(int argc, char **argv)
int udp_server_thread_pid = thread_create(
udp_server_stack_buffer, sizeof(udp_server_stack_buffer),
PRIORITY_MAIN, CREATE_STACKTEST,
init_udp_server, "init_udp_server");
init_udp_server, NULL, "init_udp_server");
printf("UDP SERVER ON PORT %d (THREAD PID: %d)\n", HTONS(SERVER_PORT), udp_server_thread_pid);
}
void init_udp_server(void)
static void *init_udp_server(void *arg)
{
(void) arg;
sockaddr6_t sa;
char buffer_main[UDP_BUFFER_SIZE];
int32_t recsize;
@ -86,6 +88,8 @@ void init_udp_server(void)
}
destiny_socket_close(sock);
return NULL;
}
/* UDP send command */

4
sys/auto_init/auto_init.c

@ -75,8 +75,6 @@
#define CONF_PAN_ID (0xabcd)
#endif
extern int main(void);
void auto_init(void)
{
#ifdef MODULE_VTIMER
@ -186,6 +184,4 @@ void auto_init(void)
DEBUG("Auto init transport layer [destiny] module.\n");
destiny_init_transport_layer();
#endif
main();
}

7
sys/chardev_thread.c

@ -127,3 +127,10 @@ void chardev_loop(ringbuffer_t *rb)
}
}
}
void *chardev_thread_entry(void *rb_)
{
ringbuffer_t *rb = rb_;
chardev_loop(rb);
return NULL;
}

1
sys/include/chardev_thread.h

@ -11,5 +11,6 @@
#include "ringbuffer.h"
void chardev_loop(ringbuffer_t *rb);
void *chardev_thread_entry(void *rb_);
#endif /* __CHARDEV_THREAD_H */

3
sys/net/include/etx_beaconing.h

@ -81,11 +81,8 @@ typedef struct etx_neighbor_t {
//prototypes
void etx_init_beaconing(ipv6_addr_t *address);
void etx_beacon(void);
void etx_clock(void);
double etx_get_metric(ipv6_addr_t *address);
void etx_update(etx_neighbor_t *neighbor);
void etx_radio(void);
#define ETX_PKT_OPT (0) //Position of Option-Type-Byte
#define ETX_PKT_OPTVAL (0x20) //Non-standard way of saying this is an ETX-Packet.

4
sys/net/network_layer/sixlowpan/ip.c

@ -331,8 +331,10 @@ int is_our_address(ipv6_addr_t *addr)
return 0;
}
void ipv6_process(void)
void *ipv6_process(void *arg)
{
(void) arg;
msg_t m_recv_lowpan, m_send_lowpan;
msg_t m_recv, m_send;
uint8_t i;

2
sys/net/network_layer/sixlowpan/ip.h

@ -93,7 +93,7 @@ uint8_t *get_payload_buf_send(uint8_t ext_len);
int icmpv6_demultiplex(const icmpv6_hdr_t *hdr);
int ipv6_init_as_router(void);
void ipv6_process(void);
void *ipv6_process(void *);
ipv6_net_if_hit_t *ipv6_net_if_addr_prefix_eq(ipv6_net_if_hit_t *hit, ipv6_addr_t *addr);
ipv6_net_if_hit_t *ipv6_net_if_addr_match(ipv6_net_if_hit_t *hit, const ipv6_addr_t *addr);
uint32_t get_remaining_time(timex_t *t);

20
sys/net/network_layer/sixlowpan/lowpan.c

@ -142,7 +142,6 @@ uint8_t context_len = 0;
uint16_t local_address = 0;
int lowpan_init(int as_border);
void lowpan_context_auto_remove(void);
uint8_t lowpan_iphc_encoding(int if_id, const uint8_t *dest, int dest_len,
ipv6_hdr_t *ipv6_buf_extra, uint8_t *ptr);
void lowpan_iphc_decoding(uint8_t *data, uint8_t length, net_if_eui64_t *s_addr,
@ -358,15 +357,16 @@ void sixlowpan_lowpan_print_fifo_buffers(void)
}
#endif
void lowpan_transfer(void)
static void *lowpan_transfer(void *arg)
{
(void) arg;
msg_t m_recv, m_send;
ipv6_hdr_t *ipv6_buf;
lowpan_reas_buf_t *current_buf;
uint8_t gotosleep;
while (1) {
gotosleep = 1;
mutex_lock(&fifo_mutex);
current_buf = packet_fifo;
@ -419,6 +419,8 @@ void lowpan_transfer(void)
thread_sleep();
}
}
return NULL;
}
uint8_t ll_get_addr_match(net_if_eui64_t *src, net_if_eui64_t *dst)
@ -1633,8 +1635,10 @@ lowpan_context_t *lowpan_context_num_lookup(uint8_t num)
return NULL;
}
void lowpan_context_auto_remove(void)
static void *lowpan_context_auto_remove(void *arg)
{
(void) arg;
timex_t minute = timex_set(60, 0);
int i;
int8_t to_remove[NDP_6LOWPAN_CONTEXT_MAX];
@ -1657,6 +1661,8 @@ void lowpan_context_auto_remove(void)
mutex_unlock(&lowpan_context_mutex);
}
return NULL;
}
void init_reas_bufs(lowpan_reas_buf_t *buf)
@ -1791,7 +1797,7 @@ int sixlowpan_lowpan_init(void)
if (!ip_process_pid) {
ip_process_pid = thread_create(ip_process_buf, IP_PROCESS_STACKSIZE,
PRIORITY_MAIN - 1, CREATE_STACKTEST,
ipv6_process, "ip_process");
ipv6_process, NULL, "ip_process");
}
if (ip_process_pid < 0) {
@ -1802,7 +1808,7 @@ int sixlowpan_lowpan_init(void)
contexts_rem_pid = thread_create(con_buf, CON_STACKSIZE,
PRIORITY_MAIN + 1, CREATE_STACKTEST,
lowpan_context_auto_remove, "lowpan_context_rem");
lowpan_context_auto_remove, NULL, "lowpan_context_rem");
if (contexts_rem_pid < 0) {
return 0;
@ -1810,7 +1816,7 @@ int sixlowpan_lowpan_init(void)
transfer_pid = thread_create(lowpan_transfer_buf, LOWPAN_TRANSFER_BUF_STACKSIZE,
PRIORITY_MAIN - 1, CREATE_STACKTEST,
lowpan_transfer, "lowpan_transfer");
lowpan_transfer, NULL, "lowpan_transfer");
if (transfer_pid < 0) {
return 0;

8
sys/net/network_layer/sixlowpan/mac.c

@ -63,8 +63,10 @@ static inline void mac_frame_short_to_eui64(net_if_eui64_t *eui64,
eui64->uint8[7] = frame_short[0];
}
void recv_ieee802154_frame(void)
static void *recv_ieee802154_frame(void *arg)
{
(void) arg;
msg_t m;
#if (defined(MODULE_AT86RF231) | \
defined(MODULE_CC2420) | \
@ -164,6 +166,8 @@ void recv_ieee802154_frame(void)
DEBUG("Unknown packet received");
}
}
return NULL;
}
void set_ieee802154_fcf_values(ieee802154_frame_t *frame, uint8_t dest_mode,
@ -317,7 +321,7 @@ int sixlowpan_mac_send_ieee802154_frame(int if_id,
int sixlowpan_mac_init(void)
{
int recv_pid = thread_create(radio_stack_buffer, RADIO_STACK_SIZE,
PRIORITY_MAIN - 2, CREATE_STACKTEST, recv_ieee802154_frame , "radio");
PRIORITY_MAIN - 2, CREATE_STACKTEST, recv_ieee802154_frame, NULL, "radio");
int if_id = -1;
while ((if_id = net_if_iter_interfaces(if_id)) >= 0) {

28
sys/net/routing/etx_beaconing.c

@ -47,6 +47,10 @@ static uint8_t etx_count_packet_tx(etx_neighbor_t *candidate);
static void etx_set_packets_received(void);
static bool etx_equal_id(ipv6_addr_t *id1, ipv6_addr_t *id2);
static void *etx_beacon(void *);
static void *etx_clock(void *);
static void *etx_radio(void *);
//Buffer
static char etx_beacon_buf[ETX_BEACON_STACKSIZE];
static char etx_radio_buf[ETX_RADIO_STACKSIZE];
@ -145,22 +149,24 @@ void etx_init_beaconing(ipv6_addr_t *address)
etx_beacon_pid = thread_create(etx_beacon_buf, ETX_BEACON_STACKSIZE,
PRIORITY_MAIN - 1, CREATE_STACKTEST,
etx_beacon, "etx_beacon");
etx_beacon, NULL, "etx_beacon");
etx_radio_pid = thread_create(etx_radio_buf, ETX_RADIO_STACKSIZE,
PRIORITY_MAIN - 1, CREATE_STACKTEST,
etx_radio, "etx_radio");
etx_radio, NULL, "etx_radio");
etx_clock_pid = thread_create(etx_clock_buf, ETX_CLOCK_STACKSIZE,
PRIORITY_MAIN - 1, CREATE_STACKTEST,
etx_clock, "etx_clock");
etx_clock, NULL, "etx_clock");
//register at transceiver
transceiver_register(TRANSCEIVER_CC1100, etx_radio_pid);
puts("...[DONE]");
}
void etx_beacon(void)
static void *etx_beacon(void *arg)
{
(void) arg;
/*
* Sends a message every ETX_INTERVAL +/- a jitter-value (default is 10%) .
* A correcting variable is needed to stay at a base interval of
@ -207,6 +213,8 @@ void etx_beacon(void)
mutex_unlock(&etx_mutex);
}
return NULL;
}
etx_neighbor_t *etx_find_candidate(ipv6_addr_t *address)
@ -225,8 +233,10 @@ etx_neighbor_t *etx_find_candidate(ipv6_addr_t *address)
return NULL ;
}
void etx_clock(void)
static void *etx_clock(void *arg)
{
(void) arg;
/*
* Manages the etx_beacon thread to wake up every full second +- jitter
*/
@ -256,6 +266,8 @@ void etx_clock(void)
jittercorrection = (ETX_MAX_JITTER) - jitter;
jitter = (uint8_t)(rand() % ETX_JITTER_MOD);
}
return NULL;
}
double etx_get_metric(ipv6_addr_t *address)
@ -377,8 +389,10 @@ void etx_handle_beacon(ipv6_addr_t *candidate_address)
etx_update(candidate);
}
void etx_radio(void)
static void *etx_radio(void *arg)
{
(void) arg;
msg_t m;
radio_packet_t *p;
@ -423,6 +437,8 @@ void etx_radio(void)
//packet is not for me, whatever
}
}
return NULL;
}
void etx_update(etx_neighbor_t *candidate)

6
sys/net/routing/rpl/rpl.c

@ -82,7 +82,7 @@ uint8_t rpl_init(int if_id)
init_trickle();
rpl_process_pid = thread_create(rpl_process_buf, RPL_PROCESS_STACKSIZE,
PRIORITY_MAIN - 1, CREATE_STACKTEST,
rpl_process, "rpl_process");
rpl_process, NULL, "rpl_process");
/* INSERT NEW OBJECTIVE FUNCTIONS HERE */
rpl_objective_functions[0] = rpl_get_of0();
@ -112,8 +112,10 @@ void rpl_init_root(void)
rpl_init_root_mode();
}
void rpl_process(void)
void *rpl_process(void *arg)
{
(void) arg;
msg_t m_recv;
msg_init_queue(rpl_msg_queue, RPL_PKT_RECV_BUF_SIZE);

4
sys/net/routing/rpl/rpl.h

@ -188,8 +188,10 @@ void recv_rpl_DAO_ACK(void);
* sending and receiving RPL-based messages. Both are necessary because of parallel access from different
* layers/modules of RIOT. May change with future structure changes.
*
* @param arg ignored
* @returns nothing
*/
void rpl_process(void);
void *rpl_process(void *arg);
/**
* @brief Returns next hop from routing table.

42
sys/net/routing/rpl/trickle.c

@ -28,10 +28,10 @@
#include "debug.h"
/* thread stacks */
char timer_over_buf[TRICKLE_TIMER_STACKSIZE];
char interval_over_buf[TRICKLE_INTERVAL_STACKSIZE];
char dao_delay_over_buf[DAO_DELAY_STACKSIZE];
char routing_table_buf[RT_STACKSIZE];
static char timer_over_buf[TRICKLE_TIMER_STACKSIZE];
static char interval_over_buf[TRICKLE_INTERVAL_STACKSIZE];
static char dao_delay_over_buf[DAO_DELAY_STACKSIZE];
static char routing_table_buf[RT_STACKSIZE];
int timer_over_pid;
int interval_over_pid;
@ -56,6 +56,11 @@ timex_t I_time;
timex_t dao_time;
timex_t rt_time;
static void *trickle_timer_over(void *arg);
static void *trickle_interval_over(void *arg);
static void *dao_delay_over(void *arg);
static void *rt_timer_over(void *arg);
void reset_trickletimer(void)
{
I = Imin;
@ -80,17 +85,17 @@ void init_trickle(void)
dao_counter = 0;
timer_over_pid = thread_create(timer_over_buf, TRICKLE_TIMER_STACKSIZE,
PRIORITY_MAIN - 1, CREATE_STACKTEST,
trickle_timer_over, "trickle_timer_over");
trickle_timer_over, NULL, "trickle_timer_over");
interval_over_pid = thread_create(interval_over_buf, TRICKLE_INTERVAL_STACKSIZE,
PRIORITY_MAIN - 1, CREATE_STACKTEST,
trickle_interval_over, "trickle_interval_over");
trickle_interval_over, NULL, "trickle_interval_over");
dao_delay_over_pid = thread_create(dao_delay_over_buf, DAO_DELAY_STACKSIZE,
PRIORITY_MAIN - 1, CREATE_STACKTEST,
dao_delay_over, "dao_delay_over");
dao_delay_over, NULL, "dao_delay_over");
rt_timer_over_pid = thread_create(routing_table_buf, RT_STACKSIZE,
PRIORITY_MAIN - 1, CREATE_STACKTEST,
rt_timer_over, "rt_timer_over");
rt_timer_over, NULL, "rt_timer_over");
}
void start_trickle(uint8_t DIOIntMin, uint8_t DIOIntDoubl,
@ -121,8 +126,10 @@ void trickle_increment_counter(void)
c++;
}
void trickle_timer_over(void)
static void *trickle_timer_over(void *arg)
{
(void) arg;
ipv6_addr_t mcast;
ipv6_addr_set_all_nodes_addr(&mcast);
@ -134,10 +141,14 @@ void trickle_timer_over(void)
send_DIO(&mcast);
}
}
return NULL;
}
void trickle_interval_over(void)
static void *trickle_interval_over(void *arg)
{
(void) arg;
while (1) {
thread_sleep();
I = I * 2;
@ -178,6 +189,7 @@ void trickle_interval_over(void)
}
}
return NULL;
}
void delay_dao(void)
@ -199,8 +211,9 @@ void long_delay_dao(void)
vtimer_set_wakeup(&dao_timer, dao_time, dao_delay_over_pid);
}
void dao_delay_over(void)
static void *dao_delay_over(void *arg)
{
(void) arg;
while (1) {
thread_sleep();
@ -215,6 +228,7 @@ void dao_delay_over(void)
long_delay_dao();
}
}
return NULL;
}
void dao_ack_received(void)
@ -223,8 +237,10 @@ void dao_ack_received(void)
long_delay_dao();
}
void rt_timer_over(void)
static void *rt_timer_over(void *arg)
{
(void) arg;
rpl_routing_entry_t *rt;
while (1) {
@ -259,4 +275,6 @@ void rt_timer_over(void)
/* Wake up every second */
vtimer_usleep(1000000);
}
return NULL;
}

4
sys/net/routing/rpl/trickle.h

@ -27,9 +27,5 @@ void reset_trickletimer(void);
void init_trickle(void);
void start_trickle(uint8_t DIOINtMin, uint8_t DIOIntDoubl, uint8_t DIORedundancyConstatnt);
void trickle_increment_counter(void);
void trickle_timer_over(void);
void trickle_interval_over(void);
void delay_dao(void);
void dao_delay_over(void);
void dao_ack_received(void);
void rt_timer_over(void);

6
sys/net/transport_layer/destiny/destiny.c

@ -44,7 +44,7 @@ int destiny_init_transport_layer(void)
/* UDP */
int udp_thread_pid = thread_create(udp_stack_buffer, UDP_STACK_SIZE,
PRIORITY_MAIN, CREATE_STACKTEST,
udp_packet_handler, "udp_packet_handler");
udp_packet_handler, NULL, "udp_packet_handler");
if (udp_thread_pid < 0) {
return -1;
@ -64,7 +64,7 @@ int destiny_init_transport_layer(void)
int tcp_thread_pid = thread_create(tcp_stack_buffer, TCP_STACK_SIZE,
PRIORITY_MAIN, CREATE_STACKTEST,
tcp_packet_handler, "tcp_packet_handler");
tcp_packet_handler, NULL, "tcp_packet_handler");
if (tcp_thread_pid < 0) {
return -1;
@ -73,7 +73,7 @@ int destiny_init_transport_layer(void)
ipv6_register_next_header_handler(IPV6_PROTO_NUM_TCP, tcp_thread_pid);
if (thread_create(tcp_timer_stack, TCP_TIMER_STACKSIZE, PRIORITY_MAIN + 1,
CREATE_STACKTEST, tcp_general_timer, "tcp_general_timer") < 0) {
CREATE_STACKTEST, tcp_general_timer, NULL, "tcp_general_timer") < 0) {
return -1;
}

4
sys/net/transport_layer/destiny/tcp.c

@ -306,8 +306,10 @@ void handle_tcp_no_flags_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
}
}
void tcp_packet_handler(void)
void *tcp_packet_handler(void *arg)
{
(void) arg;
msg_t m_recv_ip, m_send_ip;
ipv6_hdr_t *ipv6_header;
tcp_hdr_t *tcp_header;

2
sys/net/transport_layer/destiny/tcp.h

@ -96,7 +96,7 @@ extern uint8_t global_context_counter;
extern mutex_t global_sequence_counter_mutex;
extern uint32_t global_sequence_counter;
void tcp_packet_handler(void);
void *tcp_packet_handler(void *);
uint16_t tcp_csum(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header);
void printTCPHeader(tcp_hdr_t *tcp_header);
void printArrayRange_tcp(uint8_t *udp_header, uint16_t len);

4
sys/net/transport_layer/destiny/tcp_timer.c

@ -140,8 +140,10 @@ void inc_global_variables(void)
#endif
}
void tcp_general_timer(void)
void *tcp_general_timer(void *arg)
{
(void) arg;
vtimer_t tcp_vtimer;
timex_t interval = timex_set(0, TCP_TIMER_RESOLUTION);

2
sys/net/transport_layer/destiny/tcp_timer.h

@ -33,7 +33,7 @@
#define TCP_TIMEOUT 2
#define TCP_CONTINUE 3
void tcp_general_timer(void);
void *tcp_general_timer(void *);
#endif /* TCP_TIMER_H_ */
/**

4
sys/net/transport_layer/destiny/udp.c

@ -45,8 +45,10 @@ uint16_t udp_csum(ipv6_hdr_t *ipv6_header, udp_hdr_t *udp_header)
return (sum == 0) ? 0xffff : HTONS(sum);
}
void udp_packet_handler(void)
void *udp_packet_handler(void *arg)
{
(void) arg;
msg_t m_recv_ip, m_send_ip, m_recv_udp, m_send_udp;
ipv6_hdr_t *ipv6_header;
udp_hdr_t *udp_header;

2
sys/net/transport_layer/destiny/udp.h

@ -25,7 +25,7 @@
#define UDP_PKT_RECV_BUF_SIZE (64)
uint16_t udp_csum(ipv6_hdr_t *ipv6_header, udp_hdr_t *udp_header);
void udp_packet_handler(void);
void *udp_packet_handler(void *);
/**
* @}

14
sys/posix/pthread/pthread.c

@ -76,11 +76,9 @@ static volatile int pthread_reaper_pid = -1;
static char pthread_reaper_stack[PTHREAD_REAPER_STACKSIZE];
static void pthread_start_routine(void)
static void *pthread_start_routine(void *pt_)
{
pthread_t self = pthread_self();
pthread_thread_t *pt = pthread_sched_threads[self-1];
pthread_thread_t *pt = pt_;
void *retval = pt->start_routine(pt->arg);
pthread_exit(retval);
}
@ -100,14 +98,18 @@ static int insert(pthread_thread_t *pt)
return result;
}
static void pthread_reaper(void)
static void *pthread_reaper(void *arg)
{
(void) arg;
while (1) {
msg_t m;
msg_receive(&m);
DEBUG("pthread_reaper(): free(%p)\n", m.content.ptr);
free(m.content.ptr);
}
return NULL;
}
int pthread_create(pthread_t *newthread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
@ -139,6 +141,7 @@ int pthread_create(pthread_t *newthread, const pthread_attr_t *attr, void *(*sta
0,
CREATE_STACKTEST,
pthread_reaper,
NULL,
"pthread-reaper");
pthread_reaper_pid = pid;
}
@ -150,6 +153,7 @@ int pthread_create(pthread_t *newthread, const pthread_attr_t *attr, void *(*sta
PRIORITY_MAIN,
CREATE_WOUT_YIELD | CREATE_STACKTEST,
pthread_start_routine,
pt,
"pthread");
if (pt->thread_pid < 0) {
free(pt->stack);

12
sys/transceiver/transceiver.c

@ -106,7 +106,7 @@ char transceiver_stack[TRANSCEIVER_STACK_SIZE];
/*------------------------------------------------------------------------------------*/
/* function prototypes */
static void run(void);
static void *run(void *arg);
static void receive_packet(uint16_t type, uint8_t pos);
#ifdef MODULE_CC110X_NG
static void receive_cc110x_packet(radio_packet_t *trans_p);
@ -180,7 +180,7 @@ void transceiver_init(transceiver_type_t t)
/* Start the transceiver thread */
int transceiver_start(void)
{
transceiver_pid = thread_create(transceiver_stack, TRANSCEIVER_STACK_SIZE, PRIORITY_MAIN - 3, CREATE_STACKTEST, run, "Transceiver");
transceiver_pid = thread_create(transceiver_stack, TRANSCEIVER_STACK_SIZE, PRIORITY_MAIN - 3, CREATE_STACKTEST, run, NULL, "Transceiver");
if (transceiver_pid < 0) {
puts("Error creating transceiver thread");
@ -259,8 +259,10 @@ uint8_t transceiver_register(transceiver_type_t t, int pid)
* @brief The main thread run, receiving and processing messages in an infinite
* loop
*/
void run(void)
static void *run(void *arg)
{
(void) arg;
msg_t m;
transceiver_command_t *cmd;
@ -340,8 +342,8 @@ void run(void)
*((int32_t *) cmd->data) = set_pan(cmd->transceivers, cmd->data);
msg_reply(&m, &m);
break;
#ifdef DBG_IGNORE
#ifdef DBG_IGNORE
case DBG_IGN:
*((int16_t *) cmd->data) = ignore_add(cmd->transceivers, cmd->data);
msg_reply(&m, &m);
@ -353,6 +355,8 @@ void run(void)
break;
}
}
return NULL;
}
/*------------------------------------------------------------------------------------*/

8
sys/uart0/uart0.c

@ -45,11 +45,6 @@ static char buffer[UART0_BUFSIZE];
static char uart0_thread_stack[UART0_STACKSIZE];
static void uart0_loop(void)
{
chardev_loop(&uart0_ringbuffer);
}
void board_uart0_init(void)
{
ringbuffer_init(&uart0_ringbuffer, buffer, UART0_BUFSIZE);
@ -58,7 +53,8 @@ void board_uart0_init(void)
sizeof(uart0_thread_stack),
PRIORITY_MAIN - 1,
CREATE_STACKTEST | CREATE_SLEEPING,
uart0_loop,
chardev_thread_entry,
&uart0_ringbuffer,
"uart0"
);
uart0_handler_pid = pid;

28
tests/test_ipc_pingpong/main.c

@ -33,8 +33,10 @@
static char stacks[3][KERNEL_CONF_STACKSIZE_MAIN];
static int pids[3];
static void first_thread(void)
static void *first_thread(void *arg)
{
(void) arg;
puts("1st starting.");
for (unsigned i = 0; i < LIMIT; ++i) {
msg_t m;
@ -44,14 +46,18 @@ static void first_thread(void)
DEBUG("%u: Got msg with content %i\n", i, m.content.value);
if (m.content.value != i + 1) {
puts("ERROR. 1st");
return;
return NULL;
}
}
puts("1st done.");
return NULL;
}
static void second_thread(void)
static void *second_thread(void *arg)
{