[Xenomai-git] Philippe Gerum : copperplate/init: make --no-mlock a nop over Cobalt
Module: xenomai-forge Branch: master Commit: 06458a35b78ce1f09afa78282ecb091fcc132d95 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=06458a35b78ce1f09afa78282ecb091fcc132d95 Author: Philippe Gerum r...@xenomai.org Date: Sun Dec 11 16:12:15 2011 +0100 copperplate/init: make --no-mlock a nop over Cobalt --- README |4 lib/copperplate/init.c |4 +++- 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/README b/README index af92b3d..5038452 100644 --- a/README +++ b/README @@ -274,6 +274,10 @@ command line, namely: the Xenomai core as part of the emulator initialization duties. + This flag only applies to the Mercury core. Memory must be + locked when invoking dual kernel services, therefore this + switch is a nop over Cobalt. + --registry-mountpt=path Tells the emulator to mount the object registry over the given diff --git a/lib/copperplate/init.c b/lib/copperplate/init.c index f1acc7e..81e103e 100644 --- a/lib/copperplate/init.c +++ b/lib/copperplate/init.c @@ -123,7 +123,7 @@ static void usage(void) fprintf(stderr, usage: program options, where options may be:\n); fprintf(stderr, --mem-pool-size=sizeK size of the main heap (kbytes)\n); -fprintf(stderr, --no-mlock do not lock memory at init\n); +fprintf(stderr, --no-mlock do not lock memory at init (Mercury only)\n); fprintf(stderr, --registry-mountpt=pathmount point of registry\n); fprintf(stderr, --no-registrysuppress object registration\n); fprintf(stderr, --session=labellabel of shared multi-processing session\n); @@ -501,6 +501,7 @@ void copperplate_init(int *argcp, char *const **argvp) goto fail; } +#ifdef CONFIG_XENO_MERCURY if (__node_info.no_mlock == 0) { ret = mlockall(MCL_CURRENT | MCL_FUTURE); if (ret) { @@ -509,6 +510,7 @@ void copperplate_init(int *argcp, char *const **argvp) goto fail; } } +#endif /* * Now that we have bootstrapped the core, we may call the ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : powerpc: upgrade I-pipe support to 3.0.1-powerpc-2.13-05
Module: xenomai-forge Branch: master Commit: 39cbe83a5d711a6089488f7f36890d3e03e8808f URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=39cbe83a5d711a6089488f7f36890d3e03e8808f Author: Philippe Gerum r...@xenomai.org Date: Sun Dec 11 17:59:53 2011 +0100 powerpc: upgrade I-pipe support to 3.0.1-powerpc-2.13-05 --- .../adeos-ipipe-2.6.34.4-powerpc-2.10-05.patch |12102 ...tch = adeos-ipipe-3.1.5-powerpc-2.13-05.patch} | 2581 +++-- 2 files changed, 1352 insertions(+), 13331 deletions(-) Diff: http://git.xenomai.org/?p=xenomai-forge.git;a=commitdiff;h=39cbe83a5d711a6089488f7f36890d3e03e8808f ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : powerpc: upgrade I-pipe support to 3.1.5-powerpc-2.13-05
Module: xenomai-forge Branch: master Commit: 41e6e08a3bd77c38d2013bdb512812188961088c URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=41e6e08a3bd77c38d2013bdb512812188961088c Author: Philippe Gerum r...@xenomai.org Date: Sun Dec 11 17:59:53 2011 +0100 powerpc: upgrade I-pipe support to 3.1.5-powerpc-2.13-05 --- .../adeos-ipipe-2.6.34.4-powerpc-2.10-05.patch |12102 ...tch = adeos-ipipe-3.1.5-powerpc-2.13-05.patch} | 2581 +++-- 2 files changed, 1352 insertions(+), 13331 deletions(-) Diff: http://git.xenomai.org/?p=xenomai-forge.git;a=commitdiff;h=41e6e08a3bd77c38d2013bdb512812188961088c ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Gilles Chanteperdrix : cobalt: move mutexattr system calls to mutex_attr.c
Module: xenomai-gch Branch: for-forge Commit: 87ce6b67bf4b66d54a8d1c62ce65a74fbaa1cd23 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=87ce6b67bf4b66d54a8d1c62ce65a74fbaa1cd23 Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Sun Dec 11 17:35:31 2011 +0100 cobalt: move mutexattr system calls to mutex_attr.c --- include/cobalt/pthread.h | 34 -- kernel/cobalt/mutex.c |3 - kernel/cobalt/mutex.h | 22 ++ kernel/cobalt/mutex_attr.c | 158 ++- kernel/cobalt/syscall.c| 139 ++ 5 files changed, 169 insertions(+), 187 deletions(-) diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h index 3a39fbe..62a7134 100644 --- a/include/cobalt/pthread.h +++ b/include/cobalt/pthread.h @@ -273,40 +273,6 @@ int pthread_attr_getaffinity_np(const pthread_attr_t *attr, int pthread_attr_setaffinity_np(pthread_attr_t *attr, xnarch_cpumask_t mask); -int pthread_mutexattr_init(pthread_mutexattr_t *attr); - -int pthread_mutexattr_destroy(pthread_mutexattr_t *attr); - -int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, - int *type); - -int pthread_mutexattr_settype(pthread_mutexattr_t *attr, - int type); - -int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, - int *proto); - -int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, - int proto); - -int pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, int *pshared); - -int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared); - -int pthread_mutex_init(pthread_mutex_t *mutex, - const pthread_mutexattr_t *attr); - -int pthread_mutex_destroy(pthread_mutex_t *mutex); - -int pthread_mutex_trylock(pthread_mutex_t *mutex); - -int pthread_mutex_lock(pthread_mutex_t *mutex); - -int pthread_mutex_timedlock(pthread_mutex_t *mutex, - const struct timespec *to); - -int pthread_mutex_unlock(pthread_mutex_t *mutex); - int pthread_condattr_init(pthread_condattr_t *attr); int pthread_condattr_destroy(pthread_condattr_t *attr); diff --git a/kernel/cobalt/mutex.c b/kernel/cobalt/mutex.c index 28bcaac..3da89a3 100644 --- a/kernel/cobalt/mutex.c +++ b/kernel/cobalt/mutex.c @@ -51,8 +51,6 @@ #include mutex.h #include cond.h -pthread_mutexattr_t cobalt_default_mutex_attr; - static int cobalt_mutex_init_inner(struct __shadow_mutex *shadow, cobalt_mutex_t *mutex, struct mutex_dat *datp, @@ -411,7 +409,6 @@ void cobalt_mutexq_cleanup(cobalt_kqueues_t *q) void cobalt_mutex_pkg_init(void) { initq(cobalt_global_kqueues.mutexq); - pthread_mutexattr_init(cobalt_default_mutex_attr); } void cobalt_mutex_pkg_cleanup(void) diff --git a/kernel/cobalt/mutex.h b/kernel/cobalt/mutex.h index feba86f..0fbd977 100644 --- a/kernel/cobalt/mutex.h +++ b/kernel/cobalt/mutex.h @@ -124,6 +124,28 @@ static inline int cobalt_mutex_release(xnthread_t *cur, cobalt_mutex_t *mutex) return need_resched; } +int cobalt_mutexattr_init(pthread_mutexattr_t __user *u_attr); + +int cobalt_mutexattr_destroy(pthread_mutexattr_t __user *u_attr); + +int cobalt_mutexattr_gettype(const pthread_mutexattr_t __user *u_attr, +int __user *u_type); + +int cobalt_mutexattr_settype(pthread_mutexattr_t __user *u_attr, +int type); + +int cobalt_mutexattr_getprotocol(const pthread_mutexattr_t __user *u_attr, +int __user *u_proto); + +int cobalt_mutexattr_setprotocol(pthread_mutexattr_t __user *u_attr, +int proto); + +int cobalt_mutexattr_getpshared(const pthread_mutexattr_t __user *u_attr, + int __user *u_pshared); + +int cobalt_mutexattr_setpshared(pthread_mutexattr_t __user *u_attr, + int pshared); + int cobalt_mutex_check_init(struct __shadow_mutex __user *u_mx); int cobalt_mutex_init(struct __shadow_mutex __user *u_mx, diff --git a/kernel/cobalt/mutex_attr.c b/kernel/cobalt/mutex_attr.c index 3bcadf0..4729840 100644 --- a/kernel/cobalt/mutex_attr.c +++ b/kernel/cobalt/mutex_attr.c @@ -23,7 +23,7 @@ #include internal.h -static const pthread_mutexattr_t default_mutex_attr = { +const pthread_mutexattr_t cobalt_default_mutex_attr = { magic: COBALT_MUTEX_ATTR_MAGIC, type: PTHREAD_MUTEX_NORMAL, protocol: PTHREAD_PRIO_NONE, @@ -53,12 +53,12 @@ static const pthread_mutexattr_t default_mutex_attr = { * Specification./a * */ -int pthread_mutexattr_init(pthread_mutexattr_t * attr) +static inline int pthread_mutexattr_init(pthread_mutexattr_t * attr) { if (!attr) return ENOMEM; - *attr =
[Xenomai-git] Gilles Chanteperdrix : cobalt: remove thread_attr.c
Module: xenomai-gch Branch: for-forge Commit: bc58b58f23279c6a72669b139275f5ef6be79c2d URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=bc58b58f23279c6a72669b139275f5ef6be79c2d Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Sun Dec 11 17:33:55 2011 +0100 cobalt: remove thread_attr.c --- kernel/cobalt/Makefile |1 - kernel/cobalt/thread.c | 21 +- kernel/cobalt/thread_attr.c | 1088 --- 3 files changed, 16 insertions(+), 1094 deletions(-) diff --git a/kernel/cobalt/Makefile b/kernel/cobalt/Makefile index f4bc809..d54803c 100644 --- a/kernel/cobalt/Makefile +++ b/kernel/cobalt/Makefile @@ -1,7 +1,6 @@ obj-$(CONFIG_XENOMAI) += nucleus/ rtdm/ xeno_cobalt.o xeno_cobalt-y := \ - thread_attr.o \ thread.o \ mutex_attr.o \ mutex.o \ diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c index 5559ca7..00086ac 100644 --- a/kernel/cobalt/thread.c +++ b/kernel/cobalt/thread.c @@ -36,7 +36,19 @@ xnticks_t cobalt_time_slice; -static pthread_attr_t default_attr; +static const pthread_attr_t default_thread_attr = { + magic:COBALT_THREAD_ATTR_MAGIC, + detachstate:PTHREAD_CREATE_JOINABLE, + stacksize:PTHREAD_STACK_MIN, + inheritsched:PTHREAD_EXPLICIT_SCHED, + policy:SCHED_OTHER, + schedparam_ex:{ + sched_priority:0}, + + name:NULL, + fp:1, + affinity:XNPOD_ALL_CPUS, +}; static unsigned cobalt_get_magic(void) { @@ -393,7 +405,7 @@ static inline int pthread_create(pthread_t *tid, const pthread_attr_t * attr) if (!thread) return -EAGAIN; - thread-attr = attr ? *attr : default_attr; + thread-attr = attr ? *attr : default_thread_attr; cur = cobalt_current_thread(); @@ -968,7 +980,7 @@ int cobalt_thread_create(unsigned long tid, int policy, * critical fields are set in a compatible fashion wrt to the * calling context. */ - pthread_attr_init(attr); + attr = default_thread_attr; attr.policy = policy; attr.detachstate = PTHREAD_CREATE_DETACHED; attr.schedparam_ex = param; @@ -1008,7 +1020,7 @@ pthread_t cobalt_thread_shadow(struct task_struct *p, pid_t h_tid; int err; - pthread_attr_init(attr); + attr = default_thread_attr; attr.detachstate = PTHREAD_CREATE_DETACHED; attr.name = p-comm; @@ -1369,7 +1381,6 @@ void cobalt_threadq_cleanup(cobalt_kqueues_t *q) void cobalt_thread_pkg_init(u_long rrperiod) { initq(cobalt_global_kqueues.threadq); - pthread_attr_init(default_attr); cobalt_time_slice = rrperiod; xnpod_add_hook(XNHOOK_THREAD_DELETE, thread_delete_hook); } diff --git a/kernel/cobalt/thread_attr.c b/kernel/cobalt/thread_attr.c deleted file mode 100644 index 85f88eb..000 --- a/kernel/cobalt/thread_attr.c +++ /dev/null @@ -1,1088 +0,0 @@ -/* - * Written by Gilles Chanteperdrix gilles.chanteperd...@xenomai.org. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/** - * @ingroup posix_thread - * @defgroup posix_threadattr Thread creation attributes. - * - * Thread creation attributes. - * - * The services described in this section allow to set the attributes of a - * @b pthread_attr_t object, passed to the pthread_create() service in order - * to set the attributes of a created thread. - * - * A @b pthread_attr_t object has to be initialized with pthread_attr_init() - * first, which sets attributes to their default values, i.e. in kernel-space: - * - @a detachstate to PTHREAD_CREATE_JOINABLE, - * - @a stacksize to PTHREAD_STACK_MIN, - * - @a inheritsched to PTHREAD_EXPLICIT_SCHED, - * - @a schedpolicy to SCHED_OTHER, - * - @a name to NULL (only available in kernel-space), - * - scheduling priority to the minimum, - * - floating-point hardware enabled (only available in kernel-space), - * - processor affinity set to all available processors (only available as a - * thread attribute in kernel-space). - * - * In user-space, the attributes and their defaults values are those documented - * by the underlying threading library (LinuxThreads or NPTL). - * - *@{*/ - -#include internal.h - -static const pthread_attr_t default_thread_attr = { -
[Xenomai-git] Gilles Chanteperdrix : cobalt: move message queues syscalls to mq.c
Module: xenomai-gch Branch: for-forge Commit: 3b14eb4932b1b69f5a7de2fd16b94eb52e989225 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=3b14eb4932b1b69f5a7de2fd16b94eb52e989225 Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Sun Dec 11 18:12:25 2011 +0100 cobalt: move message queues syscalls to mq.c --- include/cobalt/mqueue.h | 47 --- kernel/cobalt/mq.c | 722 +++ kernel/cobalt/mq.h | 36 ++- kernel/cobalt/syscall.c | 340 +-- 4 files changed, 389 insertions(+), 756 deletions(-) diff --git a/include/cobalt/mqueue.h b/include/cobalt/mqueue.h index 8f8f677..00bc847 100644 --- a/include/cobalt/mqueue.h +++ b/include/cobalt/mqueue.h @@ -57,53 +57,6 @@ struct mq_attr { longmq_curmsgs; }; -#ifdef __cplusplus -extern C { -#endif - -int mq_getattr(mqd_t qd, - struct mq_attr *attr); - -int mq_setattr(mqd_t qd, - const struct mq_attr *__restrict__ attr, - struct mq_attr *__restrict__ oattr); - -int mq_send(mqd_t qd, - const char *buffer, - size_t len, - unsigned prio); - -int mq_close(mqd_t qd); - -ssize_t mq_receive(mqd_t q, - char *buffer, - size_t len, - unsigned *prio); - -ssize_t mq_timedreceive(mqd_t q, -char *__restrict__ buffer, -size_t len, -unsigned *__restrict__ prio, -const struct timespec *__restrict__ timeout); - -int mq_timedsend(mqd_t q, -const char *buffer, -size_t len, -unsigned prio, -const struct timespec *timeout); - -int mq_notify(mqd_t mqdes, const struct sigevent *notification); - -mqd_t mq_open(const char *name, - int oflags, - ...); - -int mq_unlink(const char *name); - -#ifdef __cplusplus -} -#endif - #else /* !(__KERNEL__ || __XENO_SIM__ || !HAVE_MQUEUE_H) */ #include_next mqueue.h diff --git a/kernel/cobalt/mq.c b/kernel/cobalt/mq.c index 732a178..352873c 100644 --- a/kernel/cobalt/mq.c +++ b/kernel/cobalt/mq.c @@ -46,8 +46,7 @@ struct cobalt_mq { cobalt_node_t nodebase; -#define node2mq(naddr) \ -((cobalt_mq_t *) (((char *)naddr) - offsetof(cobalt_mq_t, nodebase))) +#define node2mq(naddr) container_of(naddr, cobalt_mq_t, nodebase) xnpqueue_t queued; xnsynch_t receivers; @@ -62,12 +61,19 @@ struct cobalt_mq { DECLARE_XNSELECT(read_select); DECLARE_XNSELECT(write_select); -#define link2mq(laddr) \ -((cobalt_mq_t *) (((char *)laddr) - offsetof(cobalt_mq_t, link))) +#define link2mq(laddr) container_of(laddr, cobalt_mq_t, link) }; -#define any2msg(addr, member) \ -((cobalt_msg_t *)(((char *)addr) - offsetof(cobalt_msg_t, member))) +#define link2msg(addr) container_of(addr, cobalt_msg_t, link) + +typedef struct cobalt_msg { + xnpholder_t link; + size_t len; + char data[0]; +} cobalt_msg_t; + +#define cobalt_msg_get_prio(msg) (msg)-link.prio +#define cobalt_msg_set_prio(msg, prio) (msg)-link.prio = (prio) static xnqueue_t cobalt_mqq; @@ -76,7 +82,7 @@ static struct mq_attr default_attr = { mq_msgsize:128, }; -static cobalt_msg_t *cobalt_mq_msg_alloc(cobalt_mq_t * mq) +static inline cobalt_msg_t *cobalt_mq_msg_alloc(cobalt_mq_t * mq) { xnpholder_t *holder = (xnpholder_t *)getq(mq-avail); @@ -84,24 +90,21 @@ static cobalt_msg_t *cobalt_mq_msg_alloc(cobalt_mq_t * mq) return NULL; initph(holder); - return any2msg(holder, link); + return link2msg(holder); } -static void cobalt_mq_msg_free(cobalt_mq_t * mq, cobalt_msg_t * msg) +static inline void cobalt_mq_msg_free(cobalt_mq_t * mq, cobalt_msg_t * msg) { xnholder_t *holder = (xnholder_t *)(msg-link); inith(holder); prependq(mq-avail, holder); /* For earliest re-use of the block. */ } -static int cobalt_mq_init(cobalt_mq_t * mq, const struct mq_attr *attr) +static inline int cobalt_mq_init(cobalt_mq_t * mq, const struct mq_attr *attr) { unsigned i, msgsize, memsize; char *mem; - if (xnpod_asynch_p() || !xnpod_root_p()) - return EPERM; - if (!attr) attr = default_attr; else if (attr-mq_maxmsg = 0 || attr-mq_msgsize = 0) @@ -142,7 +145,7 @@ static int cobalt_mq_init(cobalt_mq_t * mq, const struct mq_attr *attr) return 0; } -static void cobalt_mq_destroy(cobalt_mq_t *mq) +static inline void cobalt_mq_destroy(cobalt_mq_t *mq) { int resched; spl_t s; @@ -231,7 +234,7 @@ static void cobalt_mq_destroy(cobalt_mq_t *mq) * Specification./a * */ -mqd_t mq_open(const char *name, int oflags, ...) +static mqd_t mq_open(const char *name, int oflags, ...) { struct mq_attr *attr;
[Xenomai-git] Gilles Chanteperdrix : cobalt: remove useless calls to xnpod_unblockable_p( )
Module: xenomai-gch Branch: for-forge Commit: 463cbaedf69396ffd6eb0bc6c36083f8f44ff0bb URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=463cbaedf69396ffd6eb0bc6c36083f8f44ff0bb Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Sun Dec 11 17:35:53 2011 +0100 cobalt: remove useless calls to xnpod_unblockable_p() --- kernel/cobalt/cond.c |3 --- kernel/cobalt/sem.c |3 --- 2 files changed, 0 insertions(+), 6 deletions(-) diff --git a/kernel/cobalt/cond.c b/kernel/cobalt/cond.c index c8200ef..c19643c 100644 --- a/kernel/cobalt/cond.c +++ b/kernel/cobalt/cond.c @@ -238,9 +238,6 @@ static inline int cobalt_cond_timedwait_prologue(xnthread_t *cur, spl_t s; int err; - if (xnpod_unblockable_p()) - return -EPERM; - xnlock_get_irqsave(nklock, s); /* If another thread waiting for cond does not use the same mutex */ diff --git a/kernel/cobalt/sem.c b/kernel/cobalt/sem.c index f855905..6b1918c 100644 --- a/kernel/cobalt/sem.c +++ b/kernel/cobalt/sem.c @@ -524,9 +524,6 @@ sem_timedwait_internal(cobalt_sem_t *sem, int timed, xnticks_t to) xnthread_t *cur; int err; - if (xnpod_unblockable_p()) - return -EPERM; - cur = xnpod_current_thread(); if ((err = sem_trywait_internal(sem)) != -EAGAIN) ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Gilles Chanteperdrix : cobalt: move cond_attr system calls to cond_attr.c
Module: xenomai-gch Branch: for-forge Commit: 9cf6dd92acb501313dc2425f84123981cac0eec9 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=9cf6dd92acb501313dc2425f84123981cac0eec9 Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Sun Dec 11 17:46:32 2011 +0100 cobalt: move cond_attr system calls to cond_attr.c --- include/cobalt/pthread.h | 93 - kernel/cobalt/cond.c |5 +-- kernel/cobalt/cond.h | 16 ++ kernel/cobalt/cond_attr.c | 124 ++--- kernel/cobalt/syscall.c | 104 ++--- 5 files changed, 129 insertions(+), 213 deletions(-) diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h index 62a7134..139802f 100644 --- a/include/cobalt/pthread.h +++ b/include/cobalt/pthread.h @@ -198,99 +198,6 @@ struct cobalt_monitor_shadow { typedef struct cobalt_mutexattr pthread_mutexattr_t; typedef struct cobalt_condattr pthread_condattr_t; - -#ifdef __cplusplus -extern C { -#endif - -int pthread_attr_init(pthread_attr_t *attr); - -int pthread_attr_destroy(pthread_attr_t *attr); - -int pthread_attr_getdetachstate(const pthread_attr_t *attr, - int *detachstate); - -int pthread_attr_setdetachstate(pthread_attr_t *attr, - int detachstate); - -int pthread_attr_getstackaddr(const pthread_attr_t *attr, - void **stackaddr); - -int pthread_attr_setstackaddr(pthread_attr_t *attr, - void *stackaddr); - -int pthread_attr_getstacksize(const pthread_attr_t *attr, - size_t *stacksize); - -int pthread_attr_setstacksize(pthread_attr_t *attr, - size_t stacksize); - -int pthread_attr_getinheritsched(const pthread_attr_t *attr, -int *inheritsched); - -int pthread_attr_setinheritsched(pthread_attr_t *attr, -int inheritsched); - -int pthread_attr_getschedpolicy(const pthread_attr_t *attr, - int *policy); - -int pthread_attr_setschedpolicy(pthread_attr_t *attr, - int policy); - -int pthread_attr_getschedparam(const pthread_attr_t *attr, - struct sched_param *par); - -int pthread_attr_getschedparam_ex(const pthread_attr_t *attr, - struct sched_param_ex *par); - -int pthread_attr_setschedparam(pthread_attr_t *attr, - const struct sched_param *par); - -int pthread_attr_setschedparam_ex(pthread_attr_t *attr, - const struct sched_param_ex *par); - -int pthread_attr_getscope(const pthread_attr_t *attr, - int *scope); - -int pthread_attr_setscope(pthread_attr_t *attr, - int scope); - -int pthread_attr_getname_np(const pthread_attr_t *attr, - const char **name); - -int pthread_attr_setname_np(pthread_attr_t *attr, - const char *name); - -int pthread_attr_getfp_np(const pthread_attr_t *attr, - int *use_fp); - -int pthread_attr_setfp_np(pthread_attr_t *attr, - int use_fp); - -int pthread_attr_getaffinity_np(const pthread_attr_t *attr, - xnarch_cpumask_t *mask); - -int pthread_attr_setaffinity_np(pthread_attr_t *attr, - xnarch_cpumask_t mask); - -int pthread_condattr_init(pthread_condattr_t *attr); - -int pthread_condattr_destroy(pthread_condattr_t *attr); - -int pthread_condattr_getclock(const pthread_condattr_t *attr, - clockid_t *clk_id); - -int pthread_condattr_setclock(pthread_condattr_t *attr, - clockid_t clk_id); - -int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared); - -int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared); - -#ifdef __cplusplus -} -#endif - #else /* !(__KERNEL__ || __XENO_SIM__) */ typedef struct { diff --git a/kernel/cobalt/cond.c b/kernel/cobalt/cond.c index c19643c..cfe5201 100644 --- a/kernel/cobalt/cond.c +++ b/kernel/cobalt/cond.c @@ -51,8 +51,6 @@ #include mutex.h #include cond.h -static pthread_condattr_t default_cond_attr; - static inline void cond_destroy_internal(cobalt_cond_t *cond, cobalt_kqueues_t *q) { @@ -106,7 +104,7 @@ pthread_cond_init(struct __shadow_cond *cnd, const pthread_condattr_t *attr) int err; if (!attr) - attr = default_cond_attr; + attr = cobalt_default_cond_attr; cond = (cobalt_cond_t *)xnmalloc(sizeof(*cond)); if (!cond) @@ -491,7 +489,6 @@ void cobalt_condq_cleanup(cobalt_kqueues_t *q) void cobalt_cond_pkg_init(void) { initq(cobalt_global_kqueues.condq); - pthread_condattr_init(default_cond_attr); } void
[Xenomai-git] Gilles Chanteperdrix : cobalt: move message queues syscalls to mq.c
Module: xenomai-gch Branch: for-forge Commit: d18103f31d7216d2d40e597bdbc0ed4c0fc71176 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=d18103f31d7216d2d40e597bdbc0ed4c0fc71176 Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Sun Dec 11 18:12:25 2011 +0100 cobalt: move message queues syscalls to mq.c --- include/cobalt/mqueue.h | 47 --- kernel/cobalt/mq.c | 724 +++ kernel/cobalt/mq.h | 36 ++- kernel/cobalt/syscall.c | 340 +- 4 files changed, 390 insertions(+), 757 deletions(-) diff --git a/include/cobalt/mqueue.h b/include/cobalt/mqueue.h index 8f8f677..00bc847 100644 --- a/include/cobalt/mqueue.h +++ b/include/cobalt/mqueue.h @@ -57,53 +57,6 @@ struct mq_attr { longmq_curmsgs; }; -#ifdef __cplusplus -extern C { -#endif - -int mq_getattr(mqd_t qd, - struct mq_attr *attr); - -int mq_setattr(mqd_t qd, - const struct mq_attr *__restrict__ attr, - struct mq_attr *__restrict__ oattr); - -int mq_send(mqd_t qd, - const char *buffer, - size_t len, - unsigned prio); - -int mq_close(mqd_t qd); - -ssize_t mq_receive(mqd_t q, - char *buffer, - size_t len, - unsigned *prio); - -ssize_t mq_timedreceive(mqd_t q, -char *__restrict__ buffer, -size_t len, -unsigned *__restrict__ prio, -const struct timespec *__restrict__ timeout); - -int mq_timedsend(mqd_t q, -const char *buffer, -size_t len, -unsigned prio, -const struct timespec *timeout); - -int mq_notify(mqd_t mqdes, const struct sigevent *notification); - -mqd_t mq_open(const char *name, - int oflags, - ...); - -int mq_unlink(const char *name); - -#ifdef __cplusplus -} -#endif - #else /* !(__KERNEL__ || __XENO_SIM__ || !HAVE_MQUEUE_H) */ #include_next mqueue.h diff --git a/kernel/cobalt/mq.c b/kernel/cobalt/mq.c index 732a178..8894f05 100644 --- a/kernel/cobalt/mq.c +++ b/kernel/cobalt/mq.c @@ -46,8 +46,7 @@ struct cobalt_mq { cobalt_node_t nodebase; -#define node2mq(naddr) \ -((cobalt_mq_t *) (((char *)naddr) - offsetof(cobalt_mq_t, nodebase))) +#define node2mq(naddr) container_of(naddr, cobalt_mq_t, nodebase) xnpqueue_t queued; xnsynch_t receivers; @@ -62,12 +61,19 @@ struct cobalt_mq { DECLARE_XNSELECT(read_select); DECLARE_XNSELECT(write_select); -#define link2mq(laddr) \ -((cobalt_mq_t *) (((char *)laddr) - offsetof(cobalt_mq_t, link))) +#define link2mq(laddr) container_of(laddr, cobalt_mq_t, link) }; -#define any2msg(addr, member) \ -((cobalt_msg_t *)(((char *)addr) - offsetof(cobalt_msg_t, member))) +#define link2msg(addr) container_of(addr, cobalt_msg_t, link) + +typedef struct cobalt_msg { + xnpholder_t link; + size_t len; + char data[0]; +} cobalt_msg_t; + +#define cobalt_msg_get_prio(msg) (msg)-link.prio +#define cobalt_msg_set_prio(msg, prio) (msg)-link.prio = (prio) static xnqueue_t cobalt_mqq; @@ -76,7 +82,7 @@ static struct mq_attr default_attr = { mq_msgsize:128, }; -static cobalt_msg_t *cobalt_mq_msg_alloc(cobalt_mq_t * mq) +static inline cobalt_msg_t *cobalt_mq_msg_alloc(cobalt_mq_t * mq) { xnpholder_t *holder = (xnpholder_t *)getq(mq-avail); @@ -84,24 +90,21 @@ static cobalt_msg_t *cobalt_mq_msg_alloc(cobalt_mq_t * mq) return NULL; initph(holder); - return any2msg(holder, link); + return link2msg(holder); } -static void cobalt_mq_msg_free(cobalt_mq_t * mq, cobalt_msg_t * msg) +static inline void cobalt_mq_msg_free(cobalt_mq_t * mq, cobalt_msg_t * msg) { xnholder_t *holder = (xnholder_t *)(msg-link); inith(holder); prependq(mq-avail, holder); /* For earliest re-use of the block. */ } -static int cobalt_mq_init(cobalt_mq_t * mq, const struct mq_attr *attr) +static inline int cobalt_mq_init(cobalt_mq_t * mq, const struct mq_attr *attr) { unsigned i, msgsize, memsize; char *mem; - if (xnpod_asynch_p() || !xnpod_root_p()) - return EPERM; - if (!attr) attr = default_attr; else if (attr-mq_maxmsg = 0 || attr-mq_msgsize = 0) @@ -142,7 +145,7 @@ static int cobalt_mq_init(cobalt_mq_t * mq, const struct mq_attr *attr) return 0; } -static void cobalt_mq_destroy(cobalt_mq_t *mq) +static inline void cobalt_mq_destroy(cobalt_mq_t *mq) { int resched; spl_t s; @@ -231,7 +234,7 @@ static void cobalt_mq_destroy(cobalt_mq_t *mq) * Specification./a * */ -mqd_t mq_open(const char *name, int oflags, ...) +static mqd_t mq_open(const char *name, int oflags, ...) { struct mq_attr *attr;
[Xenomai-git] Gilles Chanteperdrix : cobalt: remove errno
Module: xenomai-gch Branch: for-forge Commit: e196e97f582c3460f5d35fd4c4865ff9feec6ae5 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=e196e97f582c3460f5d35fd4c4865ff9feec6ae5 Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Sun Dec 11 20:03:08 2011 +0100 cobalt: remove errno --- include/asm-generic/syscall.h |4 include/cobalt/nucleus/thread.h |4 kernel/cobalt/clock.c |2 +- kernel/cobalt/nucleus/shadow.c |6 +- kernel/cobalt/nucleus/thread.c | 20 kernel/cobalt/thread.h | 10 -- 6 files changed, 2 insertions(+), 44 deletions(-) diff --git a/include/asm-generic/syscall.h b/include/asm-generic/syscall.h index 97894ae..6391b33 100644 --- a/include/asm-generic/syscall.h +++ b/include/asm-generic/syscall.h @@ -138,12 +138,8 @@ struct xnsysent { extern int nkthrptd; -extern int nkerrptd; - #define xnshadow_thrptd(t) ((t)-ptd[nkthrptd]) #define xnshadow_thread(t) ((xnthread_t *)xnshadow_thrptd(t)) -/* The errno field must be addressable for plain Linux tasks too. */ -#define xnshadow_errno(t) (*(int *)((t)-ptd[nkerrptd])) #define access_rok(addr, size) access_ok(VERIFY_READ, (addr), (size)) #define access_wok(addr, size) access_ok(VERIFY_WRITE, (addr), (size)) diff --git a/include/cobalt/nucleus/thread.h b/include/cobalt/nucleus/thread.h index b8c4511..c55bbd7 100644 --- a/include/cobalt/nucleus/thread.h +++ b/include/cobalt/nucleus/thread.h @@ -271,8 +271,6 @@ typedef struct xnthread { struct xnselector *selector;/* For select. */ - int errcode;/* Local errno */ - xnasr_t asr;/* Asynchronous service routine */ xnflags_t asrmode; /* Thread's mode for ASR */ @@ -437,8 +435,6 @@ void xnthread_cleanup_tcb(struct xnthread *thread); char *xnthread_format_status(xnflags_t status, char *buf, int size); -int *xnthread_get_errno_location(struct xnthread *thread); - xnticks_t xnthread_get_timeout(struct xnthread *thread, xnticks_t tsc_ns); xnticks_t xnthread_get_period(struct xnthread *thread); diff --git a/kernel/cobalt/clock.c b/kernel/cobalt/clock.c index 5d31e5d..95f783d 100644 --- a/kernel/cobalt/clock.c +++ b/kernel/cobalt/clock.c @@ -175,7 +175,7 @@ int cobalt_clock_gettime(clockid_t clock_id, struct timespec __user *u_ts) if (err == 0 __xn_safe_copy_to_user(u_ts, ts, sizeof(*u_ts))) return -EFAULT; - return err ? -thread_get_errno() : 0; + return err; } int cobalt_clock_settime(clockid_t clock_id, const struct timespec __user *u_ts) diff --git a/kernel/cobalt/nucleus/shadow.c b/kernel/cobalt/nucleus/shadow.c index 15430f1..7f06fe3 100644 --- a/kernel/cobalt/nucleus/shadow.c +++ b/kernel/cobalt/nucleus/shadow.c @@ -66,8 +66,6 @@ MODULE_PARM_DESC(xenomai_gid, GID of the group with access to Xenomai services int nkthrptd; EXPORT_SYMBOL_GPL(nkthrptd); -int nkerrptd; -EXPORT_SYMBOL_GPL(nkerrptd); int nkmmptd; EXPORT_SYMBOL_GPL(nkmmptd); @@ -2589,10 +2587,9 @@ int xnshadow_mount(void) sema_init(completion_mutex, 1); nkthrptd = rthal_alloc_ptdkey(); - nkerrptd = rthal_alloc_ptdkey(); nkmmptd = rthal_alloc_ptdkey(); - if (nkthrptd 0 || nkerrptd 0 || nkmmptd 0) { + if (nkthrptd 0 || nkmmptd 0) { printk(KERN_ERR Xenomai: cannot allocate PTD slots\n); return -ENOMEM; } @@ -2691,7 +2688,6 @@ void xnshadow_cleanup(void) } rthal_apc_free(lostage_apc); - rthal_free_ptdkey(nkerrptd); rthal_free_ptdkey(nkthrptd); mayday_cleanup_page(); diff --git a/kernel/cobalt/nucleus/thread.c b/kernel/cobalt/nucleus/thread.c index f9e139f..b5132de 100644 --- a/kernel/cobalt/nucleus/thread.c +++ b/kernel/cobalt/nucleus/thread.c @@ -137,7 +137,6 @@ int xnthread_init(struct xnthread *thread, thread-wwake = NULL; thread-wcontext = NULL; thread-hrescnt = 0; - thread-errcode = 0; thread-registry.handle = XN_NO_HANDLE; thread-registry.waitkey = NULL; memset(thread-stat, 0, sizeof(thread-stat)); @@ -253,25 +252,6 @@ char *xnthread_format_status(xnflags_t status, char *buf, int size) return buf; } -int *xnthread_get_errno_location(xnthread_t *thread) -{ - static int fallback_errno; - - if (unlikely(!xnpod_active_p())) - return fallback_errno; - -#ifndef __XENO_SIM__ - if (xnthread_test_state(thread, XNSHADOW)) - return thread-errcode; - - if (xnthread_test_state(thread, XNROOT)) - return xnshadow_errno(current); -#endif /* !__XENO_SIM__ */ - - return thread-errcode; -} -EXPORT_SYMBOL_GPL(xnthread_get_errno_location); - xnticks_t xnthread_get_timeout(xnthread_t *thread, xnticks_t tsc_ns) { xnticks_t timeout; diff --git a/kernel/cobalt/thread.h b/kernel/cobalt/thread.h index
[Xenomai-git] Gilles Chanteperdrix : cobalt: move timers system calls to timer.c
Module: xenomai-gch Branch: for-forge Commit: 6b883a1d661bed2e1809a521288c688045feee8c URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=6b883a1d661bed2e1809a521288c688045feee8c Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Sun Dec 11 19:53:58 2011 +0100 cobalt: move timers system calls to timer.c --- include/cobalt/time.h | 48 +- kernel/cobalt/syscall.c | 96 +-- kernel/cobalt/timer.c | 237 --- kernel/cobalt/timer.h | 15 +++ 4 files changed, 140 insertions(+), 256 deletions(-) diff --git a/include/cobalt/time.h b/include/cobalt/time.h index 3c10681..8e9f66a 100644 --- a/include/cobalt/time.h +++ b/include/cobalt/time.h @@ -65,53 +65,7 @@ */ #define CLOCK_HOST_REALTIME 42 -#if defined(__KERNEL__) || defined(__XENO_SIM__) - -struct sigevent; - -struct timespec; - -#ifdef __cplusplus -extern C { -#endif - -int clock_getres(clockid_t clock_id, -struct timespec *res); - -int clock_gettime(clockid_t clock_id, - struct timespec *tp); - -int clock_settime(clockid_t clock_id, - const struct timespec *tp); - -int clock_nanosleep(clockid_t clock_id, - int flags, - const struct timespec *rqtp, - struct timespec *rmtp); - -int nanosleep(const struct timespec *rqtp, - struct timespec *rmtp); - -int timer_create(clockid_t clockid, -const struct sigevent *__restrict__ evp, -timer_t *__restrict__ timerid); - -int timer_delete(timer_t timerid); - -int timer_settime(timer_t timerid, - int flags, - const struct itimerspec *__restrict__ value, - struct itimerspec *__restrict__ ovalue); - -int timer_gettime(timer_t timerid, struct itimerspec *value); - -int timer_getoverrun(timer_t timerid); - -#ifdef __cplusplus -} -#endif - -#else /* !(__KERNEL__ || __XENO_SIM__) */ +#if !(defined(__KERNEL__) || defined(__XENO_SIM__)) #ifdef __cplusplus extern C { diff --git a/kernel/cobalt/syscall.c b/kernel/cobalt/syscall.c index 286c5f7..4420f23 100644 --- a/kernel/cobalt/syscall.c +++ b/kernel/cobalt/syscall.c @@ -43,92 +43,6 @@ int cobalt_muxid; -static int __timer_create(clockid_t clock, - const struct sigevent __user *u_sev, - timer_t __user *u_tm) -{ - union __xeno_sem sm, __user *u_sem; - struct sigevent sev, *evp = sev; - timer_t tm; - int ret; - - if (u_sev) { - if (__xn_safe_copy_from_user(sev, u_sev, sizeof(sev))) - return -EFAULT; - - if (sev.sigev_notify == SIGEV_THREAD_ID) { - u_sem = sev.sigev_value.sival_ptr; - - if (__xn_safe_copy_from_user(sm, u_sem, sizeof(sm))) - return -EFAULT; - - sev.sigev_value.sival_ptr = sm.native_sem; - } - } else - evp = NULL; - - ret = timer_create(clock, evp, tm); - if (ret) - return -thread_get_errno(); - - if (__xn_safe_copy_to_user(u_tm, tm, sizeof(tm))) { - timer_delete(tm); - return -EFAULT; - } - - return 0; -} - -static int __timer_delete(timer_t tm) -{ - int ret = timer_delete(tm); - return ret == 0 ? 0 : -thread_get_errno(); -} - -static int __timer_settime(timer_t tm, - int flags, - const struct itimerspec __user *u_newval, - struct itimerspec __user *u_oldval) -{ - struct itimerspec newv, oldv, *oldvp; - int ret; - - oldvp = u_oldval == 0 ? NULL : oldv; - - if (__xn_safe_copy_from_user(newv, u_newval, sizeof(newv))) - return -EFAULT; - - ret = timer_settime(tm, flags, newv, oldvp); - if (ret) - return -thread_get_errno(); - - if (oldvp __xn_safe_copy_to_user(u_oldval, oldvp, sizeof(oldv))) { - timer_settime(tm, flags, oldvp, NULL); - return -EFAULT; - } - - return 0; -} - -static int __timer_gettime(timer_t tm, - struct itimerspec __user *u_val) -{ - struct itimerspec val; - int ret; - - ret = timer_gettime(tm, val); - if (ret) - return -thread_get_errno(); - - return __xn_safe_copy_to_user(u_val, val, sizeof(val)); -} - -static int __timer_getoverrun(timer_t tm) -{ - int ret = timer_getoverrun(tm); - return ret = 0 ? ret : -thread_get_errno(); -} - static int fd_valid_p(int fd) { cobalt_assoc_t *assoc; @@ -359,11 +273,11 @@ static struct xnsysent __systab[] = { SKINCALL_DEF(sc_cobalt_mq_timedsend, cobalt_mq_timedsend, primary), SKINCALL_DEF(sc_cobalt_mq_receive, cobalt_mq_receive, primary),
[Xenomai-git] Gilles Chanteperdrix : cobalt: remove errno
Module: xenomai-gch Branch: for-forge Commit: 69822314e9a4a71f9bf5bf9c5c8717a13a96c5df URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=69822314e9a4a71f9bf5bf9c5c8717a13a96c5df Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Sun Dec 11 20:03:08 2011 +0100 cobalt: remove errno --- include/asm-generic/syscall.h |4 include/cobalt/nucleus/thread.h |4 kernel/cobalt/clock.c |2 +- kernel/cobalt/nucleus/shadow.c |6 +- kernel/cobalt/nucleus/thread.c | 20 kernel/cobalt/thread.h | 10 -- 6 files changed, 2 insertions(+), 44 deletions(-) diff --git a/include/asm-generic/syscall.h b/include/asm-generic/syscall.h index 97894ae..6391b33 100644 --- a/include/asm-generic/syscall.h +++ b/include/asm-generic/syscall.h @@ -138,12 +138,8 @@ struct xnsysent { extern int nkthrptd; -extern int nkerrptd; - #define xnshadow_thrptd(t) ((t)-ptd[nkthrptd]) #define xnshadow_thread(t) ((xnthread_t *)xnshadow_thrptd(t)) -/* The errno field must be addressable for plain Linux tasks too. */ -#define xnshadow_errno(t) (*(int *)((t)-ptd[nkerrptd])) #define access_rok(addr, size) access_ok(VERIFY_READ, (addr), (size)) #define access_wok(addr, size) access_ok(VERIFY_WRITE, (addr), (size)) diff --git a/include/cobalt/nucleus/thread.h b/include/cobalt/nucleus/thread.h index b8c4511..c55bbd7 100644 --- a/include/cobalt/nucleus/thread.h +++ b/include/cobalt/nucleus/thread.h @@ -271,8 +271,6 @@ typedef struct xnthread { struct xnselector *selector;/* For select. */ - int errcode;/* Local errno */ - xnasr_t asr;/* Asynchronous service routine */ xnflags_t asrmode; /* Thread's mode for ASR */ @@ -437,8 +435,6 @@ void xnthread_cleanup_tcb(struct xnthread *thread); char *xnthread_format_status(xnflags_t status, char *buf, int size); -int *xnthread_get_errno_location(struct xnthread *thread); - xnticks_t xnthread_get_timeout(struct xnthread *thread, xnticks_t tsc_ns); xnticks_t xnthread_get_period(struct xnthread *thread); diff --git a/kernel/cobalt/clock.c b/kernel/cobalt/clock.c index 5d31e5d..95f783d 100644 --- a/kernel/cobalt/clock.c +++ b/kernel/cobalt/clock.c @@ -175,7 +175,7 @@ int cobalt_clock_gettime(clockid_t clock_id, struct timespec __user *u_ts) if (err == 0 __xn_safe_copy_to_user(u_ts, ts, sizeof(*u_ts))) return -EFAULT; - return err ? -thread_get_errno() : 0; + return err; } int cobalt_clock_settime(clockid_t clock_id, const struct timespec __user *u_ts) diff --git a/kernel/cobalt/nucleus/shadow.c b/kernel/cobalt/nucleus/shadow.c index 15430f1..7f06fe3 100644 --- a/kernel/cobalt/nucleus/shadow.c +++ b/kernel/cobalt/nucleus/shadow.c @@ -66,8 +66,6 @@ MODULE_PARM_DESC(xenomai_gid, GID of the group with access to Xenomai services int nkthrptd; EXPORT_SYMBOL_GPL(nkthrptd); -int nkerrptd; -EXPORT_SYMBOL_GPL(nkerrptd); int nkmmptd; EXPORT_SYMBOL_GPL(nkmmptd); @@ -2589,10 +2587,9 @@ int xnshadow_mount(void) sema_init(completion_mutex, 1); nkthrptd = rthal_alloc_ptdkey(); - nkerrptd = rthal_alloc_ptdkey(); nkmmptd = rthal_alloc_ptdkey(); - if (nkthrptd 0 || nkerrptd 0 || nkmmptd 0) { + if (nkthrptd 0 || nkmmptd 0) { printk(KERN_ERR Xenomai: cannot allocate PTD slots\n); return -ENOMEM; } @@ -2691,7 +2688,6 @@ void xnshadow_cleanup(void) } rthal_apc_free(lostage_apc); - rthal_free_ptdkey(nkerrptd); rthal_free_ptdkey(nkthrptd); mayday_cleanup_page(); diff --git a/kernel/cobalt/nucleus/thread.c b/kernel/cobalt/nucleus/thread.c index f9e139f..b5132de 100644 --- a/kernel/cobalt/nucleus/thread.c +++ b/kernel/cobalt/nucleus/thread.c @@ -137,7 +137,6 @@ int xnthread_init(struct xnthread *thread, thread-wwake = NULL; thread-wcontext = NULL; thread-hrescnt = 0; - thread-errcode = 0; thread-registry.handle = XN_NO_HANDLE; thread-registry.waitkey = NULL; memset(thread-stat, 0, sizeof(thread-stat)); @@ -253,25 +252,6 @@ char *xnthread_format_status(xnflags_t status, char *buf, int size) return buf; } -int *xnthread_get_errno_location(xnthread_t *thread) -{ - static int fallback_errno; - - if (unlikely(!xnpod_active_p())) - return fallback_errno; - -#ifndef __XENO_SIM__ - if (xnthread_test_state(thread, XNSHADOW)) - return thread-errcode; - - if (xnthread_test_state(thread, XNROOT)) - return xnshadow_errno(current); -#endif /* !__XENO_SIM__ */ - - return thread-errcode; -} -EXPORT_SYMBOL_GPL(xnthread_get_errno_location); - xnticks_t xnthread_get_timeout(xnthread_t *thread, xnticks_t tsc_ns) { xnticks_t timeout; diff --git a/kernel/cobalt/thread.h b/kernel/cobalt/thread.h index
[Xenomai-git] Gilles Chanteperdrix : cobalt: move timers system calls to timer.c
Module: xenomai-gch Branch: for-forge Commit: d67f5d8763dfcc690bb1b659778b15c370494340 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=d67f5d8763dfcc690bb1b659778b15c370494340 Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Sun Dec 11 19:53:58 2011 +0100 cobalt: move timers system calls to timer.c --- include/cobalt/time.h | 48 +-- kernel/cobalt/syscall.c | 96 +-- kernel/cobalt/timer.c | 235 +++ kernel/cobalt/timer.h | 15 +++ 4 files changed, 138 insertions(+), 256 deletions(-) diff --git a/include/cobalt/time.h b/include/cobalt/time.h index 3c10681..8e9f66a 100644 --- a/include/cobalt/time.h +++ b/include/cobalt/time.h @@ -65,53 +65,7 @@ */ #define CLOCK_HOST_REALTIME 42 -#if defined(__KERNEL__) || defined(__XENO_SIM__) - -struct sigevent; - -struct timespec; - -#ifdef __cplusplus -extern C { -#endif - -int clock_getres(clockid_t clock_id, -struct timespec *res); - -int clock_gettime(clockid_t clock_id, - struct timespec *tp); - -int clock_settime(clockid_t clock_id, - const struct timespec *tp); - -int clock_nanosleep(clockid_t clock_id, - int flags, - const struct timespec *rqtp, - struct timespec *rmtp); - -int nanosleep(const struct timespec *rqtp, - struct timespec *rmtp); - -int timer_create(clockid_t clockid, -const struct sigevent *__restrict__ evp, -timer_t *__restrict__ timerid); - -int timer_delete(timer_t timerid); - -int timer_settime(timer_t timerid, - int flags, - const struct itimerspec *__restrict__ value, - struct itimerspec *__restrict__ ovalue); - -int timer_gettime(timer_t timerid, struct itimerspec *value); - -int timer_getoverrun(timer_t timerid); - -#ifdef __cplusplus -} -#endif - -#else /* !(__KERNEL__ || __XENO_SIM__) */ +#if !(defined(__KERNEL__) || defined(__XENO_SIM__)) #ifdef __cplusplus extern C { diff --git a/kernel/cobalt/syscall.c b/kernel/cobalt/syscall.c index 286c5f7..4420f23 100644 --- a/kernel/cobalt/syscall.c +++ b/kernel/cobalt/syscall.c @@ -43,92 +43,6 @@ int cobalt_muxid; -static int __timer_create(clockid_t clock, - const struct sigevent __user *u_sev, - timer_t __user *u_tm) -{ - union __xeno_sem sm, __user *u_sem; - struct sigevent sev, *evp = sev; - timer_t tm; - int ret; - - if (u_sev) { - if (__xn_safe_copy_from_user(sev, u_sev, sizeof(sev))) - return -EFAULT; - - if (sev.sigev_notify == SIGEV_THREAD_ID) { - u_sem = sev.sigev_value.sival_ptr; - - if (__xn_safe_copy_from_user(sm, u_sem, sizeof(sm))) - return -EFAULT; - - sev.sigev_value.sival_ptr = sm.native_sem; - } - } else - evp = NULL; - - ret = timer_create(clock, evp, tm); - if (ret) - return -thread_get_errno(); - - if (__xn_safe_copy_to_user(u_tm, tm, sizeof(tm))) { - timer_delete(tm); - return -EFAULT; - } - - return 0; -} - -static int __timer_delete(timer_t tm) -{ - int ret = timer_delete(tm); - return ret == 0 ? 0 : -thread_get_errno(); -} - -static int __timer_settime(timer_t tm, - int flags, - const struct itimerspec __user *u_newval, - struct itimerspec __user *u_oldval) -{ - struct itimerspec newv, oldv, *oldvp; - int ret; - - oldvp = u_oldval == 0 ? NULL : oldv; - - if (__xn_safe_copy_from_user(newv, u_newval, sizeof(newv))) - return -EFAULT; - - ret = timer_settime(tm, flags, newv, oldvp); - if (ret) - return -thread_get_errno(); - - if (oldvp __xn_safe_copy_to_user(u_oldval, oldvp, sizeof(oldv))) { - timer_settime(tm, flags, oldvp, NULL); - return -EFAULT; - } - - return 0; -} - -static int __timer_gettime(timer_t tm, - struct itimerspec __user *u_val) -{ - struct itimerspec val; - int ret; - - ret = timer_gettime(tm, val); - if (ret) - return -thread_get_errno(); - - return __xn_safe_copy_to_user(u_val, val, sizeof(val)); -} - -static int __timer_getoverrun(timer_t tm) -{ - int ret = timer_getoverrun(tm); - return ret = 0 ? ret : -thread_get_errno(); -} - static int fd_valid_p(int fd) { cobalt_assoc_t *assoc; @@ -359,11 +273,11 @@ static struct xnsysent __systab[] = { SKINCALL_DEF(sc_cobalt_mq_timedsend, cobalt_mq_timedsend, primary), SKINCALL_DEF(sc_cobalt_mq_receive, cobalt_mq_receive, primary),
[Xenomai-git] Gilles Chanteperdrix : cobalt: move mutexattr system calls to mutex_attr.c
Module: xenomai-forge Branch: master Commit: 87ce6b67bf4b66d54a8d1c62ce65a74fbaa1cd23 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=87ce6b67bf4b66d54a8d1c62ce65a74fbaa1cd23 Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Sun Dec 11 17:35:31 2011 +0100 cobalt: move mutexattr system calls to mutex_attr.c --- include/cobalt/pthread.h | 34 -- kernel/cobalt/mutex.c |3 - kernel/cobalt/mutex.h | 22 ++ kernel/cobalt/mutex_attr.c | 158 ++- kernel/cobalt/syscall.c| 139 ++ 5 files changed, 169 insertions(+), 187 deletions(-) diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h index 3a39fbe..62a7134 100644 --- a/include/cobalt/pthread.h +++ b/include/cobalt/pthread.h @@ -273,40 +273,6 @@ int pthread_attr_getaffinity_np(const pthread_attr_t *attr, int pthread_attr_setaffinity_np(pthread_attr_t *attr, xnarch_cpumask_t mask); -int pthread_mutexattr_init(pthread_mutexattr_t *attr); - -int pthread_mutexattr_destroy(pthread_mutexattr_t *attr); - -int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, - int *type); - -int pthread_mutexattr_settype(pthread_mutexattr_t *attr, - int type); - -int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, - int *proto); - -int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, - int proto); - -int pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, int *pshared); - -int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared); - -int pthread_mutex_init(pthread_mutex_t *mutex, - const pthread_mutexattr_t *attr); - -int pthread_mutex_destroy(pthread_mutex_t *mutex); - -int pthread_mutex_trylock(pthread_mutex_t *mutex); - -int pthread_mutex_lock(pthread_mutex_t *mutex); - -int pthread_mutex_timedlock(pthread_mutex_t *mutex, - const struct timespec *to); - -int pthread_mutex_unlock(pthread_mutex_t *mutex); - int pthread_condattr_init(pthread_condattr_t *attr); int pthread_condattr_destroy(pthread_condattr_t *attr); diff --git a/kernel/cobalt/mutex.c b/kernel/cobalt/mutex.c index 28bcaac..3da89a3 100644 --- a/kernel/cobalt/mutex.c +++ b/kernel/cobalt/mutex.c @@ -51,8 +51,6 @@ #include mutex.h #include cond.h -pthread_mutexattr_t cobalt_default_mutex_attr; - static int cobalt_mutex_init_inner(struct __shadow_mutex *shadow, cobalt_mutex_t *mutex, struct mutex_dat *datp, @@ -411,7 +409,6 @@ void cobalt_mutexq_cleanup(cobalt_kqueues_t *q) void cobalt_mutex_pkg_init(void) { initq(cobalt_global_kqueues.mutexq); - pthread_mutexattr_init(cobalt_default_mutex_attr); } void cobalt_mutex_pkg_cleanup(void) diff --git a/kernel/cobalt/mutex.h b/kernel/cobalt/mutex.h index feba86f..0fbd977 100644 --- a/kernel/cobalt/mutex.h +++ b/kernel/cobalt/mutex.h @@ -124,6 +124,28 @@ static inline int cobalt_mutex_release(xnthread_t *cur, cobalt_mutex_t *mutex) return need_resched; } +int cobalt_mutexattr_init(pthread_mutexattr_t __user *u_attr); + +int cobalt_mutexattr_destroy(pthread_mutexattr_t __user *u_attr); + +int cobalt_mutexattr_gettype(const pthread_mutexattr_t __user *u_attr, +int __user *u_type); + +int cobalt_mutexattr_settype(pthread_mutexattr_t __user *u_attr, +int type); + +int cobalt_mutexattr_getprotocol(const pthread_mutexattr_t __user *u_attr, +int __user *u_proto); + +int cobalt_mutexattr_setprotocol(pthread_mutexattr_t __user *u_attr, +int proto); + +int cobalt_mutexattr_getpshared(const pthread_mutexattr_t __user *u_attr, + int __user *u_pshared); + +int cobalt_mutexattr_setpshared(pthread_mutexattr_t __user *u_attr, + int pshared); + int cobalt_mutex_check_init(struct __shadow_mutex __user *u_mx); int cobalt_mutex_init(struct __shadow_mutex __user *u_mx, diff --git a/kernel/cobalt/mutex_attr.c b/kernel/cobalt/mutex_attr.c index 3bcadf0..4729840 100644 --- a/kernel/cobalt/mutex_attr.c +++ b/kernel/cobalt/mutex_attr.c @@ -23,7 +23,7 @@ #include internal.h -static const pthread_mutexattr_t default_mutex_attr = { +const pthread_mutexattr_t cobalt_default_mutex_attr = { magic: COBALT_MUTEX_ATTR_MAGIC, type: PTHREAD_MUTEX_NORMAL, protocol: PTHREAD_PRIO_NONE, @@ -53,12 +53,12 @@ static const pthread_mutexattr_t default_mutex_attr = { * Specification./a * */ -int pthread_mutexattr_init(pthread_mutexattr_t * attr) +static inline int pthread_mutexattr_init(pthread_mutexattr_t * attr) { if (!attr) return ENOMEM; - *attr =
[Xenomai-git] Gilles Chanteperdrix : cobalt: move cond_attr system calls to cond_attr.c
Module: xenomai-forge Branch: master Commit: 9cf6dd92acb501313dc2425f84123981cac0eec9 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=9cf6dd92acb501313dc2425f84123981cac0eec9 Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Sun Dec 11 17:46:32 2011 +0100 cobalt: move cond_attr system calls to cond_attr.c --- include/cobalt/pthread.h | 93 - kernel/cobalt/cond.c |5 +-- kernel/cobalt/cond.h | 16 ++ kernel/cobalt/cond_attr.c | 124 ++--- kernel/cobalt/syscall.c | 104 ++--- 5 files changed, 129 insertions(+), 213 deletions(-) diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h index 62a7134..139802f 100644 --- a/include/cobalt/pthread.h +++ b/include/cobalt/pthread.h @@ -198,99 +198,6 @@ struct cobalt_monitor_shadow { typedef struct cobalt_mutexattr pthread_mutexattr_t; typedef struct cobalt_condattr pthread_condattr_t; - -#ifdef __cplusplus -extern C { -#endif - -int pthread_attr_init(pthread_attr_t *attr); - -int pthread_attr_destroy(pthread_attr_t *attr); - -int pthread_attr_getdetachstate(const pthread_attr_t *attr, - int *detachstate); - -int pthread_attr_setdetachstate(pthread_attr_t *attr, - int detachstate); - -int pthread_attr_getstackaddr(const pthread_attr_t *attr, - void **stackaddr); - -int pthread_attr_setstackaddr(pthread_attr_t *attr, - void *stackaddr); - -int pthread_attr_getstacksize(const pthread_attr_t *attr, - size_t *stacksize); - -int pthread_attr_setstacksize(pthread_attr_t *attr, - size_t stacksize); - -int pthread_attr_getinheritsched(const pthread_attr_t *attr, -int *inheritsched); - -int pthread_attr_setinheritsched(pthread_attr_t *attr, -int inheritsched); - -int pthread_attr_getschedpolicy(const pthread_attr_t *attr, - int *policy); - -int pthread_attr_setschedpolicy(pthread_attr_t *attr, - int policy); - -int pthread_attr_getschedparam(const pthread_attr_t *attr, - struct sched_param *par); - -int pthread_attr_getschedparam_ex(const pthread_attr_t *attr, - struct sched_param_ex *par); - -int pthread_attr_setschedparam(pthread_attr_t *attr, - const struct sched_param *par); - -int pthread_attr_setschedparam_ex(pthread_attr_t *attr, - const struct sched_param_ex *par); - -int pthread_attr_getscope(const pthread_attr_t *attr, - int *scope); - -int pthread_attr_setscope(pthread_attr_t *attr, - int scope); - -int pthread_attr_getname_np(const pthread_attr_t *attr, - const char **name); - -int pthread_attr_setname_np(pthread_attr_t *attr, - const char *name); - -int pthread_attr_getfp_np(const pthread_attr_t *attr, - int *use_fp); - -int pthread_attr_setfp_np(pthread_attr_t *attr, - int use_fp); - -int pthread_attr_getaffinity_np(const pthread_attr_t *attr, - xnarch_cpumask_t *mask); - -int pthread_attr_setaffinity_np(pthread_attr_t *attr, - xnarch_cpumask_t mask); - -int pthread_condattr_init(pthread_condattr_t *attr); - -int pthread_condattr_destroy(pthread_condattr_t *attr); - -int pthread_condattr_getclock(const pthread_condattr_t *attr, - clockid_t *clk_id); - -int pthread_condattr_setclock(pthread_condattr_t *attr, - clockid_t clk_id); - -int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared); - -int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared); - -#ifdef __cplusplus -} -#endif - #else /* !(__KERNEL__ || __XENO_SIM__) */ typedef struct { diff --git a/kernel/cobalt/cond.c b/kernel/cobalt/cond.c index c19643c..cfe5201 100644 --- a/kernel/cobalt/cond.c +++ b/kernel/cobalt/cond.c @@ -51,8 +51,6 @@ #include mutex.h #include cond.h -static pthread_condattr_t default_cond_attr; - static inline void cond_destroy_internal(cobalt_cond_t *cond, cobalt_kqueues_t *q) { @@ -106,7 +104,7 @@ pthread_cond_init(struct __shadow_cond *cnd, const pthread_condattr_t *attr) int err; if (!attr) - attr = default_cond_attr; + attr = cobalt_default_cond_attr; cond = (cobalt_cond_t *)xnmalloc(sizeof(*cond)); if (!cond) @@ -491,7 +489,6 @@ void cobalt_condq_cleanup(cobalt_kqueues_t *q) void cobalt_cond_pkg_init(void) { initq(cobalt_global_kqueues.condq); - pthread_condattr_init(default_cond_attr); } void
[Xenomai-git] Gilles Chanteperdrix : cobalt: remove thread_attr.c
Module: xenomai-forge Branch: master Commit: bc58b58f23279c6a72669b139275f5ef6be79c2d URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=bc58b58f23279c6a72669b139275f5ef6be79c2d Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Sun Dec 11 17:33:55 2011 +0100 cobalt: remove thread_attr.c --- kernel/cobalt/Makefile |1 - kernel/cobalt/thread.c | 21 +- kernel/cobalt/thread_attr.c | 1088 --- 3 files changed, 16 insertions(+), 1094 deletions(-) diff --git a/kernel/cobalt/Makefile b/kernel/cobalt/Makefile index f4bc809..d54803c 100644 --- a/kernel/cobalt/Makefile +++ b/kernel/cobalt/Makefile @@ -1,7 +1,6 @@ obj-$(CONFIG_XENOMAI) += nucleus/ rtdm/ xeno_cobalt.o xeno_cobalt-y := \ - thread_attr.o \ thread.o \ mutex_attr.o \ mutex.o \ diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c index 5559ca7..00086ac 100644 --- a/kernel/cobalt/thread.c +++ b/kernel/cobalt/thread.c @@ -36,7 +36,19 @@ xnticks_t cobalt_time_slice; -static pthread_attr_t default_attr; +static const pthread_attr_t default_thread_attr = { + magic:COBALT_THREAD_ATTR_MAGIC, + detachstate:PTHREAD_CREATE_JOINABLE, + stacksize:PTHREAD_STACK_MIN, + inheritsched:PTHREAD_EXPLICIT_SCHED, + policy:SCHED_OTHER, + schedparam_ex:{ + sched_priority:0}, + + name:NULL, + fp:1, + affinity:XNPOD_ALL_CPUS, +}; static unsigned cobalt_get_magic(void) { @@ -393,7 +405,7 @@ static inline int pthread_create(pthread_t *tid, const pthread_attr_t * attr) if (!thread) return -EAGAIN; - thread-attr = attr ? *attr : default_attr; + thread-attr = attr ? *attr : default_thread_attr; cur = cobalt_current_thread(); @@ -968,7 +980,7 @@ int cobalt_thread_create(unsigned long tid, int policy, * critical fields are set in a compatible fashion wrt to the * calling context. */ - pthread_attr_init(attr); + attr = default_thread_attr; attr.policy = policy; attr.detachstate = PTHREAD_CREATE_DETACHED; attr.schedparam_ex = param; @@ -1008,7 +1020,7 @@ pthread_t cobalt_thread_shadow(struct task_struct *p, pid_t h_tid; int err; - pthread_attr_init(attr); + attr = default_thread_attr; attr.detachstate = PTHREAD_CREATE_DETACHED; attr.name = p-comm; @@ -1369,7 +1381,6 @@ void cobalt_threadq_cleanup(cobalt_kqueues_t *q) void cobalt_thread_pkg_init(u_long rrperiod) { initq(cobalt_global_kqueues.threadq); - pthread_attr_init(default_attr); cobalt_time_slice = rrperiod; xnpod_add_hook(XNHOOK_THREAD_DELETE, thread_delete_hook); } diff --git a/kernel/cobalt/thread_attr.c b/kernel/cobalt/thread_attr.c deleted file mode 100644 index 85f88eb..000 --- a/kernel/cobalt/thread_attr.c +++ /dev/null @@ -1,1088 +0,0 @@ -/* - * Written by Gilles Chanteperdrix gilles.chanteperd...@xenomai.org. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/** - * @ingroup posix_thread - * @defgroup posix_threadattr Thread creation attributes. - * - * Thread creation attributes. - * - * The services described in this section allow to set the attributes of a - * @b pthread_attr_t object, passed to the pthread_create() service in order - * to set the attributes of a created thread. - * - * A @b pthread_attr_t object has to be initialized with pthread_attr_init() - * first, which sets attributes to their default values, i.e. in kernel-space: - * - @a detachstate to PTHREAD_CREATE_JOINABLE, - * - @a stacksize to PTHREAD_STACK_MIN, - * - @a inheritsched to PTHREAD_EXPLICIT_SCHED, - * - @a schedpolicy to SCHED_OTHER, - * - @a name to NULL (only available in kernel-space), - * - scheduling priority to the minimum, - * - floating-point hardware enabled (only available in kernel-space), - * - processor affinity set to all available processors (only available as a - * thread attribute in kernel-space). - * - * In user-space, the attributes and their defaults values are those documented - * by the underlying threading library (LinuxThreads or NPTL). - * - *@{*/ - -#include internal.h - -static const pthread_attr_t default_thread_attr = { -
[Xenomai-git] Gilles Chanteperdrix : cobalt: remove useless calls to xnpod_unblockable_p( )
Module: xenomai-forge Branch: master Commit: 463cbaedf69396ffd6eb0bc6c36083f8f44ff0bb URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=463cbaedf69396ffd6eb0bc6c36083f8f44ff0bb Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Sun Dec 11 17:35:53 2011 +0100 cobalt: remove useless calls to xnpod_unblockable_p() --- kernel/cobalt/cond.c |3 --- kernel/cobalt/sem.c |3 --- 2 files changed, 0 insertions(+), 6 deletions(-) diff --git a/kernel/cobalt/cond.c b/kernel/cobalt/cond.c index c8200ef..c19643c 100644 --- a/kernel/cobalt/cond.c +++ b/kernel/cobalt/cond.c @@ -238,9 +238,6 @@ static inline int cobalt_cond_timedwait_prologue(xnthread_t *cur, spl_t s; int err; - if (xnpod_unblockable_p()) - return -EPERM; - xnlock_get_irqsave(nklock, s); /* If another thread waiting for cond does not use the same mutex */ diff --git a/kernel/cobalt/sem.c b/kernel/cobalt/sem.c index f855905..6b1918c 100644 --- a/kernel/cobalt/sem.c +++ b/kernel/cobalt/sem.c @@ -524,9 +524,6 @@ sem_timedwait_internal(cobalt_sem_t *sem, int timed, xnticks_t to) xnthread_t *cur; int err; - if (xnpod_unblockable_p()) - return -EPERM; - cur = xnpod_current_thread(); if ((err = sem_trywait_internal(sem)) != -EAGAIN) ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Gilles Chanteperdrix : cobalt: move message queues syscalls to mq.c
Module: xenomai-forge Branch: master Commit: d18103f31d7216d2d40e597bdbc0ed4c0fc71176 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=d18103f31d7216d2d40e597bdbc0ed4c0fc71176 Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Sun Dec 11 18:12:25 2011 +0100 cobalt: move message queues syscalls to mq.c --- include/cobalt/mqueue.h | 47 --- kernel/cobalt/mq.c | 724 +++ kernel/cobalt/mq.h | 36 ++- kernel/cobalt/syscall.c | 340 +- 4 files changed, 390 insertions(+), 757 deletions(-) diff --git a/include/cobalt/mqueue.h b/include/cobalt/mqueue.h index 8f8f677..00bc847 100644 --- a/include/cobalt/mqueue.h +++ b/include/cobalt/mqueue.h @@ -57,53 +57,6 @@ struct mq_attr { longmq_curmsgs; }; -#ifdef __cplusplus -extern C { -#endif - -int mq_getattr(mqd_t qd, - struct mq_attr *attr); - -int mq_setattr(mqd_t qd, - const struct mq_attr *__restrict__ attr, - struct mq_attr *__restrict__ oattr); - -int mq_send(mqd_t qd, - const char *buffer, - size_t len, - unsigned prio); - -int mq_close(mqd_t qd); - -ssize_t mq_receive(mqd_t q, - char *buffer, - size_t len, - unsigned *prio); - -ssize_t mq_timedreceive(mqd_t q, -char *__restrict__ buffer, -size_t len, -unsigned *__restrict__ prio, -const struct timespec *__restrict__ timeout); - -int mq_timedsend(mqd_t q, -const char *buffer, -size_t len, -unsigned prio, -const struct timespec *timeout); - -int mq_notify(mqd_t mqdes, const struct sigevent *notification); - -mqd_t mq_open(const char *name, - int oflags, - ...); - -int mq_unlink(const char *name); - -#ifdef __cplusplus -} -#endif - #else /* !(__KERNEL__ || __XENO_SIM__ || !HAVE_MQUEUE_H) */ #include_next mqueue.h diff --git a/kernel/cobalt/mq.c b/kernel/cobalt/mq.c index 732a178..8894f05 100644 --- a/kernel/cobalt/mq.c +++ b/kernel/cobalt/mq.c @@ -46,8 +46,7 @@ struct cobalt_mq { cobalt_node_t nodebase; -#define node2mq(naddr) \ -((cobalt_mq_t *) (((char *)naddr) - offsetof(cobalt_mq_t, nodebase))) +#define node2mq(naddr) container_of(naddr, cobalt_mq_t, nodebase) xnpqueue_t queued; xnsynch_t receivers; @@ -62,12 +61,19 @@ struct cobalt_mq { DECLARE_XNSELECT(read_select); DECLARE_XNSELECT(write_select); -#define link2mq(laddr) \ -((cobalt_mq_t *) (((char *)laddr) - offsetof(cobalt_mq_t, link))) +#define link2mq(laddr) container_of(laddr, cobalt_mq_t, link) }; -#define any2msg(addr, member) \ -((cobalt_msg_t *)(((char *)addr) - offsetof(cobalt_msg_t, member))) +#define link2msg(addr) container_of(addr, cobalt_msg_t, link) + +typedef struct cobalt_msg { + xnpholder_t link; + size_t len; + char data[0]; +} cobalt_msg_t; + +#define cobalt_msg_get_prio(msg) (msg)-link.prio +#define cobalt_msg_set_prio(msg, prio) (msg)-link.prio = (prio) static xnqueue_t cobalt_mqq; @@ -76,7 +82,7 @@ static struct mq_attr default_attr = { mq_msgsize:128, }; -static cobalt_msg_t *cobalt_mq_msg_alloc(cobalt_mq_t * mq) +static inline cobalt_msg_t *cobalt_mq_msg_alloc(cobalt_mq_t * mq) { xnpholder_t *holder = (xnpholder_t *)getq(mq-avail); @@ -84,24 +90,21 @@ static cobalt_msg_t *cobalt_mq_msg_alloc(cobalt_mq_t * mq) return NULL; initph(holder); - return any2msg(holder, link); + return link2msg(holder); } -static void cobalt_mq_msg_free(cobalt_mq_t * mq, cobalt_msg_t * msg) +static inline void cobalt_mq_msg_free(cobalt_mq_t * mq, cobalt_msg_t * msg) { xnholder_t *holder = (xnholder_t *)(msg-link); inith(holder); prependq(mq-avail, holder); /* For earliest re-use of the block. */ } -static int cobalt_mq_init(cobalt_mq_t * mq, const struct mq_attr *attr) +static inline int cobalt_mq_init(cobalt_mq_t * mq, const struct mq_attr *attr) { unsigned i, msgsize, memsize; char *mem; - if (xnpod_asynch_p() || !xnpod_root_p()) - return EPERM; - if (!attr) attr = default_attr; else if (attr-mq_maxmsg = 0 || attr-mq_msgsize = 0) @@ -142,7 +145,7 @@ static int cobalt_mq_init(cobalt_mq_t * mq, const struct mq_attr *attr) return 0; } -static void cobalt_mq_destroy(cobalt_mq_t *mq) +static inline void cobalt_mq_destroy(cobalt_mq_t *mq) { int resched; spl_t s; @@ -231,7 +234,7 @@ static void cobalt_mq_destroy(cobalt_mq_t *mq) * Specification./a * */ -mqd_t mq_open(const char *name, int oflags, ...) +static mqd_t mq_open(const char *name, int oflags, ...) { struct mq_attr *attr;
[Xenomai-git] Gilles Chanteperdrix : cobalt: move timers system calls to timer.c
Module: xenomai-forge Branch: master Commit: d67f5d8763dfcc690bb1b659778b15c370494340 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=d67f5d8763dfcc690bb1b659778b15c370494340 Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org Date: Sun Dec 11 19:53:58 2011 +0100 cobalt: move timers system calls to timer.c --- include/cobalt/time.h | 48 +-- kernel/cobalt/syscall.c | 96 +-- kernel/cobalt/timer.c | 235 +++ kernel/cobalt/timer.h | 15 +++ 4 files changed, 138 insertions(+), 256 deletions(-) diff --git a/include/cobalt/time.h b/include/cobalt/time.h index 3c10681..8e9f66a 100644 --- a/include/cobalt/time.h +++ b/include/cobalt/time.h @@ -65,53 +65,7 @@ */ #define CLOCK_HOST_REALTIME 42 -#if defined(__KERNEL__) || defined(__XENO_SIM__) - -struct sigevent; - -struct timespec; - -#ifdef __cplusplus -extern C { -#endif - -int clock_getres(clockid_t clock_id, -struct timespec *res); - -int clock_gettime(clockid_t clock_id, - struct timespec *tp); - -int clock_settime(clockid_t clock_id, - const struct timespec *tp); - -int clock_nanosleep(clockid_t clock_id, - int flags, - const struct timespec *rqtp, - struct timespec *rmtp); - -int nanosleep(const struct timespec *rqtp, - struct timespec *rmtp); - -int timer_create(clockid_t clockid, -const struct sigevent *__restrict__ evp, -timer_t *__restrict__ timerid); - -int timer_delete(timer_t timerid); - -int timer_settime(timer_t timerid, - int flags, - const struct itimerspec *__restrict__ value, - struct itimerspec *__restrict__ ovalue); - -int timer_gettime(timer_t timerid, struct itimerspec *value); - -int timer_getoverrun(timer_t timerid); - -#ifdef __cplusplus -} -#endif - -#else /* !(__KERNEL__ || __XENO_SIM__) */ +#if !(defined(__KERNEL__) || defined(__XENO_SIM__)) #ifdef __cplusplus extern C { diff --git a/kernel/cobalt/syscall.c b/kernel/cobalt/syscall.c index 286c5f7..4420f23 100644 --- a/kernel/cobalt/syscall.c +++ b/kernel/cobalt/syscall.c @@ -43,92 +43,6 @@ int cobalt_muxid; -static int __timer_create(clockid_t clock, - const struct sigevent __user *u_sev, - timer_t __user *u_tm) -{ - union __xeno_sem sm, __user *u_sem; - struct sigevent sev, *evp = sev; - timer_t tm; - int ret; - - if (u_sev) { - if (__xn_safe_copy_from_user(sev, u_sev, sizeof(sev))) - return -EFAULT; - - if (sev.sigev_notify == SIGEV_THREAD_ID) { - u_sem = sev.sigev_value.sival_ptr; - - if (__xn_safe_copy_from_user(sm, u_sem, sizeof(sm))) - return -EFAULT; - - sev.sigev_value.sival_ptr = sm.native_sem; - } - } else - evp = NULL; - - ret = timer_create(clock, evp, tm); - if (ret) - return -thread_get_errno(); - - if (__xn_safe_copy_to_user(u_tm, tm, sizeof(tm))) { - timer_delete(tm); - return -EFAULT; - } - - return 0; -} - -static int __timer_delete(timer_t tm) -{ - int ret = timer_delete(tm); - return ret == 0 ? 0 : -thread_get_errno(); -} - -static int __timer_settime(timer_t tm, - int flags, - const struct itimerspec __user *u_newval, - struct itimerspec __user *u_oldval) -{ - struct itimerspec newv, oldv, *oldvp; - int ret; - - oldvp = u_oldval == 0 ? NULL : oldv; - - if (__xn_safe_copy_from_user(newv, u_newval, sizeof(newv))) - return -EFAULT; - - ret = timer_settime(tm, flags, newv, oldvp); - if (ret) - return -thread_get_errno(); - - if (oldvp __xn_safe_copy_to_user(u_oldval, oldvp, sizeof(oldv))) { - timer_settime(tm, flags, oldvp, NULL); - return -EFAULT; - } - - return 0; -} - -static int __timer_gettime(timer_t tm, - struct itimerspec __user *u_val) -{ - struct itimerspec val; - int ret; - - ret = timer_gettime(tm, val); - if (ret) - return -thread_get_errno(); - - return __xn_safe_copy_to_user(u_val, val, sizeof(val)); -} - -static int __timer_getoverrun(timer_t tm) -{ - int ret = timer_getoverrun(tm); - return ret = 0 ? ret : -thread_get_errno(); -} - static int fd_valid_p(int fd) { cobalt_assoc_t *assoc; @@ -359,11 +273,11 @@ static struct xnsysent __systab[] = { SKINCALL_DEF(sc_cobalt_mq_timedsend, cobalt_mq_timedsend, primary), SKINCALL_DEF(sc_cobalt_mq_receive, cobalt_mq_receive, primary),