summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorHubretXie <[email protected]>2019-11-26 09:30:21 +0800
committerGitHub <[email protected]>2019-11-26 09:30:21 +0800
commit17f7f1c7ca2581b2e308888f8acb99ca8a541422 (patch)
tree5236e93ab1e4e24508d4ebf4540b6743dd7c9a41 /include
parent9662e18c3688681cd95ebd65242773dbe7c1366b (diff)
parente459084fe028c837762d40326a9be3dfdc179894 (diff)
Merge pull request #8 from RT-Thread/master
sync
Diffstat (limited to 'include')
-rw-r--r--include/libc/libc_fcntl.h4
-rw-r--r--include/rtdef.h13
-rw-r--r--include/rthw.h6
-rw-r--r--include/rtthread.h25
4 files changed, 42 insertions, 6 deletions
diff --git a/include/libc/libc_fcntl.h b/include/libc/libc_fcntl.h
index 83b9af9b1e..1b7c69b1f4 100644
--- a/include/libc/libc_fcntl.h
+++ b/include/libc/libc_fcntl.h
@@ -20,7 +20,7 @@
#include <fcntl.h>
#ifndef O_NONBLOCK
-#define O_NONBLOCK 04000
+#define O_NONBLOCK 0x4000
#endif
#if defined(_WIN32)
@@ -35,7 +35,7 @@
#endif
#ifndef O_DIRECTORY
-#define O_DIRECTORY 0200000
+#define O_DIRECTORY 0x200000
#endif
#ifndef O_BINARY
diff --git a/include/rtdef.h b/include/rtdef.h
index c97e938f75..3f0b116785 100644
--- a/include/rtdef.h
+++ b/include/rtdef.h
@@ -200,11 +200,11 @@ typedef int (*init_fn_t)(void);
};
#define INIT_EXPORT(fn, level) \
const char __rti_##fn##_name[] = #fn; \
- RT_USED const struct rt_init_desc __rt_init_desc_##fn SECTION(".rti_fn."level) = \
+ RT_USED const struct rt_init_desc __rt_init_desc_##fn SECTION(".rti_fn." level) = \
{ __rti_##fn##_name, fn};
#else
#define INIT_EXPORT(fn, level) \
- RT_USED const init_fn_t __rt_init_##fn SECTION(".rti_fn."level) = fn
+ RT_USED const init_fn_t __rt_init_##fn SECTION(".rti_fn." level) = fn
#endif
#endif
#else
@@ -491,7 +491,10 @@ typedef siginfo_t rt_siginfo_t;
#define RT_THREAD_RUNNING 0x03 /**< Running status */
#define RT_THREAD_BLOCK RT_THREAD_SUSPEND /**< Blocked status */
#define RT_THREAD_CLOSE 0x04 /**< Closed status */
-#define RT_THREAD_STAT_MASK 0x0f
+#define RT_THREAD_STAT_MASK 0x07
+
+#define RT_THREAD_STAT_YIELD 0x08 /**< indicate whether remaining_tick has been reloaded since last schedule */
+#define RT_THREAD_STAT_YIELD_MASK RT_THREAD_STAT_YIELD
#define RT_THREAD_STAT_SIGNAL 0x10 /**< task hold signals */
#define RT_THREAD_STAT_SIGNAL_READY (RT_THREAD_STAT_SIGNAL | RT_THREAD_READY)
@@ -577,6 +580,7 @@ struct rt_thread
rt_uint16_t scheduler_lock_nest; /**< scheduler lock count */
rt_uint16_t cpus_lock_nest; /**< cpus lock count */
+ rt_uint16_t critical_lock_nest; /**< critical lock count */
#endif /*RT_USING_SMP*/
/* priority */
@@ -742,6 +746,8 @@ struct rt_messagequeue
void *msg_queue_head; /**< list head */
void *msg_queue_tail; /**< list tail */
void *msg_queue_free; /**< pointer indicated the free node of queue */
+
+ rt_list_t suspend_sender_thread; /**< sender thread suspended on this message queue */
};
typedef struct rt_messagequeue *rt_mq_t;
#endif
@@ -815,7 +821,6 @@ struct rt_mempool
rt_size_t block_free_count; /**< numbers of free memory block */
rt_list_t suspend_thread; /**< threads pended on this resource */
- rt_size_t suspend_thread_count; /**< numbers of thread pended on this resource */
};
typedef struct rt_mempool *rt_mp_t;
#endif
diff --git a/include/rthw.h b/include/rthw.h
index ef3dc087ad..2a602dcfe7 100644
--- a/include/rthw.h
+++ b/include/rthw.h
@@ -143,6 +143,12 @@ typedef union {
} tickets;
} rt_hw_spinlock_t;
+struct rt_spinlock
+{
+ rt_hw_spinlock_t lock;
+};
+
+void rt_hw_spin_lock_init(rt_hw_spinlock_t *lock);
void rt_hw_spin_lock(rt_hw_spinlock_t *lock);
void rt_hw_spin_unlock(rt_hw_spinlock_t *lock);
diff --git a/include/rtthread.h b/include/rtthread.h
index 04db77da46..13a1a4424b 100644
--- a/include/rtthread.h
+++ b/include/rtthread.h
@@ -379,6 +379,10 @@ rt_mq_t rt_mq_create(const char *name,
rt_err_t rt_mq_delete(rt_mq_t mq);
rt_err_t rt_mq_send(rt_mq_t mq, const void *buffer, rt_size_t size);
+rt_err_t rt_mq_send_wait(rt_mq_t mq,
+ const void *buffer,
+ rt_size_t size,
+ rt_int32_t timeout);
rt_err_t rt_mq_urgent(rt_mq_t mq, const void *buffer, rt_size_t size);
rt_err_t rt_mq_recv(rt_mq_t mq,
void *buffer,
@@ -387,6 +391,27 @@ rt_err_t rt_mq_recv(rt_mq_t mq,
rt_err_t rt_mq_control(rt_mq_t mq, int cmd, void *arg);
#endif
+/*
+ * spinlock
+ */
+#ifdef RT_USING_SMP
+struct rt_spinlock;
+
+void rt_spin_lock_init(struct rt_spinlock *lock);
+void rt_spin_lock(struct rt_spinlock *lock);
+void rt_spin_unlock(struct rt_spinlock *lock);
+rt_base_t rt_spin_lock_irqsave(struct rt_spinlock *lock);
+void rt_spin_unlock_irqrestore(struct rt_spinlock *lock, rt_base_t level);
+
+#else
+#define rt_spin_lock_init(lock) /* nothing */
+#define rt_spin_lock(lock) rt_enter_critical()
+#define rt_spin_unlock(lock) rt_exit_critical()
+#define rt_spin_lock_irqsave(lock) rt_hw_interrupt_disable()
+#define rt_spin_unlock_irqrestore(lock, level) rt_hw_interrupt_enable(level)
+
+#endif
+
/**@}*/
#ifdef RT_USING_DEVICE