orc/backport-Fix-warning-because-of-a-mismatched-OrcExecutor-function-signature.patch
2024-08-26 16:33:35 +08:00

110 lines
3.3 KiB
Diff

From d34eb15b61079415dbac7fdb74fcb08949a8acae Mon Sep 17 00:00:00 2001
From: "L. E. Segovia" <amy@centricular.com>
Date: Fri, 3 Nov 2023 17:46:16 -0300
Subject: [PATCH] orc: Fix warning because of a mismatched OrcExecutor function
signature
Fixes warning C4113 in MSVC:
> testsuite/orcc/testorc.c(27292): warning C4113: 'void (__cdecl *)(OrcExecutor *restrict )' differs in parameter lists from 'OrcExecutorFunc'
The ORC_RESTRICT definition was extracted from orcprogram-c.c.
Part-of: <https://gitlab.freedesktop.org/gstreamer/orc/-/merge_requests/118>
---
orc/orcexecutor.c | 4 ++--
orc/orcexecutor.h | 3 ++-
orc/orcutils.h | 12 ++++++++++++
testsuite/memcpy_speed.c | 2 +-
tools/orcc.c | 2 +-
5 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/orc/orcexecutor.c b/orc/orcexecutor.c
index 116220c0..9035f4e9 100644
--- a/orc/orcexecutor.c
+++ b/orc/orcexecutor.c
@@ -38,7 +38,7 @@ orc_executor_free (OrcExecutor *ex)
void
orc_executor_run (OrcExecutor *ex)
{
- void (*func) (OrcExecutor *);
+ OrcExecutorFunc func = NULL;
if (ex->program) {
func = ex->program->code_exec;
@@ -57,7 +57,7 @@ orc_executor_run (OrcExecutor *ex)
void
orc_executor_run_backup (OrcExecutor *ex)
{
- void (*func) (OrcExecutor *);
+ OrcExecutorFunc func = NULL;
if (ex->program) {
func = ex->program->backup_func;
diff --git a/orc/orcexecutor.h b/orc/orcexecutor.h
index 5de559b4..eeb55448 100644
--- a/orc/orcexecutor.h
+++ b/orc/orcexecutor.h
@@ -16,7 +16,8 @@ typedef struct _OrcExecutorAlt OrcExecutorAlt;
typedef void (*OrcOpcodeEmulateFunc)(OrcOpcodeExecutor *ex, void *user);
typedef void (*OrcOpcodeEmulateNFunc)(OrcOpcodeExecutor *ex, int index, int n);
typedef void (*OrcOpcodeEmulate16Func)(OrcOpcodeExecutor *ex);
-typedef void (*OrcExecutorFunc)(OrcExecutor *ex);
+
+typedef void (*OrcExecutorFunc)(OrcExecutor * ORC_RESTRICT ex);
/**
* OrcOpcodeExecutor:
diff --git a/orc/orcutils.h b/orc/orcutils.h
index f0475748..5df79dea 100644
--- a/orc/orcutils.h
+++ b/orc/orcutils.h
@@ -227,6 +227,18 @@ typedef unsigned int orc_bool;
#define ORC_API ORC_API_IMPORT
#endif
+#ifndef ORC_RESTRICT
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#define ORC_RESTRICT restrict
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#define ORC_RESTRICT __restrict__
+#elif defined(_MSC_VER)
+#define ORC_RESTRICT __restrict
+#else
+#define ORC_RESTRICT
+#endif
+#endif
+
ORC_BEGIN_DECLS
#ifdef ORC_ENABLE_UNSTABLE_API
diff --git a/testsuite/memcpy_speed.c b/testsuite/memcpy_speed.c
index a3089dae..e5ff2c3f 100644
--- a/testsuite/memcpy_speed.c
+++ b/testsuite/memcpy_speed.c
@@ -127,7 +127,7 @@ main(int argc, char *argv[])
orc_profile_init (&prof);
for(j=0;j<10;j++){
OrcExecutor _ex, *ex = &_ex;
- void (*func) (OrcExecutor *);
+ OrcExecutorFunc func = NULL;
orc_profile_start(&prof);
/* orc_memcpy (dest, src, size); */
diff --git a/tools/orcc.c b/tools/orcc.c
index 95b8c54e..33db66f4 100644
--- a/tools/orcc.c
+++ b/tools/orcc.c
@@ -891,7 +891,7 @@ output_code_execute (OrcProgram *p, FILE *output, int is_inline)
fprintf(output, " OrcProgram *p;\n");
}
}
- fprintf(output, " void (*func) (OrcExecutor *);\n");
+ fprintf(output, " OrcExecutorFunc func = NULL;\n");
fprintf(output, "\n");
if (use_lazy_init) {
if (use_code) {
--
GitLab