diff --git a/include/metalsvm/mailbox.h b/include/metalsvm/mailbox.h index 9801a8d5..4dff4887 100644 --- a/include/metalsvm/mailbox.h +++ b/include/metalsvm/mailbox.h @@ -21,7 +21,7 @@ #define __MAILBOX_H__ #include -#include +#include #include #ifdef __cplusplus @@ -29,14 +29,6 @@ extern "C" { #endif #define MAILBOX(name, type) \ - typedef struct mailbox_##name { \ - type buffer[MAILBOX_SIZE]; \ - int wpos, rpos; \ - sem_t mails; \ - sem_t boxes; \ - spinlock_t rlock, wlock; \ - } mailbox_##name##_t; \ - \ inline static int mailbox_##name##_init(mailbox_##name##_t* m) { \ if (BUILTIN_EXPECT(!m, 0)) \ return -1; \ @@ -106,6 +98,7 @@ extern "C" { return 0; \ }\ +MAILBOX(wait_msg, wait_msg_t) MAILBOX(int32, int32_t) MAILBOX(int16, int16_t) MAILBOX(int8, int8_t) diff --git a/include/metalsvm/mailbox_types.h b/include/metalsvm/mailbox_types.h new file mode 100644 index 00000000..f4d09c64 --- /dev/null +++ b/include/metalsvm/mailbox_types.h @@ -0,0 +1,56 @@ +/* + * Copyright 2010 Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of MetalSVM. + */ + +#ifndef __MAILBOX_TYPES_H__ +#define __MAILBOX_TYPES_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + tid_t id; + int32_t result; +} wait_msg_t; + +#define MAILBOX_TYPES(name, type) \ + typedef struct mailbox_##name { \ + type buffer[MAILBOX_SIZE]; \ + int wpos, rpos; \ + sem_t mails; \ + sem_t boxes; \ + spinlock_t rlock, wlock; \ + } mailbox_##name##_t; + +MAILBOX_TYPES(wait_msg, wait_msg_t) +MAILBOX_TYPES(int32, int32_t) +MAILBOX_TYPES(int16, int16_t) +MAILBOX_TYPES(int8, int8_t) +MAILBOX_TYPES(uint32, uint32_t) +MAILBOX_TYPES(uint16, uint16_t) +MAILBOX_TYPES(uint8, uint8_t) +MAILBOX_TYPES(ptr, void*) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/metalsvm/semaphore.h b/include/metalsvm/semaphore.h index 53cc3c6a..b0b524f6 100644 --- a/include/metalsvm/semaphore.h +++ b/include/metalsvm/semaphore.h @@ -21,22 +21,13 @@ #define __SEMAPHORE_H__ #include -#include +#include #include #ifdef __cplusplus extern "C" { #endif -typedef struct { - unsigned int value; - tid_t queue[MAX_TASKS]; - unsigned int pos; - spinlock_t lock; -} sem_t; - -#define SEM_INIT(v) {v, {[0 ... MAX_TASKS-1] = MAX_TASKS}, 0, SPINLOCK_INIT} - inline static int sem_init(sem_t* s, unsigned int v) { unsigned int i; diff --git a/include/metalsvm/semaphore_types.h b/include/metalsvm/semaphore_types.h new file mode 100644 index 00000000..09298c62 --- /dev/null +++ b/include/metalsvm/semaphore_types.h @@ -0,0 +1,42 @@ +/* + * Copyright 2010 Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of MetalSVM. + */ + +#ifndef __SEMAPHORE_TYPES_H__ +#define __SEMAPHORE_TYPES_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + unsigned int value; + tid_t queue[MAX_TASKS]; + unsigned int pos; + spinlock_t lock; +} sem_t; + +#define SEM_INIT(v) {v, {[0 ... MAX_TASKS-1] = MAX_TASKS}, 0, SPINLOCK_INIT} + +#ifdef __cplusplus +} +#endif + +#endif