3

I'm trying to make a tweak for iOS 7 so that when a device is ARM64 it runs one version and when it is not it runs another (since float is for 32 bit and double is for 64 (If you have a solution for that let me know.)

So it would be like this

if ARM64 {
    \\run double code
}
else {
    \\run float code
}
Gavin
  • 8,204
  • 3
  • 32
  • 42
Mistah_Sheep
  • 785
  • 6
  • 25

3 Answers3

10

You would do the following

#if __LP64__
    \\You're running on 64 bit
#else
    \\You're running on 32 bit
#endif
Gavin
  • 8,204
  • 3
  • 32
  • 42
  • 4
    This is a compile-time way of predicating your code. When you compile for arm64 (and the 64-bit simulator), __LP64__ will be defined and only that code will be compiled. For armv7, it will be undefined and the 32-bit code will be used. – Variable Length Coder Feb 08 '14 at 03:43
1

On arm64 environment, the pointer take 8 bytes.

- (BOOL)isArm64
{
    static BOOL arm64 = NO ;
    static dispatch_once_t once ;
    dispatch_once(&once, ^{
        arm64 = sizeof(int *) == 8 ;
    });
    return arm64 ;
}
KudoCC
  • 6,912
  • 1
  • 24
  • 53
0

Looking at the "arm_neon.h" header file, I can see that it is checking the preprocessor directive __arm64. This is on Xcode 6.1.

In addition to that, some ARM NEON intrinsics available on older ARM (32-bit) architectures are not available on ARM64, or are replaced by equivalents which go by a slightly different name.

In particular, vtbl2 is replaced by vtbl1q, because the underlying architecture has emphasized more on 128-bit NEON registers.

If you have some ARM NEON assembly code that don't compile under ARM64, try look up for changes such as this.

rwong
  • 6,062
  • 1
  • 23
  • 51