• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSInteger vs int vs int32_t
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSInteger vs int vs int32_t


  • Subject: Re: NSInteger vs int vs int32_t
  • From: Vincent Habchi <email@hidden>
  • Date: Mon, 09 Jul 2012 14:44:57 +0200

On 5 juil. 2012, at 07:41, Nathan Day <email@hidden> wrote:

> It must if 64bits is read in that mean you have just read in two 32bit words. So to put a 32bit word in a 64bit register some bit must be ditched, in some way, and if the CPU is optimise to only work with 64bit word alignment (don't know how intel does it), then to get 32 bit aligned words it must do some bit shift.

Modern CPU do not enforce strict alignment for integer access. You can perfectly access a Dword (64 bits) at any address, even or odd. It is just more efficient to align 64-bits words at 8-bytes boundary, 32-bits at 4-bytes, etc. This contrasts with the old times: for example, on a 68000 processor, trying to access a 16-bit word at an odd address (e.g. move.w d0, (a0)+ with a0 odd) would result in a exception n°3 (address error).

You still get boundary enforcement for SIMD instructions though (SSE, AVX). This is somehow reflected in C code through the use of special macros to instruct the compiler to respect these alignments.

Vincent



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: NSInteger vs int vs int32_t
      • From: Greg Parker <email@hidden>
References: 
 >NSInteger vs int vs int32_t (From: Andreas Grosam <email@hidden>)
 >Re: NSInteger vs int vs int32_t (From: Jens Alfke <email@hidden>)
 >Re: NSInteger vs int vs int32_t (From: Chris Hanson <email@hidden>)
 >Re: NSInteger vs int vs int32_t (From: Charles Srstka <email@hidden>)
 >Re: NSInteger vs int vs int32_t (From: Jens Alfke <email@hidden>)
 >Re: NSInteger vs int vs int32_t (From: Kyle Sluder <email@hidden>)
 >Re: NSInteger vs int vs int32_t (From: Jens Alfke <email@hidden>)
 >Re: NSInteger vs int vs int32_t (From: Kyle Sluder <email@hidden>)
 >Re: NSInteger vs int vs int32_t (From: David Duncan <email@hidden>)
 >Re: NSInteger vs int vs int32_t (From: Scott Ribe <email@hidden>)
 >Re: NSInteger vs int vs int32_t (From: Nathan Day <email@hidden>)
 >Re: NSInteger vs int vs int32_t (From: Scott Ribe <email@hidden>)
 >Re: NSInteger vs int vs int32_t (From: Nathan Day <email@hidden>)

  • Prev by Date: Re: Stupid block syntax!
  • Next by Date: Re: Re: Bottom-edge constraint not enforced in IB but is in runtime?
  • Previous by thread: Re: NSInteger vs int vs int32_t
  • Next by thread: Re: NSInteger vs int vs int32_t
  • Index(es):
    • Date
    • Thread