• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 #if defined(__KERNEL__) && !defined(__UBOOT__)
20 #include <linux/module.h>
21 #include <linux/kernel.h>
22 #else
23 #include <linux/math64.h>
24 #endif
25 #include "hi_osal.h"
26 
27 #ifdef __UBOOT__
28 # define EXPORT_SYMBOL(x)
29 #endif
30 
31 /* the result of u64/u32. */
osal_div_u64(unsigned long long dividend,unsigned int divisor)32 unsigned long long osal_div_u64(unsigned long long dividend, unsigned int divisor)
33 {
34     return div_u64(dividend, divisor);
35 }
36 EXPORT_SYMBOL(osal_div_u64);
37 
38 /* the result of s64/s32. */
osal_div_s64(long long dividend,int divisor)39 long long osal_div_s64(long long dividend, int divisor)
40 {
41     return div_s64(dividend, divisor);
42 }
43 EXPORT_SYMBOL(osal_div_s64);
44 
45 /* the result of u64/u64. */
osal_div64_u64(unsigned long long dividend,unsigned long long divisor)46 unsigned long long osal_div64_u64(unsigned long long dividend, unsigned long long divisor)
47 {
48     return div64_u64(dividend, divisor);
49 }
50 EXPORT_SYMBOL(osal_div64_u64);
51 
52 /* the result of s64/s64. */
osal_div64_s64(long long dividend,long long divisor)53 long long osal_div64_s64(long long dividend, long long divisor)
54 {
55     return div64_s64(dividend, divisor);
56 }
57 EXPORT_SYMBOL(osal_div64_s64);
58 
59 /* the remainder of u64/u32. */
osal_div_u64_rem(unsigned long long dividend,unsigned int divisor)60 unsigned long long osal_div_u64_rem(unsigned long long dividend, unsigned int divisor)
61 {
62     unsigned int remainder;
63 
64     div_u64_rem(dividend, divisor, &remainder);
65 
66     return remainder;
67 }
68 EXPORT_SYMBOL(osal_div_u64_rem);
69 
70 /* the remainder of s64/s32. */
osal_div_s64_rem(long long dividend,int divisor)71 long long osal_div_s64_rem(long long dividend, int divisor)
72 {
73     int remainder;
74 
75     div_s64_rem(dividend, divisor, &remainder);
76 
77     return remainder;
78 }
79 EXPORT_SYMBOL(osal_div_s64_rem);
80 
81 /* the remainder of u64/u64. */
osal_div64_u64_rem(unsigned long long dividend,unsigned long long divisor)82 unsigned long long osal_div64_u64_rem(unsigned long long dividend, unsigned long long divisor)
83 {
84     unsigned long long remainder;
85 
86     div64_u64_rem(dividend, divisor, &remainder);
87 
88     return remainder;
89 }
90 EXPORT_SYMBOL(osal_div64_u64_rem);
91