Commit b73f9b6094e2c9639fded52022ec60556ae8f8de
authorMichel Pollet <buserror@gmail.com>
Fri, 25 May 2012 12:55:11 +0000 (13:55 +0100)
committerMichel Pollet <buserror@gmail.com>
Fri, 25 May 2012 12:55:11 +0000 (13:55 +0100)
XCode 4.3 & clang fixes. Should also apply to BSD

Found a nasty bug in clang with sign bit propagation

Signed-off-by: Michel Pollet <buserror@gmail.com>
6 files changed:
Makefile.common
examples/board_reprap/src/c3/c3geometry.h
examples/parts/uart_pty.c
examples/parts/uart_pty.h
simavr/sim/sim_core.c
tests/tests.c

index 23dddecde0e2fda7406faa7a6507fda09877b1e9..d219b96d939853f581065fd305db42cc8dd9b7d9 100644 (file)
@@ -36,6 +36,8 @@ CFLAGS                += -msse2
 endif
 
 ifeq (${shell uname}, Darwin)
+# gcc 4.2 from MacOS is really not up to scratch anymore 
+CC                     = clang
 AVR_ROOT       := "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/"
 AVR_INC        := ${AVR_ROOT}/avr-4/
 AVR            := ${AVR_ROOT}/bin/avr-
@@ -56,7 +58,7 @@ CPPFLAGS      += ${patsubst %,-I%,${subst :, ,${IPATH}}}
 
 AVR_CPPFLAGS= ${CPPFLAGS} -idirafter ${AVR_INC}/include
 
-CC                     = gcc
+CC                     ?= gcc
 AR                     ?= ar
 RANLIB                 ?= ranlib
 MKDIR          ?= mkdir -p
index 480e246b21a68527097b0fcca3f055965c30b595..09b47ccdbfe288e4d04f7bc5954be5f3679a52a5 100644 (file)
@@ -111,7 +111,7 @@ IMPLEMENT_C_ARRAY(c3colorf_array);
 static inline c3geometry_type_t
 c3geometry_type(int type, int subtype)
 {
-       c3geometry_type_t r = { .type = type, . subtype = subtype };
+       c3geometry_type_t r = { .type = type, .subtype = subtype };
        return r;
 }
 
index 8fad6499739982f6bbb8021d44058bee5fa96a04..6fc3287348690244d81032e61583b5e084601703 100644 (file)
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
-#include <pty.h>
 #include <signal.h>
+#ifdef __APPLE__
+#include <util.h>
+#else
+#include <pty.h>
+#endif
 
 #include "uart_pty.h"
 #include "avr_uart.h"
index d82b762034be3418893bb4f99d4b4100dda59836..f797e58cff840cdc24f648637b627e5c50560c17 100644 (file)
@@ -23,6 +23,7 @@
 #ifndef __UART_PTY_H___
 #define __UART_PTY_H___
 
+#include <pthread.h>
 #include "sim_irq.h"
 #include "fifo_declare.h"
 
index 29f8c0e7b938ddda3f10938dd3a51d30a03091ba..6d95fb58383e13aa764a69aa86a87a5618b90ab7 100644 (file)
@@ -1277,7 +1277,8 @@ avr_flashaddr_t avr_run_one(avr_t * avr)
 
                case 0xc000: {
                        // RJMP 1100 kkkk kkkk kkkk
-                       short o = ((short)(opcode << 4)) >> 4;
+//                     int16_t o = ((int16_t)(opcode << 4)) >> 4; // CLANG BUG!
+                       int16_t o = ((int16_t)((opcode << 4)&0xffff)) >> 4;
                        STATE("rjmp .%d [%04x]\n", o, new_pc + (o << 1));
                        new_pc = new_pc + (o << 1);
                        cycle++;
@@ -1286,7 +1287,8 @@ avr_flashaddr_t avr_run_one(avr_t * avr)
 
                case 0xd000: {
                        // RCALL 1100 kkkk kkkk kkkk
-                       short o = ((short)(opcode << 4)) >> 4;
+//                     int16_t o = ((int16_t)(opcode << 4)) >> 4; // CLANG BUG!
+                       int16_t o = ((int16_t)((opcode << 4)&0xffff)) >> 4;
                        STATE("rcall .%d [%04x]\n", o, new_pc + (o << 1));
                        _avr_push16(avr, new_pc >> 1);
                        new_pc = new_pc + (o << 1);
@@ -1311,7 +1313,7 @@ avr_flashaddr_t avr_run_one(avr_t * avr)
                                case 0xf200:
                                case 0xf400:
                                case 0xf600: {  // All the SREG branches
-                                       short o = ((short)(opcode << 6)) >> 9; // offset
+                                       int16_t o = ((int16_t)(opcode << 6)) >> 9; // offset
                                        uint8_t s = opcode & 7;
                                        int set = (opcode & 0x0400) == 0;               // this bit means BRXC otherwise BRXS
                                        int branch = (avr->sreg[s] && set) || (!avr->sreg[s] && !set);
index f389f4dbb8f79ee17f4230787fa1727b014a49c3..d502fdee7fc9d146cfb44690be3112bd29c0da32 100644 (file)
@@ -38,6 +38,7 @@ static avr_cycle_count_t
 cycle_timer_longjmp_cb(struct avr_t *avr, avr_cycle_count_t when, void *param) {
        jmp_buf *jmp = param;
        longjmp(*jmp, LJR_CYCLE_TIMER);
+       return 0;       // clear warning
 }
 
 static jmp_buf *special_deinit_jmpbuf = NULL;