Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions include/sys/futex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Phoenix-RTOS
*
* libphoenix
*
* sys/futex.h
*
* Copyright 2025 Phoenix Systems
* Author: kamil kowalczyk
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#ifndef _LIBPHOENIX_SYS_FUTEX_H_
#define _LIBPHOENIX_SYS_FUTEX_H_

#include <time.h>
#include <stdint.h>

#define FUTEX_WAKEUP_ALL ((uint32_t) - 1)


extern int phFutexWait(_Atomic(uint32_t) *address, uint32_t value, time_t timeout, int clockType);


extern int phFutexWakeup(_Atomic(uint32_t) *address, uint32_t n_threads);


#endif
1 change: 1 addition & 0 deletions include/sys/interrupt.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


#include <sys/types.h>
#include <stdint.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed?



#ifdef __cplusplus
Expand Down
61 changes: 26 additions & 35 deletions include/sys/threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,30 @@ extern "C" {
#endif


extern void _uresource_init(void);


extern int mutexUnlock(handle_t m);


extern int mutexTry(handle_t m);


#define phMutexLock(m) mutexLock((m))


extern int resourceDestroy(handle_t r);


extern int condBroadcast(handle_t h);


extern int condSignal(handle_t h);


#define phCondWait(c, m, t) condWait((c), (m), (t))


typedef struct {
handle_t mutex;
handle_t cond;
Expand Down Expand Up @@ -89,19 +113,10 @@ extern int threadsinfo(int n, threadinfo_t *info);
extern int priority(int priority);


extern int phMutexCreate(handle_t *h, const struct lockAttr *attr);


extern int mutexCreate(handle_t *h);


static inline int mutexCreateWithAttr(handle_t *h, const struct lockAttr *attr)
{
return phMutexCreate(h, attr);
}


extern int phMutexLock(handle_t h);
extern int mutexCreateWithAttr(handle_t *h, const struct lockAttr *attr);


extern int mutexLock(handle_t h);
Expand All @@ -110,12 +125,6 @@ extern int mutexLock(handle_t h);
extern int mutexLock2(handle_t h1, handle_t h2);


extern int mutexTry(handle_t h);


extern int mutexUnlock(handle_t h);


extern int semaphoreCreate(semaphore_t *s, unsigned int v);


Expand All @@ -128,33 +137,15 @@ extern int semaphoreUp(semaphore_t *s);
extern int semaphoreDone(semaphore_t *s);


extern int phCondCreate(handle_t *h, const struct condAttr *attr);


extern int condCreate(handle_t *h);


static inline int condCreateWithAttr(handle_t *h, const struct condAttr *attr)
{
return phCondCreate(h, attr);
}
extern int condCreateWithAttr(handle_t *h, const struct condAttr *attr);


extern int condWait(handle_t h, handle_t m, time_t timeout);


extern int phCondWait(handle_t h, handle_t m, time_t timeout);


extern int condSignal(handle_t h);


extern int condBroadcast(handle_t h);


extern int resourceDestroy(handle_t h);


extern int signalHandle(void (*handler)(void), unsigned mask, unsigned mmask);


Expand Down
2 changes: 2 additions & 0 deletions misc/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ extern void _errno_init(void);
extern void _atexit_init(void);
extern void _init_array(void);
extern void _pthread_init(void);
extern void _uresource_init(void);


void _libc_init(void)
{
_uresource_init();
_atexit_init();
_errno_init();
_malloc_init();
Expand Down
Loading
Loading