]> rtime.felk.cvut.cz Git - frescor/fosa.git/commitdiff
Bugfixes and restyling.
authorfaggioli <faggioli@35b4ef3e-fd22-0410-ab77-dab3279adceb>
Sat, 14 Feb 2009 18:15:40 +0000 (18:15 +0000)
committerfaggioli <faggioli@35b4ef3e-fd22-0410-ab77-dab3279adceb>
Sat, 14 Feb 2009 18:15:40 +0000 (18:15 +0000)
git-svn-id: http://www.frescor.org/private/svn/frescor/fosa/trunk@1550 35b4ef3e-fd22-0410-ab77-dab3279adceb

src_aquosa/fosa_app_def_sched.c
src_aquosa/fosa_clocks_and_timers.c
src_aquosa/fosa_group_clocks.c
src_aquosa/fosa_long_jump.c
src_aquosa/fosa_platform_values.c
src_aquosa/fosa_threads_and_signals.c
src_aquosa/fosa_time.c

index ec22b9af6c54132a176962c84f5e7b56ab742f09..4807a3f4689a4d523ef4e99464f6c4b7745eeee6 100644 (file)
@@ -111,7 +111,7 @@ int fosa_ads_scheduler_create(const fosa_ads_scheduler_ops_t * scheduler_ops,
                              size_t scheduler_data_size, void * init_args,
                              size_t init_args_size)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
 /**
@@ -135,7 +135,7 @@ int fosa_ads_scheduler_create(const fosa_ads_scheduler_ops_t * scheduler_ops,
 int fosa_thread_attr_set_appscheduled(fosa_thread_attr_t *attr,
                                      bool appscheduled)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
 /**
@@ -159,7 +159,7 @@ int fosa_thread_attr_set_appscheduled(fosa_thread_attr_t *attr,
 int fosa_thread_attr_get_appscheduled(const fosa_thread_attr_t *attr,
                                      bool *appscheduled)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
 /**
@@ -187,7 +187,7 @@ int fosa_thread_attr_set_appsched_params(fosa_thread_attr_t *attr,
                                         const void *param,
                                         size_t paramsize)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
 /**
@@ -215,7 +215,7 @@ int fosa_thread_attr_set_appsched_params(fosa_thread_attr_t *attr,
 int fosa_thread_attr_get_appsched_params(const fosa_thread_attr_t *attr,
                                         void *param, size_t *paramsize)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
 /**
@@ -243,7 +243,7 @@ int fosa_thread_attr_get_appsched_params(const fosa_thread_attr_t *attr,
  **/
 int fosa_ads_set_appscheduled(fosa_thread_id_t thread, bool appscheduled)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
 /**
@@ -266,7 +266,7 @@ int fosa_ads_set_appscheduled(fosa_thread_id_t thread, bool appscheduled)
  **/
 int fosa_ads_get_appscheduled(fosa_thread_id_t thread, bool *appscheduled)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
 
@@ -295,7 +295,7 @@ int fosa_ads_get_appscheduled(fosa_thread_id_t thread, bool *appscheduled)
 int fosa_ads_set_appsched_params(fosa_thread_id_t thread,
                                 const void *param, size_t paramsize)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
 /**
@@ -324,7 +324,7 @@ int fosa_ads_set_appsched_params(fosa_thread_id_t thread,
 int fosa_ads_get_appsched_params(fosa_thread_id_t thread,
                                 void *param, size_t *paramsize)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
 
@@ -375,7 +375,7 @@ int fosa_ads_get_appsched_params(fosa_thread_id_t thread,
 int fosa_adsactions_add_reject(fosa_ads_actions_t *sched_actions,
                               fosa_thread_id_t thread)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
 /**
@@ -414,7 +414,7 @@ int fosa_adsactions_add_activate(fosa_ads_actions_t *sched_actions,
                                 fosa_thread_id_t thread,
                                 fosa_ads_urgency_t urgency)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
 /**
@@ -443,7 +443,7 @@ int fosa_adsactions_add_activate(fosa_ads_actions_t *sched_actions,
 int fosa_adsactions_add_suspend(fosa_ads_actions_t *sched_actions,
                                fosa_thread_id_t thread)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
 /**
@@ -470,7 +470,7 @@ int fosa_adsactions_add_timeout(fosa_ads_actions_t *sched_actions,
                                fosa_clock_id_t clock_id,
                                const fosa_abs_time_t *at_time)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
 /**
@@ -506,7 +506,7 @@ int fosa_adsactions_add_thread_notification(fosa_ads_actions_t *sched_actions,
                                            fosa_clock_id_t clock_id,
                                            const fosa_abs_time_t *at_time)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
 
@@ -540,7 +540,7 @@ int fosa_adsactions_add_thread_notification(fosa_ads_actions_t *sched_actions,
  **/
 int fosa_ads_set_handled_signal_set(fosa_signal_t set[], int size)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
 
