summaryrefslogtreecommitdiff
path: root/orc/orcprogram-c.c
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2010-08-19 13:32:10 -0700
committerDavid Schleef <ds@schleef.org>2010-08-19 13:32:10 -0700
commit241a7ad309ee2969672500792933f6c0afe330ee (patch)
treeeef7b196c67c5539a9645389b9597e0c597e0164 /orc/orcprogram-c.c
parente81f692bf3867c43099464cc67410898428f304e (diff)
downloadorc-241a7ad309ee2969672500792933f6c0afe330ee.tar.gz
c: Add definition of ORC_RESTRICT
Theoretically, this should allow gcc to generate better code.
Diffstat (limited to 'orc/orcprogram-c.c')
-rw-r--r--orc/orcprogram-c.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/orc/orcprogram-c.c b/orc/orcprogram-c.c
index cf92cc8..48bc5f5 100644
--- a/orc/orcprogram-c.c
+++ b/orc/orcprogram-c.c
@@ -106,6 +106,13 @@ orc_target_c_get_asm_preamble (void)
"#define ORC_DENORMAL(x) (((x) > -ORC_MIN_NORMAL && (x) < ORC_MIN_NORMAL) ? ((x)<0 ? (-0.0f) : (0.0f)) : (x))\n"
"#define ORC_MINF(a,b) (isnan(a) ? a : isnan(b) ? b : ((a)<(b)) ? (a) : (b))\n"
"#define ORC_MAXF(a,b) (isnan(a) ? a : isnan(b) ? b : ((a)>(b)) ? (a) : (b))\n"
+ "#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n"
+ "#define ORC_RESTRICT restrict\n"
+ "#elif defined(__GNUC__) && __GNUC__ >= 4\n"
+ "#define ORC_RESTRICT __restrict__\n"
+ "#else\n"
+ "#define ORC_RESTRICT\n"
+ "#endif\n"
"/* end Orc C target preamble */\n\n";
}
@@ -210,15 +217,13 @@ orc_compiler_c_assemble (OrcCompiler *compiler)
}
break;
case ORC_VAR_TYPE_SRC:
- ORC_ASM_CODE(compiler," const %s *%s ptr%d;\n",
+ ORC_ASM_CODE(compiler," const %s * ORC_RESTRICT ptr%d;\n",
c_get_type_name (var->size),
- (compiler->target_flags & ORC_TARGET_C_C99) ? "restrict " : "",
i);
break;
case ORC_VAR_TYPE_DEST:
- ORC_ASM_CODE(compiler," %s *%s ptr%d;\n",
+ ORC_ASM_CODE(compiler," %s * ORC_RESTRICT ptr%d;\n",
c_get_type_name (var->size),
- (compiler->target_flags & ORC_TARGET_C_C99) ? "restrict " : "",
i);
break;
case ORC_VAR_TYPE_ACCUMULATOR: