OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2013 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_IRT_IRT_MODULE_H_ |
| 8 #define NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_MODULE_H_ |
| 9 |
| 10 #include "native_client/src/untrusted/irt/irt.h" |
| 11 #include "native_client/src/untrusted/irt/irt_opt.h" |
| 12 |
| 13 #ifdef __cplusplus |
| 14 extern "C" { |
| 15 #endif |
| 16 |
| 17 #if 0 |
| 18 #define __init __attribute__((section(".init.text"))) |
| 19 |
| 20 typedef int (*initcall_t)(void); |
| 21 typedef int (*exitcall_t)(void); |
| 22 |
| 23 #define module_init(x) \ |
| 24 static initcall_t __initcall_##fn __attribute__((used)) \ |
| 25 __attribute__((section(".initcall.init"))) = fn |
| 26 |
| 27 #define module_exit(x) \ |
| 28 static exitcall_t __exitcall_##fn __exit_call = fn |
| 29 #endif |
| 30 |
| 31 /* |
| 32 void (*const preinit_array []) (void) |
| 33 __attribute__ ((section(".preinit_array"), |
| 34 aligned(sizeof(void *)))) = { |
| 35 &irt_logged_init |
| 36 }; |
| 37 |
| 38 void (*const fini_array []) (void) |
| 39 __attribute__ ((section(".fini_array"), |
| 40 aligned(sizeof(void *)))) = { |
| 41 &irt_logged_fini |
| 42 }; |
| 43 */ |
| 44 |
| 45 //struct nacl_irt_interface { |
| 46 // const char *name; |
| 47 // const void *table; |
| 48 // size_t size; |
| 49 //}; |
| 50 |
| 51 struct nacl_irt_layer { |
| 52 TYPE_nacl_irt_query irt_query; |
| 53 //struct nacl_irt_interface *interfaces; |
| 54 //size_t interfaces_size; |
| 55 struct nacl_irt_module *module; |
| 56 void *user_data; |
| 57 }; |
| 58 |
| 59 struct nacl_irt_module { |
| 60 const char *name; |
| 61 struct nacl_irt_layer *(*factory)(struct nacl_irt_args *args, |
| 62 struct nacl_irt_layer *next[]); |
| 63 struct nacl_irt_module *next; |
| 64 }; |
| 65 |
| 66 struct nacl_irt { |
| 67 struct nacl_irt_layer *layer; |
| 68 }; |
| 69 |
| 70 struct nacl_irt_context { |
| 71 struct nacl_irt *irt; |
| 72 void *private_data; |
| 73 }; |
| 74 |
| 75 extern struct nacl_irt_context *nacl_irt_get_context(void); |
| 76 |
| 77 extern struct nacl_irt_layer *nacl_irt_layer_new( |
| 78 ///const struct nacl_irt_interface *interfaces, |
| 79 //size_t interfaces_size, |
| 80 TYPE_nacl_irt_query query, |
| 81 void *user_data); |
| 82 |
| 83 extern void nacl_irt_layer_init(struct nacl_irt_layer *layer); |
| 84 extern void nacl_irt_layer_destroy(struct nacl_irt_layer *layer); |
| 85 |
| 86 extern struct nacl_irt *nacl_irt_new(struct nacl_irt_args *args, |
| 87 TYPE_nacl_irt_query query, |
| 88 //const struct nacl_irt_interface *itf, |
| 89 //size_t itf_size, |
| 90 void *user_data); |
| 91 |
| 92 extern void nacl_irt_register_module(struct nacl_irt_module *module); |
| 93 |
| 94 extern void __libnacl_irt_register_module(struct nacl_irt_module *module); |
| 95 |
| 96 /* |
| 97 #define NACL_IRT_REGISTER_MODULE(name, factory) \ |
| 98 static void __attribute__((section(".preinit_array"), unused)) name ## _regist
er(void) \ |
| 99 { \ |
| 100 static struct nacl_irt_module module = \ |
| 101 { #name, &factory, NULL }; \ |
| 102 nacl_irt_register_module(&module); \ |
| 103 } |
| 104 */ |
| 105 |
| 106 /* |
| 107 #define NACL_IRT_REGISTER_MODULE(name, factory) \ |
| 108 static void name ## _register(void) { \ |
| 109 static struct nacl_irt_module module = \ |
| 110 { #name, &factory, NULL }; \ |
| 111 nacl_irt_register_module(&module); \ |
| 112 } \ |
| 113 __attribute__((section(".preinit_array"), __used__)) \ |
| 114 void (*__ ## name ## _preinit)(void) = name ## _register; |
| 115 */ |
| 116 |
| 117 #define NACL_IRT_REGISTER_MODULE(name, factory) \ |
| 118 static void name ## _register(void) { \ |
| 119 static struct nacl_irt_module module = \ |
| 120 { #name, &factory, NULL }; \ |
| 121 nacl_irt_register_module(&module); \ |
| 122 } \ |
| 123 __attribute__((section(".preinit_array"), __used__)) \ |
| 124 void (*__ ## name ## _preinit)(void) = name ## _register; |
| 125 |
| 126 #ifdef __cplusplus |
| 127 } |
| 128 #endif |
| 129 |
| 130 #endif /* NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_MODULE_H_ */ |
OLD | NEW |