Support compilers that don't have the "inline" keyword
Use AC_C_INLINE autoconf macro, include config.h where needed, and add a define of JSON_INLINE to jansson.h that has the correct "inline" keyword.
This commit is contained in:
parent
c7c2edae8a
commit
29ee3832cf
1
.gitignore
vendored
1
.gitignore
vendored
@ -23,3 +23,4 @@ missing
|
|||||||
stamp-h1
|
stamp-h1
|
||||||
*.pyc
|
*.pyc
|
||||||
*.pc
|
*.pc
|
||||||
|
/src/jansson.h
|
||||||
|
@ -17,6 +17,14 @@ AC_PROG_LIBTOOL
|
|||||||
# Checks for typedefs, structures, and compiler characteristics.
|
# Checks for typedefs, structures, and compiler characteristics.
|
||||||
AC_TYPE_INT32_T
|
AC_TYPE_INT32_T
|
||||||
|
|
||||||
|
AC_C_INLINE
|
||||||
|
case $ac_cv_c_inline in
|
||||||
|
yes) json_inline=inline;;
|
||||||
|
no) json_inline=;;
|
||||||
|
*) json_inline=$ac_cv_c_inline;;
|
||||||
|
esac
|
||||||
|
AC_SUBST([json_inline])
|
||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
|
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
@ -24,6 +32,7 @@ AC_CONFIG_FILES([
|
|||||||
Makefile
|
Makefile
|
||||||
doc/Makefile
|
doc/Makefile
|
||||||
src/Makefile
|
src/Makefile
|
||||||
|
src/jansson.h
|
||||||
test/Makefile
|
test/Makefile
|
||||||
test/bin/Makefile
|
test/bin/Makefile
|
||||||
test/suites/Makefile
|
test/suites/Makefile
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
* it under the terms of the MIT license. See LICENSE for details.
|
* it under the terms of the MIT license. See LICENSE for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "hashtable.h"
|
#include "hashtable.h"
|
||||||
|
|
||||||
|
@ -10,7 +10,10 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifndef __cplusplus
|
||||||
|
#define JSON_INLINE @json_inline@
|
||||||
|
#else
|
||||||
|
#define JSON_INLINE inline
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -56,7 +59,8 @@ json_t *json_true(void);
|
|||||||
json_t *json_false(void);
|
json_t *json_false(void);
|
||||||
json_t *json_null(void);
|
json_t *json_null(void);
|
||||||
|
|
||||||
static inline json_t *json_incref(json_t *json)
|
static JSON_INLINE
|
||||||
|
json_t *json_incref(json_t *json)
|
||||||
{
|
{
|
||||||
if(json && json->refcount != (unsigned int)-1)
|
if(json && json->refcount != (unsigned int)-1)
|
||||||
++json->refcount;
|
++json->refcount;
|
||||||
@ -66,7 +70,8 @@ static inline json_t *json_incref(json_t *json)
|
|||||||
/* do not call json_delete directly */
|
/* do not call json_delete directly */
|
||||||
void json_delete(json_t *json);
|
void json_delete(json_t *json);
|
||||||
|
|
||||||
static inline void json_decref(json_t *json)
|
static JSON_INLINE
|
||||||
|
void json_decref(json_t *json)
|
||||||
{
|
{
|
||||||
if(json && json->refcount != (unsigned int)-1 && --json->refcount == 0)
|
if(json && json->refcount != (unsigned int)-1 && --json->refcount == 0)
|
||||||
json_delete(json);
|
json_delete(json);
|
||||||
@ -87,13 +92,13 @@ void *json_object_iter_next(json_t *object, void *iter);
|
|||||||
const char *json_object_iter_key(void *iter);
|
const char *json_object_iter_key(void *iter);
|
||||||
json_t *json_object_iter_value(void *iter);
|
json_t *json_object_iter_value(void *iter);
|
||||||
|
|
||||||
static inline
|
static JSON_INLINE
|
||||||
int json_object_set(json_t *object, const char *key, json_t *value)
|
int json_object_set(json_t *object, const char *key, json_t *value)
|
||||||
{
|
{
|
||||||
return json_object_set_new(object, key, json_incref(value));
|
return json_object_set_new(object, key, json_incref(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static JSON_INLINE
|
||||||
int json_object_set_nocheck(json_t *object, const char *key, json_t *value)
|
int json_object_set_nocheck(json_t *object, const char *key, json_t *value)
|
||||||
{
|
{
|
||||||
return json_object_set_new_nocheck(object, key, json_incref(value));
|
return json_object_set_new_nocheck(object, key, json_incref(value));
|
||||||
@ -108,19 +113,19 @@ int json_array_remove(json_t *array, unsigned int index);
|
|||||||
int json_array_clear(json_t *array);
|
int json_array_clear(json_t *array);
|
||||||
int json_array_extend(json_t *array, json_t *other);
|
int json_array_extend(json_t *array, json_t *other);
|
||||||
|
|
||||||
static inline
|
static JSON_INLINE
|
||||||
int json_array_set(json_t *array, unsigned int index, json_t *value)
|
int json_array_set(json_t *array, unsigned int index, json_t *value)
|
||||||
{
|
{
|
||||||
return json_array_set_new(array, index, json_incref(value));
|
return json_array_set_new(array, index, json_incref(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static JSON_INLINE
|
||||||
int json_array_append(json_t *array, json_t *value)
|
int json_array_append(json_t *array, json_t *value)
|
||||||
{
|
{
|
||||||
return json_array_append_new(array, json_incref(value));
|
return json_array_append_new(array, json_incref(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static JSON_INLINE
|
||||||
int json_array_insert(json_t *array, unsigned int index, json_t *value)
|
int json_array_insert(json_t *array, unsigned int index, json_t *value)
|
||||||
{
|
{
|
||||||
return json_array_insert_new(array, index, json_incref(value));
|
return json_array_insert_new(array, index, json_incref(value));
|
@ -6,6 +6,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user