]>
Commit | Line | Data |
---|---|---|
056a1eb7 SF |
1 | /* $Id: udivmoddi4.c $ */ |
2 | /** @file | |
3 | * IPRT - __udivmoddi4 implementation | |
4 | */ | |
5 | ||
6 | /* | |
6d209b23 | 7 | * Copyright (C) 2006-2017 Oracle Corporation |
056a1eb7 SF |
8 | * |
9 | * This file is part of VirtualBox Open Source Edition (OSE), as | |
10 | * available from http://www.virtualbox.org. This file is free software; | |
11 | * you can redistribute it and/or modify it under the terms of the GNU | |
12 | * General Public License (GPL) as published by the Free Software | |
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the | |
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the | |
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. | |
16 | * | |
17 | * The contents of this file may alternatively be used under the terms | |
18 | * of the Common Development and Distribution License Version 1.0 | |
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the | |
20 | * VirtualBox OSE distribution, in which case the provisions of the | |
21 | * CDDL are applicable instead of those of the GPL. | |
22 | * | |
23 | * You may elect to license modified versions of this file under the | |
24 | * terms and conditions of either the GPL or the CDDL or both. | |
25 | */ | |
26 | ||
27 | #include <iprt/stdint.h> | |
28 | #include <iprt/uint64.h> | |
29 | ||
30 | uint64_t __udivmoddi4(uint64_t u64A, uint64_t u64B, uint64_t *pu64R); | |
31 | ||
32 | /** | |
33 | * __udivmoddi4() implementation to satisfy external references from 32-bit | |
34 | * code generated by gcc-7 or later. | |
35 | * | |
36 | * @param u64A The divident value. | |
37 | * @param u64B The divisor value. | |
38 | * @param pu64R A pointer to the reminder. May be NULL. | |
39 | * @returns u64A / u64B | |
40 | */ | |
41 | uint64_t __udivmoddi4(uint64_t u64A, uint64_t u64B, uint64_t *pu64R) | |
42 | { | |
43 | RTUINT64U Divident; | |
44 | RTUINT64U Divisor; | |
45 | RTUINT64U Quotient; | |
46 | RTUINT64U Reminder; | |
47 | Divident.u = u64A; | |
48 | Divisor.u = u64B; | |
49 | RTUInt64DivRem(&Quotient, &Reminder, &Divident, &Divisor); | |
50 | if (pu64R) | |
51 | *pu64R = Reminder.u; | |
52 | return Quotient.u; | |
53 | } |