//================================================
#include <fosa.h>
+#include <asm/bitops.h>
/*************************
* Thread identification
return pthread_create(tid,attr,code, arg);
}
+int fosa_key_create(int *key) {
+ int idx=ffs(pthread_self()->tsd_bitmap);
+
+ if (idx<0)
+ return -FOSA_EINVAL;
+
+ pthread_self()->tsd_bitmap&=~(1<<idx);
+
+ *key=idx;
+ return 0;
+}
+
+int fosa_key_destroy(int key) {
+ pthread_self()->tsd_bitmap|=(1<<key);
+ return 0;
+}
+
/**************************************************
* Thread-specific data
return 0;
}
+int frsh_thread_attr_init(frsh_thread_attr_t *attr) {
+ return pthread_attr_init(attr);
+}
+int frsh_thread_attr_destroy(frsh_thread_attr_t *attr) {
+ return pthread_attr_destroy(attr);
+}
+int frsh_thread_attr_set_stacksize(frsh_thread_attr_t *attr,
+ size_t stacksize) {
+ return pthread_attr_setstacksize(attr, stacksize);
+}
+
+int frsh_thread_attr_get_stacksize (const frsh_thread_attr_t *attr, size_t *stacksize) {
+ return pthread_attr_getstacksize(attr, stacksize);
+}
// and that they return appropriate values
/////////////////////////////////////////////////////////////
-int init_module(void) {
+void *main_app(void *args) {
//////////////////////////////////
// Test clock functions
//////////////////////////////////
printf("--------------------------------------------------\n");
printf("test get_time\n");
-
+
struct timespec current_time;
int err;
void * obtained;
printf("timeoutcode=%d signal received=%d value=%d\n",
err,received,value_received.sival_int);
-
+ /*
//////////////////////////////////
// Test timers and signals
//////////////////////////////////
err=fosa_timer_create
(FOSA_CLOCK_REALTIME, timer_sig, timer_info,&timerid);
printf("timer created, err=%d\n",err);
-
+
err=fosa_timer_arm(timerid,false,&timerval);
printf("timer armed for 1.3 secs, err=%d\n",err);
err=fosa_thread_attr_get_appscheduled(&th1_attr,&is_appsched);
printf("thread attr get appsched=%d, err=%d\n",is_appsched,err);
-
+*/
return 0;
}
+
+static pthread_t main_thread;
+
+int init_module (void) {
+ return pthread_create(&main_thread, 0, main_app, 0);
+}
+
+void cleanup_module(void) {
+ pthread_delete_np(main_thread);
+}