From 41f98a07fc3235b64713a39238238801304ac346 Mon Sep 17 00:00:00 2001 From: Siarhei Siamashka Date: Fri, 23 Nov 2012 09:07:23 +0200 Subject: test: Change is_little_endian() into inline function Also dropped redundant volatile keyword because any object can be accessed via char* pointer without breaking aliasing rules. The compilers are able to optimize this function to either constant 0 or 1. --- test/utils.c | 8 -------- test/utils.h | 8 ++++++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/test/utils.c b/test/utils.c index c887a6d..00e74e5 100644 --- a/test/utils.c +++ b/test/utils.c @@ -237,14 +237,6 @@ compute_crc32_for_image (uint32_t crc32, return crc32; } -pixman_bool_t -is_little_endian (void) -{ - volatile uint16_t endian_check_var = 0x1234; - - return (*(volatile uint8_t *)&endian_check_var == 0x34); -} - /* perform endian conversion of pixel data */ void diff --git a/test/utils.h b/test/utils.h index f7ea34c..fa05587 100644 --- a/test/utils.h +++ b/test/utils.h @@ -69,8 +69,12 @@ compute_crc32_for_image (uint32_t in_crc32, /* Returns TRUE if running on a little endian system */ -pixman_bool_t -is_little_endian (void); +static force_inline pixman_bool_t +is_little_endian (void) +{ + unsigned long endian_check_var = 1; + return *(unsigned char *)&endian_check_var == 1; +} /* perform endian conversion of pixel data */ -- cgit v1.2.3