PKUOS - Pintos
Pintos source browser for PKU Operating System course
|
#include <stdint.h>
Go to the source code of this file.
Functions | |
static uint32_t | divl (uint64_t n, uint32_t d) |
On x86, division of one 64-bit integer by another cannot be done with a single instruction or a short sequence. More... | |
static int | nlz (uint32_t x) |
Returns the number of leading zero bits in X, which must be nonzero. More... | |
static uint64_t | udiv64 (uint64_t n, uint64_t d) |
Divides unsigned 64-bit N by unsigned 64-bit D and returns the quotient. More... | |
static uint32_t | umod64 (uint64_t n, uint64_t d) |
Divides unsigned 64-bit N by unsigned 64-bit D and returns the remainder. More... | |
static int64_t | sdiv64 (int64_t n, int64_t d) |
Divides signed 64-bit N by signed 64-bit D and returns the quotient. More... | |
static int32_t | smod64 (int64_t n, int64_t d) |
Divides signed 64-bit N by signed 64-bit D and returns the remainder. More... | |
long long | __divdi3 (long long n, long long d) |
These are the routines that GCC calls. More... | |
long long | __moddi3 (long long n, long long d) |
Signed 64-bit remainder. More... | |
unsigned long long | __udivdi3 (unsigned long long n, unsigned long long d) |
Unsigned 64-bit division. More... | |
unsigned long long | __umoddi3 (unsigned long long n, unsigned long long d) |
Unsigned 64-bit remainder. More... | |
long long __divdi3 | ( | long long | n, |
long long | d | ||
) |
These are the routines that GCC calls.
Signed 64-bit division.
Definition at line 165 of file arithmetic.c.
References sdiv64().
long long __moddi3 | ( | long long | n, |
long long | d | ||
) |
Signed 64-bit remainder.
Definition at line 172 of file arithmetic.c.
References smod64().
unsigned long long __udivdi3 | ( | unsigned long long | n, |
unsigned long long | d | ||
) |
Unsigned 64-bit division.
Definition at line 179 of file arithmetic.c.
References udiv64().
unsigned long long __umoddi3 | ( | unsigned long long | n, |
unsigned long long | d | ||
) |
Unsigned 64-bit remainder.
Definition at line 186 of file arithmetic.c.
References umod64().
On x86, division of one 64-bit integer by another cannot be done with a single instruction or a short sequence.
Thus, GCC implements 64-bit division and remainder operations through function calls. These functions are normally obtained from libgcc, which is automatically included by GCC in any link that it does.
Some x86-64 machines, however, have a compiler and utilities that can generate 32-bit x86 code without having any of the necessary libraries, including libgcc. Thus, we can make Pintos work on these machines by simply implementing our own 64-bit division routines, which are the only routines from libgcc that Pintos requires.
Completeness is another reason to include these routines. If Pintos is completely self-contained, then that makes it that much less mysterious. Uses x86 DIVL instruction to divide 64-bit N by 32-bit D to yield a 32-bit quotient. Returns the quotient. Traps with a divide error (#DE) if the quotient does not fit in 32 bits.
Definition at line 26 of file arithmetic.c.
Referenced by udiv64().
|
static |
Returns the number of leading zero bits in X, which must be nonzero.
Definition at line 42 of file arithmetic.c.
References x.
Referenced by udiv64().
Divides signed 64-bit N by signed 64-bit D and returns the quotient.
Definition at line 140 of file arithmetic.c.
References udiv64().
Referenced by __divdi3(), and smod64().
Divides signed 64-bit N by signed 64-bit D and returns the remainder.
Definition at line 151 of file arithmetic.c.
References sdiv64().
Referenced by __moddi3().
Divides unsigned 64-bit N by unsigned 64-bit D and returns the quotient.
Definition at line 78 of file arithmetic.c.
References divl(), nlz(), and s.
Referenced by __udivdi3(), sdiv64(), and umod64().
Divides unsigned 64-bit N by unsigned 64-bit D and returns the remainder.
Definition at line 132 of file arithmetic.c.
References udiv64().
Referenced by __umoddi3().