MRTG a gigabitove rychlosti - long long

Karel Zak zakkr na zf.jcu.cz
Pátek Prosinec 7 12:11:11 CET 2001


On Fri, Dec 07, 2001 at 10:24:02AM +0100, Ing. Pavel PaJaSoft Janousek wrote:
> Karel Zak wrote:
> >  Na mem i386 je int64 "long long int".
> 
> 	Kdyz uz jsme u toho, stale nekde poptavam C99 specifikaci...;-)
> 
> 	Ale k tematu - jak je to s tim longovanim?
> 
> IMHO dle ANSI C 89 plati, ze long int = long, plati rovnez je long long
> int = long long? A musi se psat long long int nebo dle C99 staci long
> long (jak je v nekolika shlednutych programech)? A skutecne je long long
> int = long long = alias int64?
> 
> 	Rad bych si to osvetlil a mozna nejenom ja tuto pomerne novou vec...

http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_5.html:

5.10 Double-Word Integers

   ISO C99 supports data types for integers that are at least 64 bits wide,
   and as an extension GCC supports them in C89 mode and in C++. Simply write
   long long int for a signed integer, or unsigned long long int for an
   unsigned integer. To make an integer constant of type long long int, add
   the suffix `LL' to the integer. To make an integer constant of type
   unsigned long long int, add the suffix `ULL' to the integer.

   You can use these types in arithmetic like any other integer types.
   Addition, subtraction, and bitwise boolean operations on these types are
   open-coded on all types of machines. Multiplication is open-coded if the
   machine supports fullword-to-doubleword a widening multiply instruction.
   Division and shifts are open-coded only on machines that provide special
   support. The operations that are not open-coded use special library
   routines that come with GCC.

   There may be pitfalls when you use long long types for function arguments,
   unless you declare function prototypes. If a function expects type int for
   its argument, and you pass a value of type long long int, confusion will
   result because the caller and the subroutine will disagree about the
   number of bytes for the argument. Likewise, if the function expects long
   long int and you pass int. The best way to avoid such problems is to use
   prototypes.


 Jinak gcc vs. standard:

    http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_2.html#SEC2

 Ja bych pro cistotu kodu psal "long long int" (aka typedef int64). 
 Korektni program todle resi v ./configure. Mohou byt pripdady kdy 
 je to int64 = long int. Dalsi veci je jak jsou na tom funkce jako 
 printf() s timto typem coz by asi take mela byt zalezitost bajneho
 ./configure :-)

            Karel

-- 
 Karel Zak  <zakkr na zf.jcu.cz>
 http://home.zf.jcu.cz/~zakkr/
 
 C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz


Další informace o konferenci Linux