Apple Darwin Manuel d'utilisateur Page 24

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 68
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 23
If you want the mask value to contain zeros in the upper 32 bits on a 64-bit architecture, the usual
fixed-width mask will work as expected, because it will be extended in an unsigned fashion to a 64-bit
quantity.
If you want the mask value to contain ones in the upper bits, however, you should write the mask as the
bitwise inverse of its inverse, as shown in Listing 3-5.
Listing 3-5 Using an inverted mask for sign extension
function_name(long value)
{
long mask = ~0x3; // 0xfffffffc or 0xfffffffffffffffc
return (value & mask);
}
In the code, note that the upper bits in the mask are filled with ones in the 64-bit case.
Tools Tips
Here are some tips to help you use the compiler more effectively in transitioning your code to 64-bit:
If data is being inadvertently truncated, to help you find the source, try turning on additional compiler
warnings.
In 64-bit-capable versions of GCC (4.0 and later), the size of a long double will be 128 bits instead of 64
bits. This change is not limited to code compiled as a 64-bit executable, but it is a toolchain change you
should be aware of.
You can find detailed tips and information about 64-bit tools changes in Compiling 64-Bit Code (page 31).
Alignment Pragmas
Occasionally, developers use alignment pragmas to change the way that data structures are laid out in memory.
They usually do this for backward compatibility. In many cases, Apple added pragmas to maintain data structure
compatibility between 68K-based and PowerPC-based code running on the same machine under Mac OS 9
and earlier. OS X retained these alignment overrides to maintain binary compatibility with existing Carbon
data structures between Mac OS 9 and OS X.
Making Code 64-Bit Clean
Tools Tips
2012-12-13 | Copyright © 2004, 2012 Apple Inc. All Rights Reserved.
24
Vue de la page 23
1 2 ... 19 20 21 22 23 24 25 26 27 28 29 ... 67 68

Commentaires sur ces manuels

Pas de commentaire