[sis190] Avoid NULL pointer dereference
[ipxe.git] / src / libgcc / __divmoddi4.c
1 #include "libgcc.h"
2
3 __libgcc int64_t __divmoddi4(int64_t num, int64_t den, int64 *rem_p)
4 {
5 int minus = 0;
6 int64_t v;
7
8 if ( num < 0 ) {
9 num = -num;
10 minus = 1;
11 }
12 if ( den < 0 ) {
13 den = -den;
14 minus ^= 1;
15 }
16
17 v = __udivmoddi4(num, den, (uint64_t *)rem_p);
18 if ( minus ) {
19 v = -v;
20 if ( rem_p )
21 *rem_p = -(*rem_p);
22 }
23
24 return v;
25 }