[waffle] [PATCH v2 8/8] nacl: add implementation for waffle_dl_sym
Emil Velikov
emil.l.velikov at gmail.com
Thu Feb 12 03:02:01 PST 2015
On 9 February 2015 at 13:24, Tapani Pälli <tapani.palli at intel.com> wrote:
> v2: use wcore_calloc, code cleanup (Emil Velikov)
> open dll only once in can_open (Chad Versace)
>
> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
> ---
> src/waffle/nacl/nacl_platform.c | 69 +++++++++++++++++++++++++++++++++++++++--
> src/waffle/nacl/nacl_platform.h | 1 +
> 2 files changed, 68 insertions(+), 2 deletions(-)
>
> diff --git a/src/waffle/nacl/nacl_platform.c b/src/waffle/nacl/nacl_platform.c
> index c4fefe5..22169da 100644
> --- a/src/waffle/nacl/nacl_platform.c
> +++ b/src/waffle/nacl/nacl_platform.c
> @@ -43,6 +43,11 @@ nacl_platform_destroy(struct wcore_platform *wc_self)
>
> nacl_teardown(self->nacl);
>
> + if (self->gl_dl)
> + if (dlclose(self->gl_dl) != 0)
> + wcore_errorf(WAFFLE_ERROR_UNKNOWN, "dlclose failed: %s",
> + dlerror());
> +
> free(self);
> return ok;
> }
> @@ -51,7 +56,41 @@ static bool
> nacl_platform_dl_can_open(struct wcore_platform *wc_self,
> int32_t waffle_dl)
> {
> - return false;
> + struct nacl_platform *self = nacl_platform(wc_self);
> +
> + switch (waffle_dl) {
> + case WAFFLE_DL_OPENGL_ES2:
> + if (!self->gl_dl)
> + self->gl_dl = dlopen(NACL_GLES2_LIBRARY, RTLD_LAZY);
> + break;
> + // API not supported
> + default:
> + return false;
> + }
> +
> + if (!self->gl_dl)
> + wcore_errorf(WAFFLE_ERROR_UNKNOWN, "dlopen failed: %s", dlerror());
> +
> + return self->gl_dl ? true : false;
> +}
> +
> +// Construct a string that maps GL function to NaCl function
> +// by concating given prefix and function name tail from 'src'.
> +static char *
> +nacl_prefix(const char *src, const char *prefix)
> +{
> + if (strncmp(src, "gl", 2) != 0)
> + return NULL;
> +
> + uint32_t len = strlen(src) + strlen(prefix);
> +
> + char *dst = wcore_calloc(len);
> + if (!dst)
> + return NULL;
> +
> + snprintf(dst, len, "%s%s", prefix, src + 2);
> +
> + return dst;
> }
>
> static void*
> @@ -59,7 +98,33 @@ nacl_platform_dl_sym(struct wcore_platform *wc_self,
> int32_t waffle_dl,
> const char *name)
> {
> - return NULL;
> + struct nacl_platform *self = nacl_platform(wc_self);
> + char *nacl_name = NULL;
> + void *func = NULL;
> +
> + if (!self->gl_dl)
> + if (!nacl_platform_dl_can_open(wc_self, waffle_dl))
I'm sorry boring this again but - doing this will not set the correct
error on WAFFLE_DL_OPENGL_ES3.
> + return false;
return NULL;
Cheers,
Emil
More information about the waffle
mailing list