rs_convert.c revision 70404fa9781f13a8ca07d621f74f3810daab9704
1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include "rs_core.rsh" 18 19 20#define CVT_FUNC_2(typeout, typein) \ 21extern typeout##2 __attribute__((const, overloadable)) \ 22 convert_##typeout##2(typein##2 i) { \ 23 return __builtin_convertvector(i, typeout##2); \ 24 } \ 25extern typeout##3 __attribute__((const, overloadable)) \ 26 convert_##typeout##3(typein##3 i) { \ 27 return __builtin_convertvector(i, typeout##3); \ 28 } \ 29extern typeout##4 __attribute__((const, overloadable)) \ 30 convert_##typeout##4(typein##4 i) { \ 31 return __builtin_convertvector(i, typeout##4); \ 32 } 33#define CVT_FUNC(type) CVT_FUNC_2(type, uchar) \ 34 CVT_FUNC_2(type, char) \ 35 CVT_FUNC_2(type, ushort) \ 36 CVT_FUNC_2(type, short) \ 37 CVT_FUNC_2(type, uint) \ 38 CVT_FUNC_2(type, int) \ 39 CVT_FUNC_2(type, ulong) \ 40 CVT_FUNC_2(type, long) \ 41 CVT_FUNC_2(type, float) \ 42 CVT_FUNC_2(type, double) 43 44CVT_FUNC(char) 45CVT_FUNC(uchar) 46CVT_FUNC(short) 47CVT_FUNC(ushort) 48CVT_FUNC(int) 49CVT_FUNC(uint) 50CVT_FUNC(long) 51CVT_FUNC(ulong) 52CVT_FUNC(float) 53CVT_FUNC(double) 54 55