eliminate compile warning

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1407 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
qiuyiuestc@gmail.com 2011-05-16 01:18:43 +00:00
parent 8a9792317f
commit 9faa3d9989
8 changed files with 142 additions and 562 deletions

View File

@ -386,7 +386,7 @@ int list_module(void)
FINSH_FUNCTION_EXPORT(list_module, list module in system) FINSH_FUNCTION_EXPORT(list_module, list module in system)
int list_module_obj(const char* name) int list_mod_detail(const char* name)
{ {
int i; int i;
struct rt_module *module; struct rt_module *module;
@ -480,7 +480,7 @@ int list_module_obj(const char* name)
return 0; return 0;
} }
FINSH_FUNCTION_EXPORT(list_module_obj, list module objects in system) FINSH_FUNCTION_EXPORT(list_mod_detail, list module objects in system)
#endif #endif
int list() int list()

View File

@ -15,7 +15,7 @@
#include <rtthread.h> #include <rtthread.h>
#include <rtm.h> #include <rtm.h>
#define MODULE_ROOT_DIR "/module" #define MODULE_ROOT_DIR "/module/lib"
void* dlopen(const char *filename, int flags) void* dlopen(const char *filename, int flags)
{ {

View File

@ -1,88 +0,0 @@
#include "ftk.h"
typedef struct _TimerInfo
{
int times;
FtkWidget* label;
}TimerInfo;
static Ret timeout(void* ctx)
{
TimerInfo* info = ctx;
char buffer[32] = {0};
if(info->times > 0)
{
snprintf(buffer, sizeof(buffer), "Quit after %d seconds", info->times);
ftk_widget_set_text(info->label, buffer);
info->times--;
return RET_OK;
}
else
{
ftk_widget_unref(ftk_widget_toplevel(info->label));
ftk_logd("%s: timeout and quit.\n", __func__);
FTK_FREE(info);
FTK_QUIT();
return RET_REMOVE;
}
}
#ifdef FTK_AS_PLUGIN
#include "ftk_app_demo.h"
FTK_HIDE int FTK_MAIN(int argc, char* argv[]);
FtkApp* ftk_app_demo_bidi_create()
{
return ftk_app_demo_create(_("bidi"), ftk_main);
}
#else
#define FTK_HIDE extern
#endif /*FTK_AS_PLUGIN*/
FTK_HIDE int FTK_MAIN(int argc, char* argv[])
{
int width = 0;
int height = 0;
FtkGc gc = {.mask = FTK_GC_BG};
TimerInfo* info = NULL;
FTK_INIT(argc, argv);
info = (TimerInfo*)FTK_ZALLOC(sizeof(TimerInfo));
info->times = 100;
FtkSource* timer = ftk_source_timer_create(1000, timeout, info);
FtkWidget* win = ftk_app_window_create();
width = ftk_widget_width(win);
height = ftk_widget_height(win);
FtkWidget* label = ftk_label_create(win, 10, 10, width - 20, 20);
ftk_widget_set_text(label, "arabic bidi demo");
label = ftk_label_create(win, 10, 40, width - 20, 20);
ftk_widget_set_text(label, "English Text");
assert(strcmp(ftk_widget_get_text(label), "English Text") == 0);
gc.bg.a = 0xff;
gc.bg.r = 0xF0;
gc.bg.g = 0xF0;
gc.bg.b = 0x80;
label = ftk_label_create(win, 10, height/2, width - 20, 120);
ftk_widget_set_gc(label, FTK_WIDGET_INSENSITIVE, &gc);
ftk_widget_unset_attr(label, FTK_ATTR_TRANSPARENT);
ftk_widget_set_text(label, "ان منح حياتك للمسيح تعد خطوة ايمان يمكنك القيام بها عن طريق الصلاة");
label = ftk_label_create(win, 50, height/2-30, width, 20);
info->label = label;
ftk_widget_set_text(win, "label demo");
ftk_widget_show_all(win, 1);
ftk_widget_set_attr(win, FTK_ATTR_IGNORE_CLOSE);
ftk_main_loop_add_source(ftk_default_main_loop(), timer);
FTK_RUN();
return 0;
}

View File

@ -1,375 +0,0 @@
#include <math.h>
#ifdef ENABLE_CAIRO
#include "ftk_cairo.h"
static cairo_t* cr = NULL;
static void paint_clip_image(int x, int y, int width, int height)
{
int w, h;
cairo_surface_t *image;
char filename[FTK_MAX_PATH+1] = {0};
cairo_translate (cr, x, y);
cairo_arc (cr, width/2, height/4, width/3, 0, 2*M_PI);
cairo_clip (cr);
cairo_new_path (cr); /* path not consumed by clip()*/
ftk_snprintf(filename, FTK_MAX_PATH, "%s/png1.png",
ftk_config_get_test_data_dir(ftk_default_config()));
image = cairo_image_surface_create_from_png (filename);
w = cairo_image_surface_get_width (image);
h = cairo_image_surface_get_height (image);
// cairo_scale (cr, 256.0/w, 256.0/h);
cairo_set_source_surface (cr, image, 0, 0);
cairo_paint (cr);
cairo_surface_destroy (image);
return;
}
static void paint_rect(int x, int y, int width, int height)
{
/* a custom shape that could be wrapped in a function */
double x0 = 25.6, /* parameters like cairo_rectangle */
y0 = 25.6,
rect_width = 204.8,
rect_height = 204.8,
radius = 102.4; /* and an approximate curvature radius */
double x1,y1;
cairo_translate (cr, x, y);
x1=x0+rect_width;
y1=y0+rect_height;
if (!rect_width || !rect_height)
return;
if (rect_width/2<radius) {
if (rect_height/2<radius) {
cairo_move_to (cr, x0, (y0 + y1)/2);
cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);
} else {
cairo_move_to (cr, x0, y0 + radius);
cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
cairo_line_to (cr, x1 , y1 - radius);
cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
cairo_curve_to (cr, x0, y1, x0, y1, x0, y1- radius);
}
} else {
if (rect_height/2<radius) {
cairo_move_to (cr, x0, (y0 + y1)/2);
cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
cairo_line_to (cr, x1 - radius, y0);
cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
cairo_line_to (cr, x0 + radius, y1);
cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);
} else {
cairo_move_to (cr, x0, y0 + radius);
cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
cairo_line_to (cr, x1 - radius, y0);
cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
cairo_line_to (cr, x1 , y1 - radius);
cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
cairo_line_to (cr, x0 + radius, y1);
cairo_curve_to (cr, x0, y1, x0, y1, x0, y1- radius);
}
}
cairo_close_path (cr);
cairo_set_source_rgb (cr, 0.5, 0.5, 1);
cairo_fill_preserve (cr);
cairo_set_source_rgba (cr, 0.5, 0, 0, 0.5);
cairo_set_line_width (cr, 10.0);
cairo_stroke (cr);
return;
}
static void paint_pic(int x, int y, int width, int height)
{
int w, h;
cairo_surface_t *image;
cairo_pattern_t *pattern;
cairo_matrix_t matrix;
char filename[FTK_MAX_PATH+1] = {0};
cairo_translate (cr, x, y);
ftk_snprintf(filename, FTK_MAX_PATH, "%s/png1.png",
ftk_config_get_test_data_dir(ftk_default_config()));
image = cairo_image_surface_create_from_png (filename);
w = cairo_image_surface_get_width (image);
h = cairo_image_surface_get_height (image);
pattern = cairo_pattern_create_for_surface (image);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
cairo_translate (cr, 128.0, 128.0);
cairo_rotate (cr, M_PI / 4);
cairo_scale (cr, 1 / sqrt (2), 1 / sqrt (2));
cairo_translate (cr, -128.0, -128.0);
cairo_matrix_init_scale (&matrix, w/256.0 * 5.0, h/256.0 * 5.0);
cairo_pattern_set_matrix (pattern, &matrix);
cairo_set_source (cr, pattern);
cairo_rectangle (cr, 0, 0, 256.0, 256.0);
cairo_fill (cr);
cairo_pattern_destroy (pattern);
cairo_surface_destroy (image);
return;
}
static void paint_arrow(int x, int y, int width, int height)
{
cairo_translate (cr, x, y);
cairo_set_line_width (cr, 40.96);
cairo_move_to (cr, 76.8, 84.48);
cairo_rel_line_to (cr, 51.2, -51.2);
cairo_rel_line_to (cr, 51.2, 51.2);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER); /* default */
cairo_stroke (cr);
cairo_move_to (cr, 76.8, 161.28);
cairo_rel_line_to (cr, 51.2, -51.2);
cairo_rel_line_to (cr, 51.2, 51.2);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL);
cairo_stroke (cr);
cairo_move_to (cr, 76.8, 238.08);
cairo_rel_line_to (cr, 51.2, -51.2);
cairo_rel_line_to (cr, 51.2, 51.2);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
cairo_stroke (cr);
return;
}
static void paint_segments(int x, int y, int width, int height)
{
cairo_translate (cr, x, y);
cairo_move_to (cr, 50.0, 75.0);
cairo_line_to (cr, 200.0, 75.0);
cairo_move_to (cr, 50.0, 125.0);
cairo_line_to (cr, 200.0, 125.0);
cairo_move_to (cr, 50.0, 175.0);
cairo_line_to (cr, 200.0, 175.0);
cairo_set_line_width (cr, 30.0);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
cairo_stroke (cr);
return;
}
static void paint_ball(int x, int y, int width, int height)
{
cairo_pattern_t *pat;
pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, height);
cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 0, 1);
cairo_pattern_add_color_stop_rgba (pat, 0, 1, 1, 1, 1);
cairo_rectangle (cr, x, y, width, height);
cairo_set_source (cr, pat);
cairo_fill (cr);
cairo_pattern_destroy (pat);
pat = cairo_pattern_create_radial (x+115.2, y+102.4, 25.6,
x+102.4, y+102.4, 128.0);
cairo_pattern_add_color_stop_rgba (pat, 0, 1, 1, 1, 1);
cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 0, 1);
cairo_set_source (cr, pat);
cairo_arc (cr, x+width/2, y+height/4, 76.8, 0, 2 * M_PI);
cairo_fill (cr);
cairo_pattern_destroy (pat);
return;
}
static void paint_helloworld(int x, int y, int width, int height)
{
cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 90.0);
cairo_move_to (cr, x+10.0, y+135.0);
cairo_show_text (cr, "Hello");
cairo_move_to (cr, x+70.0, y+165.0);
cairo_text_path (cr, "void");
cairo_set_source_rgb (cr, 0.5, 0.5, 1);
cairo_fill_preserve (cr);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_set_line_width (cr, 2.56);
cairo_stroke (cr);
/* draw helping lines */
cairo_set_source_rgba (cr, 1, 0.2, 0.2, 0.6);
cairo_arc (cr, x+10.0, y+135.0, 5.12, 0, 2*M_PI);
cairo_close_path (cr);
cairo_arc (cr, x+70.0, y+165.0, 5.12, 0, 2*M_PI);
cairo_fill (cr);
return;
}
static void paint_car(int x, int y, int width, int height)
{
cairo_set_line_width (cr, 6);
cairo_rectangle (cr, x+10, y+10, width-20, 70);
cairo_new_sub_path (cr); cairo_arc (cr, x+64, y+64, 40, 0, 2*M_PI);
cairo_new_sub_path (cr); cairo_arc_negative (cr, width-64, y+64, 40, 0, -2*M_PI);
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_set_source_rgb (cr, 0, 0.7, 0); cairo_fill_preserve (cr);
cairo_set_source_rgb (cr, 0, 0, 0); cairo_stroke (cr);
cairo_translate (cr, x, height/2);
cairo_rectangle (cr, 10, 10, width-20, 70);
cairo_new_sub_path (cr); cairo_arc (cr, 64, 64, 40, 0, 2*M_PI);
cairo_new_sub_path (cr); cairo_arc_negative (cr, width-64, 64, 40, 0, -2*M_PI);
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
cairo_set_source_rgb (cr, 0, 0, 0.9); cairo_fill_preserve (cr);
cairo_set_source_rgb (cr, 0, 0, 0); cairo_stroke (cr);
return;
}
typedef void (*PaintFunc)(int x, int y, int width, int height);
static size_t g_index = 0;
static const PaintFunc paints[] =
{
paint_car,
paint_helloworld,
paint_ball,
paint_segments,
paint_arrow,
paint_pic,
paint_rect,
paint_clip_image
};
static Ret on_paint(void* ctx, void* obj)
{
FtkWidget* thiz = obj;
FTK_BEGIN_PAINT(x, y, width, height, canvas);
ftk_logd("%s:%d\n", __func__, __LINE__);
if(cr == NULL)
{
cairo_surface_t* surface = ftk_cairo_surface_create(thiz);
cr = cairo_create(surface);
cairo_surface_destroy(surface);
ftk_logd("%s:%d\n", __func__, __LINE__);
}
cairo_save (cr);
cairo_reset_clip (cr);
cairo_identity_matrix (cr);
cairo_new_path (cr);
cairo_rectangle(cr, x, y, width, height);
cairo_clip (cr);
ftk_logd("%s:%d\n", __func__, __LINE__);
paints[g_index](x, y, width, height);
ftk_logd("%s:%d\n", __func__, __LINE__);
cairo_restore (cr);
FTK_END_PAINT();
ftk_logd("%s:%d\n", __func__, __LINE__);
return RET_OK;
}
static Ret button_prev_clicked(void* ctx, void* obj)
{
g_index = g_index > 0 ? g_index - 1 : 0;
ftk_widget_invalidate(ftk_widget_lookup(ctx, 100));
return RET_OK;
}
static Ret button_next_clicked(void* ctx, void* obj)
{
g_index++;
g_index = g_index % (sizeof(paints)/sizeof(paints[0]));
ftk_widget_invalidate(ftk_widget_lookup(ctx, 100));
return RET_OK;
}
static Ret button_quit_clicked(void* ctx, void* obj)
{
ftk_widget_unref(ctx);
return RET_OK;
}
#ifdef FTK_AS_PLUGIN
#include "ftk_app_demo.h"
FTK_HIDE int FTK_MAIN(int argc, char* argv[]);
FtkApp* ftk_app_demo_cairo_create()
{
return ftk_app_demo_create(_("cairo"), ftk_main);
}
#else
#define FTK_HIDE extern
#endif /*FTK_AS_PLUGIN*/
FTK_HIDE int FTK_MAIN(int argc, char* argv[])
{
int width = 0;
int height = 0;
FtkWidget* win = NULL;
FtkWidget* button = NULL;
FtkWidget* painter = NULL;
FTK_INIT(argc, argv);
win = ftk_app_window_create();
width = ftk_widget_width(win);
height = ftk_widget_height(win);
button = ftk_button_create(win, 0, 10, width/3, 60);
ftk_widget_set_text(button, "prev");
ftk_button_set_clicked_listener(button, button_prev_clicked, win);
button = ftk_button_create(win, width/3, 10, width/3, 60);
ftk_widget_set_text(button, "next");
ftk_button_set_clicked_listener(button, button_next_clicked, win);
button = ftk_button_create(win, width*2/3, 10, width/3, 60);
ftk_widget_set_text(button, "quit");
ftk_button_set_clicked_listener(button, button_quit_clicked, win);
painter = ftk_painter_create(win, 0, 70, width, height);
ftk_widget_set_id(painter, 100);
ftk_painter_set_paint_listener(painter, on_paint, NULL);
ftk_widget_set_text(win, "cairo demo");
ftk_widget_show_all(win, 1);
FTK_QUIT_WHEN_WIDGET_CLOSE(win);
FTK_RUN();
return 0;
}
#endif

