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 RS_RUNTIME_RS_F16_UTIL
18 #define RS_RUNTIME_RS_F16_UTIL
19 
20 typedef union {
21   half hval;
22   short sval;
23 } fp16_shape_type;
24 
25 /* half h = unsigned short s; */
26 #define SET_HALF_WORD(h, s) \
27 do {                        \
28   fp16_shape_type fp16_u;   \
29   fp16_u.sval = (s);        \
30   (h) = fp16_u.hval;        \
31 } while (0)
32 
33 /* unsigned short s = half h; */
34 #define GET_HALF_WORD(s, h) \
35 do {                        \
36   fp16_shape_type fp16_u;   \
37   fp16_u.hval = (h);        \
38   (s) = fp16_u.sval;        \
39 } while (0)
40 
41 #endif // RS_RUNTIME_RS_F16_UTIL
42