OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 #include <errno.h> | 6 #include <errno.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 | 9 |
10 int main(int argc, char* argv[]) { | 10 int main(int argc, char* argv[]) { |
(...skipping 15 matching lines...) Expand all Loading... |
26 if (err) { | 26 if (err) { |
27 fprintf(stderr, | 27 fprintf(stderr, |
28 "posix_memalign failed with err %d (EINVAL=%d,ENOMEM=%d)\n", | 28 "posix_memalign failed with err %d (EINVAL=%d,ENOMEM=%d)\n", |
29 err, EINVAL, ENOMEM); | 29 err, EINVAL, ENOMEM); |
30 fprintf(stderr, "Input params were align=%d, size=%d\n", | 30 fprintf(stderr, "Input params were align=%d, size=%d\n", |
31 align_to_test[i], sizes_to_test[j]); | 31 align_to_test[i], sizes_to_test[j]); |
32 return 1; | 32 return 1; |
33 } | 33 } |
34 if ((size_t)outp % align_to_test[i] != 0) { | 34 if ((size_t)outp % align_to_test[i] != 0) { |
35 fprintf(stderr, "posix_memalign failed to align to %zu: ptr=%p\n", | 35 fprintf(stderr, "posix_memalign failed to align to %zu: ptr=%p\n", |
36 align_to_test[i], outp); | 36 align_to_test[i], (void *) outp); |
37 return 1; | 37 return 1; |
38 } | 38 } |
39 free(outp); | 39 free(outp); |
40 j++; | 40 j++; |
41 } | 41 } |
42 i++; | 42 i++; |
43 } | 43 } |
44 | 44 |
45 /* Check that a non-power of 2 alignment fails. */ | 45 /* Check that a non-power of 2 alignment fails. */ |
46 if (posix_memalign((void**)&outp, 7, 20 * sizeof(char)) != EINVAL) { | 46 if (posix_memalign((void**)&outp, 7, 20 * sizeof(char)) != EINVAL) { |
47 fprintf(stderr, "posix_memaligned failed to return EINVAL for non-pow2!\n"); | 47 fprintf(stderr, "posix_memaligned failed to return EINVAL for non-pow2!\n"); |
48 return 1; | 48 return 1; |
49 } | 49 } |
50 | 50 |
51 /* Check that smaller than sizeof(void*) alignment fails. */ | 51 /* Check that smaller than sizeof(void*) alignment fails. */ |
52 if (posix_memalign((void**)&outp, sizeof(void*) - 1, | 52 if (posix_memalign((void**)&outp, sizeof(void*) - 1, |
53 20 * sizeof(char)) != EINVAL) { | 53 20 * sizeof(char)) != EINVAL) { |
54 fprintf(stderr, "posix_memaligned failed to return EINVAL for non-pow2!\n"); | 54 fprintf(stderr, "posix_memaligned failed to return EINVAL for non-pow2!\n"); |
55 return 1; | 55 return 1; |
56 } | 56 } |
57 | 57 |
58 return 0; | 58 return 0; |
59 } | 59 } |
OLD | NEW |