ofldend.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions
  5. are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of Intel Corporation nor the names of its
  12. contributors may be used to endorse or promote products derived
  13. from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  15. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  16. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  18. HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  19. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  20. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  21. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  22. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #if HOST_LIBRARY
  27. #include "offload_table.h"
  28. #ifdef MYO_SUPPORT
  29. #include "offload_myo_host.h"
  30. #endif // MYO_SUPPORT
  31. #else
  32. #include "offload_target.h"
  33. #ifdef MYO_SUPPORT
  34. #include "offload_myo_target.h"
  35. #endif // MYO_SUPPORT
  36. #endif // HOST_LIBRARY
  37. #ifdef TARGET_WINNT
  38. #define ALLOCATE(name) __declspec(allocate(name))
  39. #else // TARGET_WINNT
  40. #define ALLOCATE(name) __attribute__((section(name)))
  41. #endif // TARGET_WINNT
  42. // offload entry table
  43. ALLOCATE(OFFLOAD_ENTRY_TABLE_SECTION_END)
  44. #ifdef TARGET_WINNT
  45. __declspec(align(sizeof(FuncTable::Entry)))
  46. #endif // TARGET_WINNT
  47. static FuncTable::Entry __offload_entry_table_end = { (const char*)-1 };
  48. // offload function table
  49. ALLOCATE(OFFLOAD_FUNC_TABLE_SECTION_END)
  50. #ifdef TARGET_WINNT
  51. __declspec(align(sizeof(FuncTable::Entry)))
  52. #endif // TARGET_WINNT
  53. static FuncTable::Entry __offload_func_table_end = { (const char*)-1 };
  54. // data table
  55. ALLOCATE(OFFLOAD_VAR_TABLE_SECTION_END)
  56. #ifdef TARGET_WINNT
  57. __declspec(align(sizeof(VarTable::Entry)))
  58. #endif // TARGET_WINNT
  59. static VarTable::Entry __offload_var_table_end = { (const char*)-1 };
  60. #ifdef MYO_SUPPORT
  61. // offload myo shared var section epilog
  62. ALLOCATE(OFFLOAD_MYO_SHARED_TABLE_SECTION_END)
  63. #ifdef TARGET_WINNT
  64. __declspec(align(sizeof(SharedTableEntry)))
  65. static MYOVarTable::Entry __offload_myo_shared_var_end =
  66. { (const char*)-1, 0 };
  67. #else // TARGET_WINNT
  68. static MYOVarTable::Entry __offload_myo_shared_var_end = { 0 };
  69. #endif // TARGET_WINNT
  70. // offload myo shared vtable section epilog
  71. ALLOCATE(OFFLOAD_MYO_SHARED_VTABLE_SECTION_END)
  72. #ifdef TARGET_WINNT
  73. __declspec(align(sizeof(SharedTableEntry)))
  74. static MYOVarTable::Entry __offload_myo_shared_vtable_end =
  75. { (const char*)-1, 0 };
  76. #else // TARGET_WINNT
  77. static MYOVarTable::Entry __offload_myo_shared_vtable_end = { 0 };
  78. #endif // TARGET_WINNT
  79. //#if HOST_LIBRARY
  80. // offload myo shared var init section epilog
  81. ALLOCATE(OFFLOAD_MYO_SHARED_INIT_TABLE_SECTION_END)
  82. #ifdef TARGET_WINNT
  83. __declspec(align(sizeof(InitTableEntry)))
  84. static MYOInitTable::Entry __offload_myo_init_table_end =
  85. { (const char*)-1, 0 };
  86. #else // TARGET_WINNT
  87. static MYOInitTable::Entry __offload_myo_init_table_end = { 0 };
  88. #endif // TARGET_WINNT
  89. //#endif // HOST_LIBRARY
  90. // offload myo fptr section epilog
  91. ALLOCATE(OFFLOAD_MYO_FPTR_TABLE_SECTION_END)
  92. #ifdef TARGET_WINNT
  93. __declspec(align(sizeof(FptrTableEntry)))
  94. static MYOFuncTable::Entry __offload_myo_fptr_table_end =
  95. { (const char*)-1, 0, 0 };
  96. #else // TARGET_WINNT
  97. static MYOFuncTable::Entry __offload_myo_fptr_table_end = { 0 };
  98. #endif // TARGET_WINNT
  99. #endif // MYO_SUPPORT