Add a few more pthread compilant definitions
authorKevin Klues <klueska@cs.berkeley.edu>
Tue, 24 Mar 2015 16:52:00 +0000 (09:52 -0700)
committerKevin Klues <klueska@cs.berkeley.edu>
Tue, 24 Mar 2015 16:52:00 +0000 (09:52 -0700)
user/pthread/pthread.c
user/pthread/pthread.h

index 340417c..af7a5fc 100644 (file)
@@ -545,6 +545,25 @@ int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize)
        return 0;
 }
 
+int pthread_attr_getstack(const pthread_attr_t *__restrict __attr,
+                                                  void **__stackaddr, size_t *__stacksize)
+{
+       *__stackaddr = __attr->stackaddr;
+       *__stacksize = __attr->stacksize;
+       return 0;
+}
+
+int pthread_getattr_np(pthread_t __th, pthread_attr_t *__attr)
+{
+       __attr->stackaddr = __th->stacktop - __th->stacksize;
+       __attr->stacksize = __th->stacksize;
+       if (__th->detached)
+               __attr->detachstate = PTHREAD_CREATE_DETACHED;
+       else
+               __attr->detachstate = PTHREAD_CREATE_JOINABLE;
+       return 0;
+}
+
 /* Do whatever init you want.  At some point call uthread_lib_init() and pass it
  * a uthread representing thread0 (int main()) */
 void pthread_lib_init(void)
@@ -1263,3 +1282,26 @@ int pthread_setspecific(pthread_key_t key, const void *value)
        return 0;
 }
 
+int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
+                                       const struct timespec *__restrict
+                                       __abstime)
+{
+       fprintf(stderr, "Unsupported %s!", __FUNCTION__);
+       abort();
+       return -1;
+}
+int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
+                                  pthread_mutex_t *__restrict __mutex,
+                                  const struct timespec *__restrict __abstime)
+{
+       fprintf(stderr, "Unsupported %s!", __FUNCTION__);
+       abort();
+       return -1;
+}
+
+int pthread_cancel (pthread_t __th)
+{
+       fprintf(stderr, "Unsupported %s!", __FUNCTION__);
+       abort();
+       return -1;
+}
index 2613cac..0f14fb2 100644 (file)
@@ -124,6 +124,7 @@ typedef struct
 
 typedef struct 
 {
+       void *stackaddr;
        size_t stacksize;
        int detachstate;
 } pthread_attr_t;
@@ -208,6 +209,25 @@ int pthread_key_delete(pthread_key_t key);
 void *pthread_getspecific(pthread_key_t key);
 int pthread_setspecific(pthread_key_t key, const void *value);
 
+/* Common stuff. */
+int pthread_equal(pthread_t __thread1, pthread_t __thread2);
+int pthread_getattr_np(pthread_t __th, pthread_attr_t *__attr);
+int pthread_attr_getstack(const pthread_attr_t *__attr,
+                           void **__stackaddr, size_t *__stacksize);
+
+/* Unsupported Stuff */
+typedef void *upthread_once_t;
+extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
+                    const struct timespec *__restrict
+                    __abstime) __THROWNL __nonnull ((1, 2));
+extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
+                   pthread_mutex_t *__restrict __mutex,
+                   const struct timespec *__restrict __abstime)
+     __nonnull ((1, 2, 3));
+extern int pthread_once (pthread_once_t *__once_control,
+             void (*__init_routine) (void)) __nonnull ((1, 2));
+extern int pthread_cancel (pthread_t __th);
+
 #ifdef __cplusplus
   }
 #endif