diff libavutil/ppc/intreadwrite.h @ 2:897f711a7157

rearrange to work with autoconf
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Tue, 25 Sep 2012 15:55:33 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libavutil/ppc/intreadwrite.h	Tue Sep 25 15:55:33 2012 +0200
     1.3 @@ -0,0 +1,108 @@
     1.4 +/*
     1.5 + * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
     1.6 + *
     1.7 + * This file is part of FFmpeg.
     1.8 + *
     1.9 + * FFmpeg is free software; you can redistribute it and/or
    1.10 + * modify it under the terms of the GNU Lesser General Public
    1.11 + * License as published by the Free Software Foundation; either
    1.12 + * version 2.1 of the License, or (at your option) any later version.
    1.13 + *
    1.14 + * FFmpeg is distributed in the hope that it will be useful,
    1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.17 + * Lesser General Public License for more details.
    1.18 + *
    1.19 + * You should have received a copy of the GNU Lesser General Public
    1.20 + * License along with FFmpeg; if not, write to the Free Software
    1.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
    1.22 + */
    1.23 +
    1.24 +#ifndef AVUTIL_PPC_INTREADWRITE_H
    1.25 +#define AVUTIL_PPC_INTREADWRITE_H
    1.26 +
    1.27 +#include <stdint.h>
    1.28 +#include "config.h"
    1.29 +
    1.30 +#if HAVE_XFORM_ASM
    1.31 +
    1.32 +#define AV_RL16 AV_RL16
    1.33 +static av_always_inline uint16_t AV_RL16(const void *p)
    1.34 +{
    1.35 +    uint16_t v;
    1.36 +    __asm__ ("lhbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint16_t*)p));
    1.37 +    return v;
    1.38 +}
    1.39 +
    1.40 +#define AV_WL16 AV_WL16
    1.41 +static av_always_inline void AV_WL16(void *p, uint16_t v)
    1.42 +{
    1.43 +    __asm__ ("sthbrx  %1, %y0" : "=Z"(*(uint16_t*)p) : "r"(v));
    1.44 +}
    1.45 +
    1.46 +#define AV_RL32 AV_RL32
    1.47 +static av_always_inline uint32_t AV_RL32(const void *p)
    1.48 +{
    1.49 +    uint32_t v;
    1.50 +    __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
    1.51 +    return v;
    1.52 +}
    1.53 +
    1.54 +#define AV_WL32 AV_WL32
    1.55 +static av_always_inline void AV_WL32(void *p, uint32_t v)
    1.56 +{
    1.57 +    __asm__ ("stwbrx  %1, %y0" : "=Z"(*(uint32_t*)p) : "r"(v));
    1.58 +}
    1.59 +
    1.60 +#if HAVE_LDBRX
    1.61 +
    1.62 +#define AV_RL64 AV_RL64
    1.63 +static av_always_inline uint64_t AV_RL64(const void *p)
    1.64 +{
    1.65 +    uint64_t v;
    1.66 +    __asm__ ("ldbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint64_t*)p));
    1.67 +    return v;
    1.68 +}
    1.69 +
    1.70 +#define AV_WL64 AV_WL64
    1.71 +static av_always_inline void AV_WL64(void *p, uint64_t v)
    1.72 +{
    1.73 +    __asm__ ("stdbrx  %1, %y0" : "=Z"(*(uint64_t*)p) : "r"(v));
    1.74 +}
    1.75 +
    1.76 +#else
    1.77 +
    1.78 +#define AV_RL64 AV_RL64
    1.79 +static av_always_inline uint64_t AV_RL64(const void *p)
    1.80 +{
    1.81 +    union { uint64_t v; uint32_t hl[2]; } v;
    1.82 +    __asm__ ("lwbrx   %0, %y2  \n\t"
    1.83 +             "lwbrx   %1, %y3  \n\t"
    1.84 +             : "=&r"(v.hl[1]), "=r"(v.hl[0])
    1.85 +             : "Z"(*(const uint32_t*)p), "Z"(*((const uint32_t*)p+1)));
    1.86 +    return v.v;
    1.87 +}
    1.88 +
    1.89 +#define AV_WL64 AV_WL64
    1.90 +static av_always_inline void AV_WL64(void *p, uint64_t v)
    1.91 +{
    1.92 +    union { uint64_t v; uint32_t hl[2]; } vv = { v };
    1.93 +    __asm__ ("stwbrx  %2, %y0  \n\t"
    1.94 +             "stwbrx  %3, %y1  \n\t"
    1.95 +             : "=Z"(*(uint32_t*)p), "=Z"(*((uint32_t*)p+1))
    1.96 +             : "r"(vv.hl[1]), "r"(vv.hl[0]));
    1.97 +}
    1.98 +
    1.99 +#endif /* HAVE_LDBRX */
   1.100 +
   1.101 +#endif /* HAVE_XFORM_ASM */
   1.102 +
   1.103 +/*
   1.104 + * GCC fails miserably on the packed struct version which is used by
   1.105 + * default, so we override it here.
   1.106 + */
   1.107 +
   1.108 +#define AV_RB64(p) (*(const uint64_t *)(p))
   1.109 +#define AV_WB64(p, v) (*(uint64_t *)(p) = (v))
   1.110 +
   1.111 +#endif /* AVUTIL_PPC_INTREADWRITE_H */