diff options
author | Siarhei Siamashka <siarhei.siamashka@gmail.com> | 2012-11-23 09:07:23 +0200 |
---|---|---|
committer | Siarhei Siamashka <siarhei.siamashka@gmail.com> | 2012-12-06 17:20:23 +0200 |
commit | 41f98a07fc3235b64713a39238238801304ac346 (patch) | |
tree | c500e7693a66e42f177db0bae5c3bd8d2ae8ae86 | |
parent | 978bab253d1d061b00b5e80aa45ab6986aac466f (diff) |
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.
-rw-r--r-- | test/utils.c | 8 | ||||
-rw-r--r-- | 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 */ |