2 * inline.c --- Includes the inlined functions defined in the header
3 * files as standalone functions, in case the application program
4 * is compiled with inlining turned off.
6 * Copyright (C) 1993, 1994 Theodore Ts'o.
9 * This file may be redistributed under the terms of the GNU Library
10 * General Public License, version 2.
27 #include <sys/types.h>
34 #define INCLUDE_INLINE_FUNCS
38 * We used to define this as an inline, but since we are now using
39 * autoconf-defined #ifdef's, we need to export this as a
40 * library-provided function exclusively.
42 errcode_t ext2fs_get_memalign(unsigned long size,
43 unsigned long align, void *ptr)
50 #ifdef HAVE_POSIX_MEMALIGN
51 retval = posix_memalign(p, align, size);
54 return EXT2_ET_NO_MEMORY;
59 *p = memalign(align, size);
64 return EXT2_ET_NO_MEMORY;
68 if (align > sizeof(long long))
73 if ((unsigned long) *p & (align - 1)) {
78 return EXT2_ET_NO_MEMORY;
85 static int isaligned(void *ptr, unsigned long align)
87 return (((unsigned long) ptr & (align - 1)) == 0);
90 static errcode_t test_memalign(unsigned long align)
95 retval = ext2fs_get_memalign(32, align, &ptr);
96 if (!retval && !isaligned(ptr, align))
99 printf("tst_memliagn(%lu): %s\n", align,
100 retval ? error_message(retval) : "OK");
104 int main(int argc, char **argv)
108 if (test_memalign(4))
110 if (test_memalign(32))
112 if (test_memalign(1024))
114 if (test_memalign(4096))