asm.S 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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
  51. .macro endconst
  52. ELF .size \name, . - \name
  53. .purgem endconst
  54. .endm
  55. .section .rodata
  56. .align \align
  57. \name:
  58. .endm
  59. .macro movrel rd, val
  60. #if CONFIG_PIC && defined(__APPLE__)
  61. adrp \rd, \val@PAGE
  62. add \rd, \rd, \val@PAGEOFF
  63. #elif CONFIG_PIC
  64. adrp \rd, \val
  65. add \rd, \rd, :lo12:\val
  66. #else
  67. ldr \rd, =\val
  68. #endif
  69. .endm
  70. #define GLUE(a, b) a ## b
  71. #define JOIN(a, b) GLUE(a, b)
  72. #define X(s) JOIN(EXTERN_ASM, s)