The strdup() function is available on uClibc if _XOPEN_SOURCE_EXTENDED
is defined; since we're using _GNU_SOURCE elsewhere to enable extended
libc features, and uClibc will set _XOPEN_SOURCE_EXTENDED if _GNU_SOURCE
is set, let's use that.
Closes#181
When building on macOS we don't have access to EGL, and GLX support is
conditional.
We should ensure we're using the appropriate paths depending on the
platform, and protect our use of macros to avoid undefined symbols.
Closes: #176
Our caller may load (eg) epoxy_glAlphaFunc, which is a function pointer,
and then call through that value multiple times. Until the caller
re-examines the value of that function pointer, which is a copy
relocation in the executable, repeated calls mean repeated work
resolving the GL function.
We can't make the caller reinspect the variable, but the resolver
function can avoid doing redundant work.
Fixes: anholt/libepoxy#171
Signed-off-by: Adam Jackson <ajax@redhat.com>
Epoxy updates the function pointers in order to avoid calling the
resolver multiple times, but with -Bsymbolic we're going to update the
copy inside libepoxy, instead of the relocated copy in the code using
libepoxy. This leads to libepoxy constantly querying the function
resolver code instead of just once.
We still want to avoid intra-library relocations for our functions,
but we need to live with them for our global function pointers.
See issue #171
We want to consistently handle exceptions for the internal state checks;
calling `exit()` does not allow us to attach a debugger and get a proper
trace.
FreeBSD hides declarations of non-POSIX functions when POSIX macros,
such as _POSIX_C_SOURCE or _XOPEN_SOURCE, is defined. This causes
test/dlwrap.c to fail to compile because it uses dlvsym and asprintf.
Fixes: #169
Now that we're being conservative about probing libraries, these
entrypoints would not succeed unless the caller had already dlopened
stuff themselves, or had explicitly linked against the provider library.
Both of those are exactly not what we want.
Signed-off-by: Adam Jackson <ajax@redhat.com>
Mostly this is to get all the calls to get_dlopen_handle nicely isolated
so they're easier to reason about.
Signed-off-by: Adam Jackson <ajax@redhat.com>
dlsym(NULL) can only see (symbols in) libraries that are loaded
RTLD_GLOBAL, but our dlopen()s are RTLD_LOCAL and probably so was the
one the app did if it did one. So use RTLD_NOLOAD to probe for the
library even if it's LOCAL, iff the lookup is non-fatal.
Having done that, don't ever load any libraries on this path. We only
perform this check while resolving rendering API functions, and the
window system resolution paths already load the appropriate library if
they need to. Since you have to have gone through a winsys to get a
context, and our resolvers only run when a function is _called_, this
would only introduce a failure mode if you tried to call a function
without a context bound.
Signed-off-by: Adam Jackson <ajax@redhat.com>
We're about to change our dlopen paths to do RTLD_NOLOAD more
aggressively. The issue then is we can create an EGL GLES context
without libGLES* ever being loaded. test/egl_gles2_without_glx will fail
in such a world: the first gentle probe for libGLESv2 will fail, then
the less-gentle probe for libGLESv1_CM will be shot down by the test,
and we exit.
Fortunately by the time we've gotten to this point the context exists,
so we can query its version via EGL instead.
Signed-off-by: Adam Jackson <ajax@redhat.com>
If you've built Mesa with --disable-texture-float, and try to run the
tests against Xvfb, glx_public_api_core will fail: creating a direct
context with llvmpipe will fail because you don't have
ARB_texture_float, and the internal fallback to an indirect context will
fail because indirect only supports through 1.4. So the server will
throw GLXBadFBConfig at you to say "I don't support core contexts",
which we should interpret as a skip not a failure.
Signed-off-by: Adam Jackson <ajax@redhat.com>
Meson 0.46 introduced a function to check for linker flags passed to the
compiler; since the version is really brand new, I don't want to bump
the dependency on Meson just yet, so we're going to conditionally use
get_supported_link_arguments() only if we're building with Meson 0.46 or
later.
As per the previous commit, instead of assuming that Apple doesn't have dlvsym
but everywhere else does, actually check for dlvsym() existing as that function
is glibc-specific.
build_apple was introduced in 756dca as a proxy for the fact that Apple's libc
doesn't have dlvsym(), which is glibc-specific so also isn't present in other
libc implementations such as musl.
Instead of detecting whether we are building for Apple or not, just probe the to
see if we have dlvsym.
Even though meson will find the dependency gl on macOS, this does not mean that
there is a pkg-config file for it, as meson does not use pkg-config to
establish its presence. It should therefore not be added to
the libepoxy pkg-config file as a (private) requirement.
The GL version minor numbers haven't hit 10, yet, but if they do we're
going to get non-sensical encoded versions when calling
epoxy_gl_version(), like we're getting right now, with the GLSL version
numbers.
If the minor number is larger than the multiplication factor used for
the major number, we should bump up the factor to the next order of
magnitude.