GNU Radio 3.4.2 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2008 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License along 00018 * with this program; if not, write to the Free Software Foundation, Inc., 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00020 */ 00021 #ifndef INCLUDED_GR_ALTIVEC_H 00022 #define INCLUDED_GR_ALTIVEC_H 00023 00024 /* 00025 * N.B., always use "vec_float4" et al. instead of "vector float" to 00026 * ensure portability across the various powerpc compilers. Some of 00027 * them treat "vector" as a context specific keyword, some don't. 00028 * Avoid the problem by always using the defines in vec_types.h 00029 * (included below) 00030 */ 00031 00032 #include <altivec.h> 00033 #undef bool // repair namespace pollution 00034 #undef vector // repair namespace pollution 00035 00036 #ifdef HAVE_VEC_TYPES_H 00037 #include <vec_types.h> // use system version if we've got it 00038 #else 00039 #include <gr_vec_types.h> // fall back to our local copy 00040 #endif 00041 #undef qword // repair namespace pollution 00042 00043 #include <stddef.h> 00044 #include <stdio.h> 00045 00046 #ifdef __cplusplus 00047 extern "C" { 00048 #endif 00049 00050 #define VS sizeof(vec_float4) 00051 #define FLOATS_PER_VEC (sizeof(vec_float4)/sizeof(float)) 00052 00053 union v_float_u { 00054 vec_float4 v; 00055 float f[FLOATS_PER_VEC]; 00056 }; 00057 00058 void gr_print_vector_float(FILE *fp, vec_float4 v); 00059 void gr_pvf(FILE *fp, const char *label, vec_float4 v); 00060 00061 static inline float 00062 horizontal_add_f(vec_float4 v) 00063 { 00064 union v_float_u u; 00065 vec_float4 t0 = vec_add(v, vec_sld(v, v, 8)); 00066 vec_float4 t1 = vec_add(t0, vec_sld(t0, t0, 4)); 00067 u.v = t1; 00068 return u.f[0]; 00069 } 00070 00071 #ifdef __cplusplus 00072 } 00073 #endif 00074 00075 #endif /* INCLUDED_GR_ALTIVEC_H */