| Index: src/untrusted/nacl/nacl_irt_module.h
|
| diff --git a/src/untrusted/nacl/nacl_irt_module.h b/src/untrusted/nacl/nacl_irt_module.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7d2c5c0a1105e5edf6e1658d3b8875c25c5e6790
|
| --- /dev/null
|
| +++ b/src/untrusted/nacl/nacl_irt_module.h
|
| @@ -0,0 +1,130 @@
|
| +/*
|
| + * Copyright (c) 2013 The Native Client Authors. All rights reserved.
|
| + * Use of this source code is governed by a BSD-style license that can be
|
| + * found in the LICENSE file.
|
| + */
|
| +
|
| +#ifndef NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_MODULE_H_
|
| +#define NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_MODULE_H_
|
| +
|
| +#include "native_client/src/untrusted/irt/irt.h"
|
| +#include "native_client/src/untrusted/irt/irt_opt.h"
|
| +
|
| +#ifdef __cplusplus
|
| +extern "C" {
|
| +#endif
|
| +
|
| +#if 0
|
| +#define __init __attribute__((section(".init.text")))
|
| +
|
| +typedef int (*initcall_t)(void);
|
| +typedef int (*exitcall_t)(void);
|
| +
|
| +#define module_init(x) \
|
| + static initcall_t __initcall_##fn __attribute__((used)) \
|
| + __attribute__((section(".initcall.init"))) = fn
|
| +
|
| +#define module_exit(x) \
|
| + static exitcall_t __exitcall_##fn __exit_call = fn
|
| +#endif
|
| +
|
| +/*
|
| +void (*const preinit_array []) (void)
|
| + __attribute__ ((section(".preinit_array"),
|
| + aligned(sizeof(void *)))) = {
|
| + &irt_logged_init
|
| +};
|
| +
|
| +void (*const fini_array []) (void)
|
| + __attribute__ ((section(".fini_array"),
|
| + aligned(sizeof(void *)))) = {
|
| + &irt_logged_fini
|
| +};
|
| +*/
|
| +
|
| +//struct nacl_irt_interface {
|
| +// const char *name;
|
| +// const void *table;
|
| +// size_t size;
|
| +//};
|
| +
|
| +struct nacl_irt_layer {
|
| + TYPE_nacl_irt_query irt_query;
|
| + //struct nacl_irt_interface *interfaces;
|
| + //size_t interfaces_size;
|
| + struct nacl_irt_module *module;
|
| + void *user_data;
|
| +};
|
| +
|
| +struct nacl_irt_module {
|
| + const char *name;
|
| + struct nacl_irt_layer *(*factory)(struct nacl_irt_args *args,
|
| + struct nacl_irt_layer *next[]);
|
| + struct nacl_irt_module *next;
|
| +};
|
| +
|
| +struct nacl_irt {
|
| + struct nacl_irt_layer *layer;
|
| +};
|
| +
|
| +struct nacl_irt_context {
|
| + struct nacl_irt *irt;
|
| + void *private_data;
|
| +};
|
| +
|
| +extern struct nacl_irt_context *nacl_irt_get_context(void);
|
| +
|
| +extern struct nacl_irt_layer *nacl_irt_layer_new(
|
| + ///const struct nacl_irt_interface *interfaces,
|
| + //size_t interfaces_size,
|
| + TYPE_nacl_irt_query query,
|
| + void *user_data);
|
| +
|
| +extern void nacl_irt_layer_init(struct nacl_irt_layer *layer);
|
| +extern void nacl_irt_layer_destroy(struct nacl_irt_layer *layer);
|
| +
|
| +extern struct nacl_irt *nacl_irt_new(struct nacl_irt_args *args,
|
| + TYPE_nacl_irt_query query,
|
| + //const struct nacl_irt_interface *itf,
|
| + //size_t itf_size,
|
| + void *user_data);
|
| +
|
| +extern void nacl_irt_register_module(struct nacl_irt_module *module);
|
| +
|
| +extern void __libnacl_irt_register_module(struct nacl_irt_module *module);
|
| +
|
| +/*
|
| +#define NACL_IRT_REGISTER_MODULE(name, factory) \
|
| + static void __attribute__((section(".preinit_array"), unused)) name ## _register(void) \
|
| + { \
|
| + static struct nacl_irt_module module = \
|
| + { #name, &factory, NULL }; \
|
| + nacl_irt_register_module(&module); \
|
| + }
|
| +*/
|
| +
|
| +/*
|
| +#define NACL_IRT_REGISTER_MODULE(name, factory) \
|
| + static void name ## _register(void) { \
|
| + static struct nacl_irt_module module = \
|
| + { #name, &factory, NULL }; \
|
| + nacl_irt_register_module(&module); \
|
| + } \
|
| + __attribute__((section(".preinit_array"), __used__)) \
|
| + void (*__ ## name ## _preinit)(void) = name ## _register;
|
| +*/
|
| +
|
| +#define NACL_IRT_REGISTER_MODULE(name, factory) \
|
| + static void name ## _register(void) { \
|
| + static struct nacl_irt_module module = \
|
| + { #name, &factory, NULL }; \
|
| + nacl_irt_register_module(&module); \
|
| + } \
|
| + __attribute__((section(".preinit_array"), __used__)) \
|
| + void (*__ ## name ## _preinit)(void) = name ## _register;
|
| +
|
| +#ifdef __cplusplus
|
| +}
|
| +#endif
|
| +
|
| +#endif /* NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_MODULE_H_ */
|
|
|