@@ -576,7 +576,7 @@ int fosa_ads_set_handled_signal_set(fosa_signal_t set[], int size)
  **/
 int fosa_signal_queue_scheduler(fosa_signal_t signal, fosa_signal_info_t info)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
 /**
@@ -625,6 +625,6 @@ int fosa_signal_queue_scheduler(fosa_signal_t signal, fosa_signal_info_t info)
 int fosa_ads_invoke_withdata(const void *msg, size_t msg_size,
                             void *reply, size_t *reply_size)
 {
-       return -EINVAL;
+       return FOSA_EINVAL;
 }
 
index 9dae54c7ea6777781acbacac061c55f6a396bd4f..5adb0d6ba9fd8a29f25ed68bb01507e3f7d3e089 100644 (file)
@@ -231,7 +231,7 @@ int fosa_timer_delete(fosa_timer_id_t  timerid)
  * notify it to the system console and then terminate the FRSH
  * implementation and dependant applications
  **/
-int fosa_rel_timer_arm (fosa_timer_id_t timerid, const fosa_rel_time_t *value)
+int fosa_rel_timer_arm(fosa_timer_id_t timerid, const fosa_rel_time_t *value)
 {
        struct itimerspec when;
 
@@ -274,8 +274,8 @@ int fosa_abs_timer_arm(fosa_timer_id_t timerid, const fosa_abs_time_t *value)
        struct itimerspec when;
 
        /* non-periodic one shot timer */
-       when.it_value= fosa_abs_time_to_timespec(*value);
-       when.it_interval=zero_time;
+       when.it_value = fosa_abs_time_to_timespec(*value);
+       when.it_interval = zero_time;
 
        return timer_settime(timerid, TIMER_ABSTIME, &when, NULL);
 }
