|
AquilaOS documentation
How it works, and its code
|
i386: 64-bit division, for the code GCC generates. More...
#include <stdint.h>Go to the source code of this file.
Functions | |
| static uint32_t | divl (uint64_t n, uint32_t d) |
| Divides the 64-bit n by the 32-bit d with the x86 DIVL instruction, and returns the 32-bit quotient. | |
| static int | nlz (uint32_t x) |
| Returns the number of leading zero bits in x, which must not be 0. | |
| static uint64_t | udiv64 (uint64_t n, uint64_t d) |
| Divides the unsigned 64-bit n by the unsigned 64-bit d, and returns the quotient. | |
| static uint64_t | umod64 (uint64_t n, uint64_t d) |
| Divides the unsigned 64-bit n by the unsigned 64-bit d, and returns the remainder. | |
| static int64_t | sdiv64 (int64_t n, int64_t d) |
| Divides the signed 64-bit n by the signed 64-bit d, and returns the quotient. | |
| static int64_t | smod64 (int64_t n, int64_t d) |
| Divides the signed 64-bit n by the signed 64-bit d, and returns the remainder. | |
| long long | __divdi3 (long long n, long long d) |
| Divides two signed 64-bit integers. | |
| long long | __moddi3 (long long n, long long d) |
| Computes the remainder of two signed 64-bit integers. | |
| unsigned long long | __udivdi3 (unsigned long long n, unsigned long long d) |
| Divides two unsigned 64-bit integers. | |
| unsigned long long | __umoddi3 (unsigned long long n, unsigned long long d) |
| Computes the remainder of two unsigned 64-bit integers. | |
| unsigned long long | __udivmoddi4 (unsigned long long n, unsigned long long d, unsigned long long *rem) |
| Divides two unsigned 64-bit integers, giving both the quotient and the remainder. | |
i386: 64-bit division, for the code GCC generates.
A 32-bit CPU has no instruction that divides 64-bit numbers, so GCC calls these helpers (__divdi3() and the others) for / and % on 64-bit integers. User programs get them from libgcc; the kernel isn't linked with it, so it has its own. They come from Pintos (https://www.ida.liu.se/~TDIU25/pintos/src/lib/arithmetic.c).
Definition in file arith.c.
| long long __divdi3 | ( | long long | n, |
| long long | d ) |
Divides two signed 64-bit integers.
| n | the dividend |
| d | the divisor |
Definition at line 150 of file arith.c.
References __divdi3(), and sdiv64().
Referenced by __divdi3().
| long long __moddi3 | ( | long long | n, |
| long long | d ) |
Computes the remainder of two signed 64-bit integers.
| n | the dividend |
| d | the divisor |
Definition at line 162 of file arith.c.
References __moddi3(), and smod64().
Referenced by __moddi3().
| unsigned long long __udivdi3 | ( | unsigned long long | n, |
| unsigned long long | d ) |
Divides two unsigned 64-bit integers.
| n | the dividend |
| d | the divisor |
Definition at line 174 of file arith.c.
References __udivdi3(), and udiv64().
Referenced by __udivdi3().
| unsigned long long __udivmoddi4 | ( | unsigned long long | n, |
| unsigned long long | d, | ||
| unsigned long long * | rem ) |
Divides two unsigned 64-bit integers, giving both the quotient and the remainder.
| n | the dividend |
| d | the divisor |
| rem | if not NULL, set to the remainder |
Definition at line 200 of file arith.c.
References __udivmoddi4(), and udiv64().
Referenced by __udivmoddi4().
| unsigned long long __umoddi3 | ( | unsigned long long | n, |
| unsigned long long | d ) |
Computes the remainder of two unsigned 64-bit integers.
| n | the dividend |
| d | the divisor |
Definition at line 186 of file arith.c.
References __umoddi3(), and umod64().
Referenced by __umoddi3().
|
static |
Divides the unsigned 64-bit n by the unsigned 64-bit d, and returns the quotient.
Definition at line 62 of file arith.c.
References divl(), nlz(), and udiv64().
Referenced by __udivdi3(), __udivmoddi4(), sdiv64(), udiv64(), and umod64().