From 466091bc4fbce4f4036e51b412002597f6af638a Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Tue, 3 Sep 2013 21:56:28 +0200 Subject: [PATCH] Add pthread_rwlock_init(3) and pthread_rwlock_destroy(3). --- libpthread/Makefile | 2 ++ libpthread/include/pthread.h | 5 ++-- libpthread/pthread_rwlock_destroy.c++ | 30 ++++++++++++++++++++++++ libpthread/pthread_rwlock_init.c++ | 33 +++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 libpthread/pthread_rwlock_destroy.c++ create mode 100644 libpthread/pthread_rwlock_init.c++ diff --git a/libpthread/Makefile b/libpthread/Makefile index 9bd17934..d44926f2 100644 --- a/libpthread/Makefile +++ b/libpthread/Makefile @@ -32,6 +32,8 @@ pthread_mutex_init.o \ pthread_mutex_lock.o \ pthread_mutex_trylock.o \ pthread_mutex_unlock.o \ +pthread_rwlock_destroy.o \ +pthread_rwlock_init.o \ pthread_rwlock_rdlock.o \ pthread_rwlock_tryrdlock.o \ pthread_rwlock_trywrlock.o \ diff --git a/libpthread/include/pthread.h b/libpthread/include/pthread.h index d380430b..bd7f5d61 100644 --- a/libpthread/include/pthread.h +++ b/libpthread/include/pthread.h @@ -240,8 +240,9 @@ int pthread_mutexattr_init(pthread_mutexattr_t*); /* TODO: pthread_mutexattr_setrobust */ int pthread_mutexattr_settype(pthread_mutexattr_t*, int); /* TODO: pthread_once */ -/* TODO: pthread_rwlock_destroy */ -/* TODO: pthread_rwlock_init */ +int pthread_rwlock_destroy(pthread_rwlock_t*); +int pthread_rwlock_init(pthread_rwlock_t* __restrict, + const pthread_rwlockattr_t* __restrict); int pthread_rwlock_rdlock(pthread_rwlock_t*); /* TODO: pthread_rwlock_timedrdlock */ /* TODO: pthread_rwlock_timedwrlock */ diff --git a/libpthread/pthread_rwlock_destroy.c++ b/libpthread/pthread_rwlock_destroy.c++ new file mode 100644 index 00000000..53027548 --- /dev/null +++ b/libpthread/pthread_rwlock_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_rwlock_destroy.c++ + Destroys a read-write lock. + +*******************************************************************************/ + +#include + +extern "C" int pthread_rwlock_destroy(pthread_rwlock_t* /*rwlock*/) +{ + return 0; +} diff --git a/libpthread/pthread_rwlock_init.c++ b/libpthread/pthread_rwlock_init.c++ new file mode 100644 index 00000000..8be27cbc --- /dev/null +++ b/libpthread/pthread_rwlock_init.c++ @@ -0,0 +1,33 @@ +/******************************************************************************* + + 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_rwlock_init.c++ + Initializes a read-write lock. + +*******************************************************************************/ + +#include + +extern "C" +int pthread_rwlock_init(pthread_rwlock_t* restrict rwlock, + const pthread_rwlockattr_t* restrict /*attr*/) +{ + *rwlock = PTHREAD_RWLOCK_INITIALIZER; + return 0; +}