[m-rev.] diff: avoid a warning from gcc
Julien Fischer
juliensf at cs.mu.OZ.AU
Fri Jan 20 17:27:27 AEDT 2006
Estimated hours taken: 0.5
Branches: main
Avoid a warning about lvalue casts being deprecated in non .gc grades.
compiler/mercury_deep_copy.c:
When assigning to MR_hp do so through MR_hp_word, rather
than via MR_hp (which shouldn't be used as an lvalue).
Julien.
Index: mercury_deep_copy.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_copy.c,v
retrieving revision 1.35
diff -u -r1.35 mercury_deep_copy.c
--- mercury_deep_copy.c 13 Sep 2005 08:25:38 -0000 1.35
+++ mercury_deep_copy.c 20 Jan 2006 06:21:20 -0000
@@ -141,6 +141,19 @@
(val2) = swap_tmp; \
} while (0)
+/*
+** The above macro won't suffice when we want to swap the pointers to the
+** heap and the global heap since it will cause gcc to emit warnings about
+** lvalue casts being deprecated. In that case we use the following macro.
+*/
+#define SWAP_HEAP_AND_GLOBAL_HEAP \
+ do { \
+ MR_Word *swap_tmp; \
+ swap_tmp = MR_hp; \
+ MR_hp_word = (MR_Word) MR_global_hp; \
+ MR_global_hp = swap_tmp; \
+ } while (0)
+
#ifdef MR_MIGHT_RECLAIM_HP_ON_FAILURE
/*
@@ -163,8 +176,8 @@
/* temporarily swap the heap with the global heap */
SWAP(MR_ENGINE(MR_eng_heap_zone), MR_ENGINE(MR_eng_global_heap_zone),
MR_MemoryZone *);
- SWAP(MR_hp, MR_global_hp, MR_Word *);
-
+ SWAP_HEAP_AND_GLOBAL_HEAP;
+
/* copy values from the heap to the global heap */
MR_save_transient_hp();
result = MR_deep_copy(term, type_info, lower_limit,
@@ -174,8 +187,8 @@
/* swap the heap and global heap back again */
SWAP(MR_ENGINE(MR_eng_heap_zone), MR_ENGINE(MR_eng_global_heap_zone),
MR_MemoryZone *);
- SWAP(MR_hp, MR_global_hp, MR_Word *);
-
+ SWAP_HEAP_AND_GLOBAL_HEAP;
+
MR_save_transient_hp(); /* Because we played with MR_hp */
return result;
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list