On Wed, Oct 22, 2014 at 12:36:35AM +0400, Oleg Kolosov wrote:
> Hello.
> 
> Here is another patch which is useful for MSVC support but not harmful anyway.

Hi there,

This patch looks like a sensible thing to do.  It's pretty
weird/unexpected to me that all of GCC, clang and SunW (and I think
pcc, too) even accept this!

Anyway, two notes:

- You used four spaces to indent the second level of indentation,
   but 2 spaces for the first level (which is standard in our code).
   I've fixed that to use 2 spaces everywhere.
- for (x; y; ) just "looks" wrong to me, like someone forgot to put
   an increment operation there.  It's more of a style thing, and
   it doesn't matter, and you can easily see that the increment happens
   on the next line, but it does require a little bit of extra attention.
   So I changed it to move the increment back into the for loop.  It is
   semantically exactly the same, and looks more balanced.  I used the
   pre-increment operator purely for consistency with the surrounding
   code.

Attached is a signed-off copy with the mentioned changes.

Thank you for the patch!

Cheers,
Peter
-- 
http://www.more-magic.net
>From bf197bbc54dec69cef22aefdfb4f7d5844aba564 Mon Sep 17 00:00:00 2001
From: Oleg Kolosov <[email protected]>
Date: Tue, 21 Oct 2014 22:56:28 +0400
Subject: [PATCH] Removed few usages of gcc extensions from runtime

Moved calls to 'mark' and 'remark' macros into the corresponding 'for'
loop bodies. These macros are expanded into a do-while statement which is
not allowed in the loop expression position inside a 'for' loop in
standard C. In particular, MSVC compiler considers this a syntax error.

Signed-off-by: Peter Bex <[email protected]>
---
 runtime.c |   21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/runtime.c b/runtime.c
index fd3a3be..fb5d56c 100644
--- a/runtime.c
+++ b/runtime.c
@@ -2797,11 +2797,13 @@ C_regparm void C_fcall C_reclaim(void *trampoline, void 
*proc)
 
     /* Mark literal frames: */
     for(lfn = lf_list; lfn != NULL; lfn = lfn->next)
-      for(i = 0; i < lfn->count; mark(&lfn->lf[ i++ ]));
+      for(i = 0; i < lfn->count; ++i)
+        mark(&lfn->lf[i]);
 
     /* Mark symbol tables: */
     for(stp = symbol_table_list; stp != NULL; stp = stp->next)
-      for(i = 0; i < stp->size; mark(&stp->table[ i++ ]));
+      for(i = 0; i < stp->size; ++i)
+        mark(&stp->table[i]);
 
     /* Mark collectibles: */
     for(msp = collectibles; msp < collectibles_top; ++msp)
@@ -2816,14 +2818,16 @@ C_regparm void C_fcall C_reclaim(void *trampoline, void 
*proc)
   }
   else {
     /* Mark mutated slots: */
-    for(msp = mutation_stack_bottom; msp < mutation_stack_top; mark(*(msp++)));
+    for(msp = mutation_stack_bottom; msp < mutation_stack_top; ++msp)
+      mark(*msp);
   }
 
   /* Clear the mutated slot stack: */
   mutation_stack_top = mutation_stack_bottom;
 
   /* Mark live values: */
-  for(p = C_temporary_stack; p < C_temporary_stack_bottom; mark(p++));
+  for(p = C_temporary_stack; p < C_temporary_stack_bottom; ++p)
+    mark(p);
 
   /* Mark trace-buffer: */
   for(tinfo = trace_buffer; tinfo < trace_buffer_limit; ++tinfo) {
@@ -3299,11 +3303,13 @@ C_regparm void C_fcall C_rereclaim2(C_uword size, int 
double_plus)
 
   /* Mark literal frames: */
   for(lfn = lf_list; lfn != NULL; lfn = lfn->next)
-    for(i = 0; i < lfn->count; remark(&lfn->lf[ i++ ]));
+    for(i = 0; i < lfn->count; ++i)
+      remark(&lfn->lf[i]);
 
   /* Mark symbol table: */
   for(stp = symbol_table_list; stp != NULL; stp = stp->next)
-    for(i = 0; i < stp->size; remark(&stp->table[ i++ ]));
+    for(i = 0; i < stp->size; ++i)
+      remark(&stp->table[i]);
 
   /* Mark collectibles: */
   for(msp = collectibles; msp < collectibles_top; ++msp)
@@ -3318,7 +3324,8 @@ C_regparm void C_fcall C_rereclaim2(C_uword size, int 
double_plus)
   mutation_stack_top = mutation_stack_bottom;
 
   /* Mark live values: */
-  for(p = C_temporary_stack; p < C_temporary_stack_bottom; remark(p++));
+  for(p = C_temporary_stack; p < C_temporary_stack_bottom; ++p)
+    remark(p);
 
   /* Mark locative table: */
   for(i = 0; i < locative_table_count; ++i)
-- 
1.7.10.4

_______________________________________________
Chicken-hackers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to