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

Unified Diff: src/untrusted/nacl/nacl_irt.c

Issue 25027006: Stackable IRT Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/untrusted/nacl/nacl_irt.h ('k') | src/untrusted/nacl/nacl_irt_init.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/untrusted/nacl/nacl_irt.c
diff --git a/src/untrusted/nacl/nacl_irt.c b/src/untrusted/nacl/nacl_irt.c
index 888f38d6b32ea3ce804ec46c7e43b961245e0ea9..3202f1009252dac7e21a1a4909bdbadf38fe6209 100644
--- a/src/untrusted/nacl/nacl_irt.c
+++ b/src/untrusted/nacl/nacl_irt.c
@@ -7,6 +7,9 @@
#include <string.h>
#include <unistd.h>
+#include "native_client/src/include/elf_auxv.h"
+#include "native_client/src/include/elf32.h"
+#include "native_client/src/include/nacl_macros.h"
#include "native_client/src/untrusted/irt/irt_interfaces.h"
#include "native_client/src/untrusted/nacl/nacl_irt.h"
@@ -43,6 +46,7 @@ static int stub_getdents(int fd, struct dirent *dirent, size_t count,
return ENOSYS;
}
+struct nacl_irt_instance __libnacl_irt_instance;
struct nacl_irt_basic __libnacl_irt_basic;
struct nacl_irt_memory __libnacl_irt_memory;
struct nacl_irt_tls __libnacl_irt_tls;
@@ -65,6 +69,43 @@ struct nacl_irt_fdio __libnacl_irt_fdio = {
TYPE_nacl_irt_query __nacl_irt_query;
+struct nacl_interface_table {
+ const char *name;
+ void *table;
+ size_t size;
+};
+
+static const struct nacl_interface_table irt_interfaces[] = {
+ { NACL_IRT_INSTANCE_v0_1, &__libnacl_irt_instance, sizeof(__libnacl_irt_instance) },
+ { NACL_IRT_BASIC_v0_1, &__libnacl_irt_basic, sizeof(__libnacl_irt_basic) },
+ { NACL_IRT_DEV_FDIO_v0_1, &__libnacl_irt_fdio, sizeof(__libnacl_irt_fdio) },
+ { NACL_IRT_FILENAME_v0_1, &__libnacl_irt_dev_filename, sizeof(struct nacl_irt_filename) },
+ { NACL_IRT_DEV_FILENAME_v0_2, &__libnacl_irt_dev_filename, sizeof(__libnacl_irt_dev_filename) },
+ { NACL_IRT_MEMORY_v0_1, &__libnacl_irt_memory, sizeof(struct nacl_irt_memory_v0_1) },
+ { NACL_IRT_MEMORY_v0_2, &__libnacl_irt_memory, sizeof(struct nacl_irt_memory_v0_2) },
+ { NACL_IRT_MEMORY_v0_3, &__libnacl_irt_memory, sizeof(struct nacl_irt_memory) },
+ { NACL_IRT_TLS_v0_1, &__libnacl_irt_tls, sizeof(__libnacl_irt_tls) },
+ { NACL_IRT_CLOCK_v0_1, &__libnacl_irt_clock, sizeof(__libnacl_irt_clock) },
+ { NACL_IRT_DEV_GETPID_v0_1, &__libnacl_irt_dev_getpid,
+ sizeof(__libnacl_irt_dev_getpid) },
+};
+
+int nacl_irt_interface_set(const char *interface_ident,
+ void *table, size_t tablesize, void *old_table) {
+ int i;
+ for (i = 0; i < NACL_ARRAY_SIZE(irt_interfaces); ++i) {
+ if (0 == strcmp(interface_ident, irt_interfaces[i].name)) {
+ const size_t size = irt_interfaces[i].size;
+ if (size <= tablesize) {
+ memcpy(old_table, irt_interfaces[i].table, size);
+ memcpy(irt_interfaces[i].table, table, size);
+ return size;
+ }
+ break;
+ }
+ }
+ return 0;
+}
/*
* Avoid a dependency on libc's strlen function.
@@ -106,7 +147,6 @@ static void __libnacl_fatal(const char* message) {
}
-
int __libnacl_irt_query(const char *interface,
void *table, size_t table_size) {
if (NULL == __nacl_irt_query) {
@@ -125,9 +165,6 @@ void __libnacl_mandatory_irt_query(const char *interface,
}
}
-/*
- * Used to lazily initialize an IRT interface function.
- */
int __libnacl_irt_init_fn(void *interface_field, void (*init)(void)) {
if (*((void **) interface_field) == NULL) {
init();
« no previous file with comments | « src/untrusted/nacl/nacl_irt.h ('k') | src/untrusted/nacl/nacl_irt_init.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698