ofldend.cpp 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. Copyright (c) 2014 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_host.h"
  28. #include "offload_myo_host.h"
  29. #else
  30. #include "offload_target.h"
  31. #include "offload_myo_target.h"
  32. #endif
  33. #ifdef TARGET_WINNT
  34. #define ALLOCATE(name) __declspec(allocate(name))
  35. #else // TARGET_WINNT
  36. #define ALLOCATE(name) __attribute__((section(name)))
  37. #endif // TARGET_WINNT
  38. // offload entry table
  39. ALLOCATE(OFFLOAD_ENTRY_TABLE_SECTION_END)
  40. #ifdef TARGET_WINNT
  41. __declspec(align(sizeof(FuncTable::Entry)))
  42. #endif // TARGET_WINNT
  43. static FuncTable::Entry __offload_entry_table_end = { (const char*)-1 };
  44. // offload function table
  45. ALLOCATE(OFFLOAD_FUNC_TABLE_SECTION_END)
  46. #ifdef TARGET_WINNT
  47. __declspec(align(sizeof(FuncTable::Entry)))
  48. #endif // TARGET_WINNT
  49. static FuncTable::Entry __offload_func_table_end = { (const char*)-1 };
  50. // data table
  51. ALLOCATE(OFFLOAD_VAR_TABLE_SECTION_END)
  52. #ifdef TARGET_WINNT
  53. __declspec(align(sizeof(VarTable::Entry)))
  54. #endif // TARGET_WINNT
  55. static VarTable::Entry __offload_var_table_end = { (const char*)-1 };
  56. #ifdef MYO_SUPPORT
  57. // offload myo shared var section epilog
  58. ALLOCATE(OFFLOAD_MYO_SHARED_TABLE_SECTION_END)
  59. #ifdef TARGET_WINNT
  60. __declspec(align(sizeof(SharedTableEntry)))
  61. static SharedTableEntry __offload_myo_shared_table_end = { (const char*)-1, 0 };
  62. #else // TARGET_WINNT
  63. static SharedTableEntry __offload_myo_shared_table_end = { 0 };
  64. #endif // TARGET_WINNT
  65. #if HOST_LIBRARY
  66. // offload myo shared var init section epilog
  67. ALLOCATE(OFFLOAD_MYO_SHARED_INIT_TABLE_SECTION_END)
  68. #ifdef TARGET_WINNT
  69. __declspec(align(sizeof(InitTableEntry)))
  70. static InitTableEntry __offload_myo_shared_init_table_end = { (const char*)-1, 0 };
  71. #else // TARGET_WINNT
  72. static InitTableEntry __offload_myo_shared_init_table_end = { 0 };
  73. #endif // TARGET_WINNT
  74. #endif // HOST_LIBRARY
  75. // offload myo fptr section epilog
  76. ALLOCATE(OFFLOAD_MYO_FPTR_TABLE_SECTION_END)
  77. #ifdef TARGET_WINNT
  78. __declspec(align(sizeof(FptrTableEntry)))
  79. static FptrTableEntry __offload_myo_fptr_table_end = { (const char*)-1, 0, 0 };
  80. #else // TARGET_WINNT
  81. static FptrTableEntry __offload_myo_fptr_table_end = { 0 };
  82. #endif // TARGET_WINNT
  83. #endif // MYO_SUPPORT