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

Side by Side Diff: src/untrusted/irt/irt_memory.c

Issue 12209042: Ensure syscall functions are consistently prefixed with "NaClSys" (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 7 years, 10 months 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 | « src/untrusted/irt/irt_malloc.c ('k') | src/untrusted/nacl/sbrk_private.c » ('j') | 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) 2011 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2011 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 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "native_client/src/untrusted/irt/irt.h" 10 #include "native_client/src/untrusted/irt/irt.h"
11 #include "native_client/src/untrusted/nacl/syscall_bindings_trampoline.h" 11 #include "native_client/src/untrusted/nacl/syscall_bindings_trampoline.h"
12 12
13 static int nacl_irt_sysbrk(void **newbrk) { 13 static int nacl_irt_sysbrk(void **newbrk) {
14 /* 14 /*
15 * The syscall does not actually indicate error. It just returns the 15 * The syscall does not actually indicate error. It just returns the
16 * new current value, which is unchanged if something went wrong. 16 * new current value, which is unchanged if something went wrong.
17 * But if the requested value was below the end of the data segment, 17 * But if the requested value was below the end of the data segment,
18 * the new value will be greater, but this is not "going wrong". 18 * the new value will be greater, but this is not "going wrong".
19 * Here we just approximate a saner interface: you get what you requested, 19 * Here we just approximate a saner interface: you get what you requested,
20 * you did a "probe" request passing NULL in, or it's an error. 20 * you did a "probe" request passing NULL in, or it's an error.
21 * TODO(mcgrathr): this interface should just go away!! 21 * TODO(mcgrathr): this interface should just go away!!
22 */ 22 */
23 void *requested = *newbrk; 23 void *requested = *newbrk;
24 void *got = NACL_SYSCALL(sysbrk)(requested); 24 void *got = NACL_SYSCALL(brk)(requested);
25 25
26 if (got == requested || requested == NULL) { 26 if (got == requested || requested == NULL) {
27 *newbrk = got; 27 *newbrk = got;
28 return 0; 28 return 0;
29 } 29 }
30 30
31 return ENOMEM; 31 return ENOMEM;
32 } 32 }
33 33
34 static int nacl_irt_mmap(void **addr, size_t len, 34 static int nacl_irt_mmap(void **addr, size_t len,
35 int prot, int flags, int fd, off_t off) { 35 int prot, int flags, int fd, off_t off) {
36 uint32_t rv = (uintptr_t) NACL_SYSCALL(mmap)(*addr, len, prot, flags, 36 uint32_t rv = (uintptr_t) NACL_SYSCALL(mmap)(*addr, len, prot, flags,
37 fd, &off); 37 fd, &off);
38 if ((uint32_t) rv > 0xffff0000u) 38 if ((uint32_t) rv > 0xffff0000u)
39 return -(int32_t) rv; 39 return -(int32_t) rv;
40 *addr = (void *) (uintptr_t) rv; 40 *addr = (void *) (uintptr_t) rv;
41 return 0; 41 return 0;
42 } 42 }
43 43
44 static int nacl_irt_munmap(void *addr, size_t len) { 44 static int nacl_irt_munmap(void *addr, size_t len) {
45 return -NACL_SYSCALL(munmap)(addr, len); 45 return -NACL_SYSCALL(munmap)(addr, len);
46 } 46 }
47 47
48 const struct nacl_irt_memory nacl_irt_memory = { 48 const struct nacl_irt_memory nacl_irt_memory = {
49 nacl_irt_sysbrk, 49 nacl_irt_sysbrk,
50 nacl_irt_mmap, 50 nacl_irt_mmap,
51 nacl_irt_munmap, 51 nacl_irt_munmap,
52 }; 52 };
OLDNEW
« no previous file with comments | « src/untrusted/irt/irt_malloc.c ('k') | src/untrusted/nacl/sbrk_private.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698