From: Lin Xu Date: Mon, 10 Sep 2012 00:33:35 +0000 (-0700) Subject: Add an autoconf test to test whether the .section .gnu X-Git-Tag: upstream/0.11~43^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e7e0600405b1f06f0b1f3ad3c174de4832f9756e;p=platform%2Fupstream%2Fjson-c.git Add an autoconf test to test whether the .section .gnu works with the linker on the system, and define _warn_references to nothing if not. --- diff --git a/config.h.in b/config.h.in index 34ad9a8..8263c08 100644 --- a/config.h.in +++ b/config.h.in @@ -1,5 +1,8 @@ /* config.h.in. Generated from configure.in by autoheader. */ +/* Define if .gnu.warning accepts long strings. */ +#undef HAS_GNU_WARNING_LONG + /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H @@ -114,9 +117,6 @@ /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME -/* Define to the home page for this package. */ -#undef PACKAGE_URL - /* Define to the version of this package. */ #undef PACKAGE_VERSION diff --git a/configure.in b/configure.in index 5b2eea3..387b422 100644 --- a/configure.in +++ b/configure.in @@ -37,6 +37,24 @@ AC_FUNC_MALLOC AC_FUNC_REALLOC AC_CHECK_FUNCS(strcasecmp strdup strndup strerror snprintf vsnprintf vasprintf open vsyslog strncasecmp) +#check if .section.gnu.warning accepts long strings (for __warn_references) +AC_LANG_PUSH([C]) + +AC_MSG_CHECKING([if .gnu.warning accepts long strings]) +AC_LINK_IFELSE([[ +extern void json_object_get(); +__asm__(".section .gnu.json_object_get,\n\t.ascii \"Please link against libjson-c instead of libjson\"\n\t.text"); + +int main(int c,char* v) {return 0;} +]], [ + AC_DEFINE(HAS_GNU_WARNING_LONG, 1, [Define if .gnu.warning accepts long strings.]) + AC_MSG_RESULT(yes) +], [ + AC_MSG_RESULT(no) +]) + +AC_LANG_POP([C]) + AM_PROG_LIBTOOL AC_CONFIG_FILES([ diff --git a/libjson.c b/libjson.c index 48fc3a4..5284fd0 100644 --- a/libjson.c +++ b/libjson.c @@ -7,11 +7,10 @@ #ifndef __warn_references -#ifdef __GNUC__ -#define __warn_references(sym,msg) \ - __asm(".pushsection .gnu.warning." #sym "\n" \ - ".ascii \"" msg "\"\n" \ - ".popsection"); +#if defined(__GNUC__) && defined (HAS_GNU_WARNING_LONG) + +#define __warn_references(sym,msg) \ + __asm__(".section .gnu" #sym ",\n\t.ascii \"" msg "\"\n\t.text"); #else #define __warn_references(sym,msg) /* nothing */