diff --git a/com.oracle.truffle.r.native/fficall/src/truffle_common/Rinternals_truffle_common.h b/com.oracle.truffle.r.native/fficall/src/truffle_common/Rinternals_truffle_common.h
index 628f5974c669df680434ae9d71055dadf09a01de..5edea4d43b092503fe7a9dfaf848b6c120a247ac 100644
--- a/com.oracle.truffle.r.native/fficall/src/truffle_common/Rinternals_truffle_common.h
+++ b/com.oracle.truffle.r.native/fficall/src/truffle_common/Rinternals_truffle_common.h
@@ -68,6 +68,7 @@
 
 #define UNIMPLEMENTED unimplemented(__FUNCTION__)
 
+#define NO_FASTR_REDEFINE
 #include <rffiutils.h>
 
 // these two functions are here just to handle casting void* to void function pointers...
@@ -1252,7 +1253,7 @@ void DUPLICATE_ATTRIB(SEXP to, SEXP from) {
 R_len_t R_BadLongVector(SEXP x, const char *y, int z) {
     TRACE0();
     unimplemented("R_BadLongVector");
-    return (R_len_t) 0;
+    // "no return" function
 }
 
 int IS_S4_OBJECT(SEXP x) {
diff --git a/com.oracle.truffle.r.native/fficall/src/truffle_llvm/Rinternals.c b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/Rinternals.c
index 4b3d916edd833c9728fb25cc0f26c8ca8b575202..f6dcf567ef2f622bf0878352af1478402c523c3e 100644
--- a/com.oracle.truffle.r.native/fficall/src/truffle_llvm/Rinternals.c
+++ b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/Rinternals.c
@@ -21,6 +21,7 @@
  * questions.
  */
 
+#define NO_FASTR_REDEFINE
 #include <Rinterface.h>
 #include <rffiutils.h>
 #include <Rinternals_common.h>
diff --git a/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Rinternals.c b/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Rinternals.c
index 39b2d0b9ab6b6ca0cba775cd6826c9cc08494fd5..cf8ea6aa96ee13995af6de6c2c38acf878dc80cd 100644
--- a/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Rinternals.c
+++ b/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Rinternals.c
@@ -20,6 +20,7 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+#define NO_FASTR_REDEFINE
 #include <Rinterface.h>
 #include <rffiutils.h>
 #include <Rinternals_common.h>
diff --git a/com.oracle.truffle.r.native/version.source b/com.oracle.truffle.r.native/version.source
index c3f407c0955bb5738e40a82664c79b63f04a9adb..e1617e842ad9a038ec2d8332c6084300a43cb09d 100644
--- a/com.oracle.truffle.r.native/version.source
+++ b/com.oracle.truffle.r.native/version.source
@@ -1 +1 @@
-55
+57
diff --git a/mx.fastr/mx_fastr_edinclude.py b/mx.fastr/mx_fastr_edinclude.py
index 0032c54979c0af20778ea657a9375c0eb1fdea47..40d357e92ea0c54e58b544ea598780ae36d2c79a 100644
--- a/mx.fastr/mx_fastr_edinclude.py
+++ b/mx.fastr/mx_fastr_edinclude.py
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2017, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -74,6 +74,14 @@ use_internals_end = '''#endif
 
 '''
 
+set_typeof_rewrite = '''#ifdef FASTR
+SEXP SET_TYPEOF_FASTR(SEXP x, int v);
+#ifndef NO_FASTR_REDEFINE
+#define SET_TYPEOF(X,Y) X=SET_TYPEOF_FASTR(X,Y)
+#endif
+#endif
+'''
+
 def ed_r_internals(gnu_dir):
     r_internals_h = join(gnu_dir, 'Rinternals.h')
     with open(r_internals_h) as f:
@@ -105,6 +113,9 @@ def ed_r_internals(gnu_dir):
                     rewrite_var(f, var, line)
                 else:
                     f.write(line)
+            elif 'SET_TYPEOF' in line and '(SEXP' in line:
+                f.write(line)
+                f.write(set_typeof_rewrite)
             else:
                 f.write(line)