Commits

Anonymous committed c0f8a94

issue #16 patched from branch and mainlined

Comments (0)

Files changed (7)

src/platform/avr/Makefile

 
 
 CDEBUG = -g$(DEBUG_FMT)
-CWARN = -Wall -Wstrict-prototypes
+CWARN = -Wall -Wstrict-prototypes -Werror
 CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
 #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
 CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CTUNING) $(CEXTRA)
  * Integer object type operations.
  */
 
+#include <stdint.h>
+#include <limits.h>
 
 #include "pm.h"
 
 
 
 PmReturn_t
-_int_printHex(int32_t n)
+_int_printHex(intptr_t n)
 {
     PmReturn_t retval;
+    int8_t i;
 
     /* Print the hex value, most significant byte first */
-    retval = int_printHexByte((n >> (uint8_t)24) & (uint8_t)0xFF);
-    PM_RETURN_IF_ERROR(retval);
-    retval = int_printHexByte((n >> (uint8_t)16) & (uint8_t)0xFF);
-    PM_RETURN_IF_ERROR(retval);
-    retval = int_printHexByte((n >> (uint8_t)8) & (uint8_t)0xFF);
-    PM_RETURN_IF_ERROR(retval);
-    retval = int_printHexByte(n & (uint8_t)0xFF);
+    for (i = CHAR_BIT * sizeof(intptr_t) - 8; i >= 0; i -= 8)
+    {
+        retval = int_printHexByte((n >> i) & 0xFF);
+        PM_BREAK_IF_ERROR(retval);
+    }
 
     return retval;
 }
  *
  * @param n Integer to print
  */
-PmReturn_t _int_printHex(int32_t n);
+PmReturn_t _int_printHex(intptr_t n);
 
 /**
  * Prints the Int object in ascii-coded hexadecimal out the platform output
 #include "pm.h"
 
 
-/** if retval is not OK, break from the interpreter */
-#define PM_BREAK_IF_ERROR(retval) if((retval) != PM_RET_OK)break
-
-
 extern PmReturn_t (*std_nat_fxn_table[]) (pPmFrame_t *);
 extern PmReturn_t (*usr_nat_fxn_table[]) (pPmFrame_t *);
 
             plat_putByte(' ');
             plat_putByte('0');
             plat_putByte('x');
-            _int_printHex((int)pobj);
+            _int_printHex((intptr_t)pobj);
             retval = plat_putByte('>');
             if (marshallString)
             {
         retexn = (exn)
 #endif
 
+/** if retval is not OK, break from the block */
+#define PM_BREAK_IF_ERROR(retval) if((retval) != PM_RET_OK)break
+
 /** return an error code if it is not PM_RET_OK */
 #define PM_RETURN_IF_ERROR(retval)  if((retval) != PM_RET_OK) \
                                         return (retval)
 sli_strlen(char const *s)
 {
     char const *si = s;
+    int len = 0;
 
-    while (*si++);
-    return (unsigned int)si - (unsigned int)s - 1;
+    while (*si++)
+    {
+        len++;
+    }
+    return len;
 }