pixman: Branch 'master' - 2 commits

Pekka Paalanen pq at kemper.freedesktop.org
Wed Sep 9 01:35:14 PDT 2015


 test/utils.c |   23 +++++++++++++++++++----
 test/utils.h |    4 ++++
 2 files changed, 23 insertions(+), 4 deletions(-)

New commits:
commit e9ef2cc4dea04792a03d604c075c344055765217
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Tue Sep 8 09:36:48 2015 +0300

    utils.[ch]: add fence_get_page_size()
    
    Add a function to get the page size used for memory fence purposes, and
    use it everywhere where getpagesize() was used.
    
    This offers a single point in code to override the page size, in case
    one wants to experiment how the tests work with a higher page size than
    what the developer's machine has.
    
    This also offers a clean API, without adding #ifdefs, to tests for
    checking the page size.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
    Reviewed-by: Oded Gabbay <oded.gabbay at gmail.com>
    Reviewed-by: Ben Avison <bavison at riscosopen.org>

diff --git a/test/utils.c b/test/utils.c
index 9089ffc..222d4d5 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -382,6 +382,15 @@ typedef struct
 
 #if FENCE_MALLOC_ACTIVE
 
+unsigned long
+fence_get_page_size ()
+{
+    /* You can fake a page size here, if you want to test e.g. 64 kB
+     * pages on a 4 kB page system. Just put a multiplier below.
+     */
+    return getpagesize ();
+}
+
 /* This is apparently necessary on at least OS X */
 #ifndef MAP_ANONYMOUS
 #define MAP_ANONYMOUS MAP_ANON
@@ -390,7 +399,7 @@ typedef struct
 void *
 fence_malloc (int64_t len)
 {
-    unsigned long page_size = getpagesize();
+    unsigned long page_size = fence_get_page_size ();
     unsigned long page_mask = page_size - 1;
     uint32_t n_payload_bytes = (len + page_mask) & ~page_mask;
     uint32_t n_bytes =
@@ -439,7 +448,7 @@ fence_malloc (int64_t len)
 void
 fence_free (void *data)
 {
-    uint32_t page_size = getpagesize();
+    uint32_t page_size = fence_get_page_size ();
     uint8_t *payload = data;
     uint8_t *leading_protected = payload - N_LEADING_PROTECTED * page_size;
     uint8_t *initial_page = leading_protected - page_size;
@@ -472,7 +481,7 @@ fence_image_create_bits (pixman_format_code_t format,
                          int height,
                          pixman_bool_t stride_fence)
 {
-    unsigned page_size = getpagesize();
+    unsigned page_size = fence_get_page_size ();
     unsigned page_mask = page_size - 1;
     unsigned bitspp = PIXMAN_FORMAT_BPP (format);
     unsigned bits_boundary;
@@ -565,6 +574,12 @@ fence_image_create_bits (pixman_format_code_t format,
      */
 }
 
+unsigned long
+fence_get_page_size ()
+{
+    return 0;
+}
+
 #endif /* FENCE_MALLOC_ACTIVE */
 
 uint8_t *
diff --git a/test/utils.h b/test/utils.h
index 5aae554..e299d1d 100644
--- a/test/utils.h
+++ b/test/utils.h
@@ -112,6 +112,10 @@ fence_image_create_bits (pixman_format_code_t format,
                          int height,
                          pixman_bool_t stride_fence);
 
+/* Return the page size if FENCE_MALLOC_ACTIVE, or zero otherwise */
+unsigned long
+fence_get_page_size ();
+
 /* Generate n_bytes random bytes in fence_malloced memory */
 uint8_t *
 make_random_bytes (int n_bytes);
commit 82f8c997dfd3f60a48134107ecf38663b464bdc9
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Tue Sep 8 09:20:46 2015 +0300

    utils.c: fix fallback code for fence_image_create_bits()
    
    Used a wrong variable name, causing:
    /home/pq/git/pixman/demos/../test/utils.c: In function ‘fence_image_create_bits’:
    /home/pq/git/pixman/demos/../test/utils.c:562:46: error: ‘width’ undeclared (first use in this function)
    
    Use the correct variable.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
    Reviewed-by: Oded Gabbay <oded.gabbay at gmail.com>
    Reviewed-by: Ben Avison <bavison at riscosopen.org>

diff --git a/test/utils.c b/test/utils.c
index 783b97a..9089ffc 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -559,7 +559,7 @@ fence_image_create_bits (pixman_format_code_t format,
                          int height,
                          pixman_bool_t stride_fence)
 {
-    return pixman_image_create_bits (format, width, height, NULL, 0);
+    return pixman_image_create_bits (format, min_width, height, NULL, 0);
     /* Implicitly allocated storage does not need a destroy function
      * to get freed on refcount hitting zero.
      */


More information about the xorg-commit mailing list