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

Side by Side Diff: src/untrusted/nacl/nacl_startup.h

Issue 7276050: Change startup ABI for untrusted code to be C-compatible (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: disable bogus stack_frame.cc test for now Created 9 years, 5 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/nacl/nacl_irt.c ('k') | src/untrusted/nacl/pthread_initialize_minimal.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
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
4 * found in the LICENSE file.
5 */
6
7 #ifndef NATIVE_CLIENT_SRC_UNTRUSTED_NACL_NACL_STARTUP_H_
8 #define NATIVE_CLIENT_SRC_UNTRUSTED_NACL_NACL_STARTUP_H_ 1
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14 /*
15 * The true entry point for untrusted code is called with the normal C ABI,
16 * taking one argument. This is a pointer to stack space containing these
17 * words:
18 * [0] cleanup function pointer (always NULL in actual startup)
19 * [1] envc, count of envp[] pointers
20 * [2] argc, count of argv[] pointers
21 * [3] argv[0..argc] pointers, argv[argc] being NULL
22 * [3+argc] envp[0..envc] pointers, envp[envc] being NULL
23 * [3+argc+envc] auxv[] pairs
24 */
25
26 enum NaClStartupInfoIndex {
27 NACL_STARTUP_FINI, /* Cleanup function pointer for dynamic linking. */
28 NACL_STARTUP_ENVC, /* Count of envp[] pointers. */
29 NACL_STARTUP_ARGC, /* Count of argv[] pointers. */
30 NACL_STARTUP_ARGV /* argv[0] pointer. */
31 };
32
33 /*
34 * Return the dynamic linker finalizer function.
35 */
36 static inline __attribute__((unused))
37 void (*nacl_startup_fini(const uint32_t info[]))(void) {
38 return (void (*)(void)) info[NACL_STARTUP_FINI];
39 }
40
41 /*
42 * Return the count of argument strings.
43 */
44 static inline __attribute__((unused))
45 int nacl_startup_argc(const uint32_t info[]) {
46 return info[NACL_STARTUP_ARGC];
47 }
48
49 /*
50 * Return the vector of argument strings.
51 */
52 static inline __attribute__((unused))
53 char **nacl_startup_argv(const uint32_t info[]) {
54 return (char **) &info[NACL_STARTUP_ARGV];
55 }
56
57 /*
58 * Return the count of environment strings.
59 */
60 static inline __attribute__((unused))
61 int nacl_startup_envc(const uint32_t info[]) {
62 return info[NACL_STARTUP_ENVC];
63 }
64
65 /*
66 * Return the vector of environment strings.
67 */
68 static inline __attribute__((unused))
69 char **nacl_startup_envp(const uint32_t info[]) {
70 return &nacl_startup_argv(info)[nacl_startup_argc(info) + 1];
71 }
72
73 /*
74 * Return the vector of auxiliary data items.
75 */
76 static inline __attribute__((unused))
77 Elf32_auxv_t *nacl_startup_auxv(const uint32_t info[]) {
78 char **envend = &nacl_startup_envp(info)[nacl_startup_envc(info) + 1];
79 return (Elf32_auxv_t *) envend;
80 }
81
82 #ifdef __cplusplus
83 }
84 #endif
85
86 #endif /* NATIVE_CLIENT_SRC_UNTRUSTED_NACL_NACL_STARTUP_H_ */
OLDNEW
« no previous file with comments | « src/untrusted/nacl/nacl_irt.c ('k') | src/untrusted/nacl/pthread_initialize_minimal.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698