libgcc documentation problems?

Ian Lance Taylor
Thu Aug 25 18:28:00 GMT 2005

Brian Hurt <> writes:

> So I'm looking at using gcc in an embedded environment, and providing
> my own libgcc (long story).  So I was looking at the libgcc
> documentation at:
> which gives the prototype for __umoddi3 and __umodti3 as:
> unsigned long __umoddi3 (unsigned long a, unsigned long b)
> unsigned long long __umodti3 (unsigned long long a, unsigned long long b)

Those prototypes are literally wrong on many, even most, systems.  To
interpret them correctly, you have to understand the earlier

    These routines take arguments and return values of a specific
    machine mode, not a specific C type.  See Machine Modes, for an
    explanation of this concept.  For illustrative purposes, in this
    chapter the floating point type float is assumed to correspond to
    SFmode; double to DFmode; and long double to both TFmode and
    XFmode.  Similarly, the integer types int and unsigned int
    correspond to SImode; long and unsigned long to DImode; and long
    long and unsigned long long to TImode.

> Now, things work correctly, so this isn't a bug with the compiler-
> it's the documentation which is unclear.  I see two possibilities:
> 1) The prototypes on that website are just wrong- __umoddi3 is always
> called to to do long long modulo.  In this case, is __umodti3 ever
> even used?
> 2) __umodsi3 handles 32-bit words on all systems (ignoring weird
> systems for the moment), __umoddi3 handles 64-bit words- longs on
> 64-bit systems, long longs on 32-bit systems, and __umodti3 handles
> 128 bit words- long long on 64-bit systems and not used on 32-bit
> systems.

The latter is basically correct.  __umodsi3 always handles 32-bit
values.  __umoddi3 always handles 64-bit values.  __umodti3 always
handles 128-bit values.  (In saying this I am ignoring targets which
do not use 8-bit bytes).  The proper prototypes are thus
target-dependent, since the sizes of int, long, and long long are
target dependent.

For what it's worth, the correct prototypes can be written using the
__attribute__ ((mode (XX))) extension.


More information about the Gcc-help mailing list