Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: tests/libc/posix_memalign.c

Issue 41683003: Remove newlib header workaround for run_posix_memalign_test. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: rebase Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/libc/nacl.scons ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /* Newlib currently does not have posix_memalign in its headers, though
11 * the malloc implementation (dlmalloc) does support it.
12 * http://code.google.com/p/nativeclient/issues/detail?id=2505
13 */
14 #if defined(NEWLIB)
15 extern int posix_memalign(void **memptr, size_t alignment, size_t size);
16 #endif
17
18 int main(int argc, char* argv[]) { 10 int main(int argc, char* argv[]) {
19 char *outp; 11 char *outp;
20 /* Try a few alignments, some of them might be the standard malloc align. 12 /* Try a few alignments, some of them might be the standard malloc align.
21 * They should all be powers of 2 and be a multiple of sizeof(void*). 13 * They should all be powers of 2 and be a multiple of sizeof(void*).
22 */ 14 */
23 size_t align_to_test[] = {4, 8, 16, 32, 64, 128, 256, 512, 1024, 0}; 15 size_t align_to_test[] = {4, 8, 16, 32, 64, 128, 256, 512, 1024, 0};
24 size_t sizes_to_test[] = {1, 2, 4, 8, 10, 16, 32, 64, 128, 256, 512, 1024, 0}; 16 size_t sizes_to_test[] = {1, 2, 4, 8, 10, 16, 32, 64, 128, 256, 512, 1024, 0};
25 int i = 0; 17 int i = 0;
26 int j = 0; 18 int j = 0;
27 19
(...skipping 30 matching lines...) Expand all
58 50
59 /* Check that smaller than sizeof(void*) alignment fails. */ 51 /* Check that smaller than sizeof(void*) alignment fails. */
60 if (posix_memalign((void**)&outp, sizeof(void*) - 1, 52 if (posix_memalign((void**)&outp, sizeof(void*) - 1,
61 20 * sizeof(char)) != EINVAL) { 53 20 * sizeof(char)) != EINVAL) {
62 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");
63 return 1; 55 return 1;
64 } 56 }
65 57
66 return 0; 58 return 0;
67 } 59 }
OLDNEW
« no previous file with comments | « tests/libc/nacl.scons ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698