/*
* Copyright (c) 2009 Loren Merritt
*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
*
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
* 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.
*
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
* 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
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
+#define GLUE(a, b) a ## b
+#define JOIN(a, b) GLUE(a, b)
+#define X(s) JOIN(EXTERN_ASM, s)
+
+#if ARCH_PPC64
+
+#define PTR .quad
+#define lp ld
+#define lpx ldx
+#define stp std
+#define stpu stdu
+#define PS 8
+#define L(s) JOIN(., s)
+
+.macro extfunc name
+ .global X(\name)
+ .section .opd, "aw"
+X(\name):
+ .quad L(\name), .TOC.@tocbase, 0
+ .previous
+ .type X(\name), STT_FUNC
+L(\name):
+.endm
+
+.macro movrel rd, sym, gp
+ ld \rd, \sym@got(r2)
+.endm
+
+.macro get_got rd
+.endm
+
+#else /* ARCH_PPC64 */
+
+#define PTR .int
+#define lp lwz
+#define lpx lwzx
+#define stp stw
+#define stpu stwu
+#define PS 4
+#define L(s) s
+
+.macro extfunc name
+ .global X(\name)
+ .type X(\name), STT_FUNC
+X(\name):
+\name:
+.endm
+
+.macro movrel rd, sym, gp
+#if CONFIG_PIC
+ lwz \rd, \sym@got(\gp)
+#else
+ lis \rd, \sym@ha
+ la \rd, \sym@l(\rd)
+#endif
+.endm
+
+.macro get_got rd
+#if CONFIG_PIC
+ bcl 20, 31, .Lgot\@
+.Lgot\@:
+ mflr \rd
+ addis \rd, \rd, _GLOBAL_OFFSET_TABLE_ - .Lgot\@@ha
+ addi \rd, \rd, _GLOBAL_OFFSET_TABLE_ - .Lgot\@@l
+#endif
+.endm
+
+#endif /* ARCH_PPC64 */
+
#if HAVE_IBM_ASM
.macro DEFINE_REG n