[MLton-commit] r4083
Matthew Fluet
MLton@mlton.org
Fri, 9 Sep 2005 14:56:13 -0700
Include more gcc warnings
----------------------------------------------------------------------
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/assumptions.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/cheney-copy.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/frame.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c
----------------------------------------------------------------------
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile 2005-09-09 05:50:10 UTC (rev 4082)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile 2005-09-09 21:56:06 UTC (rev 4083)
@@ -49,8 +49,15 @@
endif
CC = gcc -std=gnu99
-CFLAGS = -O2 -Wall -I. -D_FILE_OFFSET_BITS=64 $(FLAGS)
-DEBUGFLAGS = $(CFLAGS) -gstabs+ -g2
+CWFLAGS = -Wall -pedantic -Wextra -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wconversion -Wsign-compare -Wstrict-prototypes -Wredundant-decls -Winline
+CWFLAGS = -pedantic -Wall -Wextra -Wno-unused \
+ -Wshadow -Wredundant-decls \
+ -Wpointer-arith -Wcast-qual -Wcast-align \
+## -Wconversion \
+ -Wstrict-prototypes \
+ -Winline
+CFLAGS = -O2 $(CWFLAGS) -I. -D_FILE_OFFSET_BITS=64 $(FLAGS)
+DEBUGFLAGS = $(CFLAGS) -Wunused -gstabs+ -g2
## Order matters, as these are concatenated together to form "gc.c".
CFILES = \
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.c 2005-09-09 05:50:10 UTC (rev 4082)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.c 2005-09-09 21:56:06 UTC (rev 4083)
@@ -7,7 +7,6 @@
*/
static inline size_t align (size_t a, size_t b) {
- assert (a >= 0);
assert (b >= 1);
a += b - 1;
a -= a % b;
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.c 2005-09-09 05:50:10 UTC (rev 4082)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.c 2005-09-09 21:56:06 UTC (rev 4083)
@@ -21,13 +21,15 @@
SPLIT_HEADER();
assert (tag == ARRAY_TAG);
+ size_t nonObjptrBytesPerElement =
+ numNonObjptrsToBytes(numNonObjptrs, ARRAY_TAG);
size_t bytesPerElement =
- numNonObjptrsToBytes(numNonObjptrs, ARRAY_TAG)
+ nonObjptrBytesPerElement
+ (numObjptrs * OBJPTR_SIZE);
return a
+ arrayIndex * bytesPerElement
- + numNonObjptrsToBytes(numNonObjptrs, tag)
+ + nonObjptrBytesPerElement
+ pointerIndex * OBJPTR_SIZE;
}
#endif
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/assumptions.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/assumptions.c 2005-09-09 05:50:10 UTC (rev 4082)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/assumptions.c 2005-09-09 21:56:06 UTC (rev 4083)
@@ -11,7 +11,7 @@
* but which are reasonable to assume on a wide variety of target
* platforms. Working around these assumptions would be difficult.
*/
-void checkAssumptions () {
+void checkAssumptions (void) {
assert(CHAR_BIT == 8);
/* assert(repof(uintptr_t) == TWOS); */
}
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/cheney-copy.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/cheney-copy.c 2005-09-09 05:50:10 UTC (rev 4082)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/cheney-copy.c 2005-09-09 21:56:06 UTC (rev 4083)
@@ -90,7 +90,7 @@
/* Shrink heap stacks.
*/
stack->reserved =
- stackReserved (s, maxZ(s->threadShrinkRatio * stack->reserved,
+ stackReserved (s, maxZ((size_t)(s->threadShrinkRatio * stack->reserved),
stack->used));
if (DEBUG_STACKS)
fprintf (stderr, "Shrinking stack to size %"PRId32".\n",
@@ -106,7 +106,7 @@
/* If the object has a valid weak pointer, link it into the weaks
* for update after the copying GC is done.
*/
- if (WEAK_TAG == tag and numObjptrs == 1) {
+ if ((WEAK_TAG == tag) and (numObjptrs == 1)) {
GC_weak w;
w = (GC_weak)(forwardState.back + GC_NORMAL_HEADER_SIZE);
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c 2005-09-09 05:50:10 UTC (rev 4082)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c 2005-09-09 21:56:06 UTC (rev 4083)
@@ -153,7 +153,7 @@
fprintf (stderr, " top = "FMTPTR" return address = "FMTPTR"\n",
(uintptr_t)top, returnAddress);
}
- frameLayout = getFrameLayout (s, returnAddress);
+ frameLayout = getFrameLayoutFromReturnAddress (s, returnAddress);
frameOffsets = frameLayout->offsets;
top -= frameLayout->numBytes;
for (i = 0 ; i < frameOffsets[0] ; ++i) {
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/frame.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/frame.c 2005-09-09 05:50:10 UTC (rev 4082)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/frame.c 2005-09-09 21:56:06 UTC (rev 4083)
@@ -6,7 +6,8 @@
* See the file MLton-LICENSE for details.
*/
-static inline uint32_t getFrameIndex (GC_state s, GC_returnAddress ra) {
+static inline uint32_t
+getFrameIndexFromReturnAddress (GC_state s, GC_returnAddress ra) {
uint32_t res;
res = s->returnAddressToFrameIndex (ra);
@@ -16,19 +17,27 @@
return res;
}
-static inline GC_frameLayout * getFrameLayout (GC_state s, GC_returnAddress ra) {
+static inline GC_frameLayout *
+getFrameLayoutFromFrameIndex (GC_state s, uint32_t index) {
GC_frameLayout *layout;
- uint32_t index;
- index = getFrameIndex (s, ra);
if (DEBUG_DETAILED)
fprintf (stderr,
- "returnAddress = "FMTRA
- " index = %"PRIx32
+ "index = %"PRIx32
" frameLayoutsSize = %"PRIu16"\n",
- ra, index, s->frameLayoutsSize);
- assert (0 <= index and index < s->frameLayoutsSize);
+ index, s->frameLayoutsSize);
+ assert (index < s->frameLayoutsSize);
layout = &(s->frameLayouts[index]);
assert (layout->numBytes > 0);
return layout;
}
+
+static inline GC_frameLayout *
+getFrameLayoutFromReturnAddress (GC_state s, GC_returnAddress ra) {
+ GC_frameLayout *layout;
+ uint32_t index;
+
+ index = getFrameIndexFromReturnAddress (s, ra);
+ layout = getFrameLayoutFromFrameIndex(s, index);
+ return layout;
+}
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.c 2005-09-09 05:50:10 UTC (rev 4082)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.c 2005-09-09 21:56:06 UTC (rev 4083)
@@ -73,6 +73,6 @@
static inline void storeObjptrFromPointer (pointer OP, pointer P, pointer B) {
*((objptr*)OP) = pointerToObjptr (P, B);
}
-static inline size_t objptrSize () {
+static inline size_t objptrSize (void) {
return OBJPTR_SIZE;
}
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.c 2005-09-09 05:50:10 UTC (rev 4082)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.c 2005-09-09 21:56:06 UTC (rev 4083)
@@ -22,13 +22,12 @@
#define SPLIT_HEADER() \
do { \
- int objectTypeIndex; \
+ unsigned int objectTypeIndex; \
GC_objectType *t; \
\
- assert (1 == (header & 1)); \
+ assert (1 == (header & GC_VALID_HEADER_MASK)); \
objectTypeIndex = (header & TYPE_INDEX_MASK) >> TYPE_INDEX_SHIFT; \
- assert (0 <= objectTypeIndex \
- and objectTypeIndex < s->objectTypesSize); \
+ assert (objectTypeIndex < s->objectTypesSize); \
t = &s->objectTypes [objectTypeIndex]; \
tag = t->tag; \
hasIdentity = t->hasIdentity; \
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h 2005-09-09 05:50:10 UTC (rev 4082)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h 2005-09-09 21:56:06 UTC (rev 4083)
@@ -30,18 +30,18 @@
#define GC_HEADER_SIZE sizeof(GC_header)
#define PRIxHDR PRIx32
#define FMTHDR "0x%08"PRIxHDR
-enum {
- TYPE_INDEX_BITS = 19,
- TYPE_INDEX_MASK = 0x000FFFFE,
- TYPE_INDEX_SHIFT = 1,
- COUNTER_BITS = 10,
- COUNTER_MASK = 0x7FF00000,
- COUNTER_SHIFT = 20,
- MARK_BITS = 1,
- MARK_MASK = 0x80000000,
- MARK_SHIFT = 31
-};
+#define GC_VALID_HEADER_MASK ((GC_header)0x1)
+#define TYPE_INDEX_BITS 19
+#define TYPE_INDEX_MASK 0x000FFFFE
+#define TYPE_INDEX_SHIFT 1
+#define COUNTER_BITS 10
+#define COUNTER_MASK 0x7FF00000
+#define COUNTER_SHIFT 20
+#define MARK_BITS 1
+#define MARK_MASK 0x80000000
+#define MARK_SHIFT 3
+
/* getHeaderp (p)
*
* Returns a pointer to the header for the object pointed to by p.
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c 2005-09-09 05:50:10 UTC (rev 4082)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c 2005-09-09 21:56:06 UTC (rev 4083)
@@ -47,9 +47,9 @@
static inline uint32_t topFrameIndex (GC_state s, GC_stack stack) {
uint32_t res;
- res = getFrameIndex (s,
- *(GC_returnAddress*)
- (stackTop (s, stack) - GC_RETURNADDRESS_SIZE));
+ res =
+ getFrameIndexFromReturnAddress
+ (s, *(GC_returnAddress*)(stackTop (s, stack) - GC_RETURNADDRESS_SIZE));
if (DEBUG_PROFILE)
fprintf (stderr, "topFrameIndex = %"PRIu32"\n", res);
return res;
@@ -58,7 +58,7 @@
static inline GC_frameLayout * topFrameLayout (GC_state s, GC_stack stack) {
GC_frameLayout *layout;
- layout = getFrameLayout (s, topFrameIndex (s, stack));
+ layout = getFrameLayoutFromFrameIndex (s, topFrameIndex (s, stack));
return layout;
}