Change the ARMv7 dispatch stubs to use ARM instead of Thumb. There's no
difference in size (since either one fits in the 128-byte alignment that
we use), but using ARM means that they'll compile and work on an ARMv6
build as well.
In __glDispatchMakeCurrent, it allocates a
__GLdispatchThreadStatePrivate struct, which would normally get freed in
__glDispatchLoseCurrent.
However, if the library gets unloaded while another thread still has a
current context, then __glDispatchLoseCurrent never gets called, and so
that memory leaks.
Add the __GLdispatchThreadStatePrivate to a linked list so that it can
free any remaining structs in __glDispatchFini.
Fixes https://gitlab.freedesktop.org/glvnd/libglvnd/-/issues/230.
In the EGL destructor, DestroyThreadState gets called by
__eglCurrentTeardown to free the threadState, but the threadState does
not get changed to NULL when this happens.
The function eglReleaseThread calls __eglDestroyCurrentThreadAPIState,
which does set the threadState to NULL, right before calling
DestroyThreadState. Both eglReleaseThread and
__eglDestroyCurrentThreadAPIState check to make sure the threadState is
NULL before continuing.
If eglReleaseThread gets externally called after destruction, the
threadState is not NULL, so DestroyThreadState will be called to free
the threadState that was already freed by the destructor, causing a
double free.
This change is to add the same setting threadState to NULL in
__eglCurrentTeardown as which already __eglDestroyCurrentThreadAPIState,
to prevent this double free situation.
When Branch Target Identifier (BTI) is enabled on aarch64,
any software which run libglvnd will fail with SIGILL, Illegal instruction.
This is because some assembler code misses the BTI landing pads.
See: https://developer.arm.com/documentation/102433/0100/Jump-oriented-programming
"hint #34" is the same thing as "BTI C" landing pad, but keep
compatibility with systems without BTI enabled.
Updated the EGL headers and XML file to the Khronos repository, from commit
0997d5398d9de08ac012e7230d6546eb342c2939.
Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
The code here is a complicated way to write exactly the same thing. If
`get_option('x11')` returns `disabled`, ie `-Dx11=disabled` then
`dependency()` short circuits and returns a not found object (just like
`dependency('', required : false)`, but with the correct name for error
messages).
There are KHR, EXT, and NV versions of eglQueryDisplayAttrib, so add
support for all of them.
Define separate eglQueryDisplayAttribEXT, eglQueryDisplayAttribKHR, and
eglQueryDisplayAttribNV functions. They all call into the same common
function, with the only difference being the name passed to an error
callback.
When loading a vendor library, check for the vendor's
eglQueryDisplayAttrib using all three suffixes, and use whichever one is
available.
Added implementations for eglQueryDisplayAttribEXT, eglQueryDeviceAttribEXT,
and eglQueryDeviceStringEXT.
Defined a new EGL_DEVICE_INDEX attribute for eglGetPlatformDisplay that uses
a device based on its index. This will allow us to test the case where
eglQueryDisplayAttribEXT returns an EGLDeviceEXT handle that libglvnd hasn't
seen before.
Added a new test program, testegldeviceadd, which tests a vendor library adding
a new EGLDeviceEXT handle after the application calls eglQueryDevicesEXT.
It's got two subtests right now. "querydevices" will test returning the new
device through a second eglQueryDevicesEXT call. "returndevice" tests returning
the new device through a vendor-provided dispatch stub.
Updated egl_test_utils.c/h to include the new eglTestReturnDevice function.
Added functions to egl_test_utils.c/h to load each vendor's DummySetDeviceCount
function using dlopen+dlsym.
Added a new function to the EGL dummy vendor called DummySetDeviceCount, which
will change the number of devices that it hands back for eglQueryDevicesEXT.
Also added a new dummy extension function, eglTestReturnDevice, which will
dispatch based on an EGLDisplay and return an EGLDeviceEXT handle. This is
used to test the new __EGLapiExports::setVendorForDevice function.
Add a dispatch stub for eglQueryDisplayAttribEXT, which updates the device
hashtable if the application queries EGL_DEVICE_EXT.
It's possible that eglQueryDisplayAttribEXT could return an EGLDeviceEXT handle
that wasn't returned by eglQueryDevicesEXT, so the dispatch stub needs to add
the handle to the device hashtable.
Export a new __EGLapiExports::setVendorForDevice function, which allows
dispatch stubs to update the device hashtable when something returns an
EGLDeviceEXT handle.
Bumped the ABI version number to 1.2.
It's possible for new devices to become available while a program is running,
so eglQueryDevicesEXT might need to return a different list.
Change the EGLDeviceEXT hashtable so that each entry is allocated and added
separately, rathat than allocating every entry in a single malloc.
Added a new __eglAddDevice function, which adds an entry to the device
hashtable.
When the application calls eglQueryDevicesEXT, always call through to each
vendor library, and add (or update) each EGLDeviceEXT to the hashtable.
There's still no provision for removing an entry from the device hashtable. The
semantics of hot-unplugging a device aren't defined yet, and there's no way to
ensure that libglvnd's mapping will get updated if a device disappears
asynchonously, so it's up to the vendor library to deal with the old handle.
The EGL tests don't use X11, and only included the Xlib headers by way
of eglplatform.h.
Now that we don't set the USE_X11 macro anymore, eglplatform.h won't try
to include anything from Xlib, and so the EGL tests don't need X11 as a
dependency.
If x11 support is enabled, then the meson and configure scripts will set
a macro named ENABLE_EGL_X11 instead of USE_X11.
USE_X11 will also select the Xlib typedef of EGLNativeDisplayType in
eglplatform.h, and libglvnd does not need or want those.
Enabling or disabling X11 support for EGL only affects platform
detection in eglGetDisplay. The rest of libEGL is supposed to treat
EGLNativeDisplayType as an opaque void* pointer.
Currently, building with -Dx11=disabled or -Dx11=auto gives identical
results.
In both cases, it only makes the x11 dependency optional: It'll still
look for libx11, and if libx11 is available, then it'll still build with
X11 support enabled.
This changes the meson build so that if you pass -Dx11=disabled, then it
will use a dummy dependency for x11, which will cause it to build as if
libx11 was not available.
Also delete files and folders that are only useful in the original
repository. Updating uthash to this version allows compiling with
CHERI LLVM where the current version of uthash (1.9.8) triggers a
warning that our build infrastructure includes in -Werror by default:
```
../../libglvnd/src/util/winsys_dispatch.c:154:9: error: cast from provenance-free integer type to pointer type will give pointer that can not be dereferenced [-Werror,-Wcheri-capability-misuse]
../../libglvnd/include/lkdhash.h:86:5: note: expanded from macro 'LKDHASH_TEARDOWN'
LKDHASH_TEARDOWN_2(_lh, _param, cur ## _ht, \
^
../../libglvnd/include/lkdhash.h:55:9: note: expanded from macro 'LKDHASH_TEARDOWN_2'
HASH_DEL(_LH(_lockedhash), _cur); \
^
../../libglvnd/src/util/uthash/src/uthash.h:271:5: note: expanded from macro 'HASH_DEL'
HASH_DELETE(hh,head,delptr)
^
../../libglvnd/src/util/uthash/src/uthash.h:239:14: note: expanded from macro 'HASH_DELETE'
((UT_hash_handle*)((ptrdiff_t)_hd_hh_del->next + \
^
```
Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
I missed this in 396c10bdd7 since I was
building with -Dglx=disabled. This fixes the build with glx if the X11
libraries are installed into a custom prefix.
Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
This fixes the build for me since I have libX11 installed to a custom
prefix, so the default include path does not include libX11. This fixes
lots of instances of the following error:
../../libglvnd/include/EGL/eglplatform.h:109:10: fatal error: 'X11/Xlib.h' file not found
Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Remove the "If only executable code is distributed..." paragraph from
the license text. Everything now uses a normal MIT license.
The only code from Khronos that's included in libglvnd is the EGL/GL
header and XML files, which do not contain that paragraph.
Fixes https://gitlab.freedesktop.org/glvnd/libglvnd/-/issues/221
LLVM currently ignores inline assembly references to symbols during
dead code and data elimination while linking with link-time optimizations
enabled.
This manifests in a very large amount of unresolved references to
entrypointFunctions when building libglvnd using clang with LTO enabled.
This issue fixes#220 by marking the entrypointFunctions array as used,
using a compiler attribute.
Signed-off-by: Charlotte Delenk <darkkirb@darkkirb.de>