diff options
author | Thomas Martitz <kugel@rockbox.org> | 2012-05-26 22:46:56 +0200 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2012-05-26 22:46:56 +0200 |
commit | 3f365fc06b67f8842b2e155349110f7c5659768d (patch) | |
tree | 3c83d9fc4802331cf542bfb23546a52b2190ba5c /firmware/target/hosted/lc-unix.c | |
parent | 3f72ba0e3f34ac47a83a426e6a19b96045b842de (diff) | |
download | rockbox-3f365fc06b67f8842b2e155349110f7c5659768d.tar.gz rockbox-3f365fc06b67f8842b2e155349110f7c5659768d.zip |
load_code: Get rid of win32 specific code in favor SDL_LoadFunction & friends APIs.
Refactor native/hosted implementation seperation while at it
(no wrappers starting with _ anymore).
Change-Id: If68ae89700443bb3be483c1cace3d6739409560a
Diffstat (limited to 'firmware/target/hosted/lc-unix.c')
-rw-r--r-- | firmware/target/hosted/lc-unix.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/firmware/target/hosted/lc-unix.c b/firmware/target/hosted/lc-unix.c index 8a265de066..6e5f15ec99 100644 --- a/firmware/target/hosted/lc-unix.c +++ b/firmware/target/hosted/lc-unix.c | |||
@@ -20,24 +20,44 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include <string.h> /* size_t */ | 22 | #include <string.h> /* size_t */ |
23 | #include <dlfcn.h> | ||
24 | #include "debug.h" | ||
23 | #include "load_code.h" | 25 | #include "load_code.h" |
24 | 26 | ||
25 | /* unix specific because WIN32 wants UCS instead of UTF-8, so filenames | ||
26 | * need to be converted */ | ||
27 | |||
28 | /* plain wrappers , nothing to do */ | ||
29 | void *lc_open(const char *filename, unsigned char *buf, size_t buf_size) | 27 | void *lc_open(const char *filename, unsigned char *buf, size_t buf_size) |
30 | { | 28 | { |
31 | return _lc_open(filename, buf, buf_size); | 29 | (void)buf; |
30 | (void)buf_size; | ||
31 | void *handle = dlopen(filename, RTLD_NOW); | ||
32 | if (handle == NULL) | ||
33 | { | ||
34 | DEBUGF("failed to load %s\n", filename); | ||
35 | DEBUGF("lc_open(%s): %s\n", filename, dlerror()); | ||
36 | } | ||
37 | return handle; | ||
32 | } | 38 | } |
33 | 39 | ||
34 | void *lc_get_header(void *handle) | 40 | void *lc_get_header(void *handle) |
35 | { | 41 | { |
36 | return _lc_get_header(handle); | 42 | char *ret = dlsym(handle, "__header"); |
43 | if (ret == NULL) | ||
44 | ret = dlsym(handle, "___header"); | ||
45 | |||
46 | return ret; | ||
37 | } | 47 | } |
38 | 48 | ||
39 | void lc_close(void *handle) | 49 | void lc_close(void *handle) |
40 | { | 50 | { |
41 | _lc_close(handle); | 51 | dlclose(handle); |
42 | } | 52 | } |
43 | 53 | ||
54 | void *lc_open_from_mem(void *addr, size_t blob_size) | ||
55 | { | ||
56 | (void)addr; | ||
57 | (void)blob_size; | ||
58 | /* we don't support loading code from memory on application builds, | ||
59 | * it doesn't make sense (since it means writing the blob to disk again and | ||
60 | * then falling back to load from disk) and requires the ability to write | ||
61 | * to an executable directory */ | ||
62 | return NULL; | ||
63 | } | ||