forked from xuos/xiuos
Merge branch 'prepare_for_master' of https://git.trustie.net/xuos/xiuos into xidatong
This commit is contained in:
@@ -32,6 +32,7 @@ extern int Ps5308Pm1_0Init(void);
|
||||
extern int Ps5308Pm2_5Init(void);
|
||||
extern int Ps5308Pm10Init(void);
|
||||
extern int Zg09Co2Init(void);
|
||||
extern int G8sCo2Init(void);
|
||||
extern int As830Ch4Init(void);
|
||||
extern int Tb600bIaq10IaqInit(void);
|
||||
extern int Tb600bTvoc10TvocInit(void);
|
||||
@@ -106,6 +107,10 @@ static struct InitDesc sensor_desc[] =
|
||||
{ "zg09_co2", Zg09Co2Init },
|
||||
#endif
|
||||
|
||||
#ifdef SENSOR_G8S
|
||||
{ "g8s_co2", G8sCo2Init },
|
||||
#endif
|
||||
|
||||
#ifdef SENSOR_QS_FX
|
||||
{ "qs_fx_wind_direction", QsFxWindDirectionInit },
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@ int main(void)
|
||||
#ifdef APPLICATION_OTA
|
||||
ApplicationOtaTaskInit();
|
||||
#endif
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
// int cppmain(void);
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@ ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_ZG09), y)
|
||||
CSRCS += co2_zg09.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_G8S), y)
|
||||
CSRCS += co2_g8s.c
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308), y)
|
||||
CSRCS += pm1_0_ps5308.c
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.12.23
|
||||
*/
|
||||
|
||||
#include <user_api.h>
|
||||
//
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
||||
Submodule APP_Framework/Applications/webnet/WebNet_XiUOS updated: d7ac9f2711...956eafa24b
@@ -39,11 +39,11 @@ if ADD_NUTTX_FETURES
|
||||
|
||||
config ADAPTER_E220_M0_PATH
|
||||
string "E220 M0 pin device"
|
||||
default "/dev/gpout0"
|
||||
default "/dev/gpio0"
|
||||
|
||||
config ADAPTER_E220_M1_PATH
|
||||
string "E220 M1 pin device"
|
||||
default "/dev/gpout1"
|
||||
default "/dev/gpio1"
|
||||
|
||||
config ADAPTER_E220_DRIVER_EXTUART
|
||||
bool "Using extra uart to support lora"
|
||||
|
||||
@@ -47,29 +47,25 @@ if ADD_XIZI_FETURES
|
||||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
config ADAPTER_E18_MODEPIN
|
||||
int "E18 MODE pin number"
|
||||
default "61"
|
||||
config ADAPTER_E18_MODE_PATH
|
||||
string "E18 MODE pin device"
|
||||
default "/dev/gpio2"
|
||||
|
||||
config ADAPTER_E18_PIN_DRIVER
|
||||
string "E18 device pin driver path"
|
||||
default "/dev/pin_dev"
|
||||
config ADAPTER_E18_DRIVER_EXTUART
|
||||
bool "Using extra uart to support zigbee"
|
||||
default y
|
||||
|
||||
config ADAPTER_E18_DRIVER
|
||||
string "E18 device uart driver path"
|
||||
default "/dev/ttyS1"
|
||||
depends on !ADAPTER_E18_DRIVER_EXTUART
|
||||
---help---
|
||||
If USART1 is selected, then fill in /dev/ttyS1 here.
|
||||
|
||||
config ADAPTER_E18_DRIVER
|
||||
string "E18 device uart driver path"
|
||||
default "/dev/ttyS1"
|
||||
depends on !ADAPTER_E18_DRIVER_EXTUART
|
||||
---help---
|
||||
If USART1 is selected, then fill in /dev/ttyS1 here.
|
||||
|
||||
if ADAPTER_E18_DRIVER_EXTUART
|
||||
config ADAPTER_E18_DRIVER
|
||||
string "E18 device extra uart driver path"
|
||||
default "/dev/extuart_dev1"
|
||||
|
||||
config ADAPTER_E18_DRIVER_EXT_PORT
|
||||
int "if E18 device using extuart, choose port"
|
||||
default "1"
|
||||
if ADAPTER_E18_DRIVER_EXTUART
|
||||
config ADAPTER_E18_DRIVER
|
||||
string "E18 device extra uart driver path"
|
||||
default "/dev/extuart_dev1"
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
@@ -42,6 +42,9 @@ char *cmd_set_ch = "AT+CH=11"; /*set channel as 11*/
|
||||
|
||||
static int E18HardwareModeGet()
|
||||
{
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
return E18_AS_HEX_MODE;
|
||||
#else
|
||||
int ret = 0;
|
||||
int pin_fd;
|
||||
|
||||
@@ -62,7 +65,8 @@ static int E18HardwareModeGet()
|
||||
} else {
|
||||
printf(" E18 as HEX mode\n");
|
||||
return E18_AS_HEX_MODE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
@@ -175,9 +179,15 @@ static int E18NetworkModeConfig(struct Adapter *adapter)
|
||||
}
|
||||
|
||||
out:
|
||||
if(E18_AS_AT_MODE == mode){
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
if(E18_AS_HEX_MODE == mode)
|
||||
#else
|
||||
if(E18_AS_AT_MODE == mode)
|
||||
#endif
|
||||
{
|
||||
AtCmdConfigAndCheck(adapter->agent, cmd_exit, "+OK");
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -242,7 +252,12 @@ static int E18NetRoleConfig(struct Adapter *adapter)
|
||||
}
|
||||
|
||||
out:
|
||||
if(E18_AS_AT_MODE == mode) {
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
if(E18_AS_HEX_MODE == mode)
|
||||
#else
|
||||
if(E18_AS_AT_MODE == mode)
|
||||
#endif
|
||||
{
|
||||
AtCmdConfigAndCheck(adapter->agent, cmd_exit, "+OK");
|
||||
}
|
||||
|
||||
@@ -384,7 +399,12 @@ static int E18Join(struct Adapter *adapter, unsigned char *priv_net_group)
|
||||
|
||||
// }
|
||||
if(!ret){
|
||||
if(E18_AS_AT_MODE == mode) {
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
if(E18_AS_HEX_MODE == mode)
|
||||
#else
|
||||
if(E18_AS_AT_MODE == mode)
|
||||
#endif
|
||||
{
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd_exit, "+OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,cmd_exit);
|
||||
|
||||
@@ -5,6 +5,6 @@ cwd = GetCurrentDir()
|
||||
|
||||
src = Glob('*.c')
|
||||
|
||||
group = DefineGroup('yolov2_json', src, depend = ['LIB_USING_CJSON'], CPPPATH = [cwd])
|
||||
group = DefineGroup('yolov2_json', src, depend = ['LIB_USING_CJSON'] + ['USING_YOLOV2'], CPPPATH = [cwd])
|
||||
|
||||
Return('group')
|
||||
|
||||
@@ -64,6 +64,7 @@ config SENSOR_ZG09
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
config SENSOR_G8S
|
||||
bool "Using g8-s"
|
||||
default n
|
||||
@@ -99,7 +100,11 @@ config SENSOR_G8S
|
||||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
|
||||
config SENSOR_DEVICE_G8S_DEV
|
||||
string "CO2 device name"
|
||||
default "/dev/ttyS3"
|
||||
---help---
|
||||
If USART1 is selected, then fill in /dev/ttyS1 here.
|
||||
endif
|
||||
|
||||
if ADD_RTTHREAD_FETURES
|
||||
|
||||
6
APP_Framework/Framework/sensor/co2/g8s/Make.defs
Normal file
6
APP_Framework/Framework/sensor/co2/g8s/Make.defs
Normal file
@@ -0,0 +1,6 @@
|
||||
############################################################################
|
||||
# APP_Framework/Framework/sensor/co2/g8s/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_SENSOR_G8S),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/co2/g8s
|
||||
endif
|
||||
@@ -1,3 +1,13 @@
|
||||
SRC_FILES := g8s.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += g8s.c
|
||||
include $(APPDIR)/Application.mk
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
SRC_FILES := g8s.c
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
@@ -37,6 +37,7 @@ static struct SensorProductInfo info =
|
||||
* @param sdev - sensor device pointer
|
||||
* @return success: 1 , failure: other
|
||||
*/
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
{
|
||||
int result = 0;
|
||||
@@ -46,7 +47,20 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
printf("open %s error\n", SENSOR_DEVICE_G8S_DEV);
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
sdev->fd = PrivOpen(SENSOR_DEVICE_G8S_DEV, O_RDWR);
|
||||
if (sdev->fd < 0) {
|
||||
printf("open %s error\n", SENSOR_DEVICE_G8S_DEV);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
struct SerialDataCfg cfg;
|
||||
cfg.serial_baud_rate = BAUD_RATE_9600;
|
||||
cfg.serial_data_bits = DATA_BITS_8;
|
||||
@@ -67,7 +81,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* @description: Read sensor device
|
||||
* @param sdev - sensor device pointer
|
||||
@@ -76,10 +90,9 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
*/
|
||||
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
|
||||
{
|
||||
uint8_t tmp = 0;
|
||||
|
||||
PrivWrite(sdev->fd, g8s_read_instruction, sizeof(g8s_read_instruction));
|
||||
|
||||
PrivTaskDelay(500);
|
||||
if (PrivRead(sdev->fd, sdev->buffer, len) < 0)
|
||||
return -1;
|
||||
|
||||
@@ -140,16 +153,26 @@ static int32_t QuantityRead(struct SensorQuantity *quant)
|
||||
result_ascii[i] = quant->sdev->buffer[i];
|
||||
}
|
||||
|
||||
if (8 == ascii_length) {
|
||||
for (i = 0; i < ascii_length; i ++) {
|
||||
result_hex[i] = result_ascii[i] - 0x30;
|
||||
result += result_hex[i] * pow(10, ascii_length - 1 - i);
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
if (ascii_length == 0){
|
||||
|
||||
printf("This reading is wrong\n");
|
||||
|
||||
result = SENSOR_QUANTITY_VALUE_ERROR;
|
||||
|
||||
return result;
|
||||
|
||||
}else{
|
||||
|
||||
for (i = 0; i < ascii_length; i ++) {
|
||||
|
||||
result_hex[i] = result_ascii[i] - 0x30;
|
||||
|
||||
result += result_hex[i] * pow(10, ascii_length - 1 - i);
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
if (quant->sdev->status == SENSOR_DEVICE_ACTIVE) {
|
||||
|
||||
@@ -111,6 +111,36 @@ uint32_t PrivGetTickTime()
|
||||
|
||||
/*********************fs**************************/
|
||||
|
||||
/*********************message queue***********************************/
|
||||
mqd_t PrivMqueueOpen(const char *name, int oflag)
|
||||
{
|
||||
return mq_open(name, oflag);
|
||||
}
|
||||
mqd_t PrivMqueueCreate(const char *name, int oflag, mode_t mode,struct mq_attr *attr)
|
||||
{
|
||||
return mq_open(name, oflag,mode,attr);
|
||||
}
|
||||
|
||||
int PrivMqueueSend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio)
|
||||
{
|
||||
return mq_send(mqdes,msg_ptr,msg_len, msg_prio);
|
||||
}
|
||||
|
||||
int PrivMqueueUnlink(const char *name)
|
||||
{
|
||||
return mq_unlink(name);
|
||||
}
|
||||
|
||||
int PrivMqueueClose(mqd_t mqdes)
|
||||
{
|
||||
return mq_close(mqdes);
|
||||
}
|
||||
|
||||
ssize_t PrivMqueueReceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio)
|
||||
{
|
||||
return mq_receive(mqdes, msg_ptr,msg_len, msg_prio);
|
||||
}
|
||||
|
||||
/************************Driver Posix Transform***********************/
|
||||
int PrivOpen(const char *path, int flags)
|
||||
{
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
#include <pthread.h>
|
||||
#include <pthread_internal.h>
|
||||
#include <semaphore.h>
|
||||
#include <sys/signal.h>
|
||||
#include <mqueue.h>
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
#include <dfs_poll.h>
|
||||
@@ -56,12 +58,15 @@
|
||||
#include <dmac.h>
|
||||
#include <dmalock.h>
|
||||
#endif
|
||||
|
||||
#include <netdev_ipaddr.h>
|
||||
#include <netdev.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifndef _STDBOOL_H
|
||||
typedef signed char bool;
|
||||
#endif
|
||||
typedef signed char int8;
|
||||
typedef signed short int16;
|
||||
typedef signed int int32;
|
||||
@@ -87,10 +92,10 @@ typedef unsigned long long uint64;
|
||||
#define GPIO_HIGH 0x01
|
||||
|
||||
#define GPIO_CFG_OUTPUT 0x00
|
||||
#define GPIO_CFG_INPUT 0x01
|
||||
#define GPIO_CFG_INPUT_PULLUP 0x02
|
||||
#define GPIO_CFG_INPUT_PULLDOWN 0x03
|
||||
#define GPIO_CFG_OUTPUT_OD 0x04
|
||||
#define GPIO_CFG_INPUT 0x01
|
||||
#define GPIO_CFG_INPUT_PULLUP 0x02
|
||||
#define GPIO_CFG_INPUT_PULLDOWN 0x03
|
||||
#define GPIO_CFG_OUTPUT_OD 0x04
|
||||
|
||||
#define GPIO_CONFIG_MODE 0xffffffff
|
||||
#ifndef SERIAL_RB_BUFSZ
|
||||
@@ -186,6 +191,14 @@ void PrivTaskQuit(void *value_ptr);
|
||||
int PrivTaskDelay(int32_t ms);
|
||||
uint32_t PrivGetTickTime();
|
||||
|
||||
/****************message queue***********************/
|
||||
mqd_t PrivMqueueOpen(const char *name, int oflag);
|
||||
mqd_t PrivMqueueCreate(const char *name, int oflag, mode_t mode,struct mq_attr *attr);
|
||||
int PrivMqueueSend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio);
|
||||
int PrivMqueueUnlink(const char *name);
|
||||
int PrivMqueueClose(mqd_t mqdes);
|
||||
ssize_t PrivMqueueReceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio);
|
||||
|
||||
/*********************driver*************************/
|
||||
|
||||
int PrivOpen(const char *path, int flags);
|
||||
|
||||
@@ -101,12 +101,12 @@ int PrivTaskDelay(int32_t ms)
|
||||
{
|
||||
UserTaskDelay(ms);
|
||||
}
|
||||
|
||||
#ifndef SEPARATE_COMPILE
|
||||
uint32_t PrivGetTickTime()
|
||||
{
|
||||
return CalculteTimeMsFromTick(CurrentTicksGain());
|
||||
}
|
||||
|
||||
#endif
|
||||
/*********************fs**************************/
|
||||
#ifdef FS_VFS
|
||||
/************************Driver Posix Transform***********************/
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#define TRANSFORM_H
|
||||
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <semaphore.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -29,10 +29,10 @@ extern "C" {
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#if defined(ARCH_ARM)
|
||||
#if defined(ARCH_ARM) && !defined(LIB_MUSLLIB)
|
||||
#include "pthread arm.h"
|
||||
#endif
|
||||
|
||||
|
||||
// enum {
|
||||
// PTHREAD_BARRIER_SERIAL_THREAD,
|
||||
// PTHREAD_CANCEL_ASYNCHRONOUS,
|
||||
@@ -94,7 +94,7 @@ int pthread_setname_np(pthread_t thread, const char *name);
|
||||
int pthread_timedjoin_np(pthread_t thread, void **retval, const struct timespec *abstime);
|
||||
|
||||
/* function in pthread_mutex.c */
|
||||
int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr);
|
||||
int pthread_mutex_init(pthread_mutex_t* mutex, const pthread_mutexattr_t* attr);
|
||||
int pthread_mutex_destroy(pthread_mutex_t *mutex);
|
||||
int pthread_mutex_lock(pthread_mutex_t *mutex);
|
||||
int pthread_mutex_unlock(pthread_mutex_t *mutex);
|
||||
@@ -105,7 +105,7 @@ int pthread_mutexattr_destroy(pthread_mutexattr_t *attr);
|
||||
int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type);
|
||||
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type);
|
||||
int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared);
|
||||
int pthread_mutexattr_getpshared(pthread_mutexattr_t *attr, int *pshared);
|
||||
int pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, int *pshared);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
return -1 ;
|
||||
|
||||
ret = UserTaskStartup(pid);
|
||||
*thread = pid;
|
||||
|
||||
*thread = (pthread_t)(long)pid;
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
@@ -63,7 +63,7 @@ void pthread_exit(void *value_ptr){
|
||||
pthread_t pthread_self(void){
|
||||
|
||||
pthread_t pthread ;
|
||||
pthread = UserGetTaskID();
|
||||
pthread = (pthread_t)(long)UserGetTaskID();
|
||||
return pthread;
|
||||
}
|
||||
|
||||
@@ -112,7 +112,8 @@ int pthread_join(pthread_t thread, void **retval)
|
||||
int pthread_kill(pthread_t thread, int sig)
|
||||
{
|
||||
/* This api should not be used, and will not be supported */
|
||||
UserTaskDelete(thread);
|
||||
int32_t *thread_id_tmp = (void *)&thread;
|
||||
UserTaskDelete(*thread_id_tmp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,118 @@
|
||||
|
||||
#include <time.h>
|
||||
#include "include/pthread.h"
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
|
||||
// #if defined(ARCH_ARM) && defined(LIB_MUSLLIB)
|
||||
#if defined(LIB_MUSLLIB)
|
||||
int pthread_mutex_init(pthread_mutex_t* p_mutex, const pthread_mutexattr_t* attr)
|
||||
{
|
||||
pthread_mutexattr_t mutexAttr;
|
||||
uint32_t mutex_handle;
|
||||
|
||||
// check p_mutex
|
||||
if (p_mutex == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
// set attr
|
||||
if (attr == NULL) {
|
||||
pthread_mutexattr_init(&mutexAttr);
|
||||
}
|
||||
else {
|
||||
mutexAttr = *attr;
|
||||
}
|
||||
|
||||
// create mutex
|
||||
mutex_handle = UserMutexCreate();
|
||||
if (mutex_handle < 0) {
|
||||
return mutex_handle;
|
||||
}
|
||||
|
||||
p_mutex->stAttr = mutexAttr;
|
||||
p_mutex->magic = _MUX_MAGIC;
|
||||
p_mutex->handle = mutex_handle;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_mutex_destroy(pthread_mutex_t *p_mutex)
|
||||
{
|
||||
if ((p_mutex == NULL) || (p_mutex->magic != _MUX_MAGIC)) {
|
||||
return EINVAL;
|
||||
}
|
||||
UserMutexDelete(p_mutex->handle);
|
||||
p_mutex->handle = _MUX_INVALID_HANDLE;
|
||||
p_mutex->magic = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_mutex_lock(pthread_mutex_t *p_mutex)
|
||||
{
|
||||
if ((p_mutex == NULL) || (p_mutex->magic != _MUX_MAGIC) ||
|
||||
(p_mutex->handle == _MUX_INVALID_HANDLE)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
return UserMutexObtain(p_mutex->handle, WAITING_FOREVER);
|
||||
}
|
||||
|
||||
int pthread_mutex_unlock(pthread_mutex_t *p_mutex)
|
||||
{
|
||||
if ((p_mutex == NULL) || (p_mutex->magic != _MUX_MAGIC) ||
|
||||
(p_mutex->handle == _MUX_INVALID_HANDLE)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
return UserMutexAbandon(p_mutex->handle);
|
||||
}
|
||||
|
||||
int pthread_mutex_trylock(pthread_mutex_t *p_mutex)
|
||||
{
|
||||
if ((p_mutex == NULL) || (p_mutex->magic != _MUX_MAGIC) ||
|
||||
(p_mutex->handle == _MUX_INVALID_HANDLE)) {
|
||||
return EINVAL;
|
||||
}
|
||||
return UserMutexObtain(p_mutex->handle , 0);
|
||||
}
|
||||
|
||||
int pthread_mutexattr_init(pthread_mutexattr_t *attr)
|
||||
{
|
||||
if (attr == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
attr->type = PTHREAD_MUTEX_DEFAULT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
|
||||
{
|
||||
if (attr == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
memset(attr, 0, sizeof(pthread_mutexattr_t));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type)
|
||||
{
|
||||
if (attr == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
*type = attr->type;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
|
||||
{
|
||||
if (attr == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
attr->type = type;
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
int pthread_mutex_init(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr)
|
||||
{
|
||||
*p_mutex = UserMutexCreate();
|
||||
@@ -82,9 +193,11 @@ int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *restrict attr, int *restrict protocol)
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
int pthread_mutexattr_getprotocol(const pthread_mutexattr_t* restrict attr, int* restrict protocol)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -118,7 +231,7 @@ int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_mutexattr_getpshared(pthread_mutexattr_t *attr, int *pshared)
|
||||
int pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, int *pshared)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user