Add upstream patch for adding size_t json_c_object_sizeof()

Enable partial multi-threaded support
This commit is contained in:
Björn Esser 2017-12-13 16:52:21 +01:00
parent 841610c9e0
commit b89190535a
No known key found for this signature in database
GPG Key ID: F52E98007594C21D
4 changed files with 132 additions and 11 deletions

View File

@ -0,0 +1,20 @@
From 87556afe2a062c28bccd910ec5bc22b9988726e7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <besser82@fedoraproject.org>
Date: Sun, 10 Dec 2017 16:29:41 +0100
Subject: [PATCH] Makefile: Add ACLOCAL_AMFLAGS
This is recommended by the libtool manual.
---
Makefile.am | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Makefile.am b/Makefile.am
index 5ad354a4a3..a0a43fc8bc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,5 @@
+ACLOCAL_AMFLAGS = -I autoconf-archive/m4
+
EXTRA_DIST = README.md README.html
EXTRA_DIST += config.h.win32
EXTRA_DIST += Doxyfile

View File

@ -0,0 +1,42 @@
From c123a1c21b944b3391fe022263ebfcdc15e5c5d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <besser82@fedoraproject.org>
Date: Mon, 11 Dec 2017 12:55:40 +0100
Subject: [PATCH] json_object: Add size_t json_object_sizeof()
---
json_object.c | 5 +++++
json_object.h | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/json_object.c b/json_object.c
index 9daa6fdb0a..f12d8f08d8 100644
--- a/json_object.c
+++ b/json_object.c
@@ -509,6 +509,11 @@ int json_object_object_length(const struct json_object *jso)
return lh_table_length(jso->o.c_object);
}
+size_t json_object_sizeof(void)
+{
+ return sizeof(struct json_object);
+}
+
struct json_object* json_object_object_get(const struct json_object* jso,
const char *key)
{
diff --git a/json_object.h b/json_object.h
index 283eb95300..6a2751d228 100644
--- a/json_object.h
+++ b/json_object.h
@@ -392,6 +392,11 @@ JSON_EXPORT struct lh_table* json_object_get_object(const struct json_object *ob
*/
JSON_EXPORT int json_object_object_length(const struct json_object* obj);
+/** Get the sizeof (struct json_object).
+ * @returns a size_t with the sizeof (struct json_object)
+ */
+JSON_EXPORT size_t json_object_sizeof(void);
+
/** Add an object field to a json_object of type json_type_object
*
* The reference count will *not* be incremented. This is to make adding

View File

@ -0,0 +1,51 @@
From 5b6d62259afbc1709d4437b8c488de429079cae0 Mon Sep 17 00:00:00 2001
From: Eric Haszlakiewicz <erh+git@nimenees.com>
Date: Tue, 12 Dec 2017 18:26:51 -0500
Subject: [PATCH] Apply gcc's "const" attribute to the json_c_object_sizeof()
function as an optimizer hint. Also, rename that function from
json_object_sizeof().
---
json_object.c | 2 +-
json_object.h | 8 +++++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/json_object.c b/json_object.c
index f12d8f08d8..042477a71b 100644
--- a/json_object.c
+++ b/json_object.c
@@ -509,7 +509,7 @@ int json_object_object_length(const struct json_object *jso)
return lh_table_length(jso->o.c_object);
}
-size_t json_object_sizeof(void)
+size_t json_c_object_sizeof(void)
{
return sizeof(struct json_object);
}
diff --git a/json_object.h b/json_object.h
index 6a2751d228..758efa6f1d 100644
--- a/json_object.h
+++ b/json_object.h
@@ -27,6 +27,12 @@
#define THIS_FUNCTION_IS_DEPRECATED(func) func
#endif
+#ifdef __GNUC__
+#define JSON_C_CONST_FUNCTION(func) func __attribute__((const))
+#else
+#define CONST_FUNCTION(func) func
+#endif
+
#if defined(_MSC_VER)
#define JSON_EXPORT __declspec(dllexport)
#else
@@ -395,7 +401,7 @@ JSON_EXPORT int json_object_object_length(const struct json_object* obj);
/** Get the sizeof (struct json_object).
* @returns a size_t with the sizeof (struct json_object)
*/
-JSON_EXPORT size_t json_object_sizeof(void);
+JSON_C_CONST_FUNCTION(JSON_EXPORT size_t json_c_object_sizeof(void));
/** Add an object field to a json_object of type json_type_object
*

View File

@ -1,4 +1,7 @@
%{!?_pkgdocdir:%global _pkgdocdir %{_docdir}/%{name}-%{version}}
%global so_ver 3 %global so_ver 3
%global reldate 20171207
# Uncomment when building a bootstrap for a bumped so-name. # Uncomment when building a bootstrap for a bumped so-name.
# You also need to adjust the parameters below. # You also need to adjust the parameters below.
@ -10,24 +13,24 @@
%global so_ver_old 2 %global so_ver_old 2
%endif %endif
%global reldate 20171207
%{!?_pkgdocdir:%global _pkgdocdir %{_docdir}/%{name}-%{version}}
Name: json-c Name: json-c
Version: 0.13 Version: 0.13
Release: 2%{?dist} Release: 3%{?dist}
Summary: JSON implementation in C Summary: JSON implementation in C
License: MIT License: MIT
URL: https://github.com/%{name}/%{name} URL: https://github.com/%{name}/%{name}
Source0: %{url}/archive/%{name}-%{version}-%{reldate}.tar.gz Source0: %{url}/archive/%{name}-%{version}-%{reldate}.tar.gz
%if 0%{?bootstrap} %if 0%{?bootstrap}
Source1: %{url}/archive/%{name}-%{version_old}-%{reldate_old}.tar.gz Source1: %{url}/archive/%{name}-%{version_old}-%{reldate_old}.tar.gz
%endif %endif
BuildRequires: autoconf # Upstreamed.
BuildRequires: automake Patch0: %{url}/pull/386.patch#/%{name}-0.13_Makefile_add_aclocal_amflags.patch
Patch1: %{url}/commit/94fd101601c24627ae44498a7a73e9f2d9fb6e91.patch#/%{name}-0.13_json_object_add_size_t_json_c_object_sizeof_1.patch
Patch2: %{url}/commit/5b6d62259afbc1709d4437b8c488de429079cae0.patch#/%{name}-0.13_json_object_add_size_t_json_c_object_sizeof_2.patch
BuildRequires: libtool BuildRequires: libtool
%description %description
@ -68,7 +71,6 @@ for doc in ChangeLog; do
%{__mv} -f ${doc}.new ${doc} %{__mv} -f ${doc}.new ${doc}
done done
%{_bindir}/echo -e '\nACLOCAL_AMFLAGS = -I autoconf-archive/m4' >> Makefile.am
%{_bindir}/autoreconf -fiv %{_bindir}/autoreconf -fiv
%if 0%{?bootstrap} %if 0%{?bootstrap}
@ -85,8 +87,10 @@ popd
%configure \ %configure \
--disable-silent-rules \ --disable-silent-rules \
--disable-static \ --disable-static \
--enable-rdrand \
--enable-shared \ --enable-shared \
--enable-rdrand --enable-threading
%make_build %make_build
%{_bindir}/doxygen Doxyfile %{_bindir}/doxygen Doxyfile
@ -97,8 +101,8 @@ pushd bootstrap_ver
--disable-rpath \ --disable-rpath \
--disable-silent-rules \ --disable-silent-rules \
--disable-static \ --disable-static \
--enable-shared \ --enable-rdrand \
--enable-rdrand --enable-shared
%make_build %make_build
popd popd
%endif %endif
@ -171,6 +175,10 @@ end
%changelog %changelog
* Wed Dec 13 2017 Björn Esser <besser82@fedoraproject.org> - 0.13-3
- Add upstream patch for adding size_t json_c_object_sizeof()
- Enable partial multi-threaded support
* Mon Dec 11 2017 Björn Esser <besser82@fedoraproject.org> - 0.13-2 * Mon Dec 11 2017 Björn Esser <besser82@fedoraproject.org> - 0.13-2
- Drop json_object_private.h - Drop json_object_private.h