mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-07 01:53:24 +09:00
[Fix] (gbm): the two defects only the Android build could find
Neither showed up in the Linux build that verified this library, and both are the kind that would have been found by the first person to build the phone half - so they are fixed here rather than left for that person. bionic only declares memfd_create from API 30 and this library builds against 26. The kernel call is far older than the declaration, so it is asked for by number: the same call with the name the headers of this API level do not carry yet. The library carries the tree's logger, which reaches Android's own log through liblog. The main target gets that library in its own Android block; a second target built from the same sources needs it for the same reason, and without it the link is what fails rather than anything in the code.
This commit is contained in:
@@ -1240,3 +1240,10 @@ if (ANDROID AND MOBILEGL_BUILD_EXTMEM_PROBE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# The GBM library carries the tree's logger, which reaches Android's own log. The main target gets
|
||||
# these libraries in its own Android block; a library built from the same sources needs them for the
|
||||
# same reason, and without them it is the LINK that fails rather than anything in the code.
|
||||
if (ANDROID)
|
||||
target_link_libraries(MobileGLGbm PRIVATE log android)
|
||||
endif()
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cerrno>
|
||||
@@ -139,7 +140,15 @@ namespace MobileGL::MG_Gbm
|
||||
device.HeapPath.c_str(), alignedSize, heapErrno, strerror(heapErrno));
|
||||
}
|
||||
|
||||
#if defined(__ANDROID__) && __ANDROID_API__ < 30
|
||||
// BIONIC ONLY DECLARES memfd_create FROM API 30, and this library builds against 26.
|
||||
// The kernel call is far older than the declaration - it has been there since 3.17 - so
|
||||
// asking for it by number is not a workaround for a missing feature, it is the same call
|
||||
// with the name the headers of this API level do not carry yet.
|
||||
const Int fd = static_cast<Int>(::syscall(__NR_memfd_create, "mobilegl-gbm", MFD_CLOEXEC));
|
||||
#else
|
||||
const Int fd = memfd_create("mobilegl-gbm", MFD_CLOEXEC);
|
||||
#endif
|
||||
if (fd < 0)
|
||||
{
|
||||
MGLOG_E_ONCE("gbm: memfd_create failed (%d: %s) and no dma-heap node is usable, so no "
|
||||
|
||||
Reference in New Issue
Block a user