mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Add pthread_mutexattr_gettype(3) and pthread_mutexattr_settype(3).
This commit is contained in:
parent
a8b5eb4268
commit
44d37c59eb
7 changed files with 83 additions and 5 deletions
|
@ -14,7 +14,9 @@ OBJS=\
|
||||||
pthread_equal.o \
|
pthread_equal.o \
|
||||||
pthread_initialize.o \
|
pthread_initialize.o \
|
||||||
pthread_mutexattr_destroy.o \
|
pthread_mutexattr_destroy.o \
|
||||||
|
pthread_mutexattr_gettype.o \
|
||||||
pthread_mutexattr_init.o \
|
pthread_mutexattr_init.o \
|
||||||
|
pthread_mutexattr_settype.o \
|
||||||
pthread_mutex_destroy.o \
|
pthread_mutex_destroy.o \
|
||||||
pthread_mutex_init.o \
|
pthread_mutex_init.o \
|
||||||
pthread_mutex_lock.o \
|
pthread_mutex_lock.o \
|
||||||
|
|
|
@ -66,10 +66,12 @@ typedef struct
|
||||||
#if defined(__is_sortix_libpthread)
|
#if defined(__is_sortix_libpthread)
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
int type;
|
||||||
} __pthread_mutexattr_t;
|
} __pthread_mutexattr_t;
|
||||||
#else
|
#else
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
int __pthread_type;
|
||||||
} __pthread_mutexattr_t;
|
} __pthread_mutexattr_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -218,13 +218,13 @@ int pthread_mutexattr_destroy(pthread_mutexattr_t*);
|
||||||
/* TODO: pthread_mutexattr_getprotocol */
|
/* TODO: pthread_mutexattr_getprotocol */
|
||||||
/* TODO: pthread_mutexattr_getpshared */
|
/* TODO: pthread_mutexattr_getpshared */
|
||||||
/* TODO: pthread_mutexattr_getrobust */
|
/* TODO: pthread_mutexattr_getrobust */
|
||||||
/* TODO: pthread_mutexattr_gettype */
|
int pthread_mutexattr_gettype(pthread_mutexattr_t* __restrict, int* __restrict);
|
||||||
int pthread_mutexattr_init(pthread_mutexattr_t*);
|
int pthread_mutexattr_init(pthread_mutexattr_t*);
|
||||||
/* TODO: pthread_mutexattr_setprioceiling */
|
/* TODO: pthread_mutexattr_setprioceiling */
|
||||||
/* TODO: pthread_mutexattr_setprotocol */
|
/* TODO: pthread_mutexattr_setprotocol */
|
||||||
/* TODO: pthread_mutexattr_setpshared */
|
/* TODO: pthread_mutexattr_setpshared */
|
||||||
/* TODO: pthread_mutexattr_setrobust */
|
/* TODO: pthread_mutexattr_setrobust */
|
||||||
/* TODO: pthread_mutexattr_settype */
|
int pthread_mutexattr_settype(pthread_mutexattr_t*, int);
|
||||||
/* TODO: pthread_once */
|
/* TODO: pthread_once */
|
||||||
/* TODO: pthread_rwlock_destroy */
|
/* TODO: pthread_rwlock_destroy */
|
||||||
/* TODO: pthread_rwlock_init */
|
/* TODO: pthread_rwlock_init */
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of Sortix libpthread.
|
||||||
|
|
||||||
|
@ -26,8 +26,19 @@
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
int pthread_mutex_init(pthread_mutex_t* restrict mutex,
|
int pthread_mutex_init(pthread_mutex_t* restrict mutex,
|
||||||
const pthread_mutexattr_t* restrict /*attr*/)
|
const pthread_mutexattr_t* restrict attr)
|
||||||
{
|
{
|
||||||
*mutex = PTHREAD_MUTEX_INITIALIZER;
|
pthread_mutexattr_t default_attr;
|
||||||
|
if ( !attr )
|
||||||
|
{
|
||||||
|
pthread_mutexattr_init(&default_attr);
|
||||||
|
attr = &default_attr;
|
||||||
|
}
|
||||||
|
|
||||||
|
mutex->lock = 0;
|
||||||
|
mutex->type = attr->type;
|
||||||
|
mutex->owner = 0;
|
||||||
|
mutex->recursion = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
32
libpthread/pthread_mutexattr_gettype.c++
Normal file
32
libpthread/pthread_mutexattr_gettype.c++
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
|
||||||
|
Copyright(C) Jonas 'Sortie' Termansen 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
pthread_mutexattr_gettype.c++
|
||||||
|
Gets the requested mutex type in a mutex attribute object.
|
||||||
|
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
int pthread_mutexattr_gettype(pthread_mutexattr_t* restrict attr,
|
||||||
|
int* restrict type)
|
||||||
|
{
|
||||||
|
return *type = attr->type, 0;
|
||||||
|
}
|
|
@ -28,5 +28,6 @@
|
||||||
extern "C" int pthread_mutexattr_init(pthread_mutexattr_t* attr)
|
extern "C" int pthread_mutexattr_init(pthread_mutexattr_t* attr)
|
||||||
{
|
{
|
||||||
memset(attr, 0, sizeof(*attr));
|
memset(attr, 0, sizeof(*attr));
|
||||||
|
attr->type = PTHREAD_MUTEX_DEFAULT;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
30
libpthread/pthread_mutexattr_settype.c++
Normal file
30
libpthread/pthread_mutexattr_settype.c++
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
|
||||||
|
Copyright(C) Jonas 'Sortie' Termansen 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
pthread_mutexattr_settype.c++
|
||||||
|
Sets the requested mutex type in a mutex attribute object.
|
||||||
|
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
extern "C" int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type)
|
||||||
|
{
|
||||||
|
return attr->type = type, 0;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue