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
21#include "config.h"
22
23#ifdef __ELF__
24#   define ELF
25#else
26#   define ELF  #
27#endif
28
29#if HAVE_AS_FUNC
30#   define FUNC
31#else
32#   define FUNC #
33#endif
34
35.macro  function name, export=0, align=2
36    .macro endfunc
37ELF     .size   \name, . - \name
38FUNC    .endfunc
39        .purgem endfunc
40    .endm
41        .text
42        .align          \align
43    .if \export
44        .global EXTERN_ASM\name
45ELF     .type   EXTERN_ASM\name, %function
46FUNC    .func   EXTERN_ASM\name
47EXTERN_ASM\name:
48    .else
49ELF     .type   \name, %function
50FUNC    .func   \name
51\name:
52    .endif
53.endm
54
55.macro  const   name, align=2
56    .macro endconst
57ELF     .size   \name, . - \name
58        .purgem endconst
59    .endm
60        .section        .rodata
61        .align          \align
62\name:
63.endm
64
65.macro  movrel rd, val
66#if CONFIG_PIC && defined(__APPLE__)
67        adrp            \rd, \val@PAGE
68        add             \rd, \rd, \val@PAGEOFF
69#elif CONFIG_PIC
70        adrp            \rd, \val
71        add             \rd, \rd, :lo12:\val
72#else
73        ldr             \rd, =\val
74#endif
75.endm
76
77#define GLUE(a, b) a ## b
78#define JOIN(a, b) GLUE(a, b)
79#define X(s) JOIN(EXTERN_ASM, s)
80