1 /*
2  * Copyright 2015 Advanced Micro Devices, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * Authors: AMD
23  *
24  */
25 
26 #ifndef BW_FIXED_H_
27 #define BW_FIXED_H_
28 
29 struct bw_fixed {
30 	int64_t value;
31 };
32 
33 struct bw_fixed bw_min3(struct bw_fixed v1, struct bw_fixed v2, struct bw_fixed v3);
34 
35 struct bw_fixed bw_max3(struct bw_fixed v1, struct bw_fixed v2, struct bw_fixed v3);
36 
37 struct bw_fixed bw_int_to_fixed(int64_t value);
38 
39 int32_t bw_fixed_to_int(struct bw_fixed value);
40 
41 struct bw_fixed bw_frc_to_fixed(int64_t num, int64_t denum);
42 
43 struct bw_fixed fixed31_32_to_bw_fixed(int64_t raw);
44 
45 struct bw_fixed bw_add(const struct bw_fixed arg1, const struct bw_fixed arg2);
46 struct bw_fixed bw_sub(const struct bw_fixed arg1, const struct bw_fixed arg2);
47 struct bw_fixed bw_mul(const struct bw_fixed arg1, const struct bw_fixed arg2);
48 struct bw_fixed bw_div(const struct bw_fixed arg1, const struct bw_fixed arg2);
49 struct bw_fixed bw_mod(const struct bw_fixed arg1, const struct bw_fixed arg2);
50 
51 struct bw_fixed bw_min2(const struct bw_fixed arg1, const struct bw_fixed arg2);
52 struct bw_fixed bw_max2(const struct bw_fixed arg1, const struct bw_fixed arg2);
53 struct bw_fixed bw_floor2(const struct bw_fixed arg, const struct bw_fixed significance);
54 struct bw_fixed bw_ceil2(const struct bw_fixed arg, const struct bw_fixed significance);
55 
56 bool bw_equ(const struct bw_fixed arg1, const struct bw_fixed arg2);
57 bool bw_neq(const struct bw_fixed arg1, const struct bw_fixed arg2);
58 bool bw_leq(const struct bw_fixed arg1, const struct bw_fixed arg2);
59 bool bw_meq(const struct bw_fixed arg1, const struct bw_fixed arg2);
60 bool bw_ltn(const struct bw_fixed arg1, const struct bw_fixed arg2);
61 bool bw_mtn(const struct bw_fixed arg1, const struct bw_fixed arg2);
62 
63 #endif //BW_FIXED_H_
64