2 * long-value math emulation for support of ntoskrnl of libcaptive
3 * Copyright (C) 2002 Jan Kratochvil <project-captive@jankratochvil.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "reactos/ntos/types.h"
23 #include <glib/gmessages.h>
28 * @a: First #LONGLONG multiplier.
29 * @b: Second #LONGLONG multiplier.
31 * Returns: @a * @b. No overflows are checked.
33 LONGLONG _allmul(LONGLONG a,LONGLONG b)
41 * @a: #LONGLONG divisor.
42 * @b: #LONGLONG divider.
43 * Value %0 is forbidden.
47 LONGLONG _alldiv(LONGLONG a,LONGLONG b)
49 g_return_val_if_fail(b!=0,0);
57 * @long_00to31: Lower part of 64-bit unsigned number to shift.
58 * @long_32to63: Upper part of 64-bit unsigned number to shift.
59 * @count: Number of bits to shift by.
61 * 64-bit shift left by @count bits.
63 * This is a special function which is declared as %data in *.def
64 * file ke/exports.def as it has three arguments passed in registers.
66 * Returns: (@long_32to63 @long_00to31) shifted left by @count bits.
68 guint64 __attribute__((__stdcall__)) __attribute__((__regparm__(3))) _allshl(
69 guint32 long_00to31, /* %eax */
70 guint32 long_32to63, /* %edx */
71 guint8 count) /* %ecx */
73 return (((((guint64)long_32to63)<<32U)|long_00to31)<<count);
79 * @long_00to31: Lower part of 64-bit signed number to shift.
80 * @long_32to63: Upper part of 64-bit signed number to shift.
81 * @count: Number of bits to shift by.
83 * 64-bit shift right by @count bits.
85 * WARNING: Although this function is call _allshr() it in fact implements
86 * instruction %sar, NOT %shr!
88 * This is a special function which is declared as %data in *.def
89 * file ke/exports.def as it has three arguments passed in registers.
91 * Returns: (@long_32to63 @long_00to31) signed-shifted right by @count bits.
93 guint64 __attribute__((__stdcall__)) __attribute__((__regparm__(3))) _allshr(
94 guint32 long_00to31, /* %eax */
95 guint32 long_32to63, /* %edx */
96 guint8 count) /* %ecx */
98 return (((((gint64)long_32to63)<<32U)|long_00to31)>>count);
104 * @long_00to31: Lower part of 64-bit unsigned number to shift.
105 * @long_32to63: Upper part of 64-bit unsigned number to shift.
106 * @count: Number of bits to shift by.
108 * 64-bit shift right by @count bits.
110 * This is a special function which is declared as %data in *.def
111 * file ke/exports.def as it has three arguments passed in registers.
113 * Returns: (@long_32to63 @long_00to31) unsigned-shifted right by @count bits.
115 guint64 __attribute__((__stdcall__)) __attribute__((__regparm__(3))) _aullshr(
116 guint32 long_00to31, /* %eax */
117 guint32 long_32to63, /* %edx */
118 guint8 count) /* %ecx */
120 return (((((guint64)long_32to63)<<32U)|long_00to31)>>count);
126 * @divident: 64-bit signed divident.
127 * @divisor: 64-bit signed divisor.
129 * Calculates the signed modulo of two 64-bit numbers.
131 * FIXME: Are we expected to behave signed?
133 * Returns: Expression "divident%divisor".
135 gint64 _allrem(gint64 divident,gint64 divisor)
137 return divident%divisor;