asm.S 2.11 KB
Newer Older
1 2 3
/*
 * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
 *
4
 * This file is part of FFmpeg.
5
 *
6
 * FFmpeg is free software; you can redistribute it and/or
7 8 9 10
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
11
 * FFmpeg is distributed in the hope that it will be useful,
12 13 14 15 16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * 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 19 20 21 22 23 24 25
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "config.h"

#ifdef __ELF__
#   define ELF
#else
26
#   define ELF  #
27 28
#endif

29 30 31 32 33 34
#if HAVE_AS_FUNC
#   define FUNC
#else
#   define FUNC #
#endif

35 36 37
.macro  function name, export=0, align=2
    .macro endfunc
ELF     .size   \name, . - \name
38
FUNC    .endfunc
39 40 41 42 43 44
        .purgem endfunc
    .endm
        .text
        .align          \align
    .if \export
        .global EXTERN_ASM\name
45
ELF     .type   EXTERN_ASM\name, %function
46
FUNC    .func   EXTERN_ASM\name
47
EXTERN_ASM\name:
48
    .else
49
ELF     .type   \name, %function
50
FUNC    .func   \name
51
\name:
52
    .endif
53 54
.endm

55
.macro  const   name, align=2, relocate=0
56 57 58 59
    .macro endconst
ELF     .size   \name, . - \name
        .purgem endconst
    .endm
60 61 62 63 64 65 66
#if HAVE_SECTION_DATA_REL_RO
.if \relocate
        .section        .data.rel.ro
.else
        .section        .rodata
.endif
#elif !defined(__MACH__)
67
        .section        .rodata
68 69 70
#else
        .const_data
#endif
71 72 73 74 75
        .align          \align
\name:
.endm

.macro  movrel rd, val
76 77 78 79
#if CONFIG_PIC && defined(__APPLE__)
        adrp            \rd, \val@PAGE
        add             \rd, \rd, \val@PAGEOFF
#elif CONFIG_PIC
80
        adrp            \rd, \val
81
        add             \rd, \rd, :lo12:\val
82 83 84 85
#else
        ldr             \rd, =\val
#endif
.endm
86 87 88 89

#define GLUE(a, b) a ## b
#define JOIN(a, b) GLUE(a, b)
#define X(s) JOIN(EXTERN_ASM, s)