Eric Biederman | 530b519 | 2003-07-01 10:05:30 +0000 | [diff] [blame] | 1 | typedef __builtin_div_t div_t; |
| 2 | typedef __builtin_ldiv_t ldiv_t; |
| 3 | typedef __builtin_udiv_t udiv_t; |
| 4 | typedef __builtin_uldiv_t uldiv_t; |
| 5 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame^] | 6 | static div_t div(int numer, int denom) |
| 7 | { |
| 8 | return __builtin_div(numer, denom); |
Eric Biederman | 530b519 | 2003-07-01 10:05:30 +0000 | [diff] [blame] | 9 | } |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame^] | 10 | static ldiv_t ldiv(long numer, long denom) |
| 11 | { |
| 12 | return __builtin_ldiv(numer, denom); |
Eric Biederman | 530b519 | 2003-07-01 10:05:30 +0000 | [diff] [blame] | 13 | } |
| 14 | static udiv_t udiv(unsigned numer, unsigned denom) |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame^] | 15 | { |
| 16 | return __builtin_udiv(numer, denom); |
Eric Biederman | 530b519 | 2003-07-01 10:05:30 +0000 | [diff] [blame] | 17 | } |
| 18 | static uldiv_t uldiv(unsigned long numer, unsigned long denom) |
| 19 | { |
| 20 | return __builtin_uldiv(numer, denom); |
| 21 | } |
| 22 | |
| 23 | static void main(void) |
| 24 | { |
| 25 | volatile long *sval = (volatile long *)0x1234; |
| 26 | volatile unsigned long *uval = (volatile unsigned long *)0x5678; |
| 27 | long int a, b, c; |
| 28 | unsigned long e, f, g; |
| 29 | ldiv_t lresult; |
| 30 | uldiv_t ulresult; |
| 31 | |
| 32 | a = sval[0]; |
| 33 | b = sval[1]; |
| 34 | lresult = ldiv(a,b); |
| 35 | sval[2] = lresult.quot; |
| 36 | sval[3] = lresult.rem; |
| 37 | |
| 38 | e = uval[0]; |
| 39 | f = uval[1]; |
| 40 | ulresult = uldiv(e, f); |
| 41 | uval[2] = ulresult.quot; |
| 42 | uval[3] = ulresult.rem; |
| 43 | } |