diff --git a/boards/avsextrem/drivers/avsextrem-smb380.c b/boards/avsextrem/drivers/avsextrem-smb380.c index 017f78249da1..ac52d99a8def 100644 --- a/boards/avsextrem/drivers/avsextrem-smb380.c +++ b/boards/avsextrem/drivers/avsextrem-smb380.c @@ -44,7 +44,7 @@ #include "lpc2387.h" -uint8_t simple_pid; +kernel_pid_t simple_pid; int16_t simple_buffer[4]; volatile int16_t *ringBuff_X = NULL; diff --git a/boards/msba2-common/drivers/include/uart0.h b/boards/msba2-common/drivers/include/uart0.h index 9ed716a1dea1..dd0f4f48f515 100644 --- a/boards/msba2-common/drivers/include/uart0.h +++ b/boards/msba2-common/drivers/include/uart0.h @@ -1,6 +1,6 @@ #ifndef __UART0_H #define __UART0_H -extern int uart0_handler_pid; +extern kernel_pid_t uart0_handler_pid; #endif /* __UART0_H */ diff --git a/core/include/kernel.h b/core/include/kernel.h index a781fc92062e..2d619c39ee2d 100644 --- a/core/include/kernel.h +++ b/core/include/kernel.h @@ -24,6 +24,7 @@ #define KERNEL_H_ #include +#include #include "attributes.h" #include "config.h" @@ -67,12 +68,11 @@ #endif /* ------------------------------------------------------------------------- */ - /** * @def PID_NULL * @brief Identifier to detect an invalid PID */ -#define PID_NULL -1 +#define KERNEL_PID_NULL -1 /** * @def PRIORITY_MIN diff --git a/core/include/kernel_types.h b/core/include/kernel_types.h new file mode 100644 index 000000000000..01e97964ba08 --- /dev/null +++ b/core/include/kernel_types.h @@ -0,0 +1,17 @@ +#ifndef KERNEL_TYPES_H +#define KERNEL_TYPES_H + +#include + +/** + * Macro for printing formatter + */ +#define PRIkernel_pid PRIi16 + +/** + * @brief Unique process identifier + * + */ +typedef int16_t kernel_pid_t; + +#endif /* KERNEL_TYPES_H */ diff --git a/core/include/msg.h b/core/include/msg.h index fe29e23c02e5..d9d0ec560550 100644 --- a/core/include/msg.h +++ b/core/include/msg.h @@ -35,6 +35,7 @@ #include #include +#include "kernel_types.h" /** * @brief Describes a message object which can be sent between threads. @@ -45,7 +46,7 @@ * */ typedef struct msg { - uint16_t sender_pid; /**< PID of sending thread. Will be filled in + kernel_pid_t sender_pid; /**< PID of sending thread. Will be filled in by msg_send. */ uint16_t type; /**< Type field. */ union { @@ -75,7 +76,7 @@ typedef struct msg { * ``block == 0`` * @return -1, on error (invalid PID) */ -int msg_send(msg_t *m, unsigned int target_pid, bool block); +int msg_send(msg_t *m, kernel_pid_t target_pid, bool block); /** @@ -107,7 +108,7 @@ int msg_send_to_self(msg_t *m); * @return 0, if receiver is not waiting and ``block == 0`` * @return -1, on error (invalid PID) */ -int msg_send_int(msg_t *m, unsigned int target_pid); +int msg_send_int(msg_t *m, kernel_pid_t target_pid); /** @@ -151,7 +152,7 @@ int msg_try_receive(msg_t *m); * * @return 1, if successful. */ -int msg_send_receive(msg_t *m, msg_t *reply, unsigned int target_pid); +int msg_send_receive(msg_t *m, msg_t *reply, kernel_pid_t target_pid); /** * @brief Replies to a message. diff --git a/core/include/sched.h b/core/include/sched.h index e024765cf306..4df0be1daa91 100644 --- a/core/include/sched.h +++ b/core/include/sched.h @@ -91,7 +91,7 @@ extern volatile int sched_num_threads; /** * Process ID of active thread */ -extern volatile int sched_active_pid; +extern volatile kernel_pid_t sched_active_pid; /** * List of runqueues per priority level diff --git a/core/include/tcb.h b/core/include/tcb.h index 3bbac882bc1c..e4fda66380f4 100644 --- a/core/include/tcb.h +++ b/core/include/tcb.h @@ -60,7 +60,7 @@ typedef struct tcb_t { char *sp; /**< thread's stack pointer */ uint16_t status; /**< thread's status */ - uint16_t pid; /**< thread's process id */ + kernel_pid_t pid; /**< thread's process id */ uint16_t priority; /**< thread's priority */ clist_node_t rq_entry; /**< run queue entry */ diff --git a/core/include/thread.h b/core/include/thread.h index e4097afc6509..ff2fb2096912 100644 --- a/core/include/thread.h +++ b/core/include/thread.h @@ -73,7 +73,7 @@ * @return value ``<0`` on error * @return pid of newly created task, otherwise */ -int thread_create(char *stack, +kernel_pid_t thread_create(char *stack, int stacksize, char priority, int flags, @@ -88,7 +88,7 @@ int thread_create(char *stack, * @return status of the thread * @return `STATUS_NOT_FOUND` if pid is unknown */ -int thread_getstatus(int pid); +int thread_getstatus(kernel_pid_t pid); /** * @brief Returns the name of a process @@ -98,7 +98,7 @@ int thread_getstatus(int pid); * @return the threads name * @return `NULL` if pid is unknown */ -const char *thread_getname(int pid); +const char *thread_getname(kernel_pid_t pid); /** * @brief Puts the current thread into sleep mode. Has to be woken up externally. @@ -121,7 +121,7 @@ void thread_yield(void); * @return `1` on success * @return `STATUS_NOT_FOUND` if pid is unknown or not sleeping */ -int thread_wakeup(int pid); +int thread_wakeup(kernel_pid_t pid); /** @@ -129,7 +129,7 @@ int thread_wakeup(int pid); * * @return obviously you are not a golfer. */ -int thread_getpid(void); +kernel_pid_t thread_getpid(void); /** * @brief Measures the stack usage of a stack diff --git a/core/msg.c b/core/msg.c index 3d50fb1b34ad..0a53449d2952 100644 --- a/core/msg.c +++ b/core/msg.c @@ -52,13 +52,13 @@ static int queue_msg(tcb_t *target, msg_t *m) return 0; } -int msg_send(msg_t *m, unsigned int target_pid, bool block) +int msg_send(msg_t *m, kernel_pid_t target_pid, bool block) { if (inISR()) { return msg_send_int(m, target_pid); } - if ((unsigned int)sched_active_pid == target_pid) { + if (sched_active_pid == target_pid) { return msg_send_to_self(m); } @@ -74,12 +74,12 @@ int msg_send(msg_t *m, unsigned int target_pid, bool block) return -1; } - DEBUG("msg_send() %s:%i: Sending from %i to %i. block=%i src->state=%i target->state=%i\n", __FILE__, __LINE__, sched_active_pid, target_pid, block, sched_active_thread->status, target->status); + DEBUG("msg_send() %s:%i: Sending from %" PRIkernel_pid " to %" PRIkernel_pid ". block=%i src->state=%i target->state=%i\n", __FILE__, __LINE__, sched_active_pid, target_pid, block, sched_active_thread->status, target->status); if (target->status != STATUS_RECEIVE_BLOCKED) { - DEBUG("msg_send() %s:%i: Target %i is not RECEIVE_BLOCKED.\n", __FILE__, __LINE__, target_pid); + DEBUG("msg_send() %s:%i: Target %" PRIkernel_pid " is not RECEIVE_BLOCKED.\n", __FILE__, __LINE__, target_pid); if (target->msg_array && queue_msg(target, m)) { - DEBUG("msg_send() %s:%i: Target %i has a msg_queue. Queueing message.\n", __FILE__, __LINE__, target_pid); + DEBUG("msg_send() %s:%i: Target %" PRIkernel_pid " has a msg_queue. Queueing message.\n", __FILE__, __LINE__, target_pid); eINT(); if (sched_active_thread->status == STATUS_REPLY_BLOCKED) { thread_yield(); @@ -118,7 +118,7 @@ int msg_send(msg_t *m, unsigned int target_pid, bool block) DEBUG("msg_send: %s: Back from send block.\n", sched_active_thread->name); } else { - DEBUG("msg_send: %s: Direct msg copy from %i to %i.\n", sched_active_thread->name, thread_getpid(), target_pid); + DEBUG("msg_send: %s: Direct msg copy from %" PRIkernel_pid " to %" PRIkernel_pid ".\n", sched_active_thread->name, thread_getpid(), target_pid); /* copy msg to target */ msg_t *target_message = (msg_t*) target->wait_data; *target_message = *m; @@ -142,7 +142,7 @@ int msg_send_to_self(msg_t *m) return res; } -int msg_send_int(msg_t *m, unsigned int target_pid) +int msg_send_int(msg_t *m, kernel_pid_t target_pid) { tcb_t *target = (tcb_t *) sched_threads[target_pid]; @@ -152,7 +152,7 @@ int msg_send_int(msg_t *m, unsigned int target_pid) } if (target->status == STATUS_RECEIVE_BLOCKED) { - DEBUG("msg_send_int: Direct msg copy from %i to %i.\n", thread_getpid(), target_pid); + DEBUG("msg_send_int: Direct msg copy from %" PRIkernel_pid " to %" PRIkernel_pid ".\n", thread_getpid(), target_pid); m->sender_pid = target_pid; @@ -170,7 +170,7 @@ int msg_send_int(msg_t *m, unsigned int target_pid) } } -int msg_send_receive(msg_t *m, msg_t *reply, unsigned int target_pid) +int msg_send_receive(msg_t *m, msg_t *reply, kernel_pid_t target_pid) { dINT(); tcb_t *me = (tcb_t*) sched_threads[sched_active_pid]; @@ -189,7 +189,7 @@ int msg_reply(msg_t *m, msg_t *reply) tcb_t *target = (tcb_t*) sched_threads[m->sender_pid]; if (!target) { - DEBUG("msg_reply(): %s: Target \"%" PRIu16 "\" not existing...dropping msg!\n", sched_active_thread->name, m->sender_pid); + DEBUG("msg_reply(): %s: Target \"%" PRIkernel_pid "\" not existing...dropping msg!\n", sched_active_thread->name, m->sender_pid); return -1; } diff --git a/core/mutex.c b/core/mutex.c index ea60f76ee5c5..7575f21a736f 100644 --- a/core/mutex.c +++ b/core/mutex.c @@ -97,7 +97,7 @@ static void mutex_wait(struct mutex_t *mutex) void mutex_unlock(struct mutex_t *mutex) { - DEBUG("%s: unlocking mutex. val: %u pid: %u\n", sched_active_thread->name, mutex->val, sched_active_pid); + DEBUG("%s: unlocking mutex. val: %u pid: %" PRIkernel_pid "\n", sched_active_thread->name, mutex->val, sched_active_pid); int irqstate = disableIRQ(); if (mutex->val != 0) { @@ -119,7 +119,7 @@ void mutex_unlock(struct mutex_t *mutex) void mutex_unlock_and_sleep(struct mutex_t *mutex) { - DEBUG("%s: unlocking mutex. val: %u pid: %u, and taking a nap\n", sched_active_thread->name, mutex->val, sched_active_pid); + DEBUG("%s: unlocking mutex. val: %u pid: %" PRIkernel_pid ", and taking a nap\n", sched_active_thread->name, mutex->val, sched_active_pid); int irqstate = disableIRQ(); if (mutex->val != 0) { diff --git a/core/sched.c b/core/sched.c index 3c02b82cce39..55bddf37424d 100644 --- a/core/sched.c +++ b/core/sched.c @@ -44,7 +44,7 @@ volatile unsigned int sched_context_switch_request; volatile tcb_t *sched_threads[MAXTHREADS]; volatile tcb_t *sched_active_thread; -volatile int sched_active_pid = -1; +volatile kernel_pid_t sched_active_pid = KERNEL_PID_NULL; clist_node_t *sched_runqueues[SCHED_PRIO_LEVELS]; static uint32_t runqueue_bitcache = 0; @@ -71,7 +71,7 @@ void sched_run(void) #ifdef SCHED_TEST_STACK if (*((unsigned int *)my_active_thread->stack_start) != (unsigned int) my_active_thread->stack_start) { - printf("scheduler(): stack overflow detected, task=%s pid=%u\n", my_active_thread->name, my_active_thread->pid); + printf("scheduler(): stack overflow detected, task=%s pid=%" PRIkernel_pid "\n", my_active_thread->name, my_active_thread->pid); } #endif @@ -93,7 +93,7 @@ void sched_run(void) clist_advance(&(sched_runqueues[nextrq])); my_active_thread = (tcb_t *)next.data; - int my_next_pid = my_active_thread->pid; + kernel_pid_t my_next_pid = my_active_thread->pid; #if SCHEDSTATISTICS sched_pidlist[my_next_pid].laststart = time; diff --git a/core/thread.c b/core/thread.c index fc76188b9f0e..2cb5767ddc42 100644 --- a/core/thread.c +++ b/core/thread.c @@ -32,12 +32,12 @@ #include "hwtimer.h" #include "sched.h" -inline int thread_getpid(void) +inline kernel_pid_t thread_getpid(void) { return sched_active_thread->pid; } -int thread_getstatus(int pid) +int thread_getstatus(kernel_pid_t pid) { if (sched_threads[pid] == NULL) { return STATUS_NOT_FOUND; @@ -46,7 +46,7 @@ int thread_getstatus(int pid) return sched_threads[pid]->status; } -const char *thread_getname(int pid) +const char *thread_getname(kernel_pid_t pid) { if (sched_threads[pid] == NULL) { return NULL; @@ -67,9 +67,9 @@ void thread_sleep(void) thread_yield(); } -int thread_wakeup(int pid) +int thread_wakeup(kernel_pid_t pid) { - DEBUG("thread_wakeup: Trying to wakeup PID %i...\n", pid); + DEBUG("thread_wakeup: Trying to wakeup PID %" PRIkernel_pid "...\n", pid); int old_state = disableIRQ(); @@ -106,7 +106,7 @@ int thread_measure_stack_free(char *stack) return space_free; } -int thread_create(char *stack, int stacksize, char priority, int flags, void *(*function)(void *arg), void *arg, const char *name) +kernel_pid_t 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; @@ -150,7 +150,7 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void *(* dINT(); } - int pid = 0; + kernel_pid_t pid = 0; while (pid < MAXTHREADS) { if (sched_threads[pid] == NULL) { @@ -196,7 +196,7 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void *(* sched_num_threads++; - DEBUG("Created thread %s. PID: %u. Priority: %u.\n", name, cb->pid, priority); + DEBUG("Created thread %s. PID: %" PRIkernel_pid ". Priority: %u.\n", name, cb->pid, priority); if (flags & CREATE_SLEEPING) { sched_set_status(cb, STATUS_SLEEPING); diff --git a/cpu/arm_common/gettimeofday.c b/cpu/arm_common/gettimeofday.c index ef96fb255dc5..8a16d153ab3a 100644 --- a/cpu/arm_common/gettimeofday.c +++ b/cpu/arm_common/gettimeofday.c @@ -19,6 +19,7 @@ */ #include +#include "kernel_types.h" #if defined MODULE_RTC # include "rtc.h" diff --git a/cpu/arm_common/syscalls.c b/cpu/arm_common/syscalls.c index c483d8de836b..7ad8f2e44236 100644 --- a/cpu/arm_common/syscalls.c +++ b/cpu/arm_common/syscalls.c @@ -263,9 +263,9 @@ void _exit(int n) while (1); } /*---------------------------------------------------------------------------*/ -int _getpid(void) +pid_t _getpid(void) { - return sched_active_thread->pid; + return (pid_t) sched_active_thread->pid; } /*---------------------------------------------------------------------------*/ int _kill_r(struct _reent *r, int pid, int sig) diff --git a/cpu/cc430/cc430-rtc.c b/cpu/cc430/cc430-rtc.c index 189aef0fcda3..99b03d692eb9 100644 --- a/cpu/cc430/cc430-rtc.c +++ b/cpu/cc430/cc430-rtc.c @@ -27,7 +27,7 @@ See the file LICENSE in the top level directory for more details. //static volatile time_t epoch; static struct tm time_to_set; static int set_time = 0; -int rtc_second_pid = 0; +kernel_pid_t rtc_second_pid = 0; /*---------------------------------------------------------------------------*/ void rtc_init(void) diff --git a/cpu/cortex-m3_common/thread_arch.c b/cpu/cortex-m3_common/thread_arch.c index f4001cc3423c..802da3308384 100644 --- a/cpu/cortex-m3_common/thread_arch.c +++ b/cpu/cortex-m3_common/thread_arch.c @@ -107,7 +107,7 @@ void thread_arch_stack_print(void) int count = 0; uint32_t *sp = (uint32_t *)sched_active_thread->sp; - printf("printing the current stack of thread %u\n", thread_getpid()); + printf("printing the current stack of thread %" PRIkernel_pid "\n", thread_getpid()); printf(" address: data:\n"); do { diff --git a/cpu/lpc1768/syscalls.c b/cpu/lpc1768/syscalls.c index 261019c94389..5c5d03c4c276 100644 --- a/cpu/lpc1768/syscalls.c +++ b/cpu/lpc1768/syscalls.c @@ -219,9 +219,9 @@ void _exit(int n) while(1); } /*---------------------------------------------------------------------------*/ -int _getpid(void) +pid_t _getpid(void) { - return sched_active_thread->pid; + return (pid_t) sched_active_thread->pid; } /*---------------------------------------------------------------------------*/ int _kill_r(struct _reent *r, int pid, int sig) diff --git a/cpu/lpc2387/rtc/lpc2387-rtc.c b/cpu/lpc2387/rtc/lpc2387-rtc.c index 811bd2639cce..88fa5e7629de 100644 --- a/cpu/lpc2387/rtc/lpc2387-rtc.c +++ b/cpu/lpc2387/rtc/lpc2387-rtc.c @@ -26,6 +26,8 @@ See the file LICENSE in the top level directory for more details. #include #include +#include "kernel_types.h" + /* cpu */ #include "VIC.h" #include "lpc2387.h" diff --git a/cpu/native/include/native_internal.h b/cpu/native/include/native_internal.h index 54c38e15d8c6..cb36cbba3e08 100644 --- a/cpu/native/include/native_internal.h +++ b/cpu/native/include/native_internal.h @@ -35,6 +35,7 @@ #endif #endif // BSD/Linux +#include "kernel_types.h" /** * internal functions diff --git a/cpu/native/net/interface.c b/cpu/native/net/interface.c index b11e141eff60..389c91497b52 100644 --- a/cpu/native/net/interface.c +++ b/cpu/native/net/interface.c @@ -55,7 +55,7 @@ uint64_t _native_net_addr_long; void nativenet_init(int transceiver_pid) { - DEBUG("nativenet_init(transceiver_pid=%d)\n", transceiver_pid); + DEBUG("nativenet_init(transceiver_pid=%" PRIkernel_pid ")\n", transceiver_pid); rx_buffer_next = 0; _native_net_pan = 0; _native_net_chan = 0; diff --git a/cpu/native/net/tap.c b/cpu/native/net/tap.c index ab734ea68668..303e1b60a316 100644 --- a/cpu/native/net/tap.c +++ b/cpu/native/net/tap.c @@ -151,7 +151,7 @@ void _native_handle_tap_input(void) #ifdef __MACH__ void sigio_child() { - pid_t parent = _native_pid; + int parent = _native_pid; if ((sigio_child_pid = real_fork()) == -1) { err(EXIT_FAILURE, "sigio_child: fork"); diff --git a/cpu/native/syscalls.c b/cpu/native/syscalls.c index 2f407bac6234..089e50117ef5 100644 --- a/cpu/native/syscalls.c +++ b/cpu/native/syscalls.c @@ -34,6 +34,7 @@ #include #endif +#include "kernel.h" #include "cpu.h" #include "irq.h" #include "vtimer.h" diff --git a/cpu/sam3x8e/syscalls.c b/cpu/sam3x8e/syscalls.c index 09f8aa711f02..e807c73ec54e 100644 --- a/cpu/sam3x8e/syscalls.c +++ b/cpu/sam3x8e/syscalls.c @@ -97,7 +97,7 @@ caddr_t _sbrk_r(struct _reent *r, size_t incr) * * @return the process ID of the current thread */ -int _getpid(void) +kernel_pid_t _getpid(void) { return sched_active_thread->pid; } @@ -111,7 +111,7 @@ int _getpid(void) * * @return TODO */ -int _kill_r(struct _reent *r, int pid, int sig) +int _kill_r(struct _reent *r, kernel_pid_t pid, int sig) { r->_errno = ESRCH; /* not implemented yet */ return -1; diff --git a/cpu/x86/include/x86_rtc.h b/cpu/x86/include/x86_rtc.h index 0ef3445b95c4..91eebb66aca5 100644 --- a/cpu/x86/include/x86_rtc.h +++ b/cpu/x86/include/x86_rtc.h @@ -136,7 +136,7 @@ typedef void (*x86_rtc_callback_t)(uint8_t reg_c); * @brief Set an RTC alarm. * @param[in] when Time when the RTC you raise an interrupt. The date part is ignored. * @param msg_content The value for msg_t::content.value. - * @param target_pid The process which shall receive the message, `-1u` to disable. + * @param target_pid The process which shall receive the message, `KERNEL_PID_NULL` to disable. * @param allow_replace Whether it is allowed to overwrite an existing alarm. * * The value of msg_t::type will be `reg_c | (RTC_REG_B_INT_UPDATE << 8)`, @@ -145,13 +145,13 @@ typedef void (*x86_rtc_callback_t)(uint8_t reg_c); * You should not call this function directly. * You should use hwtimer -- or better yet -- vtimer instead. */ -bool x86_rtc_set_alarm(const x86_rtc_data_t *when, uint32_t msg_content, unsigned int target_pid, bool allow_replace); +bool x86_rtc_set_alarm(const x86_rtc_data_t *when, uint32_t msg_content, kernel_pid_t target_pid, bool allow_replace); /** * @brief Set up periodic interrupts * @param hz How often a second the interrupt should fire, e.g. RTC_REG_A_HZ_8192. * @param msg_content The value for msg_t::content.value. - * @param target_pid The process which shall receive the message, `-1u` to disable. + * @param target_pid The process which shall receive the message, `KERNEL_PID_NULL` to disable. * @param allow_replace Whether it is allowed to overwrite an existing alarm. * * The value of msg_t::type will be `reg_c | (RTC_REG_B_INT_PERIODIC << 8)`, @@ -160,12 +160,12 @@ bool x86_rtc_set_alarm(const x86_rtc_data_t *when, uint32_t msg_content, unsigne * You should not call this function directly. * You should use hwtimer -- or better yet -- vtimer instead. */ -bool x86_rtc_set_periodic(uint8_t hz, uint32_t msg_content, unsigned int target_pid, bool allow_replace); +bool x86_rtc_set_periodic(uint8_t hz, uint32_t msg_content, kernel_pid_t target_pid, bool allow_replace); /** * @brief Set up secondly interrupts. * @param msg_content The value for msg_t::content.value. - * @param target_pid The process which shall receive the message, `-1u` to disable. + * @param target_pid The process which shall receive the message, `KERNEL_PID_NULL` to disable. * @param allow_replace Whether it is allowed to overwrite an existing alarm. * * The value of msg_t::type will be `reg_c | (RTC_REG_B_INT_UPDATE << 8)`, @@ -174,7 +174,7 @@ bool x86_rtc_set_periodic(uint8_t hz, uint32_t msg_content, unsigned int target_ * You should not call this function directly. * You should use hwtimer -- or better yet -- vtimer instead. */ -bool x86_rtc_set_update(uint32_t msg_content, unsigned int target_pid, bool allow_replace); +bool x86_rtc_set_update(uint32_t msg_content, kernel_pid_t target_pid, bool allow_replace); /** * @brief Set custom alarm interrupt handler. diff --git a/cpu/x86/x86_glue.c b/cpu/x86/x86_glue.c index 4f4697be69fd..2753caaeda6f 100644 --- a/cpu/x86/x86_glue.c +++ b/cpu/x86/x86_glue.c @@ -58,7 +58,7 @@ int close(int fildes) pid_t getpid(void) { - return sched_active_pid; + return (pid_t) sched_active_pid; } int fstat(int fildes, struct stat *buf) @@ -76,7 +76,7 @@ int isatty(int fildes) return 0; /* sic */ } -int kill(pid_t pid, int sig) +int kill(kernel_pid_t pid, int sig) { /* TODO */ (void) pid; diff --git a/cpu/x86/x86_hwtimer.c b/cpu/x86/x86_hwtimer.c index 276220ebbf1a..629f0ca6d524 100644 --- a/cpu/x86/x86_hwtimer.c +++ b/cpu/x86/x86_hwtimer.c @@ -113,7 +113,7 @@ static void measure_nop_nop_nops_per_tick(void) ts_per_nop_nop_nop += counting_end - counting_start; } x86_rtc_set_periodic_callback(NULL); - x86_rtc_set_periodic(RTC_REG_A_HZ_OFF, 0, -1, false); + x86_rtc_set_periodic(RTC_REG_A_HZ_OFF, 0, KERNEL_PID_NULL, false); /* instructions_per_second = nop_nop_nops_per_second * ts_per_nop_nop_nop: */ instructions_per_second = nop_nop_nops_per_tick * TICK_HZ_VAL * ts_per_nop_nop_nop / nop_nop_nops_per_tick / NNN_TICK_ITERATIONS; @@ -150,7 +150,7 @@ static void init_bases(void) ts_base); x86_rtc_set_periodic_callback(NULL); - x86_rtc_set_periodic(RTC_REG_A_HZ_OFF, 0, -1, false); + x86_rtc_set_periodic(RTC_REG_A_HZ_OFF, 0, KERNEL_PID_NULL, false); } void x86_init_hwtimer(void) @@ -231,17 +231,17 @@ static void stop_alarms(void) if (rtc_alarm_ie) { rtc_alarm_ie = 0; - x86_rtc_set_alarm(NULL, 0, -1u, false); + x86_rtc_set_alarm(NULL, 0, KERNEL_PID_NULL, false); } if (rtc_update_ie) { rtc_update_ie = 0; - x86_rtc_set_update(0, -1u, false); + x86_rtc_set_update(0, KERNEL_PID_NULL, false); } if (rtc_periodic_ie) { rtc_periodic_ie = 0; - x86_rtc_set_periodic(RTC_REG_A_HZ_OFF, 0, -1u, false); + x86_rtc_set_periodic(RTC_REG_A_HZ_OFF, 0, KERNEL_PID_NULL, false); } } diff --git a/cpu/x86/x86_rtc.c b/cpu/x86/x86_rtc.c index f0cd78d43671..fbd6e7acd8a8 100644 --- a/cpu/x86/x86_rtc.c +++ b/cpu/x86/x86_rtc.c @@ -34,17 +34,19 @@ #include +#include "kernel.h" + #define ENABLE_DEBUG (0) #include "debug.h" static bool valid; static int32_t alarm_msg_content, periodic_msg_content, update_msg_content; -static unsigned alarm_pid = -1u, periodic_pid = -1u, update_pid = -1u; +static unsigned alarm_pid = KERNEL_PID_NULL, periodic_pid = KERNEL_PID_NULL, update_pid = KERNEL_PID_NULL; static void alarm_callback_default(uint8_t reg_c) { - if (alarm_pid != -1u) { + if (alarm_pid != KERNEL_PID_NULL) { msg_t m; m.type = reg_c | (RTC_REG_B_INT_ALARM << 8); m.content.value = alarm_msg_content; @@ -54,7 +56,7 @@ static void alarm_callback_default(uint8_t reg_c) static void periodic_callback_default(uint8_t reg_c) { - if (periodic_pid != -1u) { + if (periodic_pid != KERNEL_PID_NULL) { msg_t m; m.type = reg_c | (RTC_REG_B_INT_PERIODIC << 8); m.content.value = periodic_msg_content; @@ -64,7 +66,7 @@ static void periodic_callback_default(uint8_t reg_c) static void update_callback_default(uint8_t reg_c) { - if (update_pid != -1u) { + if (update_pid != KERNEL_PID_NULL) { msg_t m; m.type = reg_c | (RTC_REG_B_INT_UPDATE << 8); m.content.value = update_msg_content; @@ -196,7 +198,7 @@ bool x86_rtc_read(x86_rtc_data_t *dest) return true; } -bool x86_rtc_set_alarm(const x86_rtc_data_t *when, uint32_t msg_content, unsigned int target_pid, bool allow_replace) +bool x86_rtc_set_alarm(const x86_rtc_data_t *when, uint32_t msg_content, kernel_pid_t target_pid, bool allow_replace) { if (!valid) { return false; @@ -204,15 +206,15 @@ bool x86_rtc_set_alarm(const x86_rtc_data_t *when, uint32_t msg_content, unsigne unsigned old_status = disableIRQ(); bool result; - if (target_pid == -1u) { + if (target_pid == KERNEL_PID_NULL) { result = true; - alarm_pid = -1u; + alarm_pid = KERNEL_PID_NULL; uint8_t b = x86_cmos_read(RTC_REG_B); x86_cmos_write(RTC_REG_B, b & ~RTC_REG_B_INT_ALARM); } else { - result = allow_replace || alarm_pid == -1u; + result = allow_replace || alarm_pid == KERNEL_PID_NULL; if (result) { alarm_msg_content = msg_content; alarm_pid = target_pid; @@ -236,7 +238,7 @@ bool x86_rtc_set_alarm(const x86_rtc_data_t *when, uint32_t msg_content, unsigne return result; } -bool x86_rtc_set_periodic(uint8_t hz, uint32_t msg_content, unsigned int target_pid, bool allow_replace) +bool x86_rtc_set_periodic(uint8_t hz, uint32_t msg_content, kernel_pid_t target_pid, bool allow_replace) { if (!valid) { return false; @@ -244,16 +246,16 @@ bool x86_rtc_set_periodic(uint8_t hz, uint32_t msg_content, unsigned int target_ unsigned old_status = disableIRQ(); bool result; - if (target_pid == -1u || hz == RTC_REG_A_HZ_OFF) { + if (target_pid == KERNEL_PID_NULL || hz == RTC_REG_A_HZ_OFF) { result = true; - periodic_pid = -1u; + periodic_pid = KERNEL_PID_NULL; uint8_t old_divider = x86_cmos_read(RTC_REG_A) & ~RTC_REG_A_HZ_MASK; x86_cmos_write(RTC_REG_A, old_divider | RTC_REG_A_HZ_OFF); x86_cmos_write(RTC_REG_B, x86_cmos_read(RTC_REG_B) & ~RTC_REG_B_INT_PERIODIC); } else { - result = allow_replace || periodic_pid == -1u; + result = allow_replace || periodic_pid == KERNEL_PID_NULL; if (result) { periodic_msg_content = msg_content; periodic_pid = target_pid; @@ -268,7 +270,7 @@ bool x86_rtc_set_periodic(uint8_t hz, uint32_t msg_content, unsigned int target_ return result; } -bool x86_rtc_set_update(uint32_t msg_content, unsigned int target_pid, bool allow_replace) +bool x86_rtc_set_update(uint32_t msg_content, kernel_pid_t target_pid, bool allow_replace) { if (!valid) { return false; @@ -276,14 +278,14 @@ bool x86_rtc_set_update(uint32_t msg_content, unsigned int target_pid, bool allo unsigned old_status = disableIRQ(); bool result; - if (target_pid == -1u) { + if (target_pid == KERNEL_PID_NULL) { result = true; - update_pid = -1u; + update_pid = KERNEL_PID_NULL; x86_cmos_write(RTC_REG_B, x86_cmos_read(RTC_REG_B) & ~RTC_REG_B_INT_UPDATE); } else { - result = allow_replace || update_pid == -1u; + result = allow_replace || update_pid == KERNEL_PID_NULL; if (result) { update_msg_content = msg_content; update_pid = target_pid; diff --git a/cpu/x86/x86_threading.c b/cpu/x86/x86_threading.c index 8d20b9706c7c..5c977f3e1416 100644 --- a/cpu/x86/x86_threading.c +++ b/cpu/x86/x86_threading.c @@ -51,7 +51,7 @@ static ucontext_t end_context; bool x86_in_isr = true; -static long fpu_owner = -1; +static kernel_pid_t fpu_owner = KERNEL_PID_NULL; //static ucontext_t *cur_ctx, *isr_ctx; @@ -188,7 +188,7 @@ static void fpu_used_interrupt(uint8_t intr_num, struct x86_pushad *orig_ctx, un return; } - if (fpu_owner != -1) { + if (fpu_owner != KERNEL_PID_NULL) { ucontext_t *ctx_owner = (ucontext_t *) sched_threads[fpu_owner]->sp; asm volatile ("fxsave (%0)" :: "r"(&fpu_data)); ctx_owner->__fxsave = fpu_data; @@ -205,7 +205,7 @@ static void x86_thread_exit(void) { dINT(); if (fpu_owner == sched_active_pid) { - fpu_owner = -1; + fpu_owner = KERNEL_PID_NULL; } sched_task_exit(); } diff --git a/drivers/at86rf231/at86rf231.c b/drivers/at86rf231/at86rf231.c index 4c6154ba851e..0b303934f699 100644 --- a/drivers/at86rf231/at86rf231.c +++ b/drivers/at86rf231/at86rf231.c @@ -18,7 +18,7 @@ static uint8_t radio_channel; static uint16_t radio_address; static uint64_t radio_address_long; -void at86rf231_init(int tpid) +void at86rf231_init(kernel_pid_t tpid) { transceiver_pid = tpid; diff --git a/drivers/cc110x/cc1100_phy.c b/drivers/cc110x/cc1100_phy.c index 9b5fbbca2569..580bd2f07188 100644 --- a/drivers/cc110x/cc1100_phy.c +++ b/drivers/cc110x/cc1100_phy.c @@ -83,11 +83,11 @@ static handler_entry_t handlers[MAX_PACKET_HANDLERS]; static const pm_table_t handler_table; static const char *cc1100_event_handler_name = "cc1100_event_handler"; static mutex_t cc1100_mutex; -volatile int cc1100_mutex_pid; +volatile kernel_pid_t cc1100_mutex_pid; static vtimer_t cc1100_watch_dog; static timex_t cc1100_watch_dog_period; -static uint16_t cc1100_event_handler_pid; +static kernel_pid_t cc1100_event_handler_pid; static void *cc1100_event_handler_function(void *); static char event_handler_stack[KERNEL_CONF_STACKSIZE_MAIN]; @@ -174,7 +174,7 @@ void cc1100_phy_init(void) memset(seq_buffer, 0, sizeof(seq_buffer_entry_t) * MAX_SEQ_BUFFER_SIZE); /* Initialize mutex */ - cc1100_mutex_pid = -1; + cc1100_mutex_pid = KERNEL_PID_NULL; mutex_init(&cc1100_mutex); /* Allocate event numbers and start cc1100 event process */ @@ -205,7 +205,7 @@ void cc1100_phy_mutex_lock(void) void cc1100_phy_mutex_unlock(void) { - cc1100_mutex_pid = -1; + cc1100_mutex_pid = KERNEL_PID_NULL; mutex_unlock(&cc1100_mutex); } diff --git a/drivers/cc110x_ng/cc110x.c b/drivers/cc110x_ng/cc110x.c index 930b1089a847..88000d7a30ba 100644 --- a/drivers/cc110x_ng/cc110x.c +++ b/drivers/cc110x_ng/cc110x.c @@ -49,10 +49,10 @@ static void write_register(uint8_t r, uint8_t value); /*---------------------------------------------------------------------------* * Radio Driver API * *---------------------------------------------------------------------------*/ -void cc110x_init(int tpid) +void cc110x_init(kernel_pid_t tpid) { transceiver_pid = tpid; - DEBUG("Transceiver PID: %i\n", transceiver_pid); + DEBUG("Transceiver PID: %" PRIkernel_pid "\n", transceiver_pid); rx_buffer_next = 0; diff --git a/drivers/cc2420/cc2420.c b/drivers/cc2420/cc2420.c index 8bfb5f1ba282..5809332b7447 100644 --- a/drivers/cc2420/cc2420.c +++ b/drivers/cc2420/cc2420.c @@ -74,7 +74,7 @@ void cc2420_initialize(void) cc2420_switch_to_rx(); } -void cc2420_init(int tpid) +void cc2420_init(kernel_pid_t tpid) { transceiver_pid = tpid; cc2420_initialize(); diff --git a/drivers/include/at86rf231.h b/drivers/include/at86rf231.h index e80ad2e04310..c3ad170b533b 100644 --- a/drivers/include/at86rf231.h +++ b/drivers/include/at86rf231.h @@ -28,9 +28,9 @@ typedef struct __attribute__((packed)) } at86rf231_packet_t; -extern int transceiver_pid; +extern kernel_pid_t transceiver_pid; -void at86rf231_init(int tpid); +void at86rf231_init(kernel_pid_t tpid); //void at86rf231_reset(void); void at86rf231_rx(void); void at86rf231_rx_handler(void); diff --git a/drivers/include/cc110x_ng/cc110x-interface.h b/drivers/include/cc110x_ng/cc110x-interface.h index b33d7dae8805..12c0dc6bc984 100644 --- a/drivers/include/cc110x_ng/cc110x-interface.h +++ b/drivers/include/cc110x_ng/cc110x-interface.h @@ -26,6 +26,7 @@ #include "radio/radio.h" #include "radio/types.h" #include "cc110x-config.h" +#include "kernel_types.h" #define CC1100_MAX_DATA_LENGTH (58) @@ -115,9 +116,9 @@ extern volatile uint8_t rx_buffer_next; ///< Next packet in RX queue extern volatile uint8_t radio_state; ///< Radio state extern cc110x_statistic_t cc110x_statistic; -extern int transceiver_pid; ///< the transceiver thread pid +extern kernel_pid_t transceiver_pid; ///< the transceiver thread pid -void cc110x_init(int transceiver_pid); +void cc110x_init(kernel_pid_t transceiver_pid); void cc110x_rx_handler(void); diff --git a/drivers/include/cc2420.h b/drivers/include/cc2420.h index 35c995aa10b3..588c0f586172 100644 --- a/drivers/include/cc2420.h +++ b/drivers/include/cc2420.h @@ -80,6 +80,7 @@ Frame type value: #include +#include "kernel_types.h" #include "ieee802154_frame.h" #include "cc2420_settings.h" @@ -106,8 +107,6 @@ typedef struct __attribute__ ((packed)) { /* @} */ } cc2420_packet_t; -extern int transceiver_pid; - /** * @brief Initialize the CC2420 transceiver. */ @@ -119,7 +118,7 @@ void cc2420_initialize(void); * @param[in] tpid The PID of the transceiver thread. */ -void cc2420_init(int tpid); +void cc2420_init(kernel_pid_t tpid); /** * @brief Turn CC2420 on. @@ -362,7 +361,7 @@ int16_t cc2420_send(cc2420_packet_t *packet); /** * The PID of the transceiver thread. */ -extern int transceiver_pid; +extern kernel_pid_t transceiver_pid; /* * RX Packet Buffer, read from the transceiver, filled by the cc2420_rx_handler. diff --git a/drivers/include/rtc.h b/drivers/include/rtc.h index e5efa3f78966..cb81a70ca48b 100644 --- a/drivers/include/rtc.h +++ b/drivers/include/rtc.h @@ -26,6 +26,7 @@ and Telematics group (http://cst.mi.fu-berlin.de). #include #include +#include "kernel_types.h" /** * @brief Initializes the RTC for calendar mode @@ -60,7 +61,7 @@ void rtc_get_localtime(struct tm *localt); */ time_t rtc_time(struct timeval *time); -extern int rtc_second_pid; +extern kernel_pid_t rtc_second_pid; /** @} */ #endif diff --git a/examples/ccn-lite-client/main.c b/examples/ccn-lite-client/main.c index b7d8e7c2aed4..744a8d38692b 100644 --- a/examples/ccn-lite-client/main.c +++ b/examples/ccn-lite-client/main.c @@ -50,7 +50,7 @@ char relay_stack[KERNEL_CONF_STACKSIZE_MAIN]; #if RIOT_CCN_APPSERVER char appserver_stack[KERNEL_CONF_STACKSIZE_MAIN]; #endif -int relay_pid, appserver_pid; +kernel_pid_t relay_pid, appserver_pid; int shell_max_cache_entries, shell_threshold_prefix, shell_threshold_aggregate; @@ -84,7 +84,7 @@ static void riot_ccn_appserver(int argc, char **argv) appserver_stack, sizeof(appserver_stack), PRIORITY_MAIN - 1, CREATE_STACKTEST, appserver_thread, NULL, "appserver"); - DEBUG("ccn-lite appserver on thread_id %d...\n", appserver_pid); + DEBUG("ccn-lite appserver on thread_id %" PRIkernel_pid "...\n", appserver_pid); } #endif @@ -174,7 +174,7 @@ static void riot_ccn_relay_start(int argc, char **argv) relay_stack, sizeof(relay_stack), PRIORITY_MAIN - 2, CREATE_STACKTEST, relay_thread, NULL, "relay"); - DEBUG("ccn-lite relay on thread_id %d...\n", relay_pid); + DEBUG("ccn-lite relay on thread_id %" PRIkernel_pid "...\n", relay_pid); } static void riot_ccn_relay_stop(int argc, char **argv) diff --git a/examples/ccn-lite-relay/main.c b/examples/ccn-lite-relay/main.c index 891de8a37353..ae714ac1c613 100644 --- a/examples/ccn-lite-relay/main.c +++ b/examples/ccn-lite-relay/main.c @@ -31,7 +31,7 @@ // ccn #include "ccn_lite/ccnl-riot.h" -int relay_pid; +kernel_pid_t relay_pid; char t2_stack[KERNEL_CONF_STACKSIZE_MAIN]; @@ -51,7 +51,7 @@ void set_address_handler(uint16_t a) printf("trying to set address %" PRIu16 "\n", a); mesg.type = SET_ADDRESS; - printf("transceiver_pid=%d\n", transceiver_pid); + printf("transceiver_pid=%" PRIkernel_pid"\n", transceiver_pid); msg_send_receive(&mesg, &mesg, transceiver_pid); printf("got address: %" PRIu16 "\n", a); diff --git a/examples/default/main.c b/examples/default/main.c index 10a9f6ddf9f7..51b548ef6c90 100644 --- a/examples/default/main.c +++ b/examples/default/main.c @@ -88,7 +88,7 @@ void *radio(void *arg) void init_transceiver(void) { - int radio_pid = thread_create( + kernel_pid_t radio_pid = thread_create( radio_stack_buffer, sizeof(radio_stack_buffer), PRIORITY_MAIN - 2, diff --git a/examples/ipc_pingpong/main.c b/examples/ipc_pingpong/main.c index b80d2c240732..c3b21b4529da 100644 --- a/examples/ipc_pingpong/main.c +++ b/examples/ipc_pingpong/main.c @@ -28,12 +28,12 @@ void *second_thread(void *arg) { (void) arg; - printf("2nd thread started, pid: %i\n", thread_getpid()); + printf("2nd thread started, pid: %" PRIkernel_pid "\n", thread_getpid()); msg_t m; while (1) { msg_receive(&m); - printf("2nd: Got msg from %i\n", m.sender_pid); + printf("2nd: Got msg from %" PRIkernel_pid "\n", m.sender_pid); m.content.value++; msg_reply(&m, &m); } @@ -46,11 +46,11 @@ char second_thread_stack[KERNEL_CONF_STACKSIZE_MAIN]; int main(void) { printf("Starting IPC Ping-pong example...\n"); - printf("1st thread started, pid: %i\n", thread_getpid()); + printf("1st thread started, pid: %" PRIkernel_pid "\n", thread_getpid()); msg_t m; - int pid = thread_create(second_thread_stack, sizeof(second_thread_stack), + kernel_pid_t pid = thread_create(second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN - 1, CREATE_STACKTEST, second_thread, NULL, "pong"); diff --git a/examples/rpl_udp/helper.c b/examples/rpl_udp/helper.c index 2dbd0be3e73b..7085bb9550ef 100644 --- a/examples/rpl_udp/helper.c +++ b/examples/rpl_udp/helper.c @@ -137,7 +137,7 @@ void rpl_udp_ignore(int argc, char **argv) if (argc == 2) { a = atoi(argv[1]); - printf("sending to transceiver (%u): %u\n", transceiver_pid, (*(uint8_t *)tcmd.data)); + printf("sending to transceiver (%" PRIkernel_pid "): %u\n", transceiver_pid, (*(uint8_t *)tcmd.data)); msg_send(&mesg, transceiver_pid, 1); } else { diff --git a/examples/rpl_udp/rpl.c b/examples/rpl_udp/rpl.c index a8c6ce9629ed..eee3657f961c 100644 --- a/examples/rpl_udp/rpl.c +++ b/examples/rpl_udp/rpl.c @@ -87,10 +87,13 @@ void rpl_udp_init(int argc, char **argv) } DEBUGF("Start monitor\n"); - int monitor_pid = thread_create( - monitor_stack_buffer, sizeof(monitor_stack_buffer), - PRIORITY_MAIN - 2, CREATE_STACKTEST, - rpl_udp_monitor, NULL, "monitor"); + kernel_pid_t monitor_pid = thread_create(monitor_stack_buffer, + sizeof(monitor_stack_buffer), + PRIORITY_MAIN - 2, + CREATE_STACKTEST, + rpl_udp_monitor, + NULL, + "monitor"); DEBUGF("Register at transceiver %02X\n", TRANSCEIVER); transceiver_register(TRANSCEIVER, monitor_pid); ipv6_register_packet_handler(monitor_pid); diff --git a/examples/rpl_udp/udp.c b/examples/rpl_udp/udp.c index 6f68d9dcf14c..05c49e2516a2 100644 --- a/examples/rpl_udp/udp.c +++ b/examples/rpl_udp/udp.c @@ -46,11 +46,13 @@ void udp_server(int argc, char **argv) (void) argc; (void) argv; - int udp_server_thread_pid = thread_create( - udp_server_stack_buffer, sizeof(udp_server_stack_buffer), - PRIORITY_MAIN, CREATE_STACKTEST, - init_udp_server, NULL, "init_udp_server"); - printf("UDP SERVER ON PORT %d (THREAD PID: %d)\n", HTONS(SERVER_PORT), udp_server_thread_pid); + kernel_pid_t udp_server_thread_pid = thread_create(udp_server_stack_buffer, + sizeof(udp_server_stack_buffer), + PRIORITY_MAIN, CREATE_STACKTEST, + init_udp_server, + NULL, + "init_udp_server"); + printf("UDP SERVER ON PORT %d (THREAD PID: %" PRIkernel_pid ")\n", HTONS(SERVER_PORT), udp_server_thread_pid); } static void *init_udp_server(void *arg) diff --git a/sys/chardev_thread.c b/sys/chardev_thread.c index 923f6e02f6f1..b333c1eefe0b 100644 --- a/sys/chardev_thread.c +++ b/sys/chardev_thread.c @@ -45,9 +45,9 @@ void chardev_loop(ringbuffer_t *rb) { msg_t m; - int pid = thread_getpid(); + kernel_pid_t pid = thread_getpid(); - int reader_pid = -1; + kernel_pid_t reader_pid = KERNEL_PID_NULL; struct posix_iop_t *r = NULL; puts("UART0 thread started."); @@ -61,7 +61,7 @@ void chardev_loop(ringbuffer_t *rb) switch(m.type) { case OPEN: DEBUG("OPEN\n"); - if (reader_pid == -1) { + if (reader_pid == KERNEL_PID_NULL) { reader_pid = m.sender_pid; /* no error */ m.content.value = 0; @@ -89,8 +89,8 @@ void chardev_loop(ringbuffer_t *rb) case CLOSE: DEBUG("CLOSE\n"); if (m.sender_pid == reader_pid) { - DEBUG("uart0_thread: closing file from %i\n", reader_pid); - reader_pid = -1; + DEBUG("uart0_thread: closing file from %" PRIkernel_pid "\n", reader_pid); + reader_pid = KERNEL_PID_NULL; r = NULL; m.content.value = 0; } @@ -112,7 +112,7 @@ void chardev_loop(ringbuffer_t *rb) DEBUG("Data is available\n"); int state = disableIRQ(); int nbytes = min(r->nbytes, rb->avail); - DEBUG("uart0_thread [%i]: sending %i bytes received from %i to pid %i\n", pid, nbytes, m.sender_pid, reader_pid); + DEBUG("uart0_thread [%i]: sending %i bytes received from %" PRIkernel_pid " to pid %" PRIkernel_pid "\n", pid, nbytes, m.sender_pid, reader_pid); ringbuffer_get(rb, r->buffer, nbytes); r->nbytes = nbytes; diff --git a/sys/include/board_uart0.h b/sys/include/board_uart0.h index e7af70bd571f..80355906ce21 100644 --- a/sys/include/board_uart0.h +++ b/sys/include/board_uart0.h @@ -12,9 +12,10 @@ #ifndef __BOARD_UART0_H #define __BOARD_UART0_H +#include "kernel_types.h" #include "cpu-conf.h" /* To give user access to UART0_BUFSIZE */ -extern int uart0_handler_pid; +extern kernel_pid_t uart0_handler_pid; void board_uart0_init(void); void uart0_handle_incoming(int c); diff --git a/sys/include/fd.h b/sys/include/fd.h index 95da6eaa36d9..79f679952917 100644 --- a/sys/include/fd.h +++ b/sys/include/fd.h @@ -23,6 +23,7 @@ #define FD_H #include #include +#include "kernel_types.h" #include "cpu.h" /** @@ -33,7 +34,7 @@ typedef struct { int __active; /** the internal filedescriptor */ - int fd; + kernel_pid_t fd; /** * Read *n* into *buf* from *fd*. Return the @@ -45,7 +46,7 @@ typedef struct { ssize_t (*write)(int fd, const void *buf, size_t n); /** Close the file descriptor *fd*. */ - int (*close)(int fd); + int (*close)(kernel_pid_t fd); } fd_t; /** @@ -67,7 +68,7 @@ int fd_init(void); */ int fd_new(int internal_fd, ssize_t (*internal_read)(int, void *, size_t), ssize_t (*internal_write)(int, const void *, size_t), - int (*internal_close)(int)); + int (*internal_close)(kernel_pid_t)); /** * @brief Gets the file descriptor table entry associated with file diff --git a/sys/include/posix_io.h b/sys/include/posix_io.h index 3395c3f836e3..ed820a828772 100644 --- a/sys/include/posix_io.h +++ b/sys/include/posix_io.h @@ -21,6 +21,8 @@ #ifndef __READ_H #define __READ_H +#include "kernel_types.h" + #define OPEN 0 #define CLOSE 1 #define READ 2 @@ -31,10 +33,10 @@ struct posix_iop_t { char *buffer; }; -int posix_open(int pid, int flags); -int posix_close(int pid); -int posix_read(int pid, char *buffer, int bufsize); -int posix_write(int pid, char *buffer, int bufsize); +int posix_open(kernel_pid_t pid, int flags); +int posix_close(kernel_pid_t pid); +int posix_read(kernel_pid_t pid, char *buffer, int bufsize); +int posix_write(kernel_pid_t pid, char *buffer, int bufsize); /** @} */ #endif /* __READ_H */ diff --git a/sys/include/transceiver.h b/sys/include/transceiver.h index ad01c7a3fcc6..24d5a146b15c 100644 --- a/sys/include/transceiver.h +++ b/sys/include/transceiver.h @@ -11,6 +11,7 @@ #ifndef TRANSCEIVER_H #define TRANSCEIVER_H +#include "kernel_types.h" #include "radio/types.h" /* supported transceivers * @@ -190,7 +191,7 @@ enum transceiver_msg_type_t { */ typedef struct { transceiver_type_t transceivers; ///< the tranceivers the thread is registered for - int pid; ///< the thread's pid + kernel_pid_t pid; ///< the thread's pid } registered_t; typedef struct { @@ -199,7 +200,7 @@ typedef struct { } transceiver_command_t; /* The transceiver thread's pid */ -extern int transceiver_pid; +extern kernel_pid_t transceiver_pid; /** An array of ignored link layer addresses */ extern radio_address_t transceiver_ignored_addr[TRANSCEIVER_MAX_IGNORED_ADDR]; @@ -216,7 +217,7 @@ void transceiver_init(transceiver_type_t transceivers); * * @return The transceiver thread's pid */ -int transceiver_start(void); +kernel_pid_t transceiver_start(void); /** * @brief register a thread for events from certain transceivers @@ -226,7 +227,7 @@ int transceiver_start(void); * * @return 1 on success, 0 otherwise */ -uint8_t transceiver_register(transceiver_type_t transceivers, int pid); +uint8_t transceiver_register(transceiver_type_t transceivers, kernel_pid_t pid); /** * @brief unregister a thread for events from certain transceivers @@ -236,7 +237,7 @@ uint8_t transceiver_register(transceiver_type_t transceivers, int pid); * * @return 1 on success, 0 otherwise */ -uint8_t transceiver_unregister(transceiver_type_t transceivers, int pid); +uint8_t transceiver_unregister(transceiver_type_t transceivers, kernel_pid_t pid); #endif /* TRANSCEIVER_H */ /** @} */ diff --git a/sys/include/vtimer.h b/sys/include/vtimer.h index 194c75653b0a..95829862c590 100644 --- a/sys/include/vtimer.h +++ b/sys/include/vtimer.h @@ -39,7 +39,7 @@ typedef struct vtimer_t { timex_t absolute; void (*action)(struct vtimer_t *timer); void *arg; - unsigned int pid; + kernel_pid_t pid; } vtimer_t; /** @@ -89,7 +89,7 @@ int vtimer_sleep(timex_t time); * @param[in] ptr message value * @return 0 on success, < 0 on error */ -int vtimer_set_msg(vtimer_t *t, timex_t interval, unsigned int pid, void *ptr); +int vtimer_set_msg(vtimer_t *t, timex_t interval, kernel_pid_t pid, void *ptr); /** * @brief set a vtimer with wakeup event @@ -97,7 +97,7 @@ int vtimer_set_msg(vtimer_t *t, timex_t interval, unsigned int pid, void *ptr); * @param[in] pid process id * @return 0 on success, < 0 on error */ -int vtimer_set_wakeup(vtimer_t *t, timex_t interval, int pid); +int vtimer_set_wakeup(vtimer_t *t, timex_t interval, kernel_pid_t pid); /** * @brief remove a vtimer diff --git a/sys/net/ccn_lite/ccn-lite-relay.c b/sys/net/ccn_lite/ccn-lite-relay.c index 3cd15ac1ce8a..22aaf38c7d3f 100644 --- a/sys/net/ccn_lite/ccn-lite-relay.c +++ b/sys/net/ccn_lite/ccn-lite-relay.c @@ -374,7 +374,7 @@ int ccnl_io_loop(struct ccnl_relay_s *ccnl) case (CCNL_RIOT_HALT): /* cmd to stop the relay */ hwtimer_remove(hwtimer_id); - DEBUGMSG(1, "\tSrc:\t%u\n", in.sender_pid); + DEBUGMSG(1, "\tSrc:\t%" PRIkernel_pid "\n", in.sender_pid); DEBUGMSG(1, "\tNumb:\t%" PRIu32 "\n", in.content.value); ccnl->halt_flag = 1; @@ -384,7 +384,7 @@ int ccnl_io_loop(struct ccnl_relay_s *ccnl) case (CCNL_RIOT_POPULATE): /* cmd to polulate the cache */ hwtimer_remove(hwtimer_id); - DEBUGMSG(1, "\tSrc:\t%u\n", in.sender_pid); + DEBUGMSG(1, "\tSrc:\t%" PRIkernel_pid "\n", in.sender_pid); DEBUGMSG(1, "\tNumb:\t%" PRIu32 "\n", in.content.value); handle_populate_cache(); @@ -410,7 +410,7 @@ int ccnl_io_loop(struct ccnl_relay_s *ccnl) default: hwtimer_remove(hwtimer_id); DEBUGMSG(1, "%s Packet waiting\n", riot_ccnl_event_to_string(in.type)); - DEBUGMSG(1, "\tSrc:\t%u\n", in.sender_pid); + DEBUGMSG(1, "\tSrc:\t%" PRIkernel_pid "\n", in.sender_pid); DEBUGMSG(1, "\tdropping it...\n"); break; } diff --git a/sys/net/ccn_lite/ccnl-core.h b/sys/net/ccn_lite/ccnl-core.h index 4abea9d23a60..c74957d22cb9 100644 --- a/sys/net/ccn_lite/ccnl-core.h +++ b/sys/net/ccn_lite/ccnl-core.h @@ -102,7 +102,7 @@ struct ccnl_relay_s { void *aux; int fib_threshold_prefix; /* how may name components should be considdered as dynamic */ int fib_threshold_aggregate; - int riot_pid; + kernel_pid_t riot_pid; }; struct ccnl_buf_s { diff --git a/sys/net/ccn_lite/ccnl-ext-appserver.c b/sys/net/ccn_lite/ccnl-ext-appserver.c index c41b0a5addee..972f29942698 100644 --- a/sys/net/ccn_lite/ccnl-ext-appserver.c +++ b/sys/net/ccn_lite/ccnl-ext-appserver.c @@ -37,10 +37,10 @@ /** message buffer */ msg_t msg_buffer_appserver[APPSERVER_MSG_BUFFER_SIZE]; -int relay_pid; +kernel_pid_t relay_pid; char prefix[] = "/riot/appserver/"; -static int appserver_sent_content(uint8_t *buf, int len, uint16_t from) +static int appserver_sent_content(uint8_t *buf, int len, kernel_pid_t from) { static riot_ccnl_msg_t rmsg; rmsg.payload = buf; @@ -50,8 +50,8 @@ static int appserver_sent_content(uint8_t *buf, int len, uint16_t from) msg_t m; m.type = CCNL_RIOT_MSG; m.content.ptr = (char *) &rmsg; - uint16_t dest_pid = from; - DEBUGMSG(1, "sending msg to pid=%u\n", dest_pid); + kernel_pid_t dest_pid = from; + DEBUGMSG(1, "sending msg to pid=%" PRIkernel_pid "\n", dest_pid); int ret = msg_send(&m, dest_pid, 1); DEBUGMSG(1, "msg_reply returned: %d\n", ret); return ret; @@ -132,7 +132,7 @@ static void riot_ccnl_appserver_ioloop(void) switch (in.type) { case (CCNL_RIOT_MSG): m = (riot_ccnl_msg_t *) in.content.ptr; - DEBUGMSG(1, "new msg: size=%" PRIu16 " sender_pid=%" PRIu16 "\n", + DEBUGMSG(1, "new msg: size=%" PRIu16 " sender_pid=%" PRIkernel_pid "\n", m->size, in.sender_pid); appserver_handle_interest(m->payload, m->size, in.sender_pid); @@ -151,7 +151,7 @@ static void riot_ccnl_appserver_ioloop(void) static void riot_ccnl_appserver_register(void) { char faceid[10]; - snprintf(faceid, sizeof(faceid), "%d", thread_getpid()); + snprintf(faceid, sizeof(faceid), "%" PRIkernel_pid, thread_getpid()); char *type = "newMSGface"; unsigned char *mgnt_pkg = malloc(256); @@ -166,7 +166,7 @@ static void riot_ccnl_appserver_register(void) free(mgnt_pkg); } -void ccnl_riot_appserver_start(int _relay_pid) +void ccnl_riot_appserver_start(kernel_pid_t _relay_pid) { relay_pid = _relay_pid; riot_ccnl_appserver_register(); diff --git a/sys/net/ccn_lite/ccnl-riot-compat.c b/sys/net/ccn_lite/ccnl-riot-compat.c index 1198cbda1a9d..c90bd590d8ee 100644 --- a/sys/net/ccn_lite/ccnl-riot-compat.c +++ b/sys/net/ccn_lite/ccnl-riot-compat.c @@ -76,7 +76,7 @@ int riot_send_msg(uint8_t *buf, uint16_t size, uint16_t to) msg_t m; m.type = CCNL_RIOT_MSG; m.content.ptr = (char *) rmsg; - DEBUGMSG(1, "sending msg to pid=%u\n", to); + DEBUGMSG(1, "sending msg to pid=%" PRIkernel_pid "\n", to); msg_send(&m, to, 1); return size; @@ -86,7 +86,7 @@ void riot_send_nack(uint16_t to) { msg_t m; m.type = CCNL_RIOT_NACK; - DEBUGMSG(1, "sending NACK msg to pid=%u\n", to); + DEBUGMSG(1, "sending NACK msg to pid=%" PRIkernel_pid"\n", to); msg_send(&m, to, 0); } diff --git a/sys/net/ccn_lite/util/ccnl-riot-client.c b/sys/net/ccn_lite/util/ccnl-riot-client.c index 8c9c242af4a5..56a65bd00d8e 100644 --- a/sys/net/ccn_lite/util/ccnl-riot-client.c +++ b/sys/net/ccn_lite/util/ccnl-riot-client.c @@ -32,7 +32,7 @@ msg_t mesg, rep; -int ccnl_riot_client_get(unsigned int relay_pid, char *name, char *reply_buf) +int ccnl_riot_client_get(kernel_pid_t relay_pid, char *name, char *reply_buf) { char *prefix[CCNL_MAX_NAME_COMP]; char *cp = strtok(name, "/"); @@ -60,7 +60,7 @@ int ccnl_riot_client_get(unsigned int relay_pid, char *name, char *reply_buf) } unsigned int interest_nonce = genrand_uint32(); int interest_len = mkInterest(prefix, &interest_nonce, interest_pkg); - DEBUGMSG(1, "relay_pid=%u interest_len=%d\n", relay_pid, interest_len); + DEBUGMSG(1, "relay_pid=%" PRIkernel_pid " interest_len=%d\n", relay_pid, interest_len); riot_ccnl_msg_t rmsg; rmsg.payload = interest_pkg; @@ -85,7 +85,7 @@ int ccnl_riot_client_get(unsigned int relay_pid, char *name, char *reply_buf) unsigned char *data = rmsg_reply->payload; int datalen = (int) rmsg_reply->size; - DEBUGMSG(1, "%d bytes left; msg from=%u\n", datalen, rep.sender_pid); + DEBUGMSG(1, "%d bytes left; msg from=%" PRIkernel_pid "\n", datalen, rep.sender_pid); int scope = 3, aok = 3, minsfx = 0, maxsfx = CCNL_MAX_NAME_COMP, contlen = 0; @@ -119,7 +119,7 @@ int ccnl_riot_client_get(unsigned int relay_pid, char *name, char *reply_buf) return content_len; } -int ccnl_riot_client_new_face(unsigned int relay_pid, char *type, char *faceid, +int ccnl_riot_client_new_face(kernel_pid_t relay_pid, char *type, char *faceid, unsigned char *reply_buf) { DEBUGMSG(1, "riot_new_face: mkNewFaceRquest\n"); @@ -148,7 +148,7 @@ int ccnl_riot_client_new_face(unsigned int relay_pid, char *type, char *faceid, return size; } -int ccnl_riot_client_register_prefix(unsigned int relay_pid, char *prefix, char *faceid, +int ccnl_riot_client_register_prefix(kernel_pid_t relay_pid, char *prefix, char *faceid, unsigned char *reply_buf) { DEBUGMSG(1, "riot_register_prefix: mkPrefixregRequest\n"); @@ -178,7 +178,7 @@ int ccnl_riot_client_register_prefix(unsigned int relay_pid, char *prefix, char return size; } -int ccnl_riot_client_publish(unsigned int relay_pid, char *prefix, char *faceid, char *type, unsigned char *reply_buf) +int ccnl_riot_client_publish(kernel_pid_t relay_pid, char *prefix, char *faceid, char *type, unsigned char *reply_buf) { ccnl_riot_client_new_face(relay_pid, type, faceid, reply_buf); int content_len = ccnl_riot_client_register_prefix(relay_pid, prefix, faceid, reply_buf); diff --git a/sys/net/include/ccn_lite/ccnl-riot.h b/sys/net/include/ccn_lite/ccnl-riot.h index 8330d3885e46..815a8de3ff06 100644 --- a/sys/net/include/ccn_lite/ccnl-riot.h +++ b/sys/net/include/ccn_lite/ccnl-riot.h @@ -78,7 +78,7 @@ void ccnl_riot_relay_start(int max_cache_entries, int fib_threshold_prefix, int * * @param relay_pid the pid of the relay */ -void ccnl_riot_appserver_start(int relay_pid); +void ccnl_riot_appserver_start(kernel_pid_t relay_pid); /** * @} diff --git a/sys/net/include/ccn_lite/util/ccnl-riot-client.h b/sys/net/include/ccn_lite/util/ccnl-riot-client.h index e7e0a24dadf7..a3fcbdbeb3f9 100644 --- a/sys/net/include/ccn_lite/util/ccnl-riot-client.h +++ b/sys/net/include/ccn_lite/util/ccnl-riot-client.h @@ -38,7 +38,7 @@ * * @return the length of the reply message stored in reply_buf */ -int ccnl_riot_client_get(unsigned int relay_pid, char *name, char *reply_buf); +int ccnl_riot_client_get(kernel_pid_t relay_pid, char *name, char *reply_buf); /** * @brief high level function to publish a name, e.g. "/riot/test" @@ -62,7 +62,7 @@ int ccnl_riot_client_get(unsigned int relay_pid, char *name, char *reply_buf); * * @return the length of the reply message stored in reply_buf */ -int ccnl_riot_client_publish(unsigned int relay_pid, char *prefix, char *faceid, +int ccnl_riot_client_publish(kernel_pid_t relay_pid, char *prefix, char *faceid, char *type, unsigned char *reply_buf); /** @@ -81,7 +81,7 @@ int ccnl_riot_client_publish(unsigned int relay_pid, char *prefix, char *faceid, * * @return the length of the reply message stored in reply_buf */ -int ccnl_riot_client_new_face(unsigned int relay_pid, char *type, char *faceid, +int ccnl_riot_client_new_face(kernel_pid_t relay_pid, char *type, char *faceid, unsigned char *reply_buf); /** @@ -100,7 +100,7 @@ int ccnl_riot_client_new_face(unsigned int relay_pid, char *type, char *faceid, * * @return the length of the reply message stored in reply_buf */ -int ccnl_riot_client_register_prefix(unsigned int relay_pid, char *prefix, +int ccnl_riot_client_register_prefix(kernel_pid_t relay_pid, char *prefix, char *faceid, unsigned char *reply_buf); /** diff --git a/sys/net/include/net_if.h b/sys/net/include/net_if.h index 3c03775b4d1b..e349af2f84d1 100644 --- a/sys/net/include/net_if.h +++ b/sys/net/include/net_if.h @@ -370,7 +370,7 @@ int net_if_send_packet_broadcast(net_if_trans_addr_m_t preferred_dest_mode, * * @return 1 on success, 0 otherwise */ -int net_if_register(int if_id, int pid); +int net_if_register(int if_id, kernel_pid_t pid); /** * Returns the EUI-64 of the transeivers attached to this interface. This can diff --git a/sys/net/include/sixlowpan/ip.h b/sys/net/include/sixlowpan/ip.h index f1cdc77f0b73..c3d4ee3846d6 100644 --- a/sys/net/include/sixlowpan/ip.h +++ b/sys/net/include/sixlowpan/ip.h @@ -153,7 +153,7 @@ uint8_t ipv6_get_default_hop_limit(void); * @return 0 on success, ENOMEN if maximum number of registrable * threads is exceeded. */ -uint8_t ipv6_register_packet_handler(int pid); +uint8_t ipv6_register_packet_handler(kernel_pid_t pid); /** * @brief Registers a handler thread for L4 protocol. @@ -161,14 +161,14 @@ uint8_t ipv6_register_packet_handler(int pid); * @param[in] next_header Next header ID of the L4 protocol. * @param[in] pid PID of the handler thread */ -void ipv6_register_next_header_handler(uint8_t next_header, int pid); +void ipv6_register_next_header_handler(uint8_t next_header, kernel_pid_t pid); /** * @brief Registers a handler thread for RPL options * * @param[in] pid PID of the handler thread. */ -void ipv6_register_rpl_handler(int pid); +void ipv6_register_rpl_handler(kernel_pid_t pid); /** * @brief Sets the first 64 bit of *ipv6_addr* to link local prefix. diff --git a/sys/net/include/sixlowpan/lowpan.h b/sys/net/include/sixlowpan/lowpan.h index 73bd74dad760..aec471454def 100644 --- a/sys/net/include/sixlowpan/lowpan.h +++ b/sys/net/include/sixlowpan/lowpan.h @@ -279,7 +279,7 @@ void sixlowpan_lowpan_bootstrapping(void); * @return 1 on success, ENOMEM if maximum number of registrable * threads is exceeded. */ -uint8_t sixlowpan_lowpan_register(int pid); +uint8_t sixlowpan_lowpan_register(kernel_pid_t pid); #if ENABLE_DEBUG /** diff --git a/sys/net/include/sixlowpan/mac.h b/sys/net/include/sixlowpan/mac.h index 1626552ee4dd..746213e53621 100644 --- a/sys/net/include/sixlowpan/mac.h +++ b/sys/net/include/sixlowpan/mac.h @@ -56,7 +56,7 @@ int sixlowpan_mac_send_ieee802154_frame(int if_id, const void *dest, * * @return PID of the MAC receiver thread. */ -int sixlowpan_mac_init(void); +kernel_pid_t sixlowpan_mac_init(void); /** @} */ #endif /* SIXLOWPAN_MAC_H */ diff --git a/sys/net/link_layer/net_if/net_if.c b/sys/net/link_layer/net_if/net_if.c index 533bb095d097..58ddeeff4441 100644 --- a/sys/net/link_layer/net_if/net_if.c +++ b/sys/net/link_layer/net_if/net_if.c @@ -394,7 +394,7 @@ int net_if_send_packet_long(int if_id, net_if_eui64_t *target, return (response > payload_len) ? (int)payload_len : (int)response; } -int net_if_register(int if_id, int pid) +int net_if_register(int if_id, kernel_pid_t pid) { if (if_id < 0 || if_id > NET_IF_MAX || !interfaces[if_id].initialized) { DEBUG("Register thread: No interface initialized with ID %d.\n", if_id); diff --git a/sys/net/network_layer/sixlowpan/border/border.c b/sys/net/network_layer/sixlowpan/border/border.c index 2433cf61b075..6fdef261aa7c 100644 --- a/sys/net/network_layer/sixlowpan/border/border.c +++ b/sys/net/network_layer/sixlowpan/border/border.c @@ -44,7 +44,7 @@ #define READER_STACK_SIZE (KERNEL_CONF_STACKSIZE_DEFAULT) char serial_reader_stack[READER_STACK_SIZE]; -uint16_t serial_reader_pid; +kernel_pid_t serial_reader_pid; uint8_t serial_out_buf[BORDER_BUFFER_SIZE]; uint8_t serial_in_buf[BORDER_BUFFER_SIZE]; @@ -69,14 +69,14 @@ uint8_t *get_serial_in_buffer(int offset) return &(serial_in_buf[offset]); } -uint16_t border_get_serial_reader() +kernel_pid_t border_get_serial_reader() { return serial_reader_pid; } void serial_reader_f(void) { - int main_pid = 0; + kernel_pid_t main_pid = KERNEL_PID_NULL; int bytes; msg_t m; border_packet_t *uart_buf; diff --git a/sys/net/network_layer/sixlowpan/border/flowcontrol.c b/sys/net/network_layer/sixlowpan/border/flowcontrol.c index 6687e81f2642..7924cc766062 100644 --- a/sys/net/network_layer/sixlowpan/border/flowcontrol.c +++ b/sys/net/network_layer/sixlowpan/border/flowcontrol.c @@ -32,7 +32,7 @@ static int set_timeout(vtimer_t *timeout, timex_t val, void *args); static void sending_slot(void); char sending_slot_stack[SENDING_SLOT_STACK_SIZE]; -unsigned int sending_slot_pid; +kernel_pid_t sending_slot_pid; flowcontrol_stat_t slwin_stat; sem_t connection_established; diff --git a/sys/net/network_layer/sixlowpan/icmp.h b/sys/net/network_layer/sixlowpan/icmp.h index c61dd1f42f07..e4dbfa75a4c4 100644 --- a/sys/net/network_layer/sixlowpan/icmp.h +++ b/sys/net/network_layer/sixlowpan/icmp.h @@ -44,7 +44,7 @@ enum option_types_t { OPT_DAC, }; -extern int nd_nbr_cache_rem_pid; +extern kernel_pid_t nd_nbr_cache_rem_pid; void recv_echo_req(void); diff --git a/sys/net/network_layer/sixlowpan/ip.c b/sys/net/network_layer/sixlowpan/ip.c index 78e73eb04301..f69e7ac21d4c 100644 --- a/sys/net/network_layer/sixlowpan/ip.c +++ b/sys/net/network_layer/sixlowpan/ip.c @@ -52,9 +52,9 @@ ipv6_hdr_t *ipv6_buf; icmpv6_hdr_t *icmp_buf; uint8_t *nextheader; -int udp_packet_handler_pid = 0; -int tcp_packet_handler_pid = 0; -int rpl_process_pid = 0; +kernel_pid_t udp_packet_handler_pid = KERNEL_PID_NULL; +kernel_pid_t tcp_packet_handler_pid = KERNEL_PID_NULL; +kernel_pid_t rpl_process_pid = KERNEL_PID_NULL; ipv6_addr_t *(*ip_get_next_hop)(ipv6_addr_t *) = 0; static ipv6_net_if_ext_t ipv6_net_if_ext[NET_IF_MAX]; @@ -192,7 +192,7 @@ uint8_t ipv6_get_default_hop_limit(void) } /* Register an upper layer thread */ -uint8_t ipv6_register_packet_handler(int pid) +uint8_t ipv6_register_packet_handler(kernel_pid_t pid) { uint8_t i; @@ -258,7 +258,7 @@ int icmpv6_demultiplex(const icmpv6_hdr_t *hdr) case (ICMPV6_TYPE_RPL_CONTROL): { DEBUG("INFO: packet type: RPL message\n"); - if (rpl_process_pid != 0) { + if (rpl_process_pid != KERNEL_PID_NULL) { msg_t m_send; m_send.content.ptr = (char *) &hdr->code; msg_send(&m_send, rpl_process_pid, 1); @@ -376,7 +376,7 @@ void *ipv6_process(void *arg) } case (IPV6_PROTO_NUM_TCP): { - if (tcp_packet_handler_pid != 0) { + if (tcp_packet_handler_pid != KERNEL_PID_NULL) { m_send.content.ptr = (char *) ipv6_buf; msg_send_receive(&m_send, &m_recv, tcp_packet_handler_pid); } @@ -388,7 +388,7 @@ void *ipv6_process(void *arg) } case (IPV6_PROTO_NUM_UDP): { - if (udp_packet_handler_pid != 0) { + if (udp_packet_handler_pid != KERNEL_PID_NULL) { m_send.content.ptr = (char *) ipv6_buf; msg_send_receive(&m_send, &m_recv, udp_packet_handler_pid); } @@ -749,17 +749,17 @@ uint8_t ipv6_is_router(void) return 0; } -void set_tcp_packet_handler_pid(int pid) +void set_tcp_packet_handler_pid(kernel_pid_t pid) { tcp_packet_handler_pid = pid; } -void set_udp_packet_handler_pid(int pid) +void set_udp_packet_handler_pid(kernel_pid_t pid) { udp_packet_handler_pid = pid; } -void ipv6_register_next_header_handler(uint8_t next_header, int pid) +void ipv6_register_next_header_handler(uint8_t next_header, kernel_pid_t pid) { switch (next_header) { case (IPV6_PROTO_NUM_TCP): @@ -782,7 +782,7 @@ void ipv6_iface_set_routing_provider(ipv6_addr_t *(*next_hop)(ipv6_addr_t *dest) ip_get_next_hop = next_hop; } -void ipv6_register_rpl_handler(int pid) +void ipv6_register_rpl_handler(kernel_pid_t pid) { rpl_process_pid = pid; } diff --git a/sys/net/network_layer/sixlowpan/ip.h b/sys/net/network_layer/sixlowpan/ip.h index acabf50cd837..3f10cd6bd416 100644 --- a/sys/net/network_layer/sixlowpan/ip.h +++ b/sys/net/network_layer/sixlowpan/ip.h @@ -45,7 +45,7 @@ /* extern variables */ extern uint8_t ipv6_ext_hdr_len; -extern int ip_process_pid; +extern kernel_pid_t ip_process_pid; /* base header lengths */ #define LL_HDR_LEN (0x4) diff --git a/sys/net/network_layer/sixlowpan/lowpan.c b/sys/net/network_layer/sixlowpan/lowpan.c index 3bb4d1c72cdd..9e5f1b6621c2 100644 --- a/sys/net/network_layer/sixlowpan/lowpan.c +++ b/sys/net/network_layer/sixlowpan/lowpan.c @@ -123,10 +123,10 @@ uint8_t comp_buf[512]; uint8_t first_frag = 0; mutex_t fifo_mutex; -int ip_process_pid = 0; -int nd_nbr_cache_rem_pid = 0; -int contexts_rem_pid = 0; -int transfer_pid = 0; +kernel_pid_t ip_process_pid = KERNEL_PID_NULL; +kernel_pid_t nd_nbr_cache_rem_pid = KERNEL_PID_NULL; +kernel_pid_t contexts_rem_pid = KERNEL_PID_NULL; +kernel_pid_t transfer_pid = KERNEL_PID_NULL; mutex_t lowpan_context_mutex; @@ -763,7 +763,7 @@ void add_fifo_packet(lowpan_reas_buf_t *current_packet) } /* Register an upper layer thread */ -uint8_t sixlowpan_lowpan_register(int pid) +uint8_t sixlowpan_lowpan_register(kernel_pid_t pid) { uint8_t i; diff --git a/sys/net/network_layer/sixlowpan/mac.c b/sys/net/network_layer/sixlowpan/mac.c index 272d58405532..e1310c26b3db 100644 --- a/sys/net/network_layer/sixlowpan/mac.c +++ b/sys/net/network_layer/sixlowpan/mac.c @@ -318,10 +318,11 @@ int sixlowpan_mac_send_ieee802154_frame(int if_id, } } -int sixlowpan_mac_init(void) +kernel_pid_t sixlowpan_mac_init(void) { - int recv_pid = thread_create(radio_stack_buffer, RADIO_STACK_SIZE, - PRIORITY_MAIN - 2, CREATE_STACKTEST, recv_ieee802154_frame, NULL, "radio"); + kernel_pid_t recv_pid = thread_create(radio_stack_buffer, RADIO_STACK_SIZE, + PRIORITY_MAIN - 2, CREATE_STACKTEST, + recv_ieee802154_frame, NULL, "radio"); int if_id = -1; while ((if_id = net_if_iter_interfaces(if_id)) >= 0) { diff --git a/sys/net/routing/etx_beaconing.c b/sys/net/routing/etx_beaconing.c index 1bc6c64c4fa7..c9b9be4f1e61 100644 --- a/sys/net/routing/etx_beaconing.c +++ b/sys/net/routing/etx_beaconing.c @@ -60,9 +60,9 @@ static uint8_t etx_send_buf[ETX_BUF_SIZE]; static uint8_t etx_rec_buf[ETX_BUF_SIZE]; //PIDs -int etx_beacon_pid = 0; -int etx_radio_pid = 0; -int etx_clock_pid = 0; +kernel_pid_t etx_beacon_pid = KERNEL_PID_NULL; +kernel_pid_t etx_radio_pid = KERNEL_PID_NULL; +kernel_pid_t etx_clock_pid = KERNEL_PID_NULL; //Message queue for radio static msg_t msg_que[ETX_RCV_QUEUE_SIZE]; diff --git a/sys/net/routing/rpl/rpl.c b/sys/net/routing/rpl/rpl.c index 401233856b94..b138e5e85302 100644 --- a/sys/net/routing/rpl/rpl.c +++ b/sys/net/routing/rpl/rpl.c @@ -49,7 +49,7 @@ char addr_str[IPV6_MAX_ADDR_STR_LEN]; /* global variables */ rpl_of_t *rpl_objective_functions[NUMBER_IMPLEMENTED_OFS]; rpl_routing_entry_t rpl_routing_table[RPL_MAX_ROUTING_ENTRIES]; -unsigned int rpl_process_pid; +kernel_pid_t rpl_process_pid; mutex_t rpl_recv_mutex; mutex_t rpl_send_mutex; msg_t rpl_msg_queue[RPL_PKT_RECV_BUF_SIZE]; diff --git a/sys/net/routing/rpl/rpl.h b/sys/net/routing/rpl/rpl.h index a0168897d794..8717c2a8ddef 100644 --- a/sys/net/routing/rpl/rpl.h +++ b/sys/net/routing/rpl/rpl.h @@ -44,7 +44,7 @@ /* global variables */ extern rpl_of_t *rpl_objective_functions[NUMBER_IMPLEMENTED_OFS]; extern rpl_routing_entry_t rpl_routing_table[RPL_MAX_ROUTING_ENTRIES]; -extern unsigned int rpl_process_pid; +extern kernel_pid_t rpl_process_pid; /* needed for receiving messages with ICMP-code 155. Received via IPC from ipv6.c */ extern mutex_t rpl_recv_mutex; diff --git a/sys/net/routing/rpl/trickle.c b/sys/net/routing/rpl/trickle.c index dfa9104eaadf..9acfd898bb27 100644 --- a/sys/net/routing/rpl/trickle.c +++ b/sys/net/routing/rpl/trickle.c @@ -33,10 +33,10 @@ 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; -int dao_delay_over_pid; -int rt_timer_over_pid; +kernel_pid_t timer_over_pid; +kernel_pid_t interval_over_pid; +kernel_pid_t dao_delay_over_pid; +kernel_pid_t rt_timer_over_pid; bool ack_received; uint8_t dao_counter; diff --git a/sys/net/transport_layer/destiny/destiny.c b/sys/net/transport_layer/destiny/destiny.c index 21eb90d244ff..4c3f9b1b288a 100644 --- a/sys/net/transport_layer/destiny/destiny.c +++ b/sys/net/transport_layer/destiny/destiny.c @@ -42,7 +42,7 @@ int destiny_init_transport_layer(void) memset(sockets, 0, MAX_SOCKETS * sizeof(socket_internal_t)); /* UDP */ - int udp_thread_pid = thread_create(udp_stack_buffer, UDP_STACK_SIZE, + kernel_pid_t udp_thread_pid = thread_create(udp_stack_buffer, UDP_STACK_SIZE, PRIORITY_MAIN, CREATE_STACKTEST, udp_packet_handler, NULL, "udp_packet_handler"); @@ -62,7 +62,7 @@ int destiny_init_transport_layer(void) #endif global_sequence_counter = rand(); - int tcp_thread_pid = thread_create(tcp_stack_buffer, TCP_STACK_SIZE, + kernel_pid_t tcp_thread_pid = thread_create(tcp_stack_buffer, TCP_STACK_SIZE, PRIORITY_MAIN, CREATE_STACKTEST, tcp_packet_handler, NULL, "tcp_packet_handler"); diff --git a/sys/net/transport_layer/destiny/msg_help.c b/sys/net/transport_layer/destiny/msg_help.c index 69cdad4868f6..72904d77e312 100644 --- a/sys/net/transport_layer/destiny/msg_help.c +++ b/sys/net/transport_layer/destiny/msg_help.c @@ -42,13 +42,13 @@ int net_msg_reply(msg_t *m, msg_t *reply, uint16_t message) return msg_reply(m, reply); } -int net_msg_send(msg_t *m, unsigned int pid, bool block, uint16_t message) +int net_msg_send(msg_t *m, kernel_pid_t pid, bool block, uint16_t message) { m->type = message; return msg_send(m, pid, block); } -int net_msg_send_recv(msg_t *m, msg_t *reply, unsigned int pid, uint16_t message) +int net_msg_send_recv(msg_t *m, msg_t *reply, kernel_pid_t pid, uint16_t message) { m->type = message; return msg_send_receive(m, reply, pid);; diff --git a/sys/net/transport_layer/destiny/msg_help.h b/sys/net/transport_layer/destiny/msg_help.h index 257f19665ee4..54c65f8251b3 100644 --- a/sys/net/transport_layer/destiny/msg_help.h +++ b/sys/net/transport_layer/destiny/msg_help.h @@ -37,8 +37,8 @@ void block_continue_thread(void); int net_msg_receive(msg_t *m); int net_msg_reply(msg_t *m, msg_t *reply, uint16_t message); -int net_msg_send(msg_t *m, unsigned int pid, bool block, uint16_t message); -int net_msg_send_recv(msg_t *m, msg_t *reply, unsigned int pid, uint16_t message); +int net_msg_send(msg_t *m, kernel_pid_t pid, bool block, uint16_t message); +int net_msg_send_recv(msg_t *m, msg_t *reply, kernel_pid_t pid, uint16_t message); #endif /* MSG_HELP_H_ */ /** diff --git a/sys/net/transport_layer/destiny/socket.c b/sys/net/transport_layer/destiny/socket.c index 8cb68e65310d..11cfd6009cde 100644 --- a/sys/net/transport_layer/destiny/socket.c +++ b/sys/net/transport_layer/destiny/socket.c @@ -236,7 +236,7 @@ bool is_tcp_socket(int s) } } -int bind_udp_socket(int s, sockaddr6_t *name, int namelen, uint8_t pid) +int bind_udp_socket(int s, sockaddr6_t *name, int namelen, kernel_pid_t pid) { int i; @@ -256,7 +256,7 @@ int bind_udp_socket(int s, sockaddr6_t *name, int namelen, uint8_t pid) return 0; } -int bind_tcp_socket(int s, sockaddr6_t *name, int namelen, uint8_t pid) +int bind_tcp_socket(int s, sockaddr6_t *name, int namelen, kernel_pid_t pid) { int i; @@ -676,7 +676,7 @@ int destiny_socket_connect(int socket, sockaddr6_t *addr, uint32_t addrlen) current_tcp_socket->tcp_control.state = TCP_ESTABLISHED; - current_int_tcp_socket->recv_pid = 255; + current_int_tcp_socket->recv_pid = KERNEL_PID_NULL; destiny_socket_print_sockets(); return 0; @@ -1217,7 +1217,7 @@ socket_internal_t *get_waiting_connection_socket(int socket, } int handle_new_tcp_connection(socket_internal_t *current_queued_int_socket, - socket_internal_t *server_socket, uint8_t pid) + socket_internal_t *server_socket, kernel_pid_t pid) { (void) pid; @@ -1293,8 +1293,8 @@ int handle_new_tcp_connection(socket_internal_t *current_queued_int_socket, * the TCP ACK packet */ msg_reply(&msg_recv_client_ack, &msg_send_client_ack); - /* Reset PID to an unlikely value */ - current_queued_int_socket->recv_pid = 255; + /* Reset PID to an invalid value */ + current_queued_int_socket->recv_pid = KERNEL_PID_NULL; /* Waiting for Clients ACK waiting period to time out */ vtimer_usleep(TCP_SYN_INITIAL_TIMEOUT / 2); diff --git a/sys/net/transport_layer/destiny/socket.h b/sys/net/transport_layer/destiny/socket.h index 90e715c44510..94977c872013 100644 --- a/sys/net/transport_layer/destiny/socket.h +++ b/sys/net/transport_layer/destiny/socket.h @@ -61,8 +61,8 @@ typedef struct __attribute__((packed)) { typedef struct { uint8_t socket_id; - uint8_t recv_pid; - uint8_t send_pid; + kernel_pid_t recv_pid; + kernel_pid_t send_pid; uint8_t tcp_input_buffer_end; mutex_t tcp_buffer_mutex; socket_t socket_values; diff --git a/sys/net/transport_layer/destiny/tcp.c b/sys/net/transport_layer/destiny/tcp.c index d8aafce4ffac..6723a5b7c895 100644 --- a/sys/net/transport_layer/destiny/tcp.c +++ b/sys/net/transport_layer/destiny/tcp.c @@ -122,7 +122,7 @@ void handle_tcp_ack_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header, socket_internal_t *tcp_socket) { msg_t m_recv_tcp, m_send_tcp; - uint8_t target_pid; + kernel_pid_t target_pid; if (tcp_socket->socket_values.tcp_control.state == TCP_LAST_ACK) { target_pid = tcp_socket->recv_pid; diff --git a/sys/posix/fd.c b/sys/posix/fd.c index 54e9ea505a90..0a3c3df94a64 100644 --- a/sys/posix/fd.c +++ b/sys/posix/fd.c @@ -67,7 +67,7 @@ static int fd_get_next_free(void) int fd_new(int internal_fd, ssize_t (*internal_read)(int, void *, size_t), ssize_t (*internal_write)(int, const void *, size_t), - int (*internal_close)(int)) + int (*internal_close)(kernel_pid_t)) { int fd = fd_get_next_free(); diff --git a/sys/posix/posix_io.c b/sys/posix/posix_io.c index 3ed427381260..b5a604470fd5 100644 --- a/sys/posix/posix_io.c +++ b/sys/posix/posix_io.c @@ -21,7 +21,7 @@ #include "posix_io.h" -static int _posix_fileop(int pid, int op, int flags) +static int _posix_fileop(kernel_pid_t pid, int op, int flags) { msg_t m; m.type = op; @@ -30,7 +30,7 @@ static int _posix_fileop(int pid, int op, int flags) return m.content.value; } -static int _posix_fileop_data(int pid, int op, char *buffer, int nbytes) +static int _posix_fileop_data(kernel_pid_t pid, int op, char *buffer, int nbytes) { struct posix_iop_t r; r.nbytes = nbytes; @@ -45,22 +45,22 @@ static int _posix_fileop_data(int pid, int op, char *buffer, int nbytes) return r.nbytes; } -int posix_open(int pid, int flags) +int posix_open(kernel_pid_t pid, int flags) { return _posix_fileop(pid, OPEN, flags); } -int posix_close(int pid) +int posix_close(kernel_pid_t pid) { return _posix_fileop(pid, CLOSE, 0); } -int posix_read(int pid, char *buffer, int bufsize) +int posix_read(kernel_pid_t pid, char *buffer, int bufsize) { return _posix_fileop_data(pid, READ, buffer, bufsize); } -int posix_write(int pid, char *buffer, int bufsize) +int posix_write(kernel_pid_t pid, char *buffer, int bufsize) { return _posix_fileop_data(pid, WRITE, buffer, bufsize); } diff --git a/sys/posix/pthread/include/pthread_barrier.h b/sys/posix/pthread/include/pthread_barrier.h index c9b5a0c3251b..5bbb082c4abf 100644 --- a/sys/posix/pthread/include/pthread_barrier.h +++ b/sys/posix/pthread/include/pthread_barrier.h @@ -32,7 +32,7 @@ typedef struct pthread_barrier_waiting_node { struct pthread_barrier_waiting_node *next; /**< The next waiting thread. */ - int pid; /**< The current thread to wake up. */ + kernel_pid_t pid; /**< The current thread to wake up. */ volatile int cont; /**< 0 = spurious wake up, 1 = wake up */ } pthread_barrier_waiting_node_t; diff --git a/sys/posix/pthread/pthread.c b/sys/posix/pthread/pthread.c index 0dde07cbf83b..8dd28866e306 100644 --- a/sys/posix/pthread/pthread.c +++ b/sys/posix/pthread/pthread.c @@ -54,7 +54,7 @@ enum pthread_thread_status { }; typedef struct pthread_thread { - int thread_pid; + kernel_pid_t thread_pid; enum pthread_thread_status status; int joining_thread; @@ -72,7 +72,7 @@ typedef struct pthread_thread { static pthread_thread_t *volatile pthread_sched_threads[MAXTHREADS]; static struct mutex_t pthread_mutex; -static volatile int pthread_reaper_pid = -1; +static volatile int pthread_reaper_pid = KERNEL_PID_NULL; static char pthread_reaper_stack[PTHREAD_REAPER_STACKSIZE]; @@ -116,7 +116,7 @@ int pthread_create(pthread_t *newthread, const pthread_attr_t *attr, void *(*sta { pthread_thread_t *pt = calloc(1, sizeof(pthread_thread_t)); - int pthread_pid = insert(pt); + kernel_pid_t pthread_pid = insert(pt); if (pthread_pid < 0) { free(pt); return -1; @@ -136,7 +136,7 @@ int pthread_create(pthread_t *newthread, const pthread_attr_t *attr, void *(*sta mutex_lock(&pthread_mutex); if (pthread_reaper_pid < 0) { /* volatile pid to overcome problems with double checking */ - volatile int pid = thread_create(pthread_reaper_stack, + volatile kernel_pid_t pid = thread_create(pthread_reaper_stack, PTHREAD_REAPER_STACKSIZE, 0, CREATE_STACKTEST, @@ -184,7 +184,7 @@ void pthread_exit(void *retval) ct->__routine(ct->__arg); } - self->thread_pid = -1; + self->thread_pid = KERNEL_PID_NULL; DEBUG("pthread_exit(%p), self == %p\n", retval, (void *) self); if (self->status != PTS_DETACHED) { self->returnval = retval; @@ -269,7 +269,7 @@ pthread_t pthread_self(void) { pthread_t result = 0; mutex_lock(&pthread_mutex); - int pid = sched_active_pid; /* sched_active_pid is volatile */ + kernel_pid_t pid = sched_active_pid; /* sched_active_pid is volatile */ for (int i = 0; i < MAXTHREADS; i++) { if (pthread_sched_threads[i] && pthread_sched_threads[i]->thread_pid == pid) { result = i+1; diff --git a/sys/posix/pthread/pthread_barrier.c b/sys/posix/pthread/pthread_barrier.c index 9026ccc4cae1..a1629878d0ad 100644 --- a/sys/posix/pthread/pthread_barrier.c +++ b/sys/posix/pthread/pthread_barrier.c @@ -47,13 +47,13 @@ int pthread_barrier_wait(pthread_barrier_t *barrier) * to be woken up. Once the value reaches zero, everyone gets woken up. */ mutex_lock(&barrier->mutex); - DEBUG("%s: hit a synchronization barrier. pid=%u\n", + DEBUG("%s: hit a synchronization barrier. pid=%" PRIkernel_pid"\n", sched_active_thread->name, sched_active_thread->pid); if (--barrier->count > 0) { /* need to wait for further threads */ - DEBUG("%s: waiting for %u threads. pid=%u\n", + DEBUG("%s: waiting for %u threads. pid=%" PRIkernel_pid "\n", sched_active_thread->name, barrier->count, sched_active_thread->pid); pthread_barrier_waiting_node_t node; @@ -79,7 +79,7 @@ int pthread_barrier_wait(pthread_barrier_t *barrier) else { /* all threads have arrived, wake everybody up */ - DEBUG("%s: waking every other thread up. pid=%u\n", + DEBUG("%s: waking every other thread up. pid=%" PRIkernel_pid "\n", sched_active_thread->name, sched_active_thread->pid); int count = 1; /* Count number of woken up threads. diff --git a/sys/posix/pthread/pthread_rwlock.c b/sys/posix/pthread/pthread_rwlock.c index 075fecffe16a..2a70eb6ca423 100644 --- a/sys/posix/pthread/pthread_rwlock.c +++ b/sys/posix/pthread/pthread_rwlock.c @@ -43,7 +43,7 @@ int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *at (void) attr; if (rwlock == NULL) { - DEBUG("Thread %u: pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_pid, "init"); + DEBUG("Thread %" PRIkernel_pid " pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_pid, "init"); return EINVAL; } @@ -54,7 +54,7 @@ int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *at int pthread_rwlock_destroy(pthread_rwlock_t *rwlock) { if (rwlock == NULL) { - DEBUG("Thread %u: pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_pid, "destroy"); + DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_pid, "destroy"); return EINVAL; } @@ -104,19 +104,19 @@ static int pthread_rwlock_lock(pthread_rwlock_t *rwlock, bool allow_spurious) { if (rwlock == NULL) { - DEBUG("Thread %u: 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"); return EINVAL; } mutex_lock(&rwlock->mutex); if (!is_blocked(rwlock)) { - DEBUG("Thread %u: 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"); rwlock->readers += incr_when_held; } else { - DEBUG("Thread %u: 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"); /* queue for the lock */ @@ -139,12 +139,12 @@ static int pthread_rwlock_lock(pthread_rwlock_t *rwlock, mutex_lock(&rwlock->mutex); if (waiting_node.continue_) { /* pthread_rwlock_unlock() already set rwlock->readers */ - DEBUG("Thread %u: 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"); break; } else if (allow_spurious) { - DEBUG("Thread %u: 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"); queue_remove(&rwlock->queue, &waiting_node.qnode); mutex_unlock(&rwlock->mutex); @@ -162,7 +162,7 @@ static int pthread_rwlock_trylock(pthread_rwlock_t *rwlock, int incr_when_held) { if (rwlock == NULL) { - DEBUG("Thread %u: pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_pid, "trylock"); + DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_pid, "trylock"); return EINVAL; } else if (mutex_trylock(&rwlock->mutex) == 0) { @@ -243,30 +243,30 @@ int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec * int pthread_rwlock_unlock(pthread_rwlock_t *rwlock) { if (rwlock == NULL) { - DEBUG("Thread %u: pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_pid, "unlock"); + DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_pid, "unlock"); return EINVAL; } mutex_lock(&rwlock->mutex); if (rwlock->readers == 0) { /* the lock is open */ - DEBUG("Thread %u: pthread_rwlock_%s(): lock is open\n", thread_pid, "unlock"); + DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): lock is open\n", thread_pid, "unlock"); mutex_unlock(&rwlock->mutex); return EPERM; } if (rwlock->readers > 0) { - DEBUG("Thread %u: pthread_rwlock_%s(): release %s lock\n", thread_pid, "unlock", "read"); + DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): release %s lock\n", thread_pid, "unlock", "read"); --rwlock->readers; } else { - DEBUG("Thread %u: pthread_rwlock_%s(): release %s lock\n", thread_pid, "unlock", "write"); + DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): release %s lock\n", thread_pid, "unlock", "write"); rwlock->readers = 0; } if (rwlock->readers != 0 || rwlock->queue.next == NULL) { /* this thread was not the last reader, or no one is waiting to aquire the lock */ - DEBUG("Thread %u: pthread_rwlock_%s(): no one is waiting\n", thread_pid, "unlock"); + DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): no one is waiting\n", thread_pid, "unlock"); mutex_unlock(&rwlock->mutex); return 0; } @@ -279,12 +279,12 @@ int pthread_rwlock_unlock(pthread_rwlock_t *rwlock) sched_set_status(waiting_node->thread, STATUS_PENDING); if (waiting_node->is_writer) { - DEBUG("Thread %u: pthread_rwlock_%s(): continue %s %u\n", + DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): continue %s %" PRIkernel_pid "\n", thread_pid, "unlock", "writer", waiting_node->thread->pid); --rwlock->readers; } else { - DEBUG("Thread %u: pthread_rwlock_%s(): continue %s %u\n", + DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): continue %s %" PRIkernel_pid "\n", thread_pid, "unlock", "reader", waiting_node->thread->pid); ++rwlock->readers; @@ -293,12 +293,12 @@ int pthread_rwlock_unlock(pthread_rwlock_t *rwlock) waiting_node = (__pthread_rwlock_waiter_node_t *) rwlock->queue.next->data; 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. */ - DEBUG("Thread %u: pthread_rwlock_%s(): continuing readers blocked by writer %u\n", + DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): continuing readers blocked by writer %" PRIkernel_pid "\n", thread_pid, "unlock", waiting_node->thread->pid); break; } waiting_node->continue_ = true; - DEBUG("Thread %u: pthread_rwlock_%s(): continue %s %u\n", + DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): continue %s %" PRIkernel_pid "\n", thread_pid, "unlock", "reader", waiting_node->thread->pid); /* wake up this reader */ diff --git a/sys/ps/ps.c b/sys/ps/ps.c index b4087ecaec63..9a21b576dbcb 100644 --- a/sys/ps/ps.c +++ b/sys/ps/ps.c @@ -64,7 +64,7 @@ void thread_print_all(void) #endif overall_stacksz += stacksz; stacksz -= thread_measure_stack_free(p->stack_start); - printf("\t%3u | %-21s| %-8s %.1s | %3i | %5i (%5i) %p" + printf("\t%3" PRIkernel_pid " | %-21s| %-8s %.1s | %3i | %5i (%5i) %p" #if SCHEDSTATISTICS " | %4d/1k | %8d" #endif diff --git a/sys/transceiver/transceiver.c b/sys/transceiver/transceiver.c index 03f491ca6c0a..e9942361553b 100644 --- a/sys/transceiver/transceiver.c +++ b/sys/transceiver/transceiver.c @@ -88,7 +88,7 @@ msg_t msg_buffer[TRANSCEIVER_MSG_BUFFER_SIZE]; uint32_t response; ///< response bytes for messages to upper layer threads -int transceiver_pid = -1; ///< the transceiver thread's pid +kernel_pid_t transceiver_pid = KERNEL_PID_NULL; ///< the transceiver thread's pid static volatile uint8_t rx_buffer_pos = 0; static volatile uint8_t transceiver_buffer_pos = 0; @@ -165,7 +165,7 @@ void transceiver_init(transceiver_type_t t) for (i = 0; i < TRANSCEIVER_MAX_REGISTERED; i++) { reg[i].transceivers = TRANSCEIVER_NONE; - reg[i].pid = 0; + reg[i].pid = KERNEL_PID_NULL; } /* check if a non defined bit is set */ @@ -178,7 +178,7 @@ void transceiver_init(transceiver_type_t t) } /* Start the transceiver thread */ -int transceiver_start(void) +kernel_pid_t transceiver_start(void) { transceiver_pid = thread_create(transceiver_stack, TRANSCEIVER_STACK_SIZE, PRIORITY_MAIN - 3, CREATE_STACKTEST, run, NULL, "Transceiver"); @@ -231,7 +231,7 @@ int transceiver_start(void) } /* Register an upper layer thread */ -uint8_t transceiver_register(transceiver_type_t t, int pid) +uint8_t transceiver_register(transceiver_type_t t, kernel_pid_t pid) { int result = 0; int state = disableIRQ(); @@ -250,7 +250,7 @@ uint8_t transceiver_register(transceiver_type_t t, int pid) } /* Unregister an upper layer thread */ -uint8_t transceiver_unregister(transceiver_type_t t, int pid) +uint8_t transceiver_unregister(transceiver_type_t t, kernel_pid_t pid) { int result = 0; int state = disableIRQ(); @@ -499,7 +499,7 @@ static void receive_packet(uint16_t type, uint8_t pos) while (reg[i].transceivers != TRANSCEIVER_NONE) { if (reg[i].transceivers & t) { m.content.ptr = (char *) &(transceiver_buffer[transceiver_buffer_pos]); - DEBUG("transceiver: Notify thread %i\n", reg[i].pid); + DEBUG("transceiver: Notify thread %" PRIkernel_pid "\n", reg[i].pid); if (msg_send(&m, reg[i].pid, false) && (m.type != ENOBUFFER)) { transceiver_buffer[transceiver_buffer_pos].processing++; diff --git a/sys/uart0/uart0.c b/sys/uart0/uart0.c index b7f5bae47e4e..ba571f55ffb6 100644 --- a/sys/uart0/uart0.c +++ b/sys/uart0/uart0.c @@ -39,7 +39,7 @@ #define UART0_STACKSIZE (KERNEL_CONF_STACKSIZE_DEFAULT) ringbuffer_t uart0_ringbuffer; -int uart0_handler_pid; +kernel_pid_t uart0_handler_pid; static char buffer[UART0_BUFSIZE]; @@ -48,7 +48,7 @@ static char uart0_thread_stack[UART0_STACKSIZE]; void board_uart0_init(void) { ringbuffer_init(&uart0_ringbuffer, buffer, UART0_BUFSIZE); - int pid = thread_create( + kernel_pid_t pid = thread_create( uart0_thread_stack, sizeof(uart0_thread_stack), PRIORITY_MAIN - 1, diff --git a/sys/vtimer/vtimer.c b/sys/vtimer/vtimer.c index fd2aca05947e..cf960d456852 100644 --- a/sys/vtimer/vtimer.c +++ b/sys/vtimer/vtimer.c @@ -306,7 +306,7 @@ int vtimer_init(void) return 0; } -int vtimer_set_wakeup(vtimer_t *t, timex_t interval, int pid) +int vtimer_set_wakeup(vtimer_t *t, timex_t interval, kernel_pid_t pid) { t->action = vtimer_callback_wakeup; t->arg = NULL; @@ -364,7 +364,7 @@ int vtimer_remove(vtimer_t *t) return 0; } -int vtimer_set_msg(vtimer_t *t, timex_t interval, unsigned int pid, void *ptr) +int vtimer_set_msg(vtimer_t *t, timex_t interval, kernel_pid_t pid, void *ptr) { t->action = vtimer_callback_msg; t->arg = ptr; @@ -407,7 +407,7 @@ void vtimer_print(vtimer_t *t) printf("Seconds: %" PRIu32 " - Microseconds: %" PRIu32 "\n \ action: %p\n \ arg: %p\n \ - pid: %u\n", + pid: %" PRIi32 "\n", t->absolute.seconds, t->absolute.microseconds, t->action, t->arg, diff --git a/tests/test_ipc_pingpong/main.c b/tests/test_ipc_pingpong/main.c index 5faca693b87f..f6ee1caebfba 100644 --- a/tests/test_ipc_pingpong/main.c +++ b/tests/test_ipc_pingpong/main.c @@ -30,7 +30,7 @@ #define LIMIT 1000 static char stacks[3][KERNEL_CONF_STACKSIZE_MAIN]; -static int pids[3]; +static kernel_pid_t pids[3]; static void *first_thread(void *arg) { @@ -61,7 +61,7 @@ static void *second_thread(void *arg) while (1) { msg_t m1; msg_receive(&m1); - DEBUG("2nd: got msg from %i: %i\n", m1.sender_pid, m1.content.value); + DEBUG("2nd: got msg from %" PRIkernel_pid ": %i\n", m1.sender_pid, m1.content.value); msg_t m2; m2.content.value = m1.content.value + 1; @@ -90,7 +90,7 @@ static void *third_thread(void *arg) while (1) { msg_t m; msg_receive(&m); - DEBUG("3rd: got msg from %i: %i\n", m.sender_pid, m.content.value); + DEBUG("3rd: got msg from %" PRIkernel_pid ": %i\n", m.sender_pid, m.content.value); --m.content.value; msg_reply(&m, &m); diff --git a/tests/test_nativenet/main.c b/tests/test_nativenet/main.c index b510001b4d1a..52cd76e8ad95 100644 --- a/tests/test_nativenet/main.c +++ b/tests/test_nativenet/main.c @@ -130,7 +130,7 @@ void sender(void) int main(void) { #ifndef SENDER - int radio_pid; + kernel_pid_t radio_pid; #endif int16_t a; msg_t mesg; diff --git a/tests/test_posix_semaphore/main.c b/tests/test_posix_semaphore/main.c index 497931a92c46..fa9fc97447bd 100644 --- a/tests/test_posix_semaphore/main.c +++ b/tests/test_posix_semaphore/main.c @@ -63,9 +63,13 @@ static void test1(void) } puts("first: thread create"); - int pid = thread_create(test1_thread_stack, sizeof(test1_thread_stack), - PRIORITY_MAIN - 1, CREATE_STACKTEST | CREATE_WOUT_YIELD, - test1_second_thread, NULL, "second"); + kernel_pid_t pid = thread_create(test1_thread_stack, + sizeof(test1_thread_stack), + PRIORITY_MAIN - 1, + CREATE_STACKTEST | CREATE_WOUT_YIELD, + test1_second_thread, + NULL, + "second"); if (pid < 0) { puts("first: thread create failed"); @@ -137,9 +141,13 @@ void test2(void) snprintf(names[i], sizeof(names[i]), "priority %d", priority); printf("first: thread create: %d\n", priority); - int pid = thread_create(test2_thread_stack[i], - sizeof(test2_thread_stack[i]), priority, CREATE_STACKTEST, - priority_sema_thread, NULL, names[i]); + kernel_pid_t pid = thread_create(test2_thread_stack[i], + sizeof(test2_thread_stack[i]), + priority, + CREATE_STACKTEST, + priority_sema_thread, + NULL, + names[i]); if (pid < 0) { puts("first: thread create failed"); diff --git a/tests/test_pthread_condition_variable/main.c b/tests/test_pthread_condition_variable/main.c index 92c8f1f1babe..9b3fde595246 100644 --- a/tests/test_pthread_condition_variable/main.c +++ b/tests/test_pthread_condition_variable/main.c @@ -58,13 +58,9 @@ int main(void) mutex_init(&mutex); pthread_cond_init(&cv, NULL); - int pid = thread_create(stack, - sizeof(stack), - PRIORITY_MAIN - 1, - CREATE_WOUT_YIELD | CREATE_STACKTEST, - second_thread, - NULL, - "second_thread"); + kernel_pid_t pid = thread_create(stack,sizeof(stack), PRIORITY_MAIN - 1, + CREATE_WOUT_YIELD | CREATE_STACKTEST, + second_thread, NULL, "second_thread"); while (1) { mutex_lock(&mutex); diff --git a/tests/test_pthread_rwlock/main.c b/tests/test_pthread_rwlock/main.c index 4a9d9e1c4fae..8a8dd4580bbe 100644 --- a/tests/test_pthread_rwlock/main.c +++ b/tests/test_pthread_rwlock/main.c @@ -54,7 +54,7 @@ static pthread_rwlock_t rwlock; static volatile unsigned counter; #define PRINTF(FMT, ...) \ - printf("%c%u (prio=%u): " FMT "\n", sched_active_thread->name[0], sched_active_pid, sched_active_thread->priority, __VA_ARGS__) + printf("%c%" PRIkernel_pid " (prio=%u): " FMT "\n", sched_active_thread->name[0], sched_active_pid, sched_active_thread->priority, __VA_ARGS__) static void do_sleep(int factor) { diff --git a/tests/test_queue_fairness/main.c b/tests/test_queue_fairness/main.c index 81a551aeef33..c557fd921d1f 100644 --- a/tests/test_queue_fairness/main.c +++ b/tests/test_queue_fairness/main.c @@ -28,10 +28,10 @@ #define NUM_ITERATIONS (10) static char stacks[NUM_CHILDREN][STACK_SIZE]; -static int pids[NUM_CHILDREN]; +static kernel_pid_t pids[NUM_CHILDREN]; static char names[NUM_CHILDREN][8]; -static int parent_pid; +static kernel_pid_t parent_pid; static void *child_fun(void *arg) { diff --git a/tests/test_thread_cooperation/main.c b/tests/test_thread_cooperation/main.c index 85c128dbbcbc..d8306d252cde 100644 --- a/tests/test_thread_cooperation/main.c +++ b/tests/test_thread_cooperation/main.c @@ -29,8 +29,8 @@ mutex_t mtx; volatile int storage = 1; -int main_id; -int ths[PROBLEM]; +kernel_pid_t main_id; +kernel_pid_t ths[PROBLEM]; char stacks[PROBLEM][KERNEL_CONF_STACKSIZE_MAIN]; void *run(void *arg) @@ -38,7 +38,7 @@ void *run(void *arg) (void) arg; int err; - int me = thread_getpid(); + kernel_pid_t me = thread_getpid(); printf("I am alive (%d)\n", me); msg_t m; err = msg_receive(&m); diff --git a/tests/test_thread_msg_block_w_queue/main.c b/tests/test_thread_msg_block_w_queue/main.c index 20de19d2fd64..263bdf56443e 100644 --- a/tests/test_thread_msg_block_w_queue/main.c +++ b/tests/test_thread_msg_block_w_queue/main.c @@ -27,13 +27,13 @@ char t1_stack[KERNEL_CONF_STACKSIZE_MAIN]; -uint16_t p1, p_main; +kernel_pid_t p1, p_main; void *thread1(void *arg) { (void) arg; - printf("THREAD %u start\n", p1); + printf("THREAD %" PRIkernel_pid " start\n", p1); msg_t msg, reply; memset(&msg, 1, sizeof(msg_t)); @@ -43,10 +43,10 @@ void *thread1(void *arg) /* step 2: send message, turning its status into STATUS_REPLY_BLOCKED */ msg_send_receive(&msg, &reply, p_main); - printf("received: %u, %u \n", reply.sender_pid, reply.type); + printf("received: %" PRIkernel_pid ", %u \n", reply.sender_pid, reply.type); printf("pointer: %s\n", reply.content.ptr); - printf("THREAD %u SHOULD BE BLOCKING :(\n", p1); + printf("THREAD %" PRIkernel_pid " SHOULD BE BLOCKING :(\n", p1); return NULL; } @@ -66,6 +66,6 @@ int main(void) /* step 3: receive a msg */ msg_receive(&msg); - printf("MAIN THREAD %u ALIVE!\n", p_main); + printf("MAIN THREAD %" PRIkernel_pid " ALIVE!\n", p_main); return 0; } diff --git a/tests/test_thread_msg_block_wo_queue/main.c b/tests/test_thread_msg_block_wo_queue/main.c index 42e193edc973..d03560529b01 100644 --- a/tests/test_thread_msg_block_wo_queue/main.c +++ b/tests/test_thread_msg_block_wo_queue/main.c @@ -27,7 +27,7 @@ char t1_stack[KERNEL_CONF_STACKSIZE_MAIN]; -uint16_t p1, p_main; +kernel_pid_t p1, p_main; void *thread1(void *arg) { @@ -43,10 +43,10 @@ void *thread1(void *arg) /* step 2: send message, turning its status into STATUS_REPLY_BLOCKED */ msg_send_receive(&msg, &reply, p_main); - printf("received: %u, %u \n", reply.sender_pid, reply.type); + printf("received: %" PRIkernel_pid ", %u \n", reply.sender_pid, reply.type); printf("pointer: %s\n", reply.content.ptr); - printf("THREAD %u SHOULD BE BLOCKING :(\n", p1); + printf("THREAD %" PRIkernel_pid " SHOULD BE BLOCKING :(\n", p1); return NULL; } @@ -63,6 +63,6 @@ int main(void) /* step 3: receive a msg */ msg_receive(&msg); - printf("MAIN THREAD %u ALIVE!\n", p_main); + printf("MAIN THREAD %" PRIkernel_pid " ALIVE!\n", p_main); return 0; } diff --git a/tests/test_thread_msg_seq/main.c b/tests/test_thread_msg_seq/main.c index 06b09fad9d88..942df957b545 100644 --- a/tests/test_thread_msg_seq/main.c +++ b/tests/test_thread_msg_seq/main.c @@ -29,14 +29,14 @@ char t1_stack[KERNEL_CONF_STACKSIZE_MAIN]; char t2_stack[KERNEL_CONF_STACKSIZE_MAIN]; char t3_stack[KERNEL_CONF_STACKSIZE_MAIN]; -uint16_t p1, p2, p3; +kernel_pid_t p1, p2, p3; void *sub_thread(void *arg) { (void) arg; - int pid = thread_getpid(); - printf("THREAD %s (pid:%i) start\n", thread_getname(pid), pid); + kernel_pid_t pid = thread_getpid(); + printf("THREAD %s (pid:%" PRIkernel_pid ") start\n", thread_getname(pid), pid); msg_t msg; @@ -44,7 +44,7 @@ void *sub_thread(void *arg) msg_send(&msg, 1, 1); - printf("THREAD %s (pid:%i) end.\n", thread_getname(pid), pid); + printf("THREAD %s (pid:%" PRIkernel_pid ") end.\n", thread_getname(pid), pid); return NULL; } @@ -67,7 +67,7 @@ int main(void) puts("THREADS CREATED\n"); for(int i = 0; i < 3; i++) { msg_receive(&msg); - printf("Got msg from pid %i: \"%s\"\n", msg.sender_pid, msg.content.ptr); + printf("Got msg from pid %" PRIkernel_pid ": \"%s\"\n", msg.sender_pid, msg.content.ptr); } return 0; diff --git a/tests/test_vtimer_msg/main.c b/tests/test_vtimer_msg/main.c index ab43d41d6bf8..2578ef283e55 100644 --- a/tests/test_vtimer_msg/main.c +++ b/tests/test_vtimer_msg/main.c @@ -44,7 +44,7 @@ void *timer_thread(void *arg) { (void) arg; - printf("This is thread %d\n", thread_getpid()); + printf("This is thread %" PRIkernel_pid "\n", thread_getpid()); /* we need a queue if the second message arrives while the first is still processed */ /* without a queue, the message would get lost */ @@ -77,7 +77,7 @@ void *timer_thread_local(void *arg) { (void) arg; - printf("This is thread %d\n", thread_getpid()); + printf("This is thread %" PRIkernel_pid "\n", thread_getpid()); while (1) { msg_t m; @@ -92,7 +92,7 @@ void *timer_thread_local(void *arg) int main(void) { msg_t m; - int pid = thread_create( + kernel_pid_t pid = thread_create( timer_stack, sizeof(timer_stack), PRIORITY_MAIN - 1, @@ -109,7 +109,7 @@ int main(void) m.content.ptr = (char *) &msg_b; msg_send(&m, pid, false); - int pid2 = thread_create( + kernel_pid_t pid2 = thread_create( timer_stack_local, sizeof(timer_stack_local), PRIORITY_MAIN - 1, diff --git a/tests/test_vtimer_msg_diff/main.c b/tests/test_vtimer_msg_diff/main.c index cb3747b0f09e..fbb28d64115c 100644 --- a/tests/test_vtimer_msg_diff/main.c +++ b/tests/test_vtimer_msg_diff/main.c @@ -54,7 +54,7 @@ struct timer_msg timer_msgs[] = { { .interval = { .seconds = 0, .microseconds = void *timer_thread(void *arg) { (void) arg; - printf("This is thread %d\n", thread_getpid()); + printf("This is thread %" PRIkernel_pid "\n", thread_getpid()); msg_t msgq[16]; msg_init_queue(msgq, sizeof(msgq)); @@ -103,7 +103,7 @@ void *timer_thread(void *arg) int main(void) { msg_t m; - int pid = thread_create( + kernel_pid_t pid = thread_create( timer_stack, sizeof(timer_stack), PRIORITY_MAIN - 1,