Merge branch 'haikuwork' into 'main'

port: Haiku Build Support

See merge request mesa/libdrm!78
This commit is contained in:
Alexander von Gluck 2026-01-05 23:27:08 +00:00
commit 168c17c717
4 changed files with 25 additions and 8 deletions

View file

@ -28,7 +28,6 @@
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <err.h>
#include "libdrm_macros.h"
#include "intel_bufmgr.h"
@ -52,17 +51,23 @@ read_file(const char *filename, void **ptr, size_t *size)
struct stat st;
fd = open(filename, O_RDONLY);
if (fd < 0)
errx(1, "couldn't open `%s'", filename);
if (fd < 0) {
fprintf(stderr, "couldn't open `%s'\n", filename);
exit(1);
}
ret = fstat(fd, &st);
if (ret)
errx(1, "couldn't stat `%s'", filename);
if (ret) {
fprintf(stderr, "couldn't stat `%s'\n", filename);
exit(1);
}
*size = st.st_size;
*ptr = drm_mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (*ptr == MAP_FAILED)
errx(1, "couldn't map `%s'", filename);
if (*ptr == MAP_FAILED) {
fprintf(stderr, "couldn't map `%s'\n", filename);
exit(1);
}
close(fd);
}

View file

@ -39,6 +39,11 @@ def get_symbols(nm, lib):
if platform_name == 'Linux':
if symbol_name in PLATFORM_SYMBOLS:
continue
elif platform_name == 'Haiku':
if symbol_name in PLATFORM_SYMBOLS:
continue
if symbol_name in ['_gSharedObjectHaikuABI', '_gSharedObjectHaikuVersion']:
continue
elif platform_name == 'Darwin':
assert symbol_name[0] == '_'
symbol_name = symbol_name[1:]

View file

@ -36,7 +36,7 @@ static int failed;
static int import_fd;
#if defined(__GLIBC__) || defined(__FreeBSD__)
#if defined(__GLIBC__) || defined(__FreeBSD__) || defined(__HAIKU__)
int ioctl(int fd, unsigned long request, ...)
#else
int ioctl(int fd, int request, ...)

View file

@ -66,6 +66,13 @@ extern "C" {
#define DRM_IOC_READWRITE IOC_INOUT
#define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
#endif
#if defined(__HAIKU__) && !defined(makedev)
/* Haiku has the POSIX dev_t type, no makedev macro though */
#define makedev(major,minor) (((major) << 8) | ((minor) & 0xff))
#define major(dev) ((int)(((dev) >> 8) & 0xff))
#define minor(dev) ((int)((dev) & 0xff))
#endif
/* Defaults, if nothing set in xf86config */