asm_defines.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef RTC_BASE_SYSTEM_ASM_DEFINES_H_
  11. #define RTC_BASE_SYSTEM_ASM_DEFINES_H_
  12. // clang-format off
  13. // clang formatting breaks everything here, e.g. concatenating directives,
  14. // due to absence of context via asm keyword.
  15. #if defined(__linux__) && defined(__ELF__)
  16. .section .note.GNU-stack,"",%progbits
  17. #endif
  18. // Define the macros used in ARM assembly code, so that for Mac or iOS builds
  19. // we add leading underscores for the function names.
  20. #ifdef __APPLE__
  21. .macro GLOBAL_FUNCTION name
  22. .global _\name
  23. .private_extern _\name
  24. .endm
  25. .macro DEFINE_FUNCTION name
  26. _\name:
  27. .endm
  28. .macro CALL_FUNCTION name
  29. bl _\name
  30. .endm
  31. .macro GLOBAL_LABEL name
  32. .global _\name
  33. .private_extern _\name
  34. .endm
  35. #else
  36. .macro GLOBAL_FUNCTION name
  37. .global \name
  38. .hidden \name
  39. .endm
  40. .macro DEFINE_FUNCTION name
  41. #if defined(__linux__) && defined(__ELF__)
  42. .type \name,%function
  43. #endif
  44. \name:
  45. .endm
  46. .macro CALL_FUNCTION name
  47. bl \name
  48. .endm
  49. .macro GLOBAL_LABEL name
  50. .global \name
  51. .hidden \name
  52. .endm
  53. #endif
  54. // With Apple's clang compiler, for instructions ldrb, strh, etc.,
  55. // the condition code is after the width specifier. Here we define
  56. // only the ones that are actually used in the assembly files.
  57. #if (defined __llvm__) && (defined __APPLE__)
  58. .macro streqh reg1, reg2, num
  59. strheq \reg1, \reg2, \num
  60. .endm
  61. #endif
  62. .text
  63. // clang-format on
  64. #endif // RTC_BASE_SYSTEM_ASM_DEFINES_H_