Skip to content

Instantly share code, notes, and snippets.

@matlabbe
Created March 20, 2017 18:33
Show Gist options
  • Save matlabbe/726b490c658afd3293f4b3f2f501b863 to your computer and use it in GitHub Desktop.
Save matlabbe/726b490c658afd3293f4b3f2f501b863 to your computer and use it in GitHub Desktop.
GTSAM android patch
From 6a1c1cb56233bd4f990c72f9726167e774668d9d Mon Sep 17 00:00:00 2001
From: matlabbe <matlabbe@gmail.com>
Date: Mon, 20 Mar 2017 14:29:42 -0400
Subject: [PATCH] fixed metis/GKlib compilation errors for android
---
gtsam/3rdparty/metis/GKlib/GKlibSystem.cmake | 4 +++-
gtsam/3rdparty/metis/GKlib/error.c | 2 +-
gtsam/3rdparty/metis/GKlib/gk_externs.h | 1 -
gtsam/3rdparty/metis/GKlib/gk_macros.h | 2 +-
4 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/gtsam/3rdparty/metis/GKlib/GKlibSystem.cmake b/gtsam/3rdparty/metis/GKlib/GKlibSystem.cmake
index 7ea5bab..d5d2eb9 100644
--- a/gtsam/3rdparty/metis/GKlib/GKlibSystem.cmake
+++ b/gtsam/3rdparty/metis/GKlib/GKlibSystem.cmake
@@ -28,7 +28,7 @@ if(CYGWIN)
endif(CYGWIN)
if(CMAKE_COMPILER_IS_GNUCC)
# GCC opts.
- set(GKlib_COPTIONS "${GKlib_COPTIONS} -std=c99 -fno-strict-aliasing")
+ set(GKlib_COPTIONS "${GKlib_COPTIONS} -std=c99 -fno-strict-aliasing -fno-zero-initialized-in-bss")
if(NOT MINGW)
set(GKlib_COPTIONS "${GKlib_COPTIONS} -fPIC")
endif(NOT MINGW)
@@ -74,6 +74,8 @@ if(NOT ASSERT2)
set(GKlib_COPTIONS "${GKlib_COPTIONS} -DNDEBUG2")
endif(NOT ASSERT2)
+set(GKlib_COPTIONS "${GKlib_COPTIONS} -fno-zero-initialized-in-bss")
+
# Add various options
if(PCRE)
diff --git a/gtsam/3rdparty/metis/GKlib/error.c b/gtsam/3rdparty/metis/GKlib/error.c
index e2a18cf..6b71b7b 100644
--- a/gtsam/3rdparty/metis/GKlib/error.c
+++ b/gtsam/3rdparty/metis/GKlib/error.c
@@ -19,7 +19,7 @@ This file contains functions dealing with error reporting and termination
/* These are the jmp_buf for the graceful exit in case of severe errors.
Multiple buffers are defined to allow for recursive invokation. */
#define MAX_JBUFS 128
-__thread int gk_cur_jbufs=-1;
+int gk_cur_jbufs=-1;
__thread jmp_buf gk_jbufs[MAX_JBUFS];
__thread jmp_buf gk_jbuf;
diff --git a/gtsam/3rdparty/metis/GKlib/gk_externs.h b/gtsam/3rdparty/metis/GKlib/gk_externs.h
index 2c0fdd9..7f22634 100644
--- a/gtsam/3rdparty/metis/GKlib/gk_externs.h
+++ b/gtsam/3rdparty/metis/GKlib/gk_externs.h
@@ -16,7 +16,6 @@
**************************************************************************/
#ifndef _GK_ERROR_C_
/* declared in error.c */
-extern __thread int gk_cur_jbufs;
extern __thread jmp_buf gk_jbufs[];
extern __thread jmp_buf gk_jbuf;
diff --git a/gtsam/3rdparty/metis/GKlib/gk_macros.h b/gtsam/3rdparty/metis/GKlib/gk_macros.h
index d1e288b..8c1714d 100644
--- a/gtsam/3rdparty/metis/GKlib/gk_macros.h
+++ b/gtsam/3rdparty/metis/GKlib/gk_macros.h
@@ -49,7 +49,7 @@
* gracefull library exit macro
*-------------------------------------------------------------*/
#define GKSETJMP() (setjmp(gk_return_to_entry))
-#define gk_sigcatch() (setjmp(gk_jbufs[gk_cur_jbufs]))
+#define gk_sigcatch() (setjmp(gk_jbufs[-1]))
/*-------------------------------------------------------------
--
2.7.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment