Fix memory alignment issues on arm, aarch64, ppc64le (#1115905)
This commit is contained in:
parent
a19491f639
commit
bf85dd12e2
65
libgit2-0.21.0-arm.patch
Normal file
65
libgit2-0.21.0-arm.patch
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
From 5fa8cda981940eaef54b55abe4fcba09b4e18e12 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Russell Belfer <rb@github.com>
|
||||||
|
Date: Mon, 30 Jun 2014 12:05:25 -0700
|
||||||
|
Subject: [PATCH] Round up pool alloc sizes for alignment
|
||||||
|
|
||||||
|
To make sure that items returned from pool allocations are aligned
|
||||||
|
on nice boundaries, this rounds up all pool allocation sizes to a
|
||||||
|
multiple of 8. This adds a small amount of overhead to each item.
|
||||||
|
|
||||||
|
The rounding up could be made optional with an extra parameter to
|
||||||
|
the pool initialization that turned on rounding only for pools
|
||||||
|
where item alignment actually matters, but I think for the extra
|
||||||
|
code and complexity that would be involved, that it makes sense
|
||||||
|
just to burn a little bit of extra memory and enable this all the
|
||||||
|
time.
|
||||||
|
---
|
||||||
|
src/pool.c | 2 +-
|
||||||
|
tests/core/pool.c | 10 +++++-----
|
||||||
|
2 files changed, 6 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/pool.c b/src/pool.c
|
||||||
|
index 146f118..a516ff9 100644
|
||||||
|
--- a/src/pool.c
|
||||||
|
+++ b/src/pool.c
|
||||||
|
@@ -146,7 +146,7 @@ GIT_INLINE(void) pool_remove_page(
|
||||||
|
void *git_pool_malloc(git_pool *pool, uint32_t items)
|
||||||
|
{
|
||||||
|
git_pool_page *scan = pool->open, *prev;
|
||||||
|
- uint32_t size = items * pool->item_size;
|
||||||
|
+ uint32_t size = ((items * pool->item_size) + 7) & ~7;
|
||||||
|
void *ptr = NULL;
|
||||||
|
|
||||||
|
pool->has_string_alloc = 0;
|
||||||
|
diff --git a/tests/core/pool.c b/tests/core/pool.c
|
||||||
|
index 351d0c2..a7ec880 100644
|
||||||
|
--- a/tests/core/pool.c
|
||||||
|
+++ b/tests/core/pool.c
|
||||||
|
@@ -38,19 +38,19 @@ void test_core_pool__1(void)
|
||||||
|
cl_assert(git_pool_malloc(&p, i) != NULL);
|
||||||
|
|
||||||
|
/* with fixed page size, allocation must end up with these values */
|
||||||
|
- cl_assert(git_pool__open_pages(&p) == 1);
|
||||||
|
- cl_assert(git_pool__full_pages(&p) == 505);
|
||||||
|
+ cl_assert_equal_i(1, git_pool__open_pages(&p));
|
||||||
|
+ cl_assert_equal_i(507, git_pool__full_pages(&p));
|
||||||
|
|
||||||
|
git_pool_clear(&p);
|
||||||
|
|
||||||
|
- cl_git_pass(git_pool_init(&p, 1, 4100));
|
||||||
|
+ cl_git_pass(git_pool_init(&p, 1, 4120));
|
||||||
|
|
||||||
|
for (i = 2010; i > 0; i--)
|
||||||
|
cl_assert(git_pool_malloc(&p, i) != NULL);
|
||||||
|
|
||||||
|
/* with fixed page size, allocation must end up with these values */
|
||||||
|
- cl_assert(git_pool__open_pages(&p) == 1);
|
||||||
|
- cl_assert(git_pool__full_pages(&p) == 492);
|
||||||
|
+ cl_assert_equal_i(1, git_pool__open_pages(&p));
|
||||||
|
+ cl_assert_equal_i(492, git_pool__full_pages(&p));
|
||||||
|
|
||||||
|
git_pool_clear(&p);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
1.9.3
|
||||||
|
|
11
libgit2.spec
11
libgit2.spec
@ -1,10 +1,13 @@
|
|||||||
Name: libgit2
|
Name: libgit2
|
||||||
Version: 0.21.0
|
Version: 0.21.0
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
Summary: C implementation of the Git core methods as a library with a solid API
|
Summary: C implementation of the Git core methods as a library with a solid API
|
||||||
License: GPLv2 with exceptions
|
License: GPLv2 with exceptions
|
||||||
URL: http://libgit2.github.com/
|
URL: http://libgit2.github.com/
|
||||||
Source0: https://github.com/libgit2/libgit2/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
|
Source0: https://github.com/libgit2/libgit2/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
|
||||||
|
# https://github.com/libgit2/libgit2/issues/2450
|
||||||
|
Patch0: libgit2-0.21.0-arm.patch
|
||||||
|
|
||||||
BuildRequires: cmake
|
BuildRequires: cmake
|
||||||
BuildRequires: http-parser-devel
|
BuildRequires: http-parser-devel
|
||||||
BuildRequires: libssh2-devel
|
BuildRequires: libssh2-devel
|
||||||
@ -29,6 +32,7 @@ developing applications that use %{name}.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
|
%patch0 -p1
|
||||||
# Remove VCS files from examples
|
# Remove VCS files from examples
|
||||||
find examples -name ".gitignore" -delete -print
|
find examples -name ".gitignore" -delete -print
|
||||||
|
|
||||||
@ -50,7 +54,7 @@ make %{?_smp_mflags}
|
|||||||
|
|
||||||
%check
|
%check
|
||||||
# remove when rhbz#1105552 is fixed:
|
# remove when rhbz#1105552 is fixed:
|
||||||
%ifnarch %{arm} %{power64} s390x
|
%ifnarch ppc64 s390x
|
||||||
ctest -V
|
ctest -V
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
@ -70,6 +74,9 @@ ctest -V
|
|||||||
%{_includedir}/git2/
|
%{_includedir}/git2/
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Jul 18 2014 Yaakov Selkowitz <yselkowi@redhat.com> - 0.21.0-2
|
||||||
|
- Fix memory alignment issues on arm, aarch64, ppc64le (#1115905)
|
||||||
|
|
||||||
* Sat Jun 21 2014 Christopher Meng <rpm@cicku.me> - 0.21.0-1
|
* Sat Jun 21 2014 Christopher Meng <rpm@cicku.me> - 0.21.0-1
|
||||||
- Update to 0.21.0
|
- Update to 0.21.0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user