View File

@ -9,8 +9,8 @@
const char __rtmsym_##symbol##_name[] = #symbol; \ const char __rtmsym_##symbol##_name[] = #symbol; \
const struct rt_module_symtab __rtmsym_##symbol SECTION("RTMSymTab")= \ const struct rt_module_symtab __rtmsym_##symbol SECTION("RTMSymTab")= \
{ \ { \
(rt_uint32_t)&symbol, \ (void *)&symbol, \
__rtmsym_##symbol##_name, \ __rtmsym_##symbol##_name \
}; };
#else #else
@ -19,7 +19,7 @@ const struct rt_module_symtab __rtmsym_##symbol SECTION("RTMSymTab")= \
struct rt_module_symtab struct rt_module_symtab
{ {
rt_uint32_t addr; void* addr;
const char* name; const char* name;
}; };

View File

@ -304,7 +304,7 @@ rt_err_t rt_device_control(rt_device_t dev, rt_uint8_t cmd, void* arg);
* module interface * module interface
*/ */
rt_module_t rt_module_load(const rt_uint8_t* name, void* module_ptr); rt_module_t rt_module_load(const char* name, void* module_ptr);
rt_err_t rt_module_unload(rt_module_t module); rt_err_t rt_module_unload(rt_module_t module);
rt_module_t rt_module_open(const char* filename); rt_module_t rt_module_open(const char* filename);
void *rt_module_malloc(rt_size_t size); void *rt_module_malloc(rt_size_t size);

