[Pixman] [PATCH] build: Support building Loongson code for 2e, 2f, 3a
Matt Turner
mattst88 at gmail.com
Sat Jan 26 18:57:02 PST 2013
Some preemptive explanations:
On Sat, Jan 26, 2013 at 6:54 PM, Matt Turner <mattst88 at gmail.com> wrote:
> diff --git a/pixman/pixman-mips.c b/pixman/pixman-mips.c
> index 3048813..77bef5c 100644
> --- a/pixman/pixman-mips.c
> +++ b/pixman/pixman-mips.c
> @@ -27,6 +27,10 @@
>
> #if defined(USE_MIPS_DSPR2) || defined(USE_LOONGSON_MMI)
>
> +#ifdef DLOPEN_LOONGSON_MMI
> +#include <dlfcn.h>
> +#endif
> +
> #include <string.h>
> #include <stdlib.h>
>
> @@ -69,10 +73,64 @@ pixman_implementation_t *
> _pixman_mips_get_implementations (pixman_implementation_t *imp)
> {
> #ifdef USE_LOONGSON_MMI
> + void *mmi_handle = NULL;
mmi_handle is outside of DLOPEN_LOONGSON_MMI so that I don't have to
do funny things to the if-statements below. In the !dlopen case, I
expect gcc to recognize that it's always NULL and optimize it
completely out.
> +#ifdef DLOPEN_LOONGSON_MMI
> + pixman_implementation_t *(*_pixman_implementation_create_mmx) (pixman_implementation_t *);
> +#endif
> /* I really don't know if some Loongson CPUs don't have MMI. */
> - if (!_pixman_disabled ("loongson-mmi") && have_feature ("Loongson"))
> +#ifdef HAVE_LOONGSON2E_MMI
> + if (!mmi_handle && !_pixman_disabled ("loongson-mmi")
> + && have_feature ("Loongson") && have_feature ("-2e"))
> + {
> +#ifdef DLOPEN_LOONGSON_MMI
> + mmi_handle = dlopen("libpixman-1-loongson2e-mmi.so", RTLD_LAZY | RTLD_LOCAL);
> +#else
> + imp = _pixman_implementation_create_mmx (imp);
> +#endif
> + }
> +#endif
> +#ifdef HAVE_LOONGSON2F_MMI
> + if (!mmi_handle && !_pixman_disabled ("loongson-mmi")
> + && have_feature ("Loongson") && have_feature ("-2f"))
> + {
> +#ifdef DLOPEN_LOONGSON_MMI
> + mmi_handle = dlopen("libpixman-1-loongson2f-mmi.so", RTLD_LAZY | RTLD_LOCAL);
> +#else
> + imp = _pixman_implementation_create_mmx (imp);
> +#endif
> + }
> +#endif
> +#ifdef HAVE_LOONGSON3A_MMI
> + if (!mmi_handle && !_pixman_disabled ("loongson-mmi")
> + && have_feature ("Loongson-3A"))
> + {
> +#ifdef DLOPEN_LOONGSON_MMI
> + mmi_handle = dlopen("libpixman-1-loongson3a-mmi.so", RTLD_LAZY | RTLD_LOCAL);
> +#else
> imp = _pixman_implementation_create_mmx (imp);
> #endif
> + }
> +#endif
> +
> +#ifdef DLOPEN_LOONGSON_MMI
> + if (mmi_handle)
> + {
> + _pixman_implementation_create_mmx = dlsym(mmi_handle, "_pixman_implementation_create_mmx");
> + if (_pixman_implementation_create_mmx)
> + {
> + imp = _pixman_implementation_create_mmx (imp);
> + }
> + else
> + {
> + puts(dlerror());
> + }
> + }
> + else
> + {
> + puts(dlerror());
> + }
> +#endif
> +#endif
I don't ever dlclose() the handle. I expect that it will be live for
the rest of process execution. I think there are other cases of
"leaks" like this in pixman already.
> #ifdef USE_MIPS_DSPR2
> if (!_pixman_disabled ("mips-dspr2"))
More information about the Pixman
mailing list