asm.S 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #ifndef __MACH__
  56. .section .rodata
  57. #else
  58. .const_data
  59. #endif
  60. .align \align
  61. \name:
  62. .endm
  63. .macro movrel rd, val
  64. #if CONFIG_PIC && defined(__APPLE__)
  65. adrp \rd, \val@PAGE
  66. add \rd, \rd, \val@PAGEOFF
  67. #elif CONFIG_PIC
  68. adrp \rd, \val
  69. add \rd, \rd, :lo12:\val
  70. #else
  71. ldr \rd, =\val
  72. #endif
  73. .endm
  74. #define GLUE(a, b) a ## b
  75. #define JOIN(a, b) GLUE(a, b)
  76. #define X(s) JOIN(EXTERN_ASM, s)