Fix conflict on UNUSED() macro from OpenJDK 7

The OpenJDK 7 recently introduced the UNUSED() macro in their jni_md.h
header file, which is included from <jni.h>.  This causes a
compile-error if "constants.h", which defines our own UNUSED() macro, is
included as well as <jni.h>.

The OpenJDK UNUSED() macro is unsuitable for our own use, because it
prefixes the unused identifier with "UNUSED_" whereas we depend on the
parameter name remaining unchanged.

I have reported this as a Request for Enhancement with Oracle Java,
asking them to remove the UNUSED() macro, since it is not used by any
JNI or Java extension header files.  Review ID: JI-9013689.

In the meantime, constants.h now undefines UNUSED before defining it, so
including <jni.h> before "constants.h" will avoid a compile error.
This commit is contained in:
Andrew Bettison 2014-07-23 10:33:41 +09:30
parent 5a38d2eb0c
commit d436705e64
13 changed files with 29 additions and 22 deletions

2
cli.c
View File

@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <stdio.h>
#include <assert.h>
#include "cli.h"
#include "constants.h"
#include "serval_types.h"
#include "rhizome_types.h"
@ -28,7 +29,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "str.h"
#include "strbuf_helpers.h"
#include "dataformats.h"
#include "cli.h"
int cli_usage(const struct cli_schema *commands, XPRINTF xpf)
{

5
cli.h
View File

@ -20,13 +20,12 @@
#ifndef __SERVAL_DNA__CLI_H
#define __SERVAL_DNA__CLI_H
#include "xprintf.h"
#include "log.h"
#include <stdint.h>
#ifdef HAVE_JNI_H
#include <jni.h>
#endif
#include "xprintf.h"
#include "log.h"
#define COMMAND_LINE_MAX_LABELS (32)

View File

@ -25,11 +25,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Number of elements in an array (Warning: does not work if A is a pointer!).
#define NELS(A) (sizeof (A) / sizeof *(A))
// Stop OpenJDK 7 from foisting their UNUSED() macro on us in <jni_md.h>
#ifdef UNUSED
# undef UNUSED
#endif
// To suppress the "unused parameter" warning from -Wunused-parameter.
#ifdef __GNUC__
# define UNUSED(x) x __attribute__((__unused__))
#ifndef __has_attribute
#define __has_attribute(x) 0
#endif
#if (defined(__GNUC__)) || __has_attribute(unused)
#define UNUSED(x) x __attribute__((__unused__))
#else
# define UNUSED(x) x
#define UNUSED(x) x
#endif
// UDP Port numbers for various Serval services.

View File

@ -23,8 +23,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <stdio.h>
#include <unistd.h>
#include <inttypes.h>
#include "constants.h"
#include "serval.h"
#include "constants.h"
#include "mdp_client.h"
#include "str.h"

View File

@ -52,13 +52,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <sys/stat.h>
#include <signal.h>
#include "sighandlers.h"
#include "serval.h"
#include "conf.h"
#include "str.h"
#include "strbuf.h"
#include "strbuf_helpers.h"
#include "dataformats.h"
#include "overlay_address.h"
#include "serval.h"
/*
The challenge with making an interface for calling an external program to

View File

@ -20,13 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <stdio.h>
#include <assert.h>
#include "constants.h"
#include "serval.h"
#include "str.h"
#include "mem.h"
#include "rotbuf.h"
#include "conf.h"
#include "rhizome.h"
#include "conf.h"
#include "constants.h"
#include "nacl.h"
#include "overlay_address.h"
#include "crypto.h"
@ -35,6 +32,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "overlay_buffer.h"
#include "keyring.h"
#include "dataformats.h"
#include "str.h"
#include "mem.h"
#include "rotbuf.h"
static void keyring_free_keypair(keypair *kp);
static void keyring_free_context(keyring_context *c);

View File

@ -17,8 +17,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "conf.h"
#include "serval.h"
#include "conf.h"
#include "httpd.h"
#include "strbuf_helpers.h"

View File

@ -18,11 +18,11 @@
*/
#include <signal.h>
#include "cli.h"
#include "serval_types.h"
#include "mdp_client.h"
#include "msp_client.h"
#include "fdqueue.h"
#include "cli.h"
#include "log.h"
#include "mem.h"
#include "str.h"

View File

@ -17,9 +17,9 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "cli.h"
#include "constants.h"
#include "os.h"
#include "cli.h"
int nonce_initialised=0;
unsigned char nonce_buffer[128];

View File

@ -17,8 +17,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "conf.h"
#include "serval.h"
#include "conf.h"
#include "httpd.h"
#include "str.h"
#include "strbuf.h"

View File

@ -17,8 +17,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "conf.h"
#include "serval.h"
#include "conf.h"
#include "httpd.h"
#include "strbuf_helpers.h"

View File

@ -117,11 +117,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <fcntl.h>
#include <sys/stat.h>
#include "cli.h"
#include "serval_types.h"
#include "sighandlers.h"
#include "instance.h"
#include "fdqueue.h"
#include "cli.h"
#include "constants.h"
#include "mem.h"
#include "xprintf.h"

View File

@ -24,15 +24,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <time.h>
#include <sys/time.h>
#include "console.h"
#include "conf.h"
#include "mem.h"
#include "socket.h"
#include "fdqueue.h"
#include "str.h"
#include "strbuf.h"
#include "strbuf_helpers.h"
#include "conf.h"
#include "net.h"
#include "console.h"
#include "limit.h"
#define MTU 1600