Commit 4ecfbddf authored by Adam Wujek's avatar Adam Wujek

lib/util: use a special function to divide two signed 64 numbers

Saves ~1.4KB
Signed-off-by: 's avatarAdam Wujek <adam.wujek@creotech.pl>
parent 9858c916
......@@ -51,10 +51,4 @@ long long __udivdi3 (long long A, long long B)
return 0;
}
/* was used in set_phase_shift, phase_to_cf_units */
long long __divdi3 (long long A, long long B)
{
__you_should_not_divide_ll_in_wrpc_sw();
return 0;
}
#endif
......@@ -271,3 +271,20 @@ int atoi(const char *s)
fromdec(s, &res);
return res;
}
/* To save code, in the div of two int64 numbers
* use signed 64bit division, then correct the sign of the result */
long long __divdi3 (long long A, long long B)
{
int sign_a, sign_b;
unsigned long long a_u;
unsigned long long b_u;
sign_a = A < 0 ? -1 : 1;
sign_b = B < 0 ? -1 : 1;
a_u = A * sign_a;
b_u = A * sign_b;
return sign_a * sign_b * (long long) (a_u / b_u);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment