Add ORC_RESTRICT to prototypes
authorDavid Schleef <ds@schleef.org>
Wed, 13 Apr 2011 22:17:00 +0000 (15:17 -0700)
committerDavid Schleef <ds@schleef.org>
Wed, 13 Apr 2011 22:59:43 +0000 (15:59 -0700)
Fixes #30984

orc/orcemulateopcodes.c
orc/orcfunctions.c
orc/orcfunctions.h
orc/orcprogram-c.c
tools/orcc.c

index ebf4e50..d384f32 100644 (file)
@@ -39,6 +39,7 @@
 #define ORC_ISNAN(x) ((((x)&0x7f800000) == 0x7f800000) && (((x)&0x007fffff) != 0))
 #define ORC_DENORMAL_DOUBLE(x) ((x) & ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == 0) ? ORC_UINT64_C(0xfff0000000000000) : ORC_UINT64_C(0xffffffffffffffff)))
 #define ORC_ISNAN_DOUBLE(x) ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == ORC_UINT64_C(0x7ff0000000000000)) && (((x)&ORC_UINT64_C(0x000fffffffffffff)) != 0))
+#ifndef ORC_RESTRICT
 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
 #define ORC_RESTRICT restrict
 #elif defined(__GNUC__) && __GNUC__ >= 4
@@ -46,6 +47,7 @@
 #else
 #define ORC_RESTRICT
 #endif
+#endif
 /* end Orc C target preamble */
 
 
index 37dbe98..45c2d8c 100644 (file)
@@ -54,9 +54,18 @@ typedef union { orc_int16 i; orc_int8 x2[2]; } orc_union16;
 typedef union { orc_int32 i; float f; orc_int16 x2[2]; orc_int8 x4[4]; } orc_union32;
 typedef union { orc_int64 i; double f; orc_int32 x2[2]; float x2f[2]; orc_int16 x4[4]; } orc_union64;
 #endif
+#ifndef ORC_RESTRICT
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#define ORC_RESTRICT restrict
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#define ORC_RESTRICT __restrict__
+#else
+#define ORC_RESTRICT
+#endif
+#endif
 
-void orc_memcpy (void * d1, const void * s1, int n);
-void orc_memset (void * d1, int p1, int n);
+void orc_memcpy (void * ORC_RESTRICT d1, const void * s1, int n);
+void orc_memset (void * ORC_RESTRICT d1, int p1, int n);
 
 
 /* begin Orc C target preamble */
@@ -90,6 +99,7 @@ void orc_memset (void * d1, int p1, int n);
 #define ORC_ISNAN(x) ((((x)&0x7f800000) == 0x7f800000) && (((x)&0x007fffff) != 0))
 #define ORC_DENORMAL_DOUBLE(x) ((x) & ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == 0) ? ORC_UINT64_C(0xfff0000000000000) : ORC_UINT64_C(0xffffffffffffffff)))
 #define ORC_ISNAN_DOUBLE(x) ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == ORC_UINT64_C(0x7ff0000000000000)) && (((x)&ORC_UINT64_C(0x000fffffffffffff)) != 0))
+#ifndef ORC_RESTRICT
 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
 #define ORC_RESTRICT restrict
 #elif defined(__GNUC__) && __GNUC__ >= 4
@@ -97,6 +107,7 @@ void orc_memset (void * d1, int p1, int n);
 #else
 #define ORC_RESTRICT
 #endif
+#endif
 /* end Orc C target preamble */
 
 
@@ -104,7 +115,7 @@ void orc_memset (void * d1, int p1, int n);
 /* orc_memcpy */
 #ifdef DISABLE_ORC
 void
-orc_memcpy (void * d1, const void * s1, int n){
+orc_memcpy (void * ORC_RESTRICT d1, const void * s1, int n){
   int i;
   orc_int8 * ORC_RESTRICT ptr0;
   const orc_int8 * ORC_RESTRICT ptr4;
@@ -153,7 +164,7 @@ _backup_orc_memcpy (OrcExecutor * ORC_RESTRICT ex)
 }
 
 void
-orc_memcpy (void * d1, const void * s1, int n)
+orc_memcpy (void * ORC_RESTRICT d1, const void * s1, int n)
 {
   OrcExecutor _ex, *ex = &_ex;
   static int p_inited = 0;
@@ -163,7 +174,6 @@ orc_memcpy (void * d1, const void * s1, int n)
   if (!p_inited) {
     orc_once_mutex_lock ();
     if (!p_inited) {
-      OrcCompileResult result;
       OrcProgram *p;
 
       p = orc_program_new ();
@@ -174,7 +184,7 @@ orc_memcpy (void * d1, const void * s1, int n)
 
       orc_program_append_2 (p, "copyb", 0, ORC_VAR_D1, ORC_VAR_S1, ORC_VAR_D1, ORC_VAR_D1);
 
-      result = orc_program_compile (p);
+      orc_program_compile (p);
       c = orc_program_take_code (p);
       orc_program_free (p);
     }
@@ -197,7 +207,7 @@ orc_memcpy (void * d1, const void * s1, int n)
 /* orc_memset */
 #ifdef DISABLE_ORC
 void
-orc_memset (void * d1, int p1, int n){
+orc_memset (void * ORC_RESTRICT d1, int p1, int n){
   int i;
   orc_int8 * ORC_RESTRICT ptr0;
   orc_int8 var32;
@@ -242,7 +252,7 @@ _backup_orc_memset (OrcExecutor * ORC_RESTRICT ex)
 }
 
 void
-orc_memset (void * d1, int p1, int n)
+orc_memset (void * ORC_RESTRICT d1, int p1, int n)
 {
   OrcExecutor _ex, *ex = &_ex;
   static int p_inited = 0;
@@ -252,7 +262,6 @@ orc_memset (void * d1, int p1, int n)
   if (!p_inited) {
     orc_once_mutex_lock ();
     if (!p_inited) {
-      OrcCompileResult result;
       OrcProgram *p;
 
       p = orc_program_new ();
@@ -263,7 +272,7 @@ orc_memset (void * d1, int p1, int n)
 
       orc_program_append_2 (p, "copyb", 0, ORC_VAR_D1, ORC_VAR_P1, ORC_VAR_D1, ORC_VAR_D1);
 
-      result = orc_program_compile (p);
+      orc_program_compile (p);
       c = orc_program_take_code (p);
       orc_program_free (p);
     }
index 6ebc92c..fe50661 100644 (file)
@@ -57,8 +57,17 @@ typedef union { orc_int16 i; orc_int8 x2[2]; } orc_union16;
 typedef union { orc_int32 i; float f; orc_int16 x2[2]; orc_int8 x4[4]; } orc_union32;
 typedef union { orc_int64 i; double f; orc_int32 x2[2]; float x2f[2]; orc_int16 x4[4]; } orc_union64;
 #endif
-void orc_memcpy (void * d1, const void * s1, int n);
-void orc_memset (void * d1, int p1, int n);
+#ifndef ORC_RESTRICT
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#define ORC_RESTRICT restrict
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#define ORC_RESTRICT __restrict__
+#else
+#define ORC_RESTRICT
+#endif
+#endif
+void orc_memcpy (void * ORC_RESTRICT d1, const void * s1, int n);
+void orc_memset (void * ORC_RESTRICT d1, int p1, int n);
 
 #ifdef __cplusplus
 }
index 416971d..86b2775 100644 (file)
@@ -74,6 +74,15 @@ orc_target_c_get_typedefs (void)
     "typedef union { orc_int16 i; orc_int8 x2[2]; } orc_union16;\n"
     "typedef union { orc_int32 i; float f; orc_int16 x2[2]; orc_int8 x4[4]; } orc_union32;\n"
     "typedef union { orc_int64 i; double f; orc_int32 x2[2]; float x2f[2]; orc_int16 x4[4]; } orc_union64;\n"
+    "#endif\n"
+    "#ifndef ORC_RESTRICT\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"
     "#endif\n";
 }
 
@@ -112,6 +121,7 @@ orc_target_c_get_asm_preamble (void)
     "#define ORC_ISNAN(x) ((((x)&0x7f800000) == 0x7f800000) && (((x)&0x007fffff) != 0))\n"
     "#define ORC_DENORMAL_DOUBLE(x) ((x) & ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == 0) ? ORC_UINT64_C(0xfff0000000000000) : ORC_UINT64_C(0xffffffffffffffff)))\n"
     "#define ORC_ISNAN_DOUBLE(x) ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == ORC_UINT64_C(0x7ff0000000000000)) && (((x)&ORC_UINT64_C(0x000fffffffffffff)) != 0))\n"
+    "#ifndef ORC_RESTRICT\n"
     "#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n"
     "#define ORC_RESTRICT restrict\n"
     "#elif defined(__GNUC__) && __GNUC__ >= 4\n"
@@ -119,6 +129,7 @@ orc_target_c_get_asm_preamble (void)
     "#else\n"
     "#define ORC_RESTRICT\n"
     "#endif\n"
+    "#endif\n"
     "/* end Orc C target preamble */\n\n";
 }
 
index cb5146f..c4dd903 100644 (file)
@@ -506,10 +506,10 @@ output_prototype (OrcProgram *p, FILE *output)
     if (var->size) {
       if (need_comma) fprintf(output, ", ");
       if (var->type_name) {
-        fprintf(output, "%s * %s", var->type_name,
+        fprintf(output, "%s * ORC_RESTRICT %s", var->type_name,
             varnames[ORC_VAR_D1 + i]);
       } else {
-        fprintf(output, "orc_uint%d * %s", var->size*8,
+        fprintf(output, "orc_uint%d * ORC_RESTRICT %s", var->size*8,
             varnames[ORC_VAR_D1 + i]);
       }
       if (p->is_2d) {
@@ -523,10 +523,10 @@ output_prototype (OrcProgram *p, FILE *output)
     if (var->size) {
       if (need_comma) fprintf(output, ", ");
       if (var->type_name) {
-        fprintf(output, "%s * %s", var->type_name,
+        fprintf(output, "%s * ORC_RESTRICT %s", var->type_name,
             varnames[ORC_VAR_A1 + i]);
       } else {
-        fprintf(output, "orc_uint%d * %s", var->size*8,
+        fprintf(output, "orc_uint%d * ORC_RESTRICT %s", var->size*8,
             varnames[ORC_VAR_A1 + i]);
       }
       need_comma = TRUE;
@@ -537,10 +537,10 @@ output_prototype (OrcProgram *p, FILE *output)
     if (var->size) {
       if (need_comma) fprintf(output, ", ");
       if (var->type_name) {
-        fprintf(output, "const %s * %s", var->type_name,
+        fprintf(output, "const %s * ORC_RESTRICT %s", var->type_name,
             varnames[ORC_VAR_S1 + i]);
       } else {
-        fprintf(output, "const orc_uint%d * %s", var->size*8,
+        fprintf(output, "const orc_uint%d * ORC_RESTRICT %s", var->size*8,
             varnames[ORC_VAR_S1 + i]);
       }
       if (p->is_2d) {