diff --git a/gcc/config/tilegx/linux.h b/gcc/config/tilegx/linux.h
index f68b044..8ed3d02 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/tilepro/linux.h b/gcc/config/tilepro/linux.h
index c7791f9..ebe15f4 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/libgcc/config/m68k/linux-atomic.c b/libgcc/config/m68k/linux-atomic.c
index 5dec6e5..6fe4932 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 78fa9a9..6abe6e1 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
 
 