@@ -300,7 +300,7 @@ int fosa_timer_get_remaining_time(fosa_timer_id_t timerid,
        int ret;
        struct itimerspec time;
 
-       if (remaining_time == NULL)
+       if (!remaining_time)
                return FOSA_EINVAL;
 
        ret = timer_gettime(timerid, &time);
@@ -331,7 +331,7 @@ int fosa_timer_disarm(fosa_timer_id_t timerid,
        int ret;
        struct itimerspec time;
 
-       if (remaining_time == NULL)
+       if (!remaining_time)
                return FOSA_EINVAL;
 
        ret = timer_gettime(timerid, &time);
index 6b960639e7a22c6765e2789c089e311157087247..f0e8a38ed0c47e47e3e309038328c9f083734e7f 100644 (file)
@@ -87,7 +87,7 @@
  **/
 int fosa_thread_set_create(fosa_thread_set_id_t *set)
 {
-       return -EINVAL;
+       return EINVAL;
 }
     
 
@@ -111,7 +111,7 @@ int fosa_thread_set_create(fosa_thread_set_id_t *set)
  **/
 int fosa_thread_set_destroy(fosa_thread_set_id_t set)
 {
-       return -EINVAL;
+       return EINVAL;
 }
 
 
@@ -135,7 +135,7 @@ int fosa_thread_set_destroy(fosa_thread_set_id_t set)
  **/
 int fosa_thread_set_add(fosa_thread_set_id_t set, fosa_thread_id_t thread_id)
 {
-       return -EINVAL;
+       return EINVAL;
 }
 
 
@@ -159,7 +159,7 @@ int fosa_thread_set_add(fosa_thread_set_id_t set, fosa_thread_id_t thread_id)
 
 int fosa_thread_set_del(fosa_thread_set_id_t set, fosa_thread_id_t thread_id)
 {
-       return -EINVAL;
+       return EINVAL;
 }
 
 
@@ -184,6 +184,6 @@ int fosa_thread_set_del(fosa_thread_set_id_t set, fosa_thread_id_t thread_id)
 int fosa_get_groupcpu_clock(const fosa_thread_set_id_t set,
                            fosa_clock_id_t *clock_id)
 {
-       return -EINVAL;
+       return EINVAL;
 }
 
index 829e2c7a5aeed5023322a03d4047025f3b8a94c0..b1e193a2af05006430b48b38c7600527fde61340 100644 (file)
@@ -132,7 +132,7 @@ int fosa_long_jump_save_context(fosa_long_jump_context_t *context)
 int fosa_long_jump_was_performed(const fosa_long_jump_context_t *context,
                                 int *jumped)
 {
-       return ENOSYS;
+       return EINVAL;
 }
 
 /** 
@@ -140,7 +140,8 @@ int fosa_long_jump_was_performed(const fosa_long_jump_context_t *context,
  **/
 void __long_jump_handler(int n, siginfo_t *info, void *c)
 {
-       fosa_long_jump_context_t *context = (fosa_long_jump_context_t*)info->si_ptr;
+       fosa_long_jump_context_t *context =
+               (fosa_long_jump_context_t*) info->si_ptr;
 
        siglongjmp(*context, 1);
 }
index da350d1fa7c3bb37afaa7a905b0acbf282e0c27d..23c1db84432ebcbe18a0a34f8a72b3cd27a7586b 100644 (file)
@@ -84,6 +84,6 @@
 
 int fosa_get_cpu_resource_id(fosa_resource_id_t *cpu_id)
 {
-        return -ENOSYS;
+        return FOSA_EINVAL;
 }
 
index 1cb47959fffe0fa3322250bc5460e10fef904faa..3f64a674dfd2c883ba99b58e0ec20e7b550bcbea 100644 (file)
@@ -135,6 +135,14 @@ fosa_thread_id_t fosa_thread_self()
  * Thread attributes
  *************************/
 
+static inline int __fosa_check_thread(const fosa_thread_id_t *tid)
+{
+       if (tid->linux_pid == tid->linux_tid)
+               return 0;
+
+       return 1;
+}
+
 /**
  * fosa_thread_attr_init()
  *
@@ -149,13 +157,6 @@ fosa_thread_id_t fosa_thread_self()
  **/
 int fosa_thread_attr_init(fosa_thread_attr_t *attr)
 {
-       fosa_thread_id_t self;
-
-       /* only POSIX threads have attributes */
-       self = fosa_thread_self();
-       if (self.linux_pid == self.linux_tid)
-               return EINVAL;
-
        return pthread_attr_init(attr);
 }
 
@@ -171,13 +172,6 @@ int fosa_thread_attr_init(fosa_thread_attr_t *attr)
  **/
 int fosa_thread_attr_destroy(fosa_thread_attr_t *attr)
 {
-       fosa_thread_id_t self;
-
-       /* only POSIX threads can have attributes */
-       self = fosa_thread_self();
-       if (self.linux_pid == self.linux_tid)
-               return EINVAL;
-
        return pthread_attr_destroy(attr);
 }
 
@@ -199,13 +193,6 @@ int fosa_thread_attr_destroy(fosa_thread_attr_t *attr)
 int fosa_thread_attr_set_stacksize(fosa_thread_attr_t *attr,
                                   size_t stacksize)
 {
-       fosa_thread_id_t self;
-
-       /* only POSIX threads can set the size of the stack */
-       self = fosa_thread_self();
-       if (self.linux_pid == self.linux_tid)
-               return EINVAL;
-
        return pthread_attr_setstacksize(attr, stacksize);
 }
 
@@ -222,13 +209,6 @@ int fosa_thread_attr_set_stacksize(fosa_thread_attr_t *attr,
 int fosa_thread_attr_get_stacksize(const fosa_thread_attr_t *attr,
                                   size_t *stacksize)
 {
-       fosa_thread_id_t self;
-
-       /* only POSIX threads can set the size of the stack */
-       self = fosa_thread_self();
-       if (self.linux_pid == self.linux_tid)
-               return EINVAL;
-
        return pthread_attr_getstacksize(attr, stacksize);
 }
 
@@ -301,12 +281,6 @@ int fosa_key_create(int *key)
 {
        int i, error = 0;
        bool found = false;
-       fosa_thread_id_t self;
-
-       /* only POSIX threads can have specific data */
-       self = fosa_thread_self();
-       if (self.linux_pid == self.linux_tid)
-               return EINVAL;
 
        if ((error = pthread_mutex_lock(&key_lock)) != 0)
                return error;
@@ -341,12 +315,6 @@ int fosa_key_create(int *key)
 int fosa_key_destroy(int key)
 {
        int error;
-       fosa_thread_id_t self;
-
-       /* only POSIX threads can have specific data */
-       self = fosa_thread_self();
-       if (self.linux_pid == self.linux_tid)
-               return EINVAL;
 
        if ((error = pthread_mutex_lock(&key_lock)) != 0)
                return error;
@@ -379,11 +347,8 @@ int fosa_key_destroy(int key)
                                   fosa_thread_id_t tid,
                                   const void * value)
 {
-       fosa_thread_id_t self;
-
        /* only POSIX threads can have specific data */
-       self = fosa_thread_self();
-       if (self.linux_pid == self.linux_tid)
+       if (!__fosa_check_thread(&tid))
                return EINVAL;
 
        return pthread_setspecific(key_list[key], value);
@@ -407,11 +372,8 @@ int fosa_thread_get_specific_data(int key,
                                  fosa_thread_id_t tid,
                                  void ** value)
 {
-       fosa_thread_id_t self;
-
        /* only POSIX threads can have specific data */
-       self = fosa_thread_self();
-       if (self.linux_pid == self.linux_tid)
+       if (!__fosa_check_thread(&tid))
                return EINVAL;
 
        if ((value = pthread_getspecific(key_list[key])) != NULL)
@@ -470,14 +432,8 @@ int fosa_get_priority_min()
 int fosa_thread_attr_set_prio(fosa_thread_attr_t *attr, int prio)
 {
        int error;
-       fosa_thread_id_t self;
        struct sched_param param;
 
-       /* normal UNIX processes have no attributes */
-       self = fosa_thread_self();
-       if (self.linux_pid == self.linux_tid)
-               return EINVAL;
-       
        param.sched_priority = prio;
        if ((error = pthread_attr_setschedpolicy(attr, SCHED_RR)) == 0)
                return error;
@@ -498,14 +454,8 @@ int fosa_thread_attr_set_prio(fosa_thread_attr_t *attr, int prio)
 int fosa_thread_attr_get_prio(const fosa_thread_attr_t *attr, int *prio)
 {
        int error;
-       fosa_thread_id_t self;
        struct sched_param param;
 
-       /* normal UNIX processes have no attributes */
-       self = fosa_thread_self();
-       if (self.linux_pid == self.linux_tid)
-               return EINVAL;
-
        if ((error = pthread_attr_getschedparam(attr, &param)) == 0)
                *prio = param.sched_priority;
 
@@ -529,8 +479,7 @@ int fosa_thread_set_prio(fosa_thread_id_t tid, int prio)
 {
        struct sched_param param;
 
-       param.sched_priority=prio;
-
+       param.sched_priority = prio;
        return sched_setscheduler(0, SCHED_RR, &param);
 }
 
@@ -547,12 +496,12 @@ int fosa_thread_set_prio(fosa_thread_id_t tid, int prio)
 int fosa_thread_get_prio(fosa_thread_id_t tid, int *prio)
 {
        struct sched_param param;
-       int error;
+       int ret;
 
-       error = sched_getparam(0, &param);
+       ret = sched_getparam(0, &param);
        *prio = param.sched_priority;
 
-       return error;
+       return ret;
 }
 
 /*******************************************************************
@@ -609,7 +558,7 @@ int fosa_set_accepted_signals(fosa_signal_t set[], int size)
        }
 
        self = fosa_thread_self();
-       if (self.linux_pid == self.linux_tid)
+       if (__fosa_check_thread(&self))
                return pthread_sigmask(SIG_BLOCK, &sigset, NULL);
        else
                return sigprocmask(SIG_BLOCK, &sigset, NULL);
index fdbf95e17f5b2d2c204156ec6c80700c7d9ddad5..571ccce8ce787512ab4d7a4aecbb11f21b8e08a0 100644 (file)
@@ -64,6 +64,7 @@
 //================================================
 
 #include "fosa_time.h"
+#include "fosa_clocks_and_timers.h"
 #include "fosa_threads_and_signals.h"
 
 /**
@@ -79,11 +80,8 @@ void inline fosa_eat(const struct timespec *cpu_time)
        struct timespec current_time, time_to_go;
 
        self = fosa_thread_self();
-       if (self.linux_pid == self.linux_tid)
-               error = clock_getcpuclockid(self.linux_pid, &clock_id);
-       else
-               error = pthread_getcpuclockid(self.pthread_id, &clock_id);
-       if (error != 0)
+       error = fosa_thread_get_cputime_clock(self, &clock_id);
+       if (!error)
                return;
 
        if (clock_gettime(clock_id, &current_time) != 0)