diff --git a/modules/jit/cache-tests b/modules/jit/cache-tests
index eff828890d..6a713f8bb9 100644
--- a/modules/jit/cache-tests
+++ b/modules/jit/cache-tests
@@ -7,6 +7,7 @@ unportable-test
 
 Depends-on:
 getpagesize
+host-cpu-c-abi
 pagealign_alloc
 stdint
 
diff --git a/tests/jit/test-cache.c b/tests/jit/test-cache.c
index 3158d02117..2919605e33 100644
--- a/tests/jit/test-cache.c
+++ b/tests/jit/test-cache.c
@@ -29,10 +29,55 @@
 
 #include "macros.h"
 
+/*  On most platforms, function pointers are just a pointer to the
+    code, i.e. to the first instruction to be executed.  This,
+    however, is not universally true, see:
+    https://git.savannah.gnu.org/gitweb/?p=libffcall.git;a=blob;f=porting-tools/abis/function-pointer.txt.  */
+
+#define CODE(fn) (((struct func *) (fn))->code_address)
+#if ((defined __powerpc__ || defined __powerpc64__) && defined _AIX) || (defined __powerpc64__ && defined __linux__)
+struct func
+{
+  void *code_address;
+  void *toc_pointer;
+  void *static_chain;
+};
+#elif defined __ia64__
+struct func
+{
+  void *code_address;
+  void *global_pointer;
+};
+#elif defined __ia64_ilp32__
+struct func
+{
+  void *code_address;
+  void *unused1;
+  void *global_pointer;
+  void *unused2;
+};
+#elif __hppa__
+struct func
+{
+  void *code_address;
+  void *pic_base;
+};
+#elif __hppa64__
+struct func
+{
+  void *some_other_code_address;
+  void *some_other_pic_base;
+  void *code_address;
+  void *pic_base;
+};
+#else
+# undef CODE
+# define CODE(fn) ((void *) (fn))
+#endif
+
 /* This test assumes that the code generated by the compiler for the
    procedures `return1' and `return2' is position independent.  It
-   also assumes that function pointers are compatible with data
-   pointers and that these are bit-compatible to integers.  */
+   also assumes that data pointers are bit-compatible to integers.  */
 
 static int
 return1 (void)
