diff options
Diffstat (limited to 'tests/align.c')
-rw-r--r-- | tests/align.c | 87 |
1 files changed, 39 insertions, 48 deletions
diff --git a/tests/align.c b/tests/align.c index 1b2c540..bdb9cab 100644 --- a/tests/align.c +++ b/tests/align.c @@ -2,19 +2,7 @@ This file is part of the LZO real-time data compression library. - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer All Rights Reserved. The LZO library is free software; you can redistribute it and/or @@ -49,14 +37,14 @@ #include "examples/portab.h" -int opt_verbose = 0; +static int opt_verbose = 0; /************************************************************************* // **************************************************************************/ -long align_test(lzo_bytep block, lzo_uint len, lzo_uint step) +static unsigned long align_test(lzo_bytep block, lzo_uint len, lzo_uint step) { lzo_bytep b1 = block; lzo_bytep b2 = block; @@ -65,7 +53,7 @@ long align_test(lzo_bytep block, lzo_uint len, lzo_uint step) lzo_bytep k; lzo_bytep x; lzo_uint offset = 0; - long i = 0; + unsigned long i = 0; assert(step > 0); assert(step <= 65536L); @@ -77,20 +65,20 @@ long align_test(lzo_bytep block, lzo_uint len, lzo_uint step) k2 = b2 + offset; if (k1 != k2) { - printf("error 1: i %ld step %ld offset %ld: " - "%p (%ld) %p (%ld)\n", - i, (long) step, (long) offset, - k1, (long) (k1 - block), - k2, (long) (k2 - block)); + printf("error 1: i %lu step %ld offset %ld: " + "%p (%ld) %p (%ld)\n", + i, (long) step, (long) offset, + k1, (long) (k1 - block), + k2, (long) (k2 - block)); return 0; } if (k1 - step != b1) { - printf("error 2: i %ld step %ld offset %ld: " - "%p (%ld) %p (%ld)\n", - i, (long) step, (long) offset, - b1, (long) (b1 - block), - k1, (long) (k1 - block)); + printf("error 2: i %lu step %ld offset %ld: " + "%p (%ld) %p (%ld)\n", + i, (long) step, (long) offset, + b1, (long) (b1 - block), + k1, (long) (k1 - block)); return 0; } @@ -124,13 +112,13 @@ long align_test(lzo_bytep block, lzo_uint len, lzo_uint step) x = LZO_PTR_ALIGN_UP(k,step); if (x != k1) { - printf("error 3: base: %p %p %p i %ld step %ld offset %ld: " - "%p (%ld) %p (%ld) %p (%ld)\n", - block, b1, b2, - i, (long) step, (long) offset, - k1, (long) (k1 - block), - k, (long) (k - block), - x, (long) (x - block)); + printf("error 3: base: %p %p %p i %lu step %ld offset %ld: " + "%p (%ld) %p (%ld) %p (%ld)\n", + block, b1, b2, + i, (long) step, (long) offset, + k1, (long) (k1 - block), + k, (long) (k - block), + x, (long) (x - block)); return 0; } } @@ -147,7 +135,7 @@ long align_test(lzo_bytep block, lzo_uint len, lzo_uint step) // **************************************************************************/ -#define BLOCK_LEN (128*1024L) +#define BLOCK_SIZE (128*1024ul) int main(int argc, char *argv[]) { @@ -162,33 +150,39 @@ int main(int argc, char *argv[]) printf("lzo_init() failed !!!\n"); return 3; } - buf = (lzo_bytep) lzo_malloc(2*BLOCK_LEN + 256); + buf = (lzo_bytep) lzo_malloc(2*BLOCK_SIZE + 256); if (buf == NULL) { printf("out of memory\n"); return 2; } +#if defined(lzo_uintptr_t) + printf("Align init: %p ( 0x%lx )\n", buf, (unsigned long) (lzo_uintptr_t) buf); +#elif defined(__LZO_MMODEL_HUGE) printf("Align init: %p ( 0x%lx )\n", buf, (unsigned long) buf); +#else + printf("Align init: %p ( 0x%lx )\n", buf, (unsigned long) (size_t) buf); +#endif for (step = 1; step <= 65536L; step *= 2) { lzo_bytep block = buf; - long n; + unsigned long n; unsigned gap; - gap = __lzo_align_gap(block,step); - block = LZO_PTR_ALIGN_UP(block,step); + gap = __lzo_align_gap(block, step); + block = LZO_PTR_ALIGN_UP(block, step); if (opt_verbose >= 1) - printf("STEP %5ld: GAP: %5lu %p %p %5ld\n", - (long) step, (long) gap, buf, block, - (long) (block - buf)); - n = align_test(block,BLOCK_LEN,step); + printf("STEP %5lu: GAP: %5lu %p %p %5lu\n", + (unsigned long) step, (unsigned long) gap, buf, block, + (unsigned long) (block - buf)); + n = align_test(block, BLOCK_SIZE, step); if (n == 0) return 1; - if ((n + 1) * step != BLOCK_LEN) + if ((n + 1) * step != BLOCK_SIZE) { - printf("error 4: %ld %ld\n",(long)step,n); + printf("error 4: %ld %lu\n", (long)step, n); return 1; } } @@ -199,7 +193,4 @@ int main(int argc, char *argv[]) } -/* -vi:ts=4:et -*/ - +/* vim:set ts=4 sw=4 et: */ |