diff --color -rupN old/include/c99_alloca.h new/include/c99_alloca.h
--- old/include/c99_alloca.h	2021-07-01 02:18:55.320469900 +0800
+++ new/include/c99_alloca.h	2021-12-30 17:00:52.904429824 +0800
@@ -41,6 +41,7 @@
 
 #else /* !defined(_MSC_VER) */
 
+#  include <alloca.h>
 #  include <stdlib.h>
 
 #endif /* !defined(_MSC_VER) */
diff --color -rupN old/include/drm-uapi/drm.h new/include/drm-uapi/drm.h
--- old/include/drm-uapi/drm.h	2021-07-01 02:18:55.321470000 +0800
+++ new/include/drm-uapi/drm.h	2021-12-30 17:01:34.480854422 +0800
@@ -42,6 +42,12 @@
 #include <asm/ioctl.h>
 typedef unsigned int drm_handle_t;
 
+#elif defined(__lyos__)
+
+#include <lyos/types.h>
+#include <asm/ioctl.h>
+typedef unsigned int drm_handle_t;
+
 #else /* One of the BSDs */
 
 #include <stdint.h>
diff --color -rupN old/meson.build new/meson.build
--- old/meson.build	2021-07-01 02:18:55.330470000 +0800
+++ new/meson.build	2021-12-30 17:02:38.320497542 +0800
@@ -154,7 +154,7 @@ with_any_opengl = with_opengl or with_gl
 # Only build shared_glapi if at least one OpenGL API is enabled
 with_shared_glapi = with_shared_glapi and with_any_opengl
 
-system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux', 'sunos'].contains(host_machine.system())
+system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux', 'sunos', 'lyos'].contains(host_machine.system())
 
 dri_drivers = get_option('dri-drivers')
 if dri_drivers.contains('auto')
@@ -972,7 +972,7 @@ if cc.compiles('__uint128_t foo(void) {
 endif
 
 # TODO: this is very incomplete
-if ['linux', 'cygwin', 'gnu', 'freebsd', 'gnu/kfreebsd', 'haiku'].contains(host_machine.system())
+if ['linux', 'cygwin', 'gnu', 'freebsd', 'gnu/kfreebsd', 'haiku', 'lyos'].contains(host_machine.system())
   pre_args += '-D_GNU_SOURCE'
 elif host_machine.system() == 'sunos'
   pre_args += '-D__EXTENSIONS__'
@@ -1034,11 +1034,9 @@ if cc.get_id() == 'msvc'
   endforeach
 else
   _trial = [
-    '-Werror=implicit-function-declaration',
     '-Werror=missing-prototypes',
     '-Werror=return-type',
     '-Werror=empty-body',
-    '-Werror=incompatible-pointer-types',
     '-Werror=int-conversion',
     '-Wimplicit-fallthrough',
     '-Werror=thread-safety',
diff --color -rupN old/src/compiler/glsl/glsl_lexer.ll new/src/compiler/glsl/glsl_lexer.ll
--- old/src/compiler/glsl/glsl_lexer.ll	2021-07-01 02:18:55.420472000 +0800
+++ new/src/compiler/glsl/glsl_lexer.ll	2021-12-30 17:03:05.023680624 +0800
@@ -22,7 +22,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 #include <ctype.h>
-#include <limits.h>
+#include <climits>
 #include "util/strtod.h"
 #include "ast.h"
 #include "glsl_parser_extras.h"
diff --color -rupN old/src/gallium/include/pipe/p_config.h new/src/gallium/include/pipe/p_config.h
--- old/src/gallium/include/pipe/p_config.h	2021-07-01 02:18:55.847480300 +0800
+++ new/src/gallium/include/pipe/p_config.h	2021-12-30 17:03:35.550174012 +0800
@@ -137,6 +137,10 @@
 #define PIPE_OS_LINUX
 #endif
 
+#if DETECT_OS_LYOS
+#define PIPE_OS_LYOS
+#endif
+
 #if DETECT_OS_UNIX
 #define PIPE_OS_UNIX
 #endif
diff --color -rupN old/src/util/detect_os.h new/src/util/detect_os.h
--- old/src/util/detect_os.h	2021-07-01 02:18:56.182486800 +0800
+++ new/src/util/detect_os.h	2021-12-30 17:04:41.573132207 +0800
@@ -81,6 +81,10 @@
 #define DETECT_OS_UNIX 1
 #endif
 
+#if defined(__lyos__)
+#define DETECT_OS_LYOS 1
+#define DETECT_OS_UNIX 1
+#endif
 
 /*
  * Make sure DETECT_OS_* are always defined, so that they can be used with #if
@@ -127,5 +131,7 @@
 #ifndef DETECT_OS_WINDOWS
 #define DETECT_OS_WINDOWS 0
 #endif
-
+#ifndef DETECT_OS_LYOS
+#define DETECT_OS_LYOS 0
+#endif
 #endif /* DETECT_OS_H */
diff --color -rupN old/src/util/os_file.c new/src/util/os_file.c
--- old/src/util/os_file.c	2021-07-01 02:18:56.214487600 +0800
+++ new/src/util/os_file.c	2021-12-30 17:05:10.036303660 +0800
@@ -32,7 +32,7 @@ os_file_create_unique(const char *filena
    int fd = open(filename, O_CREAT | O_EXCL | O_WRONLY, filemode);
    if (fd == -1)
       return NULL;
-   return fdopen(fd, "w");
+   return _fdopen_r(_REENT, fd, "w");
 }
 
 
diff --color -rupN old/src/util/os_misc.c new/src/util/os_misc.c
--- old/src/util/os_misc.c	2021-07-01 02:18:56.214487600 +0800
+++ new/src/util/os_misc.c	2021-12-30 17:05:40.566129917 +0800
@@ -57,7 +57,7 @@
 #  include <unistd.h>
 #  include <log/log.h>
 #  include <cutils/properties.h>
-#elif DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD
+#elif DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD || DETECT_OS_LYOS
 #  include <unistd.h>
 #elif DETECT_OS_OPENBSD || DETECT_OS_FREEBSD
 #  include <sys/resource.h>
@@ -224,7 +224,7 @@ os_get_option(const char *name)
 bool
 os_get_total_physical_memory(uint64_t *size)
 {
-#if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD
+#if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD || DETECT_OS_LYOS
    const long phys_pages = sysconf(_SC_PHYS_PAGES);
    const long page_size = sysconf(_SC_PAGE_SIZE);
 
