The integer arithmetic routines are used on platforms that don’t providehardware support for arithmetic operations on some modes.
int__ashlsi3(inta, intb) ¶long__ashldi3(longa, intb) ¶long long__ashlti3(long longa, intb) ¶These functions return the result of shiftinga left byb bits.
int__ashrsi3(inta, intb) ¶long__ashrdi3(longa, intb) ¶long long__ashrti3(long longa, intb) ¶These functions return the result of arithmetically shiftinga rightbyb bits.
int__divsi3(inta, intb) ¶long__divdi3(longa, longb) ¶long long__divti3(long longa, long longb) ¶These functions return the quotient of the signed division ofa andb.
int__lshrsi3(inta, intb) ¶long__lshrdi3(longa, intb) ¶long long__lshrti3(long longa, intb) ¶These functions return the result of logically shiftinga right byb bits.
int__modsi3(inta, intb) ¶long__moddi3(longa, longb) ¶long long__modti3(long longa, long longb) ¶These functions return the remainder of the signed division ofaandb.
int__mulsi3(inta, intb) ¶long__muldi3(longa, longb) ¶long long__multi3(long longa, long longb) ¶These functions return the product ofa andb.
long__negdi2(longa) ¶long long__negti2(long longa) ¶These functions return the negation ofa.
unsigned int__udivsi3(unsigned inta, unsigned intb) ¶unsigned long__udivdi3(unsigned longa, unsigned longb) ¶unsigned long long__udivti3(unsigned long longa, unsigned long longb) ¶These functions return the quotient of the unsigned division ofaandb.
unsigned long__udivmoddi4(unsigned longa, unsigned longb, unsigned long *c) ¶unsigned long long__udivmodti4(unsigned long longa, unsigned long longb, unsigned long long *c) ¶These functions calculate both the quotient and remainder of the unsigneddivision ofa andb. The return value is the quotient, andthe remainder is placed in variable pointed to byc.
unsigned int__umodsi3(unsigned inta, unsigned intb) ¶unsigned long__umoddi3(unsigned longa, unsigned longb) ¶unsigned long long__umodti3(unsigned long longa, unsigned long longb) ¶These functions return the remainder of the unsigned division ofaandb.
The following functions implement integral comparisons. These functionsimplement a low-level compare, upon which the higher level comparisonoperators (such as less than and greater than or equal to) can beconstructed. The returned values lie in the range zero to two, to allowthe high-level operators to be implemented by testing the returnedresult using either signed or unsigned comparison.
int__cmpdi2(longa, longb) ¶int__cmpti2(long longa, long longb) ¶These functions perform a signed comparison ofa andb. Ifa is less thanb, they return 0; ifa is greater thanb, they return 2; and ifa andb are equal they return 1.
int__ucmpdi2(unsigned longa, unsigned longb) ¶int__ucmpti2(unsigned long longa, unsigned long longb) ¶These functions perform an unsigned comparison ofa andb.Ifa is less thanb, they return 0; ifa is greater thanb, they return 2; and ifa andb are equal they return 1.
The following functions implement trapping arithmetic. These functionscall the libc functionabort upon signed arithmetic overflow.
int__absvsi2(inta) ¶long__absvdi2(longa) ¶These functions return the absolute value ofa.
int__addvsi3(inta, intb) ¶long__addvdi3(longa, longb) ¶These functions return the sum ofa andb; that isa +b.
int__mulvsi3(inta, intb) ¶long__mulvdi3(longa, longb) ¶The functions return the product ofa andb; that isa *b.
int__clzsi2(unsigned inta) ¶int__clzdi2(unsigned longa) ¶int__clzti2(unsigned long longa) ¶These functions return the number of leading 0-bits ina, startingat the most significant bit position. Ifa is zero, the result isundefined.
int__ctzsi2(unsigned inta) ¶int__ctzdi2(unsigned longa) ¶int__ctzti2(unsigned long longa) ¶These functions return the number of trailing 0-bits ina, startingat the least significant bit position. Ifa is zero, the result isundefined.
int__ffsdi2(unsigned longa) ¶int__ffsti2(unsigned long longa) ¶These functions return the index of the least significant 1-bit ina,or the value zero ifa is zero. The least significant bit is indexone.
int__paritysi2(unsigned inta) ¶int__paritydi2(unsigned longa) ¶int__parityti2(unsigned long longa) ¶These functions return the value zero if the number of bits set ina is even, and the value one otherwise.
_BitInt(n) library functions operate on arrays of limbs, whereeach limb has__LIBGCC_BITINT_LIMB_WIDTH__ bits and the limbs areordered according to__LIBGCC_BITINT_ORDER__ ordering. The mostsignificant limb ifn is not divisible by__LIBGCC_BITINT_LIMB_WIDTH__ contains padding bits which should beignored on read (sign or zero extended), but extended on write. For thelibrary functions, all bit-precise integers regardless ofn arerepresented like that, even when the target ABI says that for some smalln they should be represented differently in memory. A pointerto the array of limbs argument is always accompanied with a bit sizeargument. If that argument is positive, it is number of bits and thenumber is assumed to be zero-extended to infinite precision, if thatargument is negative, it is negated number of bits above which all bitsare assumed to be sign-extended to infinite precision. These number of bitsarguments don’t need to match actualn for the operation used in thesource, they could be lowered because of sign or zero extensions on theinput or because value-range optimization figures value will need certainlower number of bits. For big-endian ordering of limbs, when loweringthe bit size argument the pointer argument needs to be adjusted as well.Negative bit size argument should be always smaller or equal to-2,becausesigned _BitInt(1) is not valid.For output arguments, either the corresponding bit size argument shouldbe always positive (for multiplication and division), or is negative whenthe output of conversion from floating-point value is signed and positivewhen unsigned. The arrays of limbs output arguments point to should notoverlap any inputs, while input arrays of limbs can overlap.UBILtype below stands for unsigned integer type with__LIBGCC_BITINT_LIMB_WIDTH__ bit precision.
void__mulbitint3(UBILtype *ret, int32_tretprec, constUBILtype *u, int32_tuprec, constUBILtype *v, int32_tvprec) ¶This function multiplies bit-precise integer operandsu andv and storesresult intoretprec precision bit-precise integer resultret.
void__divmodbitint4(UBILtype *q, int32_tqprec,UBILtype *r, int32_trprec, constUBILtype *u, int32_tuprec, constUBILtype *v, int32_tvprec) ¶This function divides bit-precise integer operandsu andv and storesquotient intoqprec precision bit-precise integer resultq(unlessq isNULL andqprec is 0, in that case quotientis not stored anywhere) and remainder intorprec precision bit-preciseinteger resultr (similarly, unlessr isNULL andrprecis 0).