/usr/include/osl/container/tripleInt.h is in libosl-dev 0.6.0-3.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | /* tripleInt.h
*/
#ifndef EVAL_CONTAINER_TRIPLE_INT_H
#define EVAL_CONTAINER_TRIPLE_INT_H
#include "osl/misc/carray.h"
#include "osl/misc/align16New.h"
#include "osl/misc/cstdint.h"
#include "osl/config.h"
#include <iosfwd>
#if (defined __INTEL_COMPILER || defined __clang__)
# include <emmintrin.h>
# define __builtin_ia32_pxor128 _mm_xor_si128
# define __builtin_ia32_psubd128 _mm_sub_epi32
# define __builtin_ia32_paddd128 _mm_add_epi32
#endif
#ifndef OSL_NO_SSE
#if (defined __x86_64__) || (defined __i386__)
# ifndef OSL_USE_SSE
# define OSL_USE_SSE 1
# endif
#else
# warning "TripleInt without SSE"
#endif
#endif
namespace osl
{
namespace container
{
#ifndef OSL_USE_SSE
typedef CArray<int32_t,4> v4si;
typedef CArray<int64_t,2> v2di;
#elif defined __INTEL_COMPILER
typedef __v4si v4si;
typedef __v2di v2di;
#else
typedef int v4si __attribute__ ((vector_size (16)));
typedef long long v2di __attribute__ ((vector_size (16)));
#endif
struct TripleInt : public misc::Align16New
{
union XMM{
CArray<int,4> iv;
v4si v4;
v2di v2;
} v
#ifdef __GNUC__
__attribute__((aligned(16)))
#endif
;
TripleInt(){
#if OSL_USE_SSE
assert(reinterpret_cast<size_t>(this) % 16 == 0);
#endif
clear();
}
TripleInt(TripleInt const& si){
#if OSL_USE_SSE
assert(reinterpret_cast<size_t>(this) % 16 == 0);
v.v4=si.v.v4;
#else
for(int i=0;i<3;i++) v.iv[i]=si.v.iv[i];
#endif
}
TripleInt(int a, int b, int c){
#if OSL_USE_SSE
assert(reinterpret_cast<size_t>(this) % 16 == 0);
v.v4 = (v4si){a, b, c, 0};
#elif __GNUC__
v.iv = (CArray<int,4>){{a, b, c, 0}};
#else
v.iv[0] = a, v.iv[1] = b, v.iv[2] = c;
#endif
}
void clear()
{
#if OSL_USE_SSE
v.v4=(v4si){ 0, 0, 0, 0 };
#else
for(int i=0;i<3;i++) v.iv[i]=0;
#endif
}
int& operator[](int i) {
return v.iv[i];
}
const int& operator[](int i) const {
return v.iv[i];
}
TripleInt operator-() const{
TripleInt ret;
#if OSL_USE_SSE
ret.v.v4=__builtin_ia32_psubd128(ret.v.v4,v.v4);
#else
for(int i=0;i<3;i++) ret.v.iv[i]= -v.iv[i];
#endif
return ret;
}
TripleInt& operator+=(TripleInt const& si){
#if OSL_USE_SSE
v.v4=__builtin_ia32_paddd128(v.v4,si.v.v4);
#else
for(int i=0;i<3;i++) v.iv[i]+=si.v.iv[i];
#endif
return *this;
}
TripleInt& operator-=(TripleInt const& si){
#if OSL_USE_SSE
v.v4=__builtin_ia32_psubd128(v.v4,si.v.v4);
#else
for(int i=0;i<3;i++) v.iv[i]-=si.v.iv[i];
#endif
return *this;
}
TripleInt& operator*=(int scale){
#if OSL_USE_SSE41
XMM val;
unsigned long long scalescale=(unsigned long long )((unsigned int)scale);
scalescale|=scalescale<<32ull;
val.v2=__builtin_ia32_vec_set_v2di(val.v2,(long long)scalescale,0);
val.v2=__builtin_ia32_vec_set_v2di(val.v2,(long long)scalescale,1);
v.v4=__builtin_ia32_pmulld128(v.v4,val.v4);
#else
for(int i=0;i<3;i++) v.iv[i]*=scale;
#endif
return *this;
}
TripleInt& operator/=(int div)
{
for(int i=0;i<3;i++) v.iv[i] /= div;
return *this;
}
TripleInt& operator>>=(int shift)
{
#if OSL_USE_SSE
v.v4= __builtin_ia32_psradi128 (v.v4, shift);
#else
for(int i=0;i<3;i++) v.iv[i] >>= shift;
#endif
return *this;
}
static size_t size() { return 3; }
};
inline TripleInt operator+(TripleInt const& si0,TripleInt const& si1)
{
TripleInt ret(si0);
ret+=si1;
return ret;
}
inline TripleInt operator-(TripleInt const& si0,TripleInt const& si1)
{
TripleInt ret(si0);
ret-=si1;
return ret;
}
inline TripleInt operator*(TripleInt const& si0,int scale)
{
TripleInt ret(si0);
ret*=scale;
return ret;
}
inline bool operator==(TripleInt const& l,TripleInt const& r)
{
for(int i=0;i<3;i++)
if (l[i] != r[i])
return false;
return true;
}
class TripleIntPair{
CArray<TripleInt,2> v;
public:
TripleIntPair() {}
const TripleInt& operator[](int i) const{
return v[i];
}
const TripleInt& operator[](Player pl) const{
return v[pl];
}
TripleInt& operator[](int i){
return v[i];
}
TripleInt& operator[](Player pl){
return v[pl];
}
TripleIntPair& operator+=(TripleIntPair const& a){
v[0]+=a.v[0];
v[1]+=a.v[1];
return *this;
}
TripleIntPair& operator-=(TripleIntPair const& a){
v[0]-=a.v[0];
v[1]-=a.v[1];
return *this;
}
};
inline TripleIntPair operator+(TripleIntPair const& si0,TripleIntPair const& si1)
{
TripleIntPair ret(si0);
ret+=si1;
return ret;
}
inline TripleIntPair operator-(TripleIntPair const& si0,TripleIntPair const& si1)
{
TripleIntPair ret(si0);
ret-=si1;
return ret;
}
inline bool operator==(TripleIntPair const& l,TripleIntPair const& r)
{
return l[0] == r[0] && l[1] == r[1];
}
std::ostream& operator<<(std::ostream& os,TripleInt const& ti);
}
using container::TripleInt;
using container::TripleIntPair;
}
#endif // EVAL_CONTAINER_TRIPLE_INT_H
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|