From a8b5eb42680eb89b54bb1463b1281f6be420013e Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Tue, 3 Sep 2013 14:51:44 +0200 Subject: [PATCH] Add pthread_mutexattr_init(3) and pthread_mutexattr_destroy(3). --- libpthread/Makefile | 2 ++ libpthread/include/__/pthread.h | 10 +++++++- libpthread/include/pthread.h | 4 +-- libpthread/pthread_mutexattr_destroy.c++ | 30 ++++++++++++++++++++++ libpthread/pthread_mutexattr_init.c++ | 32 ++++++++++++++++++++++++ 5 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 libpthread/pthread_mutexattr_destroy.c++ create mode 100644 libpthread/pthread_mutexattr_init.c++ diff --git a/libpthread/Makefile b/libpthread/Makefile index 22247d94..46c79323 100644 --- a/libpthread/Makefile +++ b/libpthread/Makefile @@ -13,6 +13,8 @@ CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti OBJS=\ pthread_equal.o \ pthread_initialize.o \ +pthread_mutexattr_destroy.o \ +pthread_mutexattr_init.o \ pthread_mutex_destroy.o \ pthread_mutex_init.o \ pthread_mutex_lock.o \ diff --git a/libpthread/include/__/pthread.h b/libpthread/include/__/pthread.h index 249c03ee..8c96fa94 100644 --- a/libpthread/include/__/pthread.h +++ b/libpthread/include/__/pthread.h @@ -63,7 +63,15 @@ typedef struct } __pthread_mutex_t; #endif -typedef int __pthread_mutexattr_t; +#if defined(__is_sortix_libpthread) +typedef struct +{ +} __pthread_mutexattr_t; +#else +typedef struct +{ +} __pthread_mutexattr_t; +#endif typedef int __pthread_once_t; diff --git a/libpthread/include/pthread.h b/libpthread/include/pthread.h index d4b1367e..d2e8fac8 100644 --- a/libpthread/include/pthread.h +++ b/libpthread/include/pthread.h @@ -213,13 +213,13 @@ int pthread_mutex_lock(pthread_mutex_t*); /* TODO: pthread_mutex_timedlock */ int pthread_mutex_trylock(pthread_mutex_t*); int pthread_mutex_unlock(pthread_mutex_t*); -/* TODO: pthread_mutexattr_destroy */ +int pthread_mutexattr_destroy(pthread_mutexattr_t*); /* TODO: pthread_mutexattr_getprioceiling */ /* TODO: pthread_mutexattr_getprotocol */ /* TODO: pthread_mutexattr_getpshared */ /* TODO: pthread_mutexattr_getrobust */ /* TODO: pthread_mutexattr_gettype */ -/* TODO: pthread_mutexattr_init */ +int pthread_mutexattr_init(pthread_mutexattr_t*); /* TODO: pthread_mutexattr_setprioceiling */ /* TODO: pthread_mutexattr_setprotocol */ /* TODO: pthread_mutexattr_setpshared */ diff --git a/libpthread/pthread_mutexattr_destroy.c++ b/libpthread/pthread_mutexattr_destroy.c++ new file mode 100644 index 00000000..0df7d363 --- /dev/null +++ b/libpthread/pthread_mutexattr_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_mutexattr_destroy.c++ + Destroys a mutex attributes object. + +*******************************************************************************/ + +#include + +extern "C" int pthread_mutexattr_destroy(pthread_mutexattr_t* /*attr*/) +{ + return 0; +} diff --git a/libpthread/pthread_mutexattr_init.c++ b/libpthread/pthread_mutexattr_init.c++ new file mode 100644 index 00000000..4debce55 --- /dev/null +++ b/libpthread/pthread_mutexattr_init.c++ @@ -0,0 +1,32 @@ +/******************************************************************************* + + 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_mutexattr_init.c++ + Initialize a mutex attributes object. + +*******************************************************************************/ + +#include +#include + +extern "C" int pthread_mutexattr_init(pthread_mutexattr_t* attr) +{ + memset(attr, 0, sizeof(*attr)); + return 0; +}