mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-08 14:43:04 +08:00
add module feature
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@604 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
1 parent
ca6a1a7ecb
commit
5211e7ff8f
7 files changed
+663
-16
No files matched your search
@@ -0,0 +1,23 @@
|
||||
#include <rtthread.h>
|
||||
|
||||
static void thread_entry(void* parameter)
|
||||
{
|
||||
rt_kprintf("thread dynamicly created ok\n");
|
||||
rt_thread_delay(10);
|
||||
rt_kprintf("thread exit\n");
|
||||
}
|
||||
|
||||
int rtm_main()
|
||||
{
|
||||
rt_thread_t tid;
|
||||
|
||||
tid = rt_thread_create("test",
|
||||
thread_entry, RT_NULL,
|
||||
THREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_TIMESLICE);
|
||||
if (tid != RT_NULL)
|
||||
rt_thread_startup(tid);
|
||||
else
|
||||
tc_stat(TC_STAT_END | TC_STAT_FAILED);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef __RTM_H__
|
||||
#define __RTM_H__
|
||||
|
||||
#include <rtdef.h>
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
#define RTM_EXPORT(symbol) \
|
||||
const char __rtmsym_##symbol##_name[] = #symbol; \
|
||||
const struct rt_module_symtab __rtmsym_##symbol SECTION("RTMSymTab")= \
|
||||
{ \
|
||||
(rt_uint32_t)&symbol, \
|
||||
__rtmsym_##symbol##_name, \
|
||||
};
|
||||
#else
|
||||
#define RTM_EXPORT(symbol)
|
||||
#endif
|
||||
|
||||
struct rt_module_symtab
|
||||
{
|
||||
rt_uint32_t addr;
|
||||
const char* name;
|
||||
};
|
||||
|
||||
#endif
|
||||
+27
-15
@@ -14,6 +14,8 @@
|
||||
* 2006-08-10 Bernard add version information
|
||||
* 2007-01-28 Bernard rename RT_OBJECT_Class_Static to RT_Object_Class_Static
|
||||
* 2007-03-03 Bernard clean up the definitions to rtdef.h
|
||||
* 2010-04-11 yi.qiu add module feature
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __RT_THREAD_H__
|
||||
@@ -25,6 +27,16 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__CC_ARM)
|
||||
#ifdef RT_USING_MODULE
|
||||
#define RTT_API __declspec(dllimport)
|
||||
#else
|
||||
#define RTT_API __declspec(dllexport)
|
||||
#endif
|
||||
#elif defined(__GNUC__)
|
||||
#define RTT_API
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup KernelObject
|
||||
*/
|
||||
@@ -91,27 +103,27 @@ void rt_timer_timeout_sethook(void (*hook)(struct rt_timer* timer));
|
||||
/*
|
||||
* thread interface
|
||||
*/
|
||||
rt_err_t rt_thread_init(struct rt_thread* thread,
|
||||
RTT_API rt_err_t rt_thread_init(struct rt_thread* thread,
|
||||
const char* name,
|
||||
void (*entry)(void* parameter), void* parameter,
|
||||
void* stack_start, rt_uint32_t stack_size,
|
||||
rt_uint8_t priority, rt_uint32_t tick);
|
||||
rt_err_t rt_thread_detach(rt_thread_t thread);
|
||||
rt_thread_t rt_thread_create (const char* name,
|
||||
RTT_API rt_err_t rt_thread_detach(rt_thread_t thread);
|
||||
RTT_API rt_thread_t rt_thread_create (const char* name,
|
||||
void (*entry)(void* parameter), void* parameter,
|
||||
rt_uint32_t stack_size,
|
||||
rt_uint8_t priority, rt_uint32_t tick);
|
||||
rt_thread_t rt_thread_self(void);
|
||||
rt_thread_t rt_thread_find(char* name);
|
||||
rt_err_t rt_thread_startup(rt_thread_t thread);
|
||||
rt_err_t rt_thread_delete(rt_thread_t thread);
|
||||
RTT_API rt_thread_t rt_thread_self(void);
|
||||
RTT_API rt_thread_t rt_thread_find(char* name);
|
||||
RTT_API rt_err_t rt_thread_startup(rt_thread_t thread);
|
||||
RTT_API rt_err_t rt_thread_delete(rt_thread_t thread);
|
||||
|
||||
rt_err_t rt_thread_yield(void);
|
||||
rt_err_t rt_thread_delay(rt_tick_t tick);
|
||||
rt_err_t rt_thread_control(rt_thread_t thread, rt_uint8_t cmd, void* arg);
|
||||
rt_err_t rt_thread_suspend(rt_thread_t thread);
|
||||
rt_err_t rt_thread_resume(rt_thread_t thread);
|
||||
void rt_thread_timeout(void* parameter);
|
||||
RTT_API rt_err_t rt_thread_yield(void);
|
||||
RTT_API rt_err_t rt_thread_delay(rt_tick_t tick);
|
||||
RTT_API rt_err_t rt_thread_control(rt_thread_t thread, rt_uint8_t cmd, void* arg);
|
||||
RTT_API rt_err_t rt_thread_suspend(rt_thread_t thread);
|
||||
RTT_API rt_err_t rt_thread_resume(rt_thread_t thread);
|
||||
RTT_API void rt_thread_timeout(void* parameter);
|
||||
|
||||
/*
|
||||
* idle thread interface
|
||||
@@ -312,8 +324,8 @@ void rt_interrupt_leave(void);
|
||||
rt_int32_t rt_sprintf(char *buf ,const char *format,...);
|
||||
rt_int32_t rt_vsprintf(char *dest, const char *format, va_list arg_ptr);
|
||||
rt_int32_t rt_sprintf(char *buf ,const char *format,...);
|
||||
rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *format, ...);
|
||||
|
||||
rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *format, ...);
|
||||
|
||||
rt_device_t rt_console_set_device(const char* name);
|
||||
void rt_kprintf(const char *fmt, ...);
|
||||
|
||||
|
||||
+6
-1
@@ -941,12 +941,12 @@ __weak void rt_hw_console_output(const char* str)
|
||||
*/
|
||||
void rt_kprintf(const char *fmt, ...)
|
||||
{
|
||||
|
||||
va_list args;
|
||||
rt_size_t length;
|
||||
static char rt_log_buf[RT_CONSOLEBUF_SIZE];
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
length = vsnprintf(rt_log_buf, sizeof(rt_log_buf), fmt, args);
|
||||
if (_console_device == RT_NULL)
|
||||
{
|
||||
@@ -977,4 +977,9 @@ char *strdup(const char *s) __attribute__((weak, alias("rt_strdup")));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
#include <rtm.h>
|
||||
/* some buildin kernel symbol */
|
||||
RTM_EXPORT(rt_kprintf)
|
||||
#endif
|
||||
/*@}*/
|
||||
+360
File diff suppressed because it is too large.
Load diff
+205
File diff suppressed because it is too large.
Load diff
@@ -19,6 +19,7 @@
|
||||
* 2006-09-03 Bernard implement rt_thread_detach
|
||||
* 2008-02-16 Bernard fix the rt_thread_timeout bug
|
||||
* 2010-03-21 Bernard change the errno of rt_thread_delay/sleep to RT_EOK.
|
||||
* 2010-04-11 yi.qiu add module feature
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
@@ -627,4 +628,21 @@ rt_thread_t rt_thread_find(char* name)
|
||||
return thread;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
#include <rtm.h>
|
||||
/* some buildin kernel symbol */
|
||||
RTM_EXPORT(rt_thread_init)
|
||||
RTM_EXPORT(rt_thread_detach)
|
||||
RTM_EXPORT(rt_thread_create)
|
||||
RTM_EXPORT(rt_thread_self)
|
||||
RTM_EXPORT(rt_thread_find)
|
||||
RTM_EXPORT(rt_thread_startup)
|
||||
RTM_EXPORT(rt_thread_delete)
|
||||
RTM_EXPORT(rt_thread_yield)
|
||||
RTM_EXPORT(rt_thread_delay)
|
||||
RTM_EXPORT(rt_thread_control)
|
||||
RTM_EXPORT(rt_thread_suspend)
|
||||
RTM_EXPORT(rt_thread_resume)
|
||||
RTM_EXPORT(rt_thread_timeout)
|
||||
#endif
|
||||
/*@}*/
|
||||
Reference in new issue
Block a user