bw_fixed.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #ifndef BW_FIXED_H_
  26. #define BW_FIXED_H_
  27. struct bw_fixed {
  28. int64_t value;
  29. };
  30. struct bw_fixed bw_min3(struct bw_fixed v1, struct bw_fixed v2, struct bw_fixed v3);
  31. struct bw_fixed bw_max3(struct bw_fixed v1, struct bw_fixed v2, struct bw_fixed v3);
  32. struct bw_fixed bw_int_to_fixed(int64_t value);
  33. int32_t bw_fixed_to_int(struct bw_fixed value);
  34. struct bw_fixed bw_frc_to_fixed(int64_t num, int64_t denum);
  35. struct bw_fixed fixed31_32_to_bw_fixed(int64_t raw);
  36. struct bw_fixed bw_add(const struct bw_fixed arg1, const struct bw_fixed arg2);
  37. struct bw_fixed bw_sub(const struct bw_fixed arg1, const struct bw_fixed arg2);
  38. struct bw_fixed bw_mul(const struct bw_fixed arg1, const struct bw_fixed arg2);
  39. struct bw_fixed bw_div(const struct bw_fixed arg1, const struct bw_fixed arg2);
  40. struct bw_fixed bw_mod(const struct bw_fixed arg1, const struct bw_fixed arg2);
  41. struct bw_fixed bw_min2(const struct bw_fixed arg1, const struct bw_fixed arg2);
  42. struct bw_fixed bw_max2(const struct bw_fixed arg1, const struct bw_fixed arg2);
  43. struct bw_fixed bw_floor2(const struct bw_fixed arg, const struct bw_fixed significance);
  44. struct bw_fixed bw_ceil2(const struct bw_fixed arg, const struct bw_fixed significance);
  45. bool bw_equ(const struct bw_fixed arg1, const struct bw_fixed arg2);
  46. bool bw_neq(const struct bw_fixed arg1, const struct bw_fixed arg2);
  47. bool bw_leq(const struct bw_fixed arg1, const struct bw_fixed arg2);
  48. bool bw_meq(const struct bw_fixed arg1, const struct bw_fixed arg2);
  49. bool bw_ltn(const struct bw_fixed arg1, const struct bw_fixed arg2);
  50. bool bw_mtn(const struct bw_fixed arg1, const struct bw_fixed arg2);
  51. #endif //BW_FIXED_H_