Skip to content

Commit 8e1ac56

Browse files
ycsincarlescufi
authored andcommitted
lib: posix: mutex: stubs remaining of _POSIX_THREAD_PRIO_PROTECT
Create stub functions for the remaining of `_POSIX_THREAD_PRIO_PROTECT` option group. Signed-off-by: Yong Cong Sin <[email protected]>
1 parent 0c4870a commit 8e1ac56

File tree

7 files changed

+68
-14
lines changed

7 files changed

+68
-14
lines changed

doc/services/portability/posix/aep/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ The *Minimal Realtime System Profile* (PSE51) includes all of the
6969
:ref:`_POSIX_THREAD_ATTR_STACKSIZE<posix_option_thread_attr_stacksize>`, 200809L, :kconfig:option:`CONFIG_POSIX_THREAD_ATTR_STACKSIZE`
7070
:ref:`_POSIX_THREAD_CPUTIME <posix_option_thread_cputime>`, 200809L, :kconfig:option:`CONFIG_POSIX_CPUTIME`
7171
:ref:`_POSIX_THREAD_PRIO_INHERIT <posix_option_thread_prio_inherit>`, 200809L, :kconfig:option:`CONFIG_POSIX_THREAD_PRIO_INHERIT`
72-
:ref:`_POSIX_THREAD_PRIO_PROTECT <posix_option_thread_prio_protect>`, -1, :kconfig:option:`CONFIG_POSIX_THREAD_PRIO_PROTECT`
72+
:ref:`_POSIX_THREAD_PRIO_PROTECT <posix_option_thread_prio_protect>`, 200809L, :kconfig:option:`CONFIG_POSIX_THREAD_PRIO_PROTECT`
7373
:ref:`_POSIX_THREAD_PRIORITY_SCHEDULING <posix_option_thread_priority_scheduling>`, 200809L, :kconfig:option:`CONFIG_POSIX_THREAD_PRIORITY_SCHEDULING`
7474
_POSIX_THREAD_SPORADIC_SERVER, -1,
7575

doc/services/portability/posix/conformance/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ POSIX System Interfaces
8383
:ref:`_POSIX_THREAD_ATTR_STACKSIZE<posix_option_thread_attr_stacksize>`, 200809L, :kconfig:option:`CONFIG_POSIX_THREAD_ATTR_STACKSIZE`
8484
:ref:`_POSIX_THREAD_CPUTIME <posix_option_thread_cputime>`, 200809L, :kconfig:option:`CONFIG_POSIX_CPUTIME`
8585
:ref:`_POSIX_THREAD_PRIO_INHERIT <posix_option_thread_prio_inherit>`, 200809L, :kconfig:option:`CONFIG_POSIX_THREAD_PRIO_INHERIT`
86-
:ref:`_POSIX_THREAD_PRIO_PROTECT <posix_option_thread_prio_protect>`, -1, :kconfig:option:`CONFIG_POSIX_THREAD_PRIO_PROTECT`
86+
:ref:`_POSIX_THREAD_PRIO_PROTECT <posix_option_thread_prio_protect>`, 200809L, :kconfig:option:`CONFIG_POSIX_THREAD_PRIO_PROTECT`
8787
:ref:`_POSIX_THREAD_PRIORITY_SCHEDULING <posix_option_thread_priority_scheduling>`, 200809L, :kconfig:option:`CONFIG_POSIX_THREAD_PRIORITY_SCHEDULING`
8888
_POSIX_THREAD_PROCESS_SHARED, -1,
8989
_POSIX_THREAD_SPORADIC_SERVER, -1,

doc/services/portability/posix/option_groups/index.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -942,11 +942,11 @@ Enable this option with :kconfig:option:`CONFIG_POSIX_THREAD_PRIO_PROTECT`.
942942
:header: API, Supported
943943
:widths: 50,10
944944

945-
pthread_mutex_getprioceiling(),
946-
pthread_mutex_setprioceiling(),
947-
pthread_mutexattr_getprioceiling(),
945+
pthread_mutex_getprioceiling(),yes
946+
pthread_mutex_setprioceiling(),yes
947+
pthread_mutexattr_getprioceiling(),yes
948948
pthread_mutexattr_getprotocol(),yes
949-
pthread_mutexattr_setprioceiling(),
949+
pthread_mutexattr_setprioceiling(),yes
950950
pthread_mutexattr_setprotocol(),yes
951951

952952
.. _posix_option_thread_priority_scheduling:

include/zephyr/posix/pthread.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,16 +350,22 @@ int pthread_barrierattr_getpshared(const pthread_barrierattr_t *ZRESTRICT attr,
350350
int pthread_condattr_getpshared(const pthread_condattr_t * int *);
351351
int pthread_condattr_setpshared(pthread_condattr_t *, int);
352352
int pthread_mutex_consistent(pthread_mutex_t *);
353-
int pthread_mutex_getprioceiling(const pthread_mutex_t * int *);
354-
int pthread_mutex_setprioceiling(pthread_mutex_t *, int int *);
355-
int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *, int *);
356353
int pthread_mutexattr_getpshared(const pthread_mutexattr_t * int *);
357354
int pthread_mutexattr_getrobust(const pthread_mutexattr_t * int *);
358-
int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
359355
int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
360356
int pthread_mutexattr_setrobust(pthread_mutexattr_t *, int);
361357
*/
362358