View File

@ -20,7 +20,7 @@
#include "string.h" #include "string.h"
#include "kservice.h" #include "kservice.h"
/* #define RT_MODULE_DEBUG */ #define RT_MODULE_DEBUG
#ifdef RT_USING_MODULE #ifdef RT_USING_MODULE
#include "module.h" #include "module.h"
@ -43,7 +43,6 @@ struct rt_module_page
rt_size_t npage; /* number of pages */ rt_size_t npage; /* number of pages */
rt_list_t list; rt_list_t list;
}; };
static struct rt_module_page *rt_module_page_list;
/* module memory allocator */ /* module memory allocator */
struct rt_mem_head struct rt_mem_head
@ -67,12 +66,18 @@ struct rt_module_symtab *_rt_module_symtab_begin = RT_NULL, *_rt_module_symtab_e
*/ */
void rt_system_module_init(void) void rt_system_module_init(void)
{ {
#ifdef __GNUC__
extern int __rtmsymtab_start; extern int __rtmsymtab_start;
extern int __rtmsymtab_end; extern int __rtmsymtab_end;
#ifdef __GNUC__
_rt_module_symtab_begin = (struct rt_module_symtab *)&__rtmsymtab_start; _rt_module_symtab_begin = (struct rt_module_symtab *)&__rtmsymtab_start;
_rt_module_symtab_end = (struct rt_module_symtab *)&__rtmsymtab_end; _rt_module_symtab_end = (struct rt_module_symtab *)&__rtmsymtab_end;
#elif defined (__CC_ARM)
extern int RTMSymTab$$Base;
extern int RTMSymTab$$Limit;
_rt_module_symtab_begin = (struct rt_module_symtab *)&RTMSymTab$$Base;
_rt_module_symtab_end = (struct rt_module_symtab *)&RTMSymTab$$Limit;
#endif #endif
rt_list_init(&rt_module_symbol_list); rt_list_init(&rt_module_symbol_list);
@ -81,14 +86,14 @@ void rt_system_module_init(void)
rt_current_module = RT_NULL; rt_current_module = RT_NULL;
} }
static rt_uint32_t rt_module_symbol_find(const rt_uint8_t* sym_str) static rt_uint32_t rt_module_symbol_find(const char* sym_str)
{ {
/* find in kernel symbol table */ /* find in kernel symbol table */
struct rt_module_symtab* index; struct rt_module_symtab* index;
for (index = _rt_module_symtab_begin; index != _rt_module_symtab_end; index ++) for (index = _rt_module_symtab_begin; index != _rt_module_symtab_end; index ++)
{ {
if (rt_strcmp(index->name, (const char*)sym_str) == 0) if (rt_strcmp(index->name, sym_str) == 0)
return index->addr; return (rt_uint32_t)index->addr;
} }
return 0; return 0;
@ -249,14 +254,14 @@ static void rt_module_init_object_container(struct rt_module* module)
* @return the module object * @return the module object
* *
*/ */
rt_module_t rt_module_load(const rt_uint8_t* name, void* module_ptr) rt_module_t rt_module_load(const char* name, void* module_ptr)
{ {
rt_uint8_t *ptr = RT_NULL; rt_uint8_t *ptr = RT_NULL;
rt_module_t module = RT_NULL; rt_module_t module = RT_NULL;
rt_bool_t linked = RT_FALSE; rt_bool_t linked = RT_FALSE;
rt_uint32_t index, module_size = 0; rt_uint32_t index, module_size = 0;
rt_kprintf("rt_module_load: %s\n", name); rt_kprintf("rt_module_load: %s ,", name);
/* check ELF header */ /* check ELF header */
if (rt_memcmp(elf_module->e_ident, RTMMAG, SELFMAG) == 0) if (rt_memcmp(elf_module->e_ident, RTMMAG, SELFMAG) == 0)
@ -306,6 +311,8 @@ rt_module_t rt_module_load(const rt_uint8_t* name, void* module_ptr)
ptr = module->module_space; ptr = module->module_space;
rt_memset(ptr, 0, module_size); rt_memset(ptr, 0, module_size);
rt_kprintf(" load address at 0x%x\n", ptr);
for (index = 0; index < elf_module->e_phnum; index++) for (index = 0; index < elf_module->e_phnum; index++)
{ {
if(phdr[index].p_type == PT_LOAD) if(phdr[index].p_type == PT_LOAD)
@ -353,7 +360,7 @@ rt_module_t rt_module_load(const rt_uint8_t* name, void* module_ptr)
rt_kprintf("unresolved relocate symbol: %s\n", strtab + sym->st_name); rt_kprintf("unresolved relocate symbol: %s\n", strtab + sym->st_name);
#endif #endif
/* need to resolve symbol in kernel symbol table */ /* need to resolve symbol in kernel symbol table */
addr = rt_module_symbol_find(strtab + sym->st_name); addr = rt_module_symbol_find((const char*)(strtab + sym->st_name));
if (addr == 0) if (addr == 0)
{ {
rt_kprintf("can't find %s in kernel symbol table\n", strtab + sym->st_name); rt_kprintf("can't find %s in kernel symbol table\n", strtab + sym->st_name);
@ -378,7 +385,7 @@ rt_module_t rt_module_load(const rt_uint8_t* name, void* module_ptr)
{ {
/* find .dynsym section */ /* find .dynsym section */
rt_uint8_t* shstrab = (rt_uint8_t*) module_ptr + shdr[elf_module->e_shstrndx].sh_offset; rt_uint8_t* shstrab = (rt_uint8_t*) module_ptr + shdr[elf_module->e_shstrndx].sh_offset;
if (rt_strcmp(shstrab + shdr[index].sh_name, ELF_DYNSYM) == 0) break; if (rt_strcmp((const char *)(shstrab + shdr[index].sh_name), ELF_DYNSYM) == 0) break;
} }
/* found .dynsym section */ /* found .dynsym section */
@ -403,12 +410,12 @@ rt_module_t rt_module_load(const rt_uint8_t* name, void* module_ptr)
{ {
if((ELF_ST_BIND(symtab[i].st_info) == STB_GLOBAL) && (ELF_ST_TYPE(symtab[i].st_info) == STT_FUNC)) if((ELF_ST_BIND(symtab[i].st_info) == STB_GLOBAL) && (ELF_ST_TYPE(symtab[i].st_info) == STT_FUNC))
{ {
rt_size_t length = rt_strlen(strtab + symtab[i].st_name) + 1; rt_size_t length = rt_strlen((const char*)(strtab + symtab[i].st_name)) + 1;
module->symtab[count].addr = module->module_space + symtab[i].st_value; module->symtab[count].addr = (void*)(module->module_space + symtab[i].st_value);
module->symtab[count].name = rt_malloc(length); module->symtab[count].name = rt_malloc(length);
rt_memset(module->symtab[count].name, 0, length); rt_memset((void*)module->symtab[count].name, 0, length);
rt_memcpy(module->symtab[count].name, strtab + symtab[i].st_name, length); rt_memcpy((void*)module->symtab[count].name, strtab + symtab[i].st_name, length);
count++; count++;
} }
} }
@ -732,7 +739,7 @@ rt_err_t rt_module_unload(rt_module_t module)
rt_free(module->module_space); rt_free(module->module_space);
/* release module symbol table */ /* release module symbol table */
for(i=0; i<module->nsym; i++) rt_free(module->symtab[i].name); for(i=0; i<module->nsym; i++) rt_free((void *)module->symtab[i].name);
if(module->symtab != RT_NULL) rt_free(module->symtab); if(module->symtab != RT_NULL) rt_free(module->symtab);
/* delete module object */ /* delete module object */

186
src/rtm.c
View File

@ -26,130 +26,133 @@
/* /*
* thread interface symbol * thread interface symbol
*/ */
RTM_EXPORT(rt_thread_init)
RTM_EXPORT(rt_thread_detach) RTM_EXPORT(rt_thread_init);
RTM_EXPORT(rt_thread_create) RTM_EXPORT(rt_thread_detach);
RTM_EXPORT(rt_thread_self) RTM_EXPORT(rt_thread_create);
RTM_EXPORT(rt_thread_find) RTM_EXPORT(rt_thread_self);
RTM_EXPORT(rt_thread_startup) RTM_EXPORT(rt_thread_find);
RTM_EXPORT(rt_thread_delete) RTM_EXPORT(rt_thread_startup);
RTM_EXPORT(rt_thread_yield) RTM_EXPORT(rt_thread_delete);
RTM_EXPORT(rt_thread_delay) RTM_EXPORT(rt_thread_yield);
RTM_EXPORT(rt_thread_control) RTM_EXPORT(rt_thread_delay);
RTM_EXPORT(rt_thread_suspend) RTM_EXPORT(rt_thread_control);
RTM_EXPORT(rt_thread_resume) RTM_EXPORT(rt_thread_suspend);
RTM_EXPORT(rt_thread_timeout) RTM_EXPORT(rt_thread_resume);
RTM_EXPORT(rt_thread_timeout);
#ifdef RT_USING_SEMAPHORE #ifdef RT_USING_SEMAPHORE
/* /*
* semaphore interface symbol * semaphore interface symbol
*/ */
RTM_EXPORT(rt_sem_init) RTM_EXPORT(rt_sem_init);
RTM_EXPORT(rt_sem_detach) RTM_EXPORT(rt_sem_detach);
RTM_EXPORT(rt_sem_create) RTM_EXPORT(rt_sem_create);
RTM_EXPORT(rt_sem_delete) RTM_EXPORT(rt_sem_delete);
RTM_EXPORT(rt_sem_take) RTM_EXPORT(rt_sem_take);
RTM_EXPORT(rt_sem_trytake) RTM_EXPORT(rt_sem_trytake);
RTM_EXPORT(rt_sem_release) RTM_EXPORT(rt_sem_release);
RTM_EXPORT(rt_sem_control) RTM_EXPORT(rt_sem_control);
#endif #endif
#ifdef RT_USING_MUTEX #ifdef RT_USING_MUTEX
/* /*
* mutex interface symbol * mutex interface symbol
*/ */
RTM_EXPORT(rt_mutex_init) RTM_EXPORT(rt_mutex_init);
RTM_EXPORT(rt_mutex_detach) RTM_EXPORT(rt_mutex_detach);
RTM_EXPORT(rt_mutex_create) RTM_EXPORT(rt_mutex_create);
RTM_EXPORT(rt_mutex_delete) RTM_EXPORT(rt_mutex_delete);
RTM_EXPORT(rt_mutex_take) RTM_EXPORT(rt_mutex_take);
RTM_EXPORT(rt_mutex_release) RTM_EXPORT(rt_mutex_release);
RTM_EXPORT(rt_mutex_control) RTM_EXPORT(rt_mutex_control);
#endif #endif
#ifdef RT_USING_EVENT #ifdef RT_USING_EVENT
/* /*
* event interface symbol * event interface symbol
*/ */
RTM_EXPORT(rt_event_init) RTM_EXPORT(rt_event_init);
RTM_EXPORT(rt_event_detach) RTM_EXPORT(rt_event_detach);
RTM_EXPORT(rt_event_create) RTM_EXPORT(rt_event_create);
RTM_EXPORT(rt_event_delete) RTM_EXPORT(rt_event_delete);
RTM_EXPORT(rt_event_send) RTM_EXPORT(rt_event_send);
RTM_EXPORT(rt_event_recv) RTM_EXPORT(rt_event_recv);
RTM_EXPORT(rt_event_control) RTM_EXPORT(rt_event_control);
#endif #endif
#ifdef RT_USING_MAILBOX #ifdef RT_USING_MAILBOX
/* /*
* mailbox interface symbol * mailbox interface symbol
*/ */
RTM_EXPORT(rt_mb_init) RTM_EXPORT(rt_mb_init);
RTM_EXPORT(rt_mb_detach) RTM_EXPORT(rt_mb_detach);
RTM_EXPORT(rt_mb_create) RTM_EXPORT(rt_mb_create);
RTM_EXPORT(rt_mb_delete) RTM_EXPORT(rt_mb_delete);
RTM_EXPORT(rt_mb_send) RTM_EXPORT(rt_mb_send);
RTM_EXPORT(rt_mb_recv) RTM_EXPORT(rt_mb_recv);
RTM_EXPORT(rt_mb_control) RTM_EXPORT(rt_mb_control);
#endif #endif
#ifdef RT_USING_MESSAGEQUEUE #ifdef RT_USING_MESSAGEQUEUE
/* /*
* message queue interface symbol * message queue interface symbol
*/ */
RTM_EXPORT(rt_mq_init) RTM_EXPORT(rt_mq_init);
RTM_EXPORT(rt_mq_detach) RTM_EXPORT(rt_mq_detach);
RTM_EXPORT(rt_mq_create) RTM_EXPORT(rt_mq_create);
RTM_EXPORT(rt_mq_delete) RTM_EXPORT(rt_mq_delete);
RTM_EXPORT(rt_mq_send) RTM_EXPORT(rt_mq_send);
RTM_EXPORT(rt_mq_urgent) RTM_EXPORT(rt_mq_urgent);
RTM_EXPORT(rt_mq_recv) RTM_EXPORT(rt_mq_recv);
RTM_EXPORT(rt_mq_control) RTM_EXPORT(rt_mq_control);
#endif #endif
#ifdef RT_USING_MEMPOOL #ifdef RT_USING_MEMPOOL
/* /*
* memory pool interface symbol * memory pool interface symbol
*/ */
RTM_EXPORT(rt_mp_init) RTM_EXPORT(rt_mp_init);
RTM_EXPORT(rt_mp_detach) RTM_EXPORT(rt_mp_detach);
RTM_EXPORT(rt_mp_create) RTM_EXPORT(rt_mp_create);
RTM_EXPORT(rt_mp_delete) RTM_EXPORT(rt_mp_delete);
RTM_EXPORT(rt_mp_alloc) RTM_EXPORT(rt_mp_alloc);
RTM_EXPORT(rt_mp_free) RTM_EXPORT(rt_mp_free);
#endif #endif
#ifdef RT_USING_HEAP #ifdef RT_USING_HEAP
/* /*
* heap memory interface symbol * heap memory interface symbol
*/ */
RTM_EXPORT(rt_malloc) RTM_EXPORT(rt_malloc);
RTM_EXPORT(rt_free) RTM_EXPORT(rt_free);
RTM_EXPORT(rt_realloc) RTM_EXPORT(rt_realloc);
RTM_EXPORT(rt_calloc) RTM_EXPORT(rt_calloc);
#endif #endif
/* /*
* clock & timer interface symbol * clock & timer interface symbol
*/ */
RTM_EXPORT(rt_tick_get) RTM_EXPORT(rt_tick_get);
RTM_EXPORT(rt_tick_from_millisecond) RTM_EXPORT(rt_tick_from_millisecond);
RTM_EXPORT(rt_system_timer_init) RTM_EXPORT(rt_system_timer_init);
RTM_EXPORT(rt_system_timer_thread_init) RTM_EXPORT(rt_system_timer_thread_init);
RTM_EXPORT(rt_timer_init) RTM_EXPORT(rt_timer_init);
RTM_EXPORT(rt_timer_detach) RTM_EXPORT(rt_timer_detach);
RTM_EXPORT(rt_timer_create) RTM_EXPORT(rt_timer_create);
RTM_EXPORT(rt_timer_delete) RTM_EXPORT(rt_timer_delete);
RTM_EXPORT(rt_timer_start) RTM_EXPORT(rt_timer_start);
RTM_EXPORT(rt_timer_stop) RTM_EXPORT(rt_timer_stop);
RTM_EXPORT(rt_timer_control) RTM_EXPORT(rt_timer_control);
/* /*
* kservice interface symbol * kservice interface symbol
*/ */
RTM_EXPORT(rt_memcpy) RTM_EXPORT(rt_memcpy)
RTM_EXPORT(rt_memcmp)
RTM_EXPORT(rt_memset) RTM_EXPORT(rt_memset)
RTM_EXPORT(rt_kprintf) RTM_EXPORT(rt_kprintf)
RTM_EXPORT(rt_sprintf) RTM_EXPORT(rt_sprintf)
RTM_EXPORT(rt_strstr)
/* /*
* misc interface symbol * misc interface symbol
@ -160,6 +163,7 @@ extern int __aeabi_dmul;
extern int __aeabi_i2d; extern int __aeabi_i2d;
extern int __aeabi_uidiv; extern int __aeabi_uidiv;
extern int __aeabi_uidivmod; extern int __aeabi_uidivmod;
extern int __aeabi_idivmod;
extern int __aeabi_d2iz; extern int __aeabi_d2iz;
RTM_EXPORT(__aeabi_ddiv) RTM_EXPORT(__aeabi_ddiv)
@ -167,9 +171,11 @@ RTM_EXPORT(__aeabi_dmul)
RTM_EXPORT(__aeabi_i2d) RTM_EXPORT(__aeabi_i2d)
RTM_EXPORT(__aeabi_uidiv) RTM_EXPORT(__aeabi_uidiv)
RTM_EXPORT(__aeabi_idiv) RTM_EXPORT(__aeabi_idiv)
RTM_EXPORT(__aeabi_idivmod)
RTM_EXPORT(__aeabi_uidivmod) RTM_EXPORT(__aeabi_uidivmod)
RTM_EXPORT(__aeabi_d2iz) RTM_EXPORT(__aeabi_d2iz)
RTM_EXPORT(strcmp) RTM_EXPORT(strcmp)
RTM_EXPORT(strcpy)
RTM_EXPORT(strlen) RTM_EXPORT(strlen)
RTM_EXPORT(rand) RTM_EXPORT(rand)
RTM_EXPORT(memset) RTM_EXPORT(memset)
@ -189,13 +195,27 @@ RTM_EXPORT(time)
#endif #endif
#ifdef RT_USING_DFS
#include <dfs_posix.h>
RTM_EXPORT(open)
RTM_EXPORT(close)
RTM_EXPORT(read)
RTM_EXPORT(write)
RTM_EXPORT(stat)
#endif
#ifdef RT_USING_RTGUI #ifdef RT_USING_RTGUI
/* FIX ME , should be removed from here */ /* FIX ME , should be removed from here */
#include <rtgui/dc.h> #include <rtgui/dc.h>
#include <rtgui/rtgui_server.h>
#include <rtgui/rtgui_system.h> #include <rtgui/rtgui_system.h>
#include <rtgui/widgets/view.h> #include <rtgui/widgets/view.h>
#include <rtgui/widgets/workbench.h> #include <rtgui/widgets/workbench.h>
#include <rtgui/widgets/widget.h> #include <rtgui/widgets/widget.h>
#include <rtgui/widgets/button.h>
#include <rtgui/widgets/list_view.h>
#include <rtgui/widgets/filelist_view.h>
RTM_EXPORT(rtgui_view_show) RTM_EXPORT(rtgui_view_show)
RTM_EXPORT(rtgui_view_create) RTM_EXPORT(rtgui_view_create)
@ -212,11 +232,27 @@ RTM_EXPORT(rtgui_workbench_destroy)
RTM_EXPORT(rtgui_workbench_close) RTM_EXPORT(rtgui_workbench_close)
RTM_EXPORT(rtgui_timer_start) RTM_EXPORT(rtgui_timer_start)
RTM_EXPORT(rtgui_timer_create) RTM_EXPORT(rtgui_timer_create)
RTM_EXPORT(rtgui_timer_destory)
RTM_EXPORT(rtgui_timer_stop) RTM_EXPORT(rtgui_timer_stop)
RTM_EXPORT(rtgui_widget_focus)
RTM_EXPORT(rtgui_widget_set_event_handler)
RTM_EXPORT(rtgui_thread_register) RTM_EXPORT(rtgui_thread_register)
RTM_EXPORT(rtgui_thread_deregister) RTM_EXPORT(rtgui_thread_deregister)
RTM_EXPORT(rtgui_widget_focus)
RTM_EXPORT(rtgui_widget_set_event_handler)
RTM_EXPORT(rtgui_widget_rect_to_device)
RTM_EXPORT(rtgui_widget_update)
RTM_EXPORT(rtgui_widget_get_rect)
RTM_EXPORT(rtgui_widget_set_rect)
RTM_EXPORT(rtgui_widget_get_toplevel)
RTM_EXPORT(rtgui_panel_register)
RTM_EXPORT(rtgui_panel_set_default_focused)
RTM_EXPORT(rtgui_button_create)
RTM_EXPORT(rtgui_button_destroy)
RTM_EXPORT(rtgui_button_set_onbutton)
RTM_EXPORT(rtgui_container_add_child)
RTM_EXPORT(rtgui_filelist_view_create)
RTM_EXPORT(rtgui_filelist_view_get_fullpath)
RTM_EXPORT(rtgui_list_view_create)
RTM_EXPORT(rtgui_list_view_destroy)
#endif
#endif
#endif
#endif