diff --git a/gcc/config/tilegx/linux.h b/gcc/config/tilegx/linux.h
index cbff114..e8e887c 100644
--- a/gcc/config/tilegx/linux.h
+++ b/gcc/config/tilegx/linux.h
@@ -55,12 +55,23 @@
 /* For __clear_cache in libgcc2.c.  */
 #ifdef IN_LIBGCC2
 
-#include <arch/icache.h>
-
 /* Use the minimum page size of 4K.  Alternatively we can call
-   getpagesize() but it introduces a libc dependence.  */
+   getpagesize() but it introduces a libc dependence.
+   See Linux arch/tile/include/uapi/arch/icache.h for more commentary.  */
 #undef CLEAR_INSN_CACHE
-#define CLEAR_INSN_CACHE(beg, end) invalidate_icache (beg, end - beg, 4096)
+#define CLEAR_INSN_CACHE(BEG, END)                                      \
+{                                                                       \
+  long size = (long) (END) - (long) (BEG);                              \
+  if (size)                                                             \
+    {                                                                   \
+      const char *p = (const char *) ((unsigned long) (BEG) & -64L);    \
+      const char *end = p + (size < 4096 ? size : 4096) - 1;            \
+      __insn_mf ();                                                     \
+      for (; p <= end; p += 64)                                         \
+        __insn_icoh (p);                                                \
+      __insn_drain ();                                                  \
+    }                                                                   \
+}
 
 #else
 
diff --git a/gcc/config/tilegx/t-tilegx b/gcc/config/tilegx/t-tilegx
index 4e3203c..8a48ae9 100644
--- a/gcc/config/tilegx/t-tilegx
+++ b/gcc/config/tilegx/t-tilegx
@@ -12,7 +12,7 @@ tilegx-c.o: $(srcdir)/config/tilegx/tilegx-c.c \
 
 $(srcdir)/config/tilegx/mul-tables.c: \
     $(srcdir)/config/tilepro/gen-mul-tables.cc
-	$(CC_FOR_BUILD) $(BUILD_CPPFLAGS) -O2 -o gen-mul-tables -lstdc++ $<;
+	$(CC_FOR_BUILD) $(BUILD_CPPFLAGS) -O2 -o gen-mul-tables $< -lstdc++ ;
 	./gen-mul-tables > $@
 
 mul-tables.o: $(srcdir)/config/tilegx/mul-tables.c \
diff --git a/gcc/config/tilepro/linux.h b/gcc/config/tilepro/linux.h
index 5aee13f..275699b 100644
--- a/gcc/config/tilepro/linux.h
+++ b/gcc/config/tilepro/linux.h
@@ -47,12 +47,31 @@
 /* For __clear_cache in libgcc2.c.  */
 #ifdef IN_LIBGCC2
 
-#include <arch/icache.h>
-
-/* Use the minimum page size of 4K.  Alternatively we can call getpagesize()
-   but it introduces a libc dependence.  */
+/* Use the minimum page size of 4K.  Alternatively we can call
+   getpagesize() but it introduces a libc dependence.
+   See Linux arch/tile/include/uapi/arch/icache.h for more commentary.  */
 #undef CLEAR_INSN_CACHE
-#define CLEAR_INSN_CACHE(beg, end) invalidate_icache (beg, end - beg, 4096)
+#define CLEAR_INSN_CACHE(BEG, END)                                      \
+{                                                                       \
+  long size = (long) (END) - (long) (BEG);                              \
+  if (size)                                                             \
+    {                                                                   \
+      const char *start = (const char *) ((unsigned long) (BEG) & -64L);\
+      const char *end =  start + (size < 16384 ? size : 16384) - 1;     \
+      long num_passes = 4;                                              \
+      __insn_mf ();                                                     \
+      do                                                                \
+      {                                                                 \
+        const char *p;                                                  \
+        for (p = start; p <= end; p += 64)                              \
+          __insn_icoh (p);                                              \
+        start += 4096;                                                  \
+        end += 4096;                                                    \
+      }                                                                 \
+      while (--num_passes > 0);                                         \
+      __insn_drain ();                                                  \
+    }                                                                   \
+}
 
 #else
 
diff --git a/gcc/config/tilepro/t-tilepro b/gcc/config/tilepro/t-tilepro
index bc2a5aa..b456eea 100644
--- a/gcc/config/tilepro/t-tilepro
+++ b/gcc/config/tilepro/t-tilepro
@@ -6,7 +6,7 @@ tilepro-c.o: $(srcdir)/config/tilepro/tilepro-c.c \
 $(srcdir)/config/tilepro/mul-tables.c: \
     $(srcdir)/config/tilepro/gen-mul-tables.cc
 	$(CC_FOR_BUILD) $(BUILD_CPPFLAGS) -O2 -DTILEPRO \
-	  -o gen-mul-tables -lstdc++ $<;
+	  -o gen-mul-tables $< -lstdc++ ;
 	./gen-mul-tables > $@
 
 mul-tables.o: $(srcdir)/config/tilepro/mul-tables.c \
diff --git a/libgcc/config/m68k/linux-atomic.c b/libgcc/config/m68k/linux-atomic.c
index 5ddddac..a1f38f8 100644
--- a/libgcc/config/m68k/linux-atomic.c
+++ b/libgcc/config/m68k/linux-atomic.c
@@ -33,7 +33,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    using the kernel helper defined below.  There is no support for
    64-bit operations yet.  */
 
-#include <asm/unistd.h>
+//#include <asm/unistd.h>
 #include <stdbool.h>
 
 #ifndef __NR_atomic_cmpxchg_32
diff --git a/libgcc/config/tilepro/atomic.h b/libgcc/config/tilepro/atomic.h
index 4505549..be5364f 100644
--- a/libgcc/config/tilepro/atomic.h
+++ b/libgcc/config/tilepro/atomic.h
@@ -93,9 +93,11 @@
 #endif
 
 #ifdef __tilegx__
-#include <arch/spr_def.h>
+#define SPR_CMPEXCH_VALUE 0x2780
 #else
-#include <asm/unistd.h>
+#define __NR_FAST_cmpxchg	-1
+#define __NR_FAST_atomic_update	-2
+#define __NR_FAST_cmpxchg64	-3
 #endif
 
 
diff --git a/libgcc/unwind-generic.h b/libgcc/unwind-generic.h
index a51ffd6..3540dbc 100644
--- a/libgcc/unwind-generic.h
+++ b/libgcc/unwind-generic.h
@@ -221,7 +221,7 @@ _Unwind_SjLj_Resume_or_Rethrow (struct _Unwind_Exception *);
    compatible with the standard ABI for IA-64, we inline these.  */
 
 #ifdef __ia64__
-#include <stdlib.h>
+//#include <stdlib.h>
 
 static inline _Unwind_Ptr
 _Unwind_GetDataRelBase (struct _Unwind_Context *_C)
