• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavutil/ppc/intreadwrite.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
00003  *
00004  * This file is part of FFmpeg.
00005  *
00006  * FFmpeg is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * FFmpeg is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with FFmpeg; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00020 
00021 #ifndef AVUTIL_PPC_INTREADWRITE_H
00022 #define AVUTIL_PPC_INTREADWRITE_H
00023 
00024 #include <stdint.h>
00025 #include "config.h"
00026 
00027 #if HAVE_XFORM_ASM
00028 
00029 #define AV_RL16 AV_RL16
00030 static av_always_inline uint16_t AV_RL16(const void *p)
00031 {
00032     uint16_t v;
00033     __asm__ ("lhbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint16_t*)p));
00034     return v;
00035 }
00036 
00037 #define AV_WL16 AV_WL16
00038 static av_always_inline void AV_WL16(void *p, uint16_t v)
00039 {
00040     __asm__ ("sthbrx  %1, %y0" : "=Z"(*(uint16_t*)p) : "r"(v));
00041 }
00042 
00043 #define AV_RL32 AV_RL32
00044 static av_always_inline uint32_t AV_RL32(const void *p)
00045 {
00046     uint32_t v;
00047     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
00048     return v;
00049 }
00050 
00051 #define AV_WL32 AV_WL32
00052 static av_always_inline void AV_WL32(void *p, uint32_t v)
00053 {
00054     __asm__ ("stwbrx  %1, %y0" : "=Z"(*(uint32_t*)p) : "r"(v));
00055 }
00056 
00057 #if HAVE_LDBRX
00058 
00059 #define AV_RL64 AV_RL64
00060 static av_always_inline uint64_t AV_RL64(const void *p)
00061 {
00062     uint64_t v;
00063     __asm__ ("ldbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint64_t*)p));
00064     return v;
00065 }
00066 
00067 #define AV_WL64 AV_WL64
00068 static av_always_inline void AV_WL64(void *p, uint64_t v)
00069 {
00070     __asm__ ("stdbrx  %1, %y0" : "=Z"(*(uint64_t*)p) : "r"(v));
00071 }
00072 
00073 #else
00074 
00075 #define AV_RL64 AV_RL64
00076 static av_always_inline uint64_t AV_RL64(const void *p)
00077 {
00078     union { uint64_t v; uint32_t hl[2]; } v;
00079     __asm__ ("lwbrx   %0, %y2  \n\t"
00080              "lwbrx   %1, %y3  \n\t"
00081              : "=&r"(v.hl[1]), "=r"(v.hl[0])
00082              : "Z"(*(const uint32_t*)p), "Z"(*((const uint32_t*)p+1)));
00083     return v.v;
00084 }
00085 
00086 #define AV_WL64 AV_WL64
00087 static av_always_inline void AV_WL64(void *p, uint64_t v)
00088 {
00089     union { uint64_t v; uint32_t hl[2]; } vv = { v };
00090     __asm__ ("stwbrx  %2, %y0  \n\t"
00091              "stwbrx  %3, %y1  \n\t"
00092              : "=Z"(*(uint32_t*)p), "=Z"(*((uint32_t*)p+1))
00093              : "r"(vv.hl[1]), "r"(vv.hl[0]));
00094 }
00095 
00096 #endif /* HAVE_LDBRX */
00097 
00098 #endif /* HAVE_XFORM_ASM */
00099 
00100 /*
00101  * GCC fails miserably on the packed struct version which is used by
00102  * default, so we override it here.
00103  */
00104 
00105 #define AV_RB64(p) (*(const uint64_t *)(p))
00106 #define AV_WB64(p, v) (*(uint64_t *)(p) = (v))
00107 
00108 #endif /* AVUTIL_PPC_INTREADWRITE_H */

Generated on Fri Sep 16 2011 17:17:51 for FFmpeg by  doxygen 1.7.1