Difference between revisions of "Low-level integer routines with gcc"

From LPTMS Wiki
Jump to: navigation, search
m
Line 1: Line 1:
 
Gcc supports low-level integer routines similar to the FORTRAN routines POPCOUNT, ISHIFT...
 
Gcc supports low-level integer routines similar to the FORTRAN routines POPCOUNT, ISHIFT...
 +
 +
The examples below are given for ''long long'', the routines name changes for ''long'' and ''int''
 
<source lang="cpp">
 
<source lang="cpp">
 
long long __ashlti3 (long long a, int b )      //These functions return the result of shifting a left by b bits.
 
long long __ashlti3 (long long a, int b )      //These functions return the result of shifting a left by b bits.

Revision as of 16:31, 11 April 2012

Gcc supports low-level integer routines similar to the FORTRAN routines POPCOUNT, ISHIFT...

The examples below are given for long long, the routines name changes for long and int

long long __ashlti3 (long long a, int b )       //These functions return the result of shifting a left by b bits.
long long __ashrti3 (long long a, int b )       //These functions return the result of arithmetically shifting a right by b bits.
long long __divti3  (long long a, long long b ) //These functions return the quotient of the signed division of a and b.
long long __lshrti3 (long long a, int b )       //These functions return the result of logically shifting a right by b bits.
int __clzti2 (long long a ) //These functions return the number of leading 0-bits in a, starting at the most significant bit position. 
                            //If a is zero, the result is undefined.
int __ctzti2 (long long a ) //These functions return the number of trailing 0-bits in a, starting at the least significant bit position. 
                            //If a is zero, the result is undefined.
int __ffsti2 (long long a ) //These functions return the index of the least significant 1-bit in a, or the value zero if a is zero.
                            // The least significant bit is index one.
int __parityti2 (long long a )   //These functions return the value zero if the number of bits set in a is even, and the value one otherwise.
int __popcountti2 (long long a ) //These functions return the number of bits set in a.
int64_t __bswapdi2 (int64 t a )  //These functions return the a byteswapped.