2022-11-12 00:31:10 +08:00
|
|
|
/*
|
|
|
|
* @Author: jiejie
|
|
|
|
* @Github: https://github.com/jiejieTop
|
|
|
|
* @Date: 2019-12-15 18:31:33
|
|
|
|
* @LastEditTime: 2020-10-17 14:17:31
|
2022-11-12 13:55:15 +08:00
|
|
|
* @Description: the code belongs to jiejie, please keep the author information
|
|
|
|
* and source code according to the license.
|
2022-11-12 00:31:10 +08:00
|
|
|
*/
|
|
|
|
#ifndef _PLATFORM_MUTEX_H_
|
|
|
|
#define _PLATFORM_MUTEX_H_
|
2022-11-12 15:20:51 +08:00
|
|
|
#include "PikaObj.h"
|
2022-11-12 13:55:15 +08:00
|
|
|
#ifdef __linux
|
2022-11-12 15:20:51 +08:00
|
|
|
#include <pthread.h>
|
|
|
|
typedef struct platform_mutex {
|
|
|
|
pthread_mutex_t mutex;
|
|
|
|
} platform_mutex_t;
|
|
|
|
#elif PIKA_FREERTOS_ENABLE
|
|
|
|
#include "FreeRTOS.h"
|
|
|
|
#include "semphr.h"
|
|
|
|
typedef struct platform_mutex {
|
|
|
|
SemaphoreHandle_t mutex;
|
|
|
|
} platform_mutex_t;
|
2022-11-12 14:02:43 +08:00
|
|
|
#else
|
2022-11-12 15:20:51 +08:00
|
|
|
/*
|
|
|
|
You need to create the __platform_thread.h for your platform.
|
|
|
|
For example:
|
|
|
|
You can #include <rtthread.h> in the __platform_thread.h
|
|
|
|
*/
|
|
|
|
#include "__platform_thread.h"
|
2022-11-12 13:55:15 +08:00
|
|
|
#endif
|
2022-11-12 00:31:10 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
int platform_mutex_init(platform_mutex_t* m);
|
|
|
|
int platform_mutex_lock(platform_mutex_t* m);
|
|
|
|
int platform_mutex_trylock(platform_mutex_t* m);
|
|
|
|
int platform_mutex_unlock(platform_mutex_t* m);
|
|
|
|
int platform_mutex_destroy(platform_mutex_t* m);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|