summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Faye-Lund <erik.faye-lund@collabora.com>2023-02-24 15:54:11 +0100
committerErik Faye-Lund <erik.faye-lund@collabora.com>2023-02-27 08:55:05 +0000
commita3c640939dc5b55156ce24c3f0e9f8518e0a18d2 (patch)
tree394d2de087bfccd4047a8706597259fe3193d978
parentd248d8ceffa8182259e78578ab4b5140bd64b4b3 (diff)
downloadmesa-demos-a3c640939dc5b55156ce24c3f0e9f8518e0a18d2.tar.gz
util: do not require sincos()
This function isn't portable, so we need to check for it. Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com>
-rw-r--r--meson.build5
-rw-r--r--src/util/matrix.c6
2 files changed, 10 insertions, 1 deletions
diff --git a/meson.build b/meson.build
index dd88dd87..9299004b 100644
--- a/meson.build
+++ b/meson.build
@@ -148,6 +148,11 @@ if host_machine.system() == 'darwin'
add_project_arguments('-DGL_SILENCE_DEPRECATION', language: 'c')
endif
+if cc.has_function('sincos', prefix: '#define _GNU_SOURCE\n#include <math.h>',
+ dependencies: dep_m)
+ add_project_arguments('-DHAVE_SINCOS', language: 'c')
+endif
+
c_args = []
if cc.get_argument_syntax() == 'msvc'
c_args += '-D_CRT_SECURE_NO_WARNINGS'
diff --git a/src/util/matrix.c b/src/util/matrix.c
index e8dcc4d1..fb375c42 100644
--- a/src/util/matrix.c
+++ b/src/util/matrix.c
@@ -37,8 +37,12 @@ void
mat4_rotate(float *m, float angle, float x, float y, float z)
{
double s, c;
-
+#if HAVE_SINCOS
sincos(angle, &s, &c);
+#else
+ s = sin(angle);
+ c = cos(angle);
+#endif
float r[16] = {
x * x * (1 - c) + c, y * x * (1 - c) + z * s, x * z * (1 - c) - y * s, 0,
x * y * (1 - c) - z * s, y * y * (1 - c) + c, y * z * (1 - c) + x * s, 0,