diff --git a/libpthread/Makefile b/libpthread/Makefile index 9e19df01..913ef94d 100644 --- a/libpthread/Makefile +++ b/libpthread/Makefile @@ -11,6 +11,8 @@ CPPFLAGS:=$(CPPFLAGS) -D__is_sortix_libpthread -I include CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti OBJS=\ +pthread_condattr_destroy.o \ +pthread_condattr_init.o \ pthread_cond_broadcast.o \ pthread_cond_destroy.o \ pthread_cond_init.o \ diff --git a/libpthread/include/__/pthread.h b/libpthread/include/__/pthread.h index b277c744..595f0e7b 100644 --- a/libpthread/include/__/pthread.h +++ b/libpthread/include/__/pthread.h @@ -53,7 +53,15 @@ typedef struct } __pthread_cond_t; #endif -typedef int __pthread_condattr_t; +#if defined(__is_sortix_libpthread) +typedef struct +{ +} __pthread_condattr_t; +#else +typedef struct +{ +} __pthread_condattr_t; +#endif typedef int __pthread_key_t; diff --git a/libpthread/include/pthread.h b/libpthread/include/pthread.h index 61cdfc13..c86b5ac5 100644 --- a/libpthread/include/pthread.h +++ b/libpthread/include/pthread.h @@ -197,10 +197,10 @@ int pthread_cond_timedwait(pthread_cond_t* __restrict, pthread_mutex_t* __restrict, const struct timespec* __restrict); int pthread_cond_wait(pthread_cond_t* __restrict, pthread_mutex_t* __restrict); -/* TODO: pthread_condattr_destroy */ +int pthread_condattr_destroy(pthread_condattr_t*); /* TODO: pthread_condattr_getclock */ /* TODO: pthread_condattr_getpshared */ -/* TODO: pthread_condattr_init */ +int pthread_condattr_init(pthread_condattr_t*); /* TODO: pthread_condattr_setclock */ /* TODO: pthread_condattr_setpshared */ /* TODO: pthread_create */ diff --git a/libpthread/pthread_cond_init.c++ b/libpthread/pthread_cond_init.c++ index 0502310d..1d137987 100644 --- a/libpthread/pthread_cond_init.c++ +++ b/libpthread/pthread_cond_init.c++ @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2013. + Copyright(C) Jonas 'Sortie' Termansen 2013, 2014. This file is part of Sortix libpthread. @@ -26,8 +26,17 @@ extern "C" int pthread_cond_init(pthread_cond_t* restrict cond, - const pthread_condattr_t* restrict /*attr*/) + const pthread_condattr_t* restrict attr) { - *cond = PTHREAD_COND_INITIALIZER; + pthread_condattr_t default_attr; + if ( !attr ) + { + pthread_condattr_init(&default_attr); + attr = &default_attr; + } + + cond->first = NULL; + cond->last = NULL; + return 0; } diff --git a/libpthread/pthread_condattr_destroy.c++ b/libpthread/pthread_condattr_destroy.c++ new file mode 100644 index 00000000..9d349859 --- /dev/null +++ b/libpthread/pthread_condattr_destroy.c++ @@ -0,0 +1,30 @@ +/******************************************************************************* + + Copyright(C) Jonas 'Sortie' Termansen 2013. + + This file is part of Sortix libpthread. + + Sortix libpthread is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + Sortix libpthread 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 Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Sortix libpthread. If not, see . + + pthread_condattr_destroy.c++ + Destroys a condition variable attributes object. + +*******************************************************************************/ + +#include + +extern "C" int pthread_condattr_destroy(pthread_condattr_t* /*attr*/) +{ + return 0; +} diff --git a/libpthread/pthread_condattr_init.c++ b/libpthread/pthread_condattr_init.c++ new file mode 100644 index 00000000..2ac61275 --- /dev/null +++ b/libpthread/pthread_condattr_init.c++ @@ -0,0 +1,32 @@ +/******************************************************************************* + + Copyright(C) Jonas 'Sortie' Termansen 2013, 2014. + + This file is part of Sortix libpthread. + + Sortix libpthread is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + Sortix libpthread 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 Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Sortix libpthread. If not, see . + + pthread_condattr_init.c++ + Initialize a condition variable attributes object. + +*******************************************************************************/ + +#include +#include + +extern "C" int pthread_condattr_init(pthread_condattr_t* attr) +{ + memset(attr, 0, sizeof(*attr)); + return 0; +}