ARM support

Orion Poplawski <[email protected]>
Newsgroups gmane.comp.gis.gmt.user
Message-ID <[email protected]>
While building GMT 5.1.0 for Fedora on ARM, I got:

cd /builddir/build/BUILD/gmt-5.1.0/build/src && /usr/bin/cc  -DLIBRARY_EXPORTS
-std=gnu99 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
-fexceptions -fstack-protector-strong --param=ssp-buffer-size=4
-grecord-gcc-switches  -march=armv7-a -mfpu=vfpv3-d16  -mfloat-abi=hard
-fopenmp -DNDEBUG -fPIC -I/builddir/build/BUILD/gmt-5.1.0/build/src
-I/builddir/build/BUILD/gmt-5.1.0/src -I/usr/include/gdal
-I/builddir/build/BUILD/gmt-5.1.0/build/src/gshhg
-I/builddir/build/BUILD/gmt-5.1.0/build/src/img
-I/builddir/build/BUILD/gmt-5.1.0/build/src/meca
-I/builddir/build/BUILD/gmt-5.1.0/build/src/mgd77
-I/builddir/build/BUILD/gmt-5.1.0/build/src/misc
-I/builddir/build/BUILD/gmt-5.1.0/build/src/potential
-I/builddir/build/BUILD/gmt-5.1.0/build/src/segy
-I/builddir/build/BUILD/gmt-5.1.0/build/src/spotter
-I/builddir/build/BUILD/gmt-5.1.0/build/src/x2sys    -o
CMakeFiles/gmtlib.dir/gmt_api.c.o   -c
/builddir/build/BUILD/gmt-5.1.0/src/gmt_api.c
/builddir/build/BUILD/gmt-5.1.0/src/common_sighandler.c: In function
'sig_handler':
/builddir/build/BUILD/gmt-5.1.0/src/common_sighandler.c:77:48: error:
'mcontext_t' has no member named 'gregs'
 #  define UC_IP(uc) ((void *) (uc)->uc_mcontext.gregs[REG_EIP])
                                                ^
/builddir/build/BUILD/gmt-5.1.0/src/common_sighandler.c:144:14: note: in
expansion of macro 'UC_IP'
  array [0] = UC_IP (uc); /* caller's address */
              ^
/builddir/build/BUILD/gmt-5.1.0/src/common_sighandler.c:77:55: error:
'REG_EIP' undeclared (first use in this function)
 #  define UC_IP(uc) ((void *) (uc)->uc_mcontext.gregs[REG_EIP])
                                                       ^
/builddir/build/BUILD/gmt-5.1.0/src/common_sighandler.c:144:14: note: in
expansion of macro 'UC_IP'
  array [0] = UC_IP (uc); /* caller's address */
              ^
/builddir/build/BUILD/gmt-5.1.0/src/common_sighandler.c:77:55: note: each
undeclared identifier is reported only once for each function it appears in
 #  define UC_IP(uc) ((void *) (uc)->uc_mcontext.gregs[REG_EIP])
                                                       ^
/builddir/build/BUILD/gmt-5.1.0/src/common_sighandler.c:144:14: note: in
expansion of macro 'UC_IP'
  array [0] = UC_IP (uc); /* caller's address */


The attached patch allows it to compile at least.  From what I've read it may
even be correct.

-- 
Orion Poplawski
Technical Manager                     303-415-9701 x222
NWRA, Boulder/CoRA Office             FAX: 303-415-9702
3380 Mitchell Lane                       [email protected]
Boulder, CO 80301                   http://www.nwra.com

To unsubscribe, send the message "signoff gmt-help" to [email protected]
GMT-arm.patch (text/x-patch, 1 KB)
diff -up gmt-5.1.0/src/common_sighandler.c.arm gmt-5.1.0/src/common_sighandler.c
--- gmt-5.1.0/src/common_sighandler.c.arm	2013-09-07 10:37:35.000000000 -0600
+++ gmt-5.1.0/src/common_sighandler.c	2014-01-02 09:43:42.226566150 -0700
@@ -67,18 +67,24 @@ void backtrace_symbols_fd(void *const *b
 #elif defined(__FreeBSD__)
 # ifdef __x86_64__
 #  define UC_IP(uc) ((void *) (uc)->uc_mcontext.mc_rip)
+# elif defined( __arm__)
+#  define UC_IP(uc) ((void *) (uc)->uc_mcontext.arm_pc)
 # else
 #  define UC_IP(uc) ((void *) (uc)->uc_mcontext.mc_eip)
 # endif
 #elif defined(SIZEOF_GREG_T)
 # ifdef __x86_64__
 #  define UC_IP(uc) ((void *) (uc)->uc_mcontext.gregs[REG_RIP])
+# elif defined( __arm__)
+#  define UC_IP(uc) ((void *) (uc)->uc_mcontext.arm_pc)
 # else
 #  define UC_IP(uc) ((void *) (uc)->uc_mcontext.gregs[REG_EIP])
 # endif
 #else
 # ifdef __x86_64__
 #  define UC_IP(uc) ((void *) (uc)->uc_mcontext.rip)
+# elif defined( __arm__)
+#  define UC_IP(uc) ((void *) (uc)->uc_mcontext.arm_pc)
 # else
 #  define UC_IP(uc) ((void *) (uc)->uc_mcontext.eip)
 # endif
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.