Apple Darwin User Manual Page 14

  • Download
  • Add to my manuals
  • Print
  • Page
    / 68
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 13
Note: Floating-point data type sizes are the same whether you are generating a 32-bit or 64-bit
executable. However, the size of long double is 128 bits wide in GCC 4.0 and later (required for
64-bit compilation). Previous versions of the compiler (3.3 and earlier) used a 64-bit-wide long
double type.
In addition to these changes to the base data types, various layers of OS X have other data types that change
size or underlying type in a 64-bit environment. The most notable of these changes is that NSInteger and
NSUInteger (Cocoa data types) are 64-bit in a 64-bit environment and 32-bit in a 32-bit environment. These
changes are described in 64-Bit Guide for Carbon Developers, 64-Bit Transition Guide for Cocoa, and Kernel
Extensions and Drivers (page 58).
Because changes in size and alignment can significantly affect the data size produced by your code, you should
generally pack structures so that the largest data types appear first, followed by progressively smaller data
types. In this way, you maximize the use of space.
If, for compatibility, you need to support on-disk or network data structures containing 64-bit values aligned
on 4-byte boundaries, you can override the default alignment using pragmas. See Making Code 64-Bit
Clean (page 16) for more information.
Data Type Impact on Code
Data type and alignment changes impact developers in several broad areas.
Interprocess communication, networking, shared memory, and user-kernel boundary crossings
If you need your 64-bit software to communicate with 32-bit software (whether over a network, through
local IPC mechanisms, through shared memory, or through crossing the user-kernel boundary in any way),
choose data types carefully. A good practice is to always use explicitly sized data types, such as uint32_t,
rather than generic data types (such as long).
You may find it hard to use some mechanisms of interprocess communication, such as shared memory,
when sharing data between 32-bit and 64-bit code. In particular, you should avoid passing pointers into
shared memory regions and instead use offsets into the shared buffer.
Files stored on disk
If you need your application to write binary data in a file format that is shared between 64-bit and 32-bit
versions, make sure that the size and alignment of data structures are the same in both versions. Specifically,
these programs should avoid storing data of type long to disk.
Alternatively, you can create a separate file format that is specific to the 64-bit version of your application.
For some applications, creating a new format may be easier than maintaining a shared file format. This
should be considered the exception rather than the rule, however.
Major 64-Bit Changes
Data Type Changes
2012-12-13 | Copyright © 2004, 2012 Apple Inc. All Rights Reserved.
14
Page view 13
1 2 ... 9 10 11 12 13 14 15 16 17 18 19 ... 67 68

Comments to this Manuals

No comments