Browse Source

[libgcc] Provide __divmoddi4()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
67f539fa80
4 changed files with 28 additions and 31 deletions
  1. 1
    17
      src/libgcc/__divdi3.c
  2. 25
    0
      src/libgcc/__divmoddi4.c
  3. 1
    14
      src/libgcc/__moddi3.c
  4. 1
    0
      src/libgcc/libgcc.h

+ 1
- 17
src/libgcc/__divdi3.c View File

@@ -6,21 +6,5 @@
6 6
 
7 7
 __libgcc int64_t __divdi3(int64_t num, int64_t den)
8 8
 {
9
-  int minus = 0;
10
-  int64_t v;
11
-
12
-  if ( num < 0 ) {
13
-    num = -num;
14
-    minus = 1;
15
-  }
16
-  if ( den < 0 ) {
17
-    den = -den;
18
-    minus ^= 1;
19
-  }
20
-
21
-  v = __udivmoddi4(num, den, NULL);
22
-  if ( minus )
23
-    v = -v;
24
-
25
-  return v;
9
+  return __divmoddi4(num, den, NULL);
26 10
 }

+ 25
- 0
src/libgcc/__divmoddi4.c View File

@@ -0,0 +1,25 @@
1
+#include "libgcc.h"
2
+
3
+__libgcc int64_t __divmoddi4(int64_t num, int64_t den, int64 *rem_p)
4
+{
5
+  int minus = 0;
6
+  int64_t v;
7
+
8
+  if ( num < 0 ) {
9
+    num = -num;
10
+    minus = 1;
11
+  }
12
+  if ( den < 0 ) {
13
+    den = -den;
14
+    minus ^= 1;
15
+  }
16
+
17
+  v = __udivmoddi4(num, den, (uint64_t *)rem_p);
18
+  if ( minus ) {
19
+    v = -v;
20
+    if ( rem_p )
21
+      *rem_p = -(*rem_p);
22
+  }
23
+
24
+  return v;
25
+}

+ 1
- 14
src/libgcc/__moddi3.c View File

@@ -6,21 +6,8 @@
6 6
 
7 7
 __libgcc int64_t __moddi3(int64_t num, int64_t den)
8 8
 {
9
-  int minus = 0;
10 9
   int64_t v;
11 10
 
12
-  if ( num < 0 ) {
13
-    num = -num;
14
-    minus = 1;
15
-  }
16
-  if ( den < 0 ) {
17
-    den = -den;
18
-    minus ^= 1;
19
-  }
20
-
21
-  (void) __udivmoddi4(num, den, (uint64_t *)&v);
22
-  if ( minus )
23
-    v = -v;
24
-
11
+  (void) __divmoddi4(num, den, &v);
25 12
   return v;
26 13
 }

+ 1
- 0
src/libgcc/libgcc.h View File

@@ -8,6 +8,7 @@ extern __libgcc uint64_t __udivmoddi4 ( uint64_t num, uint64_t den,
8 8
 					uint64_t *rem );
9 9
 extern __libgcc uint64_t __udivdi3  (uint64_t num, uint64_t den );
10 10
 extern __libgcc uint64_t __umoddi3 ( uint64_t num, uint64_t den );
11
+extern __libgcc int64_t __divmoddi4 ( int64_t num, int64_t den, int64_t *rem );
11 12
 extern __libgcc int64_t __divdi3 ( int64_t num, int64_t den );
12 13
 extern __libgcc int64_t __moddi3 ( int64_t num, int64_t den );
13 14
 

Loading…
Cancel
Save