1 | /* $Id: udivmoddi4.c 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - __udivmoddi4 implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * The contents of this file may alternatively be used under the terms
|
---|
26 | * of the Common Development and Distribution License Version 1.0
|
---|
27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | * CDDL are applicable instead of those of the GPL.
|
---|
30 | *
|
---|
31 | * You may elect to license modified versions of this file under the
|
---|
32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | *
|
---|
34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | */
|
---|
36 |
|
---|
37 | #include <iprt/stdint.h>
|
---|
38 | #include <iprt/uint64.h>
|
---|
39 |
|
---|
40 | uint64_t __udivmoddi4(uint64_t u64A, uint64_t u64B, uint64_t *pu64R);
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * __udivmoddi4() implementation to satisfy external references from 32-bit
|
---|
44 | * code generated by gcc-7 or later.
|
---|
45 | *
|
---|
46 | * @param u64A The divident value.
|
---|
47 | * @param u64B The divisor value.
|
---|
48 | * @param pu64R A pointer to the reminder. May be NULL.
|
---|
49 | * @returns u64A / u64B
|
---|
50 | */
|
---|
51 | uint64_t __udivmoddi4(uint64_t u64A, uint64_t u64B, uint64_t *pu64R)
|
---|
52 | {
|
---|
53 | RTUINT64U Divident;
|
---|
54 | RTUINT64U Divisor;
|
---|
55 | RTUINT64U Quotient;
|
---|
56 | RTUINT64U Reminder;
|
---|
57 | Divident.u = u64A;
|
---|
58 | Divisor.u = u64B;
|
---|
59 | Quotient.u = 0; /* shut up gcc 10 */
|
---|
60 | Reminder.u = 0; /* shut up gcc 10 */
|
---|
61 | RTUInt64DivRem(&Quotient, &Reminder, &Divident, &Divisor);
|
---|
62 | if (pu64R)
|
---|
63 | *pu64R = Reminder.u;
|
---|
64 | return Quotient.u;
|
---|
65 | }
|
---|