1169689Skan/* Miscellaneous BPABI functions.
2169689Skan
3169689Skan   Copyright (C) 2003, 2004  Free Software Foundation, Inc.
4169689Skan   Contributed by CodeSourcery, LLC.
5169689Skan
6169689Skan   This file is free software; you can redistribute it and/or modify it
7169689Skan   under the terms of the GNU General Public License as published by the
8169689Skan   Free Software Foundation; either version 2, or (at your option) any
9169689Skan   later version.
10169689Skan
11169689Skan   In addition to the permissions in the GNU General Public License, the
12169689Skan   Free Software Foundation gives you unlimited permission to link the
13169689Skan   compiled version of this file into combinations with other programs,
14169689Skan   and to distribute those combinations without any restriction coming
15169689Skan   from the use of this file.  (The General Public License restrictions
16169689Skan   do apply in other respects; for example, they cover modification of
17169689Skan   the file, and distribution when not linked into a combine
18169689Skan   executable.)
19169689Skan
20169689Skan   This file is distributed in the hope that it will be useful, but
21169689Skan   WITHOUT ANY WARRANTY; without even the implied warranty of
22169689Skan   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23169689Skan   General Public License for more details.
24169689Skan
25169689Skan   You should have received a copy of the GNU General Public License
26169689Skan   along with this program; see the file COPYING.  If not, write to
27169689Skan   the Free Software Foundation, 51 Franklin Street, Fifth Floor,
28169689Skan   Boston, MA 02110-1301, USA.  */
29169689Skan
30169689Skanextern long long __divdi3 (long long, long long);
31169689Skanextern unsigned long long __udivdi3 (unsigned long long,
32169689Skan				     unsigned long long);
33169689Skanextern long long __gnu_ldivmod_helper (long long, long long, long long *);
34169689Skanextern unsigned long long __gnu_uldivmod_helper (unsigned long long,
35169689Skan						 unsigned long long,
36169689Skan						 unsigned long long *);
37169689Skan
38169689Skan
39169689Skanlong long
40169689Skan__gnu_ldivmod_helper (long long a,
41169689Skan		      long long b,
42169689Skan		      long long *remainder)
43169689Skan{
44169689Skan  long long quotient;
45169689Skan
46169689Skan  quotient = __divdi3 (a, b);
47169689Skan  *remainder = a - b * quotient;
48169689Skan  return quotient;
49169689Skan}
50169689Skan
51169689Skanunsigned long long
52169689Skan__gnu_uldivmod_helper (unsigned long long a,
53169689Skan		       unsigned long long b,
54169689Skan		       unsigned long long *remainder)
55169689Skan{
56169689Skan  unsigned long long quotient;
57169689Skan
58169689Skan  quotient = __udivdi3 (a, b);
59169689Skan  *remainder = a - b * quotient;
60169689Skan  return quotient;
61169689Skan}
62