359+
#ifdef CONFIG_POSIX_THREAD_PRIO_PROTECT
360+
int pthread_mutex_getprioceiling(const pthread_mutex_t *ZRESTRICT mutex,
361+
int *ZRESTRICT prioceiling);
362+
int pthread_mutex_setprioceiling(pthread_mutex_t *ZRESTRICT mutex, int prioceiling,
363+
int *ZRESTRICT old_ceiling);
364+
int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *ZRESTRICT attr,
365+
int *ZRESTRICT prioceiling);
366+
int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, int prioceiling);
367+
#endif /* CONFIG_POSIX_THREAD_PRIO_PROTECT */
368+
363369
/* Base Pthread related APIs */
364370

365371
/**

lib/posix/options/mutex.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,42 @@ int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
407407
}
408408
}
409409

410+
#ifdef CONFIG_POSIX_THREAD_PRIO_PROTECT
411+
int pthread_mutex_getprioceiling(const pthread_mutex_t *mutex, int *prioceiling)
412+
{
413+
ARG_UNUSED(mutex);
414+
ARG_UNUSED(prioceiling);
415+
416+
return ENOSYS;
417+
}
418+
419+
int pthread_mutex_setprioceiling(pthread_mutex_t *mutex, int prioceiling, int *old_ceiling)
420+
{
421+
ARG_UNUSED(mutex);
422+
ARG_UNUSED(prioceiling);
423+
ARG_UNUSED(old_ceiling);
424+
425+
return ENOSYS;
426+
}
427+
428+
int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *attr, int *prioceiling)
429+
{
430+
ARG_UNUSED(attr);
431+
ARG_UNUSED(prioceiling);
432+
433+
return ENOSYS;
434+
}
435+
436+
int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, int prioceiling)
437+
{
438+
ARG_UNUSED(attr);
439+
ARG_UNUSED(prioceiling);
440+
441+
return ENOSYS;
442+
}
443+
444+
#endif /* CONFIG_POSIX_THREAD_PRIO_PROTECT */
445+
410446
static int pthread_mutex_pool_init(void)
411447
{
412448
int err;

tests/posix/common/src/mutex.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ static void test_mutex_common(int type, void *(*entry)(void *arg))
8585
zassert_ok(pthread_mutex_destroy(&mutex), "Destroying mutex is failed");
8686
}
8787

88+
ZTEST(mutex, test_mutex_prioceiling_stubs)
89+
{
90+
#ifdef CONFIG_POSIX_THREAD_PRIO_PROTECT
91+
zassert_equal(pthread_mutex_getprioceiling(NULL, NULL), ENOSYS);
92+
zassert_equal(pthread_mutex_setprioceiling(NULL, 0, NULL), ENOSYS);
93+
zassert_equal(pthread_mutexattr_getprioceiling(NULL, NULL), ENOSYS);
94+
zassert_equal(pthread_mutexattr_setprioceiling(NULL, 0), ENOSYS);
95+
#else
96+
ztest_test_skip();
97+
#endif /* CONFIG_POSIX_THREAD_PRIO_PROTECT */
98+
}
99+
88100
/**
89101
* @brief Test to demonstrate PTHREAD_MUTEX_NORMAL
90102
*

tests/posix/headers/src/pthread_h.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,21 @@ ZTEST(posix_headers, test_pthread_h)
113113
zassert_not_null(pthread_key_delete);
114114
/* zassert_not_null(pthread_mutex_consistent); */ /* not implemented */
115115
zassert_not_null(pthread_mutex_destroy);
116-
/* zassert_not_null(pthread_mutex_getprioceiling); */ /* not implemented */
116+
zassert_not_null(pthread_mutex_getprioceiling);
117117
zassert_not_null(pthread_mutex_init);
118118
zassert_not_null(pthread_mutex_lock);
119-
/* zassert_not_null(pthread_mutex_setprioceiling); */ /* not implemented */
119+
zassert_not_null(pthread_mutex_setprioceiling);
120120
zassert_not_null(pthread_mutex_timedlock);
121121
zassert_not_null(pthread_mutex_trylock);
122122
zassert_not_null(pthread_mutex_unlock);
123123
zassert_not_null(pthread_mutexattr_destroy);
124-
/* zassert_not_null(pthread_mutexattr_getprioceiling); */ /* not implemented */
124+
zassert_not_null(pthread_mutexattr_getprioceiling);
125125
zassert_not_null(pthread_mutexattr_getprotocol);
126126
/* zassert_not_null(pthread_mutexattr_getpshared); */ /* not implemented */
127127
/* zassert_not_null(pthread_mutexattr_getrobust); */ /* not implemented */
128128
zassert_not_null(pthread_mutexattr_gettype);
129129
zassert_not_null(pthread_mutexattr_init);
130-
/* zassert_not_null(pthread_mutexattr_setprioceiling); */ /* not implemented */
130+
zassert_not_null(pthread_mutexattr_setprioceiling);
131131
zassert_not_null(pthread_mutexattr_setprotocol);
132132
/* zassert_not_null(pthread_mutexattr_setpshared); */ /* not implemented */
133133
/* zassert_not_null(pthread_mutexattr_setrobust); */ /* not implemented */

0 commit comments

Comments
 (0)