1 /* 2 * Copyright (C) 2016 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 #ifndef _FLOAT_RT_H_ 18 #define _FLOAT_RT_H_ 19 20 #include <stdint.h> 21 22 #ifdef USE_NANOHUB_FLOAT_RUNTIME 23 24 // Under this define, we want to use these custom methods rather than trust 25 // our built-in float runtime. 26 27 uint64_t floatToUint64(float f); 28 int64_t floatToInt64(float f); 29 float floatFromUint64(uint64_t v); 30 float floatFromInt64(int64_t v); 31 32 33 #else // USE_NANOHUB_FLOAT_RUNTIME 34 floatToUint64(float f)35static inline uint64_t floatToUint64(float f) 36 { 37 return f; 38 } 39 floatToInt64(float f)40static inline int64_t floatToInt64(float f) 41 { 42 return f; 43 } 44 floatFromUint64(uint64_t v)45static inline float floatFromUint64(uint64_t v) 46 { 47 return v; 48 } 49 floatFromInt64(int64_t v)50static inline float floatFromInt64(int64_t v) 51 { 52 return v; 53 } 54 55 #endif // USE_NANOHUB_FLOAT_RUNTIME 56 57 #endif 58 59 60