[Libreoffice-commits] core.git: desktop/unx
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Thu Apr 7 08:40:16 UTC 2016
desktop/unx/source/file_image_unx.c | 30 +++++++++++-------------------
1 file changed, 11 insertions(+), 19 deletions(-)
New commits:
commit 71aa80300c89c726254049f775d1c48518b6dfe4
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Apr 7 01:32:05 2016 +0200
refactor pagein, as it still seems to cause rare crashes
Change-Id: I51e6cdf79c19c3709e00dc10175527ec6583a758
Reviewed-on: https://gerrit.libreoffice.org/23872
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Tested-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/desktop/unx/source/file_image_unx.c b/desktop/unx/source/file_image_unx.c
index 522c491..ec229f9 100644
--- a/desktop/unx/source/file_image_unx.c
+++ b/desktop/unx/source/file_image_unx.c
@@ -74,37 +74,29 @@ cleanup_and_leave:
*/
int file_image_pagein (file_image * image)
{
- file_image w;
- long s;
- size_t k;
- // force touching of each page despite the optimizer
+ long s = -1;
volatile char c =0;
+ size_t idx;
if (image == NULL)
return EINVAL;
-
- if ((w.m_base = image->m_base) == NULL)
+ if (image->m_base == NULL)
return EINVAL;
- if ((w.m_size = image->m_size) == 0)
+ if (image->m_size == 0)
return 0;
- if (madvise (w.m_base, w.m_size, MADV_WILLNEED) == -1)
+ if (madvise (image->m_base, image->m_size, MADV_WILLNEED) == -1)
return errno;
- if ((s = sysconf (_SC_PAGESIZE)) == -1)
+ s = sysconf (_SC_PAGESIZE);
+ if (s == -1)
s = 0x1000;
-
- k = (size_t)(s);
- while (w.m_size > k)
- {
- c ^= ((char*)(w.m_base))[0];
- w.m_base = (char*)(w.m_base) + k;
- w.m_size -= k;
- }
- if (w.m_size > 0)
+ // force touching of each page despite the optimizer
+ for(idx = 0; idx < image->m_size; idx += (size_t)s)
{
- c ^= ((char*)(w.m_base))[0];
+ c ^= ((volatile const char*)(image->m_base))[idx];
}
+ c ^= ((volatile const char*)(image->m_base))[image->m_size-1];
return 0;
}
More information about the Libreoffice-commits
mailing list