ReactOS 0.4.15-dev-7958-gcd0bb1a
__rt_div_worker.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  _ARM_DIVRESULT
 

Typedefs

typedef unsigned int UINT3264
 
typedef int INT3264
 
typedef unsigned long long RETURN_TYPE
 
typedef union _ARM_DIVRESULT ARM_DIVRESULT
 

Functions

__forceinline void __brkdiv0 (void)
 
RETURN_TYPE __rt_div_worker (UINT3264 divisor, UINT3264 dividend)
 

Typedef Documentation

◆ ARM_DIVRESULT

◆ INT3264

typedef int INT3264

Definition at line 31 of file __rt_div_worker.h.

◆ RETURN_TYPE

Definition at line 32 of file __rt_div_worker.h.

◆ UINT3264

Definition at line 30 of file __rt_div_worker.h.

Function Documentation

◆ __brkdiv0()

__forceinline void __brkdiv0 ( void  )

Definition at line 37 of file __rt_div_worker.h.

38{
39 __emit(0xDEF9);
40}

Referenced by __rt_div_worker().

◆ __rt_div_worker()

RETURN_TYPE __rt_div_worker ( UINT3264  divisor,
UINT3264  dividend 
)

Definition at line 53 of file __rt_div_worker.h.

56{
60 UINT3264 quotient;
61#ifdef _SIGNED_DIV_
62 int dividend_sign = 0;
63 int divisor_sign = 0;
64#endif // _SIGNED_DIV_
65
66 if (divisor == 0)
67 {
68 /* Raise divide by zero error */
69 __brkdiv0();
70 }
71
72#ifdef _SIGNED_DIV_
73 if ((INT3264)dividend < 0)
74 {
75 dividend_sign = 1;
76 dividend = -(INT3264)dividend;
77 }
78
79 if ((INT3264)divisor < 0)
80 {
81 divisor_sign = 1;
83 }
84#endif // _SIGNED_DIV_
85
86 if (divisor > dividend)
87 {
88 result.data.quotient = 0;
89#ifdef _SIGNED_DIV_
90 if (dividend_sign)
91 dividend = -(INT3264)dividend;
92#endif // _SIGNED_DIV_
93 result.data.modulus = dividend;
94 return result.raw_data;
95 }
96
97 /* Get the difference in count of leading zeros between dividend and divisor */
99 shift -= _CountLeadingZeros(dividend);
100
101 /* Shift the divisor to the left, so that it's highest bit is the same
102 as the highest bit of the dividend */
103 divisor <<= shift;
104
105 mask = (UINT3264)1 << shift;
106
107 quotient = 0;
108 do
109 {
110 if (dividend >= divisor)
111 {
112 quotient |= mask;
113 dividend -= divisor;
114 }
115 divisor >>= 1;
116 mask >>= 1;
117 }
118 while (mask);
119
120#ifdef _SIGNED_DIV_
121 if (dividend_sign ^ divisor_sign)
122 {
123 quotient = -(INT3264)quotient;
124 }
125
126 if (dividend_sign)
127 {
128 dividend = -(INT3264)dividend;
129 }
130#endif // _SIGNED_DIV_
131
132 result.data.quotient = quotient;
133 result.data.modulus = dividend;
134 return result.raw_data;
135}
__forceinline void __brkdiv0(void)
unsigned int UINT3264
int INT3264
GLenum GLint GLuint mask
Definition: glext.h:6028
GLuint divisor
Definition: glext.h:6313
GLuint64EXT * result
Definition: glext.h:11304
__INTRIN_INLINE unsigned _CountLeadingZeros(long Mask)
Definition: intrin_arm.h:47
#define shift
Definition: input.c:1755