asm.S 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "config.h"
  21. #ifdef __ELF__
  22. # define ELF
  23. #else
  24. # define ELF #
  25. #endif
  26. #if HAVE_AS_FUNC
  27. # define FUNC
  28. #else
  29. # define FUNC #
  30. #endif
  31. .macro function name, export=0, align=2
  32. .macro endfunc
  33. ELF .size \name, . - \name
  34. FUNC .endfunc
  35. .purgem endfunc
  36. .endm
  37. .text
  38. .align \align
  39. .if \export
  40. .global EXTERN_ASM\name
  41. ELF .type EXTERN_ASM\name, %function
  42. FUNC .func EXTERN_ASM\name
  43. EXTERN_ASM\name:
  44. .else
  45. ELF .type \name, %function
  46. FUNC .func \name
  47. \name:
  48. .endif
  49. .endm
  50. .macro const name, align=2, relocate=0
  51. .macro endconst
  52. ELF .size \name, . - \name
  53. .purgem endconst
  54. .endm
  55. #if HAVE_SECTION_DATA_REL_RO
  56. .if \relocate
  57. .section .data.rel.ro
  58. .else
  59. .section .rodata
  60. .endif
  61. #elif !defined(__MACH__)
  62. .section .rodata
  63. #else
  64. .const_data
  65. #endif
  66. .align \align
  67. \name:
  68. .endm
  69. .macro movrel rd, val
  70. #if CONFIG_PIC && defined(__APPLE__)
  71. adrp \rd, \val@PAGE
  72. add \rd, \rd, \val@PAGEOFF
  73. #elif CONFIG_PIC
  74. adrp \rd, \val
  75. add \rd, \rd, :lo12:\val
  76. #else
  77. ldr \rd, =\val
  78. #endif
  79. .endm
  80. #define GLUE(a, b) a ## b
  81. #define JOIN(a, b) GLUE(a, b)
  82. #define X(s) JOIN(EXTERN_ASM, s)