Skip to content

[src] Remove pointer-size checks and code. #22666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions docs/website/mtouch-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -3555,11 +3555,7 @@ This indicates something is wrong in the build process. Please file a new issue

This indicates an API wasn't bound correctly. If this is an API exposed by Xamarin, please file a new issue on [GitHub](https://github.com/xamarin/xamarin-macios/issues/new). If it's a third-party binding, please contact the vendor.

<a name="MT8010"></a>

### MT8010: Native type size mismatch between Xamarin.[iOS|Mac].dll and the executing architecture. Xamarin.[iOS|Mac].dll was built for *-bit, while the current process is *-bit.

This indicates something is wrong in the build process. Please file a new issue on [GitHub](https://github.com/xamarin/xamarin-macios/issues/new).
<!-- MT8010 is not reported anymore -->

<a name="MT8011"></a>

Expand Down
3 changes: 0 additions & 3 deletions src/AppKit/NSGradient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ public NSGradient (NSColor [] colors, float [] locations, NSColorSpace colorSpac
public NSGradient (NSColor [] colors, double [] locations, NSColorSpace colorSpace) : base (NSObjectFlag.Empty)
{
unsafe {
if (IntPtr.Size != 8)
throw new PlatformNotSupportedException ("Use the overload that takes an array of 'nfloat' values as locations instead.");

fixed (void* locationPtr = locations) {
Initialize (colors, locations?.Length, (IntPtr) locationPtr, colorSpace);
}
Expand Down
40 changes: 4 additions & 36 deletions src/ObjCRuntime/BindAs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,7 @@ unsafe static IntPtr ConvertManagedArrayToNSArray2<T, U> (T []? array, delegate*
static System.Single xamarin_nsnumber_to_float (IntPtr value) { if (value == IntPtr.Zero) return default (System.Single); return Runtime.GetNSObject<NSNumber> (value)?.FloatValue ?? default (System.Single); }
static System.Double xamarin_nsnumber_to_double (IntPtr value) { if (value == IntPtr.Zero) return default (System.Double); return Runtime.GetNSObject<NSNumber> (value)?.DoubleValue ?? default (System.Double); }
static System.Boolean xamarin_nsnumber_to_bool (IntPtr value) { if (value == IntPtr.Zero) return default (System.Boolean); return Runtime.GetNSObject<NSNumber> (value)?.BoolValue ?? default (System.Boolean); }
static nfloat xamarin_nsnumber_to_nfloat (IntPtr value)
{
if (value == IntPtr.Zero)
return default (nfloat);
var number = Runtime.GetNSObject<NSNumber> (value);
if (number is null)
return default (nfloat);
if (IntPtr.Size == 4)
return (nfloat) number.FloatValue;
return (nfloat) number.DoubleValue;
}
static nfloat xamarin_nsnumber_to_nfloat (IntPtr value) { if (value == IntPtr.Zero) return default (nfloat); return (nfloat?) Runtime.GetNSObject<NSNumber> (value)?.DoubleValue ?? default (nfloat); }

static System.SByte? xamarin_nsnumber_to_nullable_sbyte (IntPtr value) { return Runtime.GetNSObject<NSNumber> (value)?.SByteValue ?? null; }
static System.Byte? xamarin_nsnumber_to_nullable_byte (IntPtr value) { return Runtime.GetNSObject<NSNumber> (value)?.ByteValue ?? null; }
Expand All @@ -230,17 +220,7 @@ static nfloat xamarin_nsnumber_to_nfloat (IntPtr value)
static System.Single? xamarin_nsnumber_to_nullable_float (IntPtr value) { return Runtime.GetNSObject<NSNumber> (value)?.FloatValue ?? null; }
static System.Double? xamarin_nsnumber_to_nullable_double (IntPtr value) { return Runtime.GetNSObject<NSNumber> (value)?.DoubleValue ?? null; }
static System.Boolean? xamarin_nsnumber_to_nullable_bool (IntPtr value) { return Runtime.GetNSObject<NSNumber> (value)?.BoolValue ?? null; }
static nfloat? xamarin_nsnumber_to_nullable_nfloat (IntPtr value)
{
if (value == IntPtr.Zero)
return null;
var number = Runtime.GetNSObject<NSNumber> (value);
if (number is null)
return null;
if (IntPtr.Size == 4)
return (nfloat) number.FloatValue;
return (nfloat) number.DoubleValue;
}
static nfloat? xamarin_nsnumber_to_nullable_nfloat (IntPtr value) { return (nfloat?) Runtime.GetNSObject<NSNumber> (value)?.DoubleValue ?? null; }

static IntPtr xamarin_sbyte_to_nsnumber (System.SByte value) { return NSNumber.FromSByte (value).DangerousRetain ().DangerousAutorelease ().Handle; }
static IntPtr xamarin_byte_to_nsnumber (System.Byte value) { return NSNumber.FromByte (value).DangerousRetain ().DangerousAutorelease ().Handle; }
Expand All @@ -255,12 +235,7 @@ static nfloat xamarin_nsnumber_to_nfloat (IntPtr value)
static IntPtr xamarin_float_to_nsnumber (System.Single value) { return NSNumber.FromFloat (value).DangerousRetain ().DangerousAutorelease ().Handle; }
static IntPtr xamarin_double_to_nsnumber (System.Double value) { return NSNumber.FromDouble (value).DangerousRetain ().DangerousAutorelease ().Handle; }
static IntPtr xamarin_bool_to_nsnumber (System.Boolean value) { return NSNumber.FromBoolean (value).DangerousRetain ().DangerousAutorelease ().Handle; }
static IntPtr xamarin_nfloat_to_nsnumber (nfloat value)
{
if (IntPtr.Size == 4)
return NSNumber.FromFloat ((float) value).DangerousRetain ().DangerousAutorelease ().Handle;
return NSNumber.FromDouble ((double) value).DangerousRetain ().DangerousAutorelease ().Handle;
}
static IntPtr xamarin_nfloat_to_nsnumber (nfloat value) { return NSNumber.FromDouble ((double) value).DangerousRetain ().DangerousAutorelease ().Handle; }

static IntPtr xamarin_nullable_sbyte_to_nsnumber (System.SByte? value) { if (!value.HasValue) return IntPtr.Zero; return NSNumber.FromSByte (value.Value).DangerousRetain ().DangerousAutorelease ().Handle; }
static IntPtr xamarin_nullable_byte_to_nsnumber (System.Byte? value) { if (!value.HasValue) return IntPtr.Zero; return NSNumber.FromByte (value.Value).DangerousRetain ().DangerousAutorelease ().Handle; }
Expand All @@ -275,13 +250,6 @@ static IntPtr xamarin_nfloat_to_nsnumber (nfloat value)
static IntPtr xamarin_nullable_float_to_nsnumber (System.Single? value) { if (!value.HasValue) return IntPtr.Zero; return NSNumber.FromFloat (value.Value).DangerousRetain ().DangerousAutorelease ().Handle; }
static IntPtr xamarin_nullable_double_to_nsnumber (System.Double? value) { if (!value.HasValue) return IntPtr.Zero; return NSNumber.FromDouble (value.Value).DangerousRetain ().DangerousAutorelease ().Handle; }
static IntPtr xamarin_nullable_bool_to_nsnumber (System.Boolean? value) { if (!value.HasValue) return IntPtr.Zero; return NSNumber.FromBoolean (value.Value).DangerousRetain ().DangerousAutorelease ().Handle; }
static IntPtr xamarin_nullable_nfloat_to_nsnumber (nfloat? value)
{
if (!value.HasValue)
return IntPtr.Zero;
if (IntPtr.Size == 4)
return NSNumber.FromFloat ((float) value.Value).DangerousRetain ().DangerousAutorelease ().Handle;
return NSNumber.FromDouble ((double) value.Value).DangerousRetain ().DangerousAutorelease ().Handle;
}
static IntPtr xamarin_nullable_nfloat_to_nsnumber (nfloat? value) { if (!value.HasValue) return IntPtr.Zero; return NSNumber.FromDouble ((double) value.Value).DangerousRetain ().DangerousAutorelease ().Handle; }
}
}
9 changes: 0 additions & 9 deletions src/ObjCRuntime/Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,6 @@ unsafe static void Initialize (InitializationOptions* options)
throw ErrorHelper.CreateError (8001, msg);
}

if (IntPtr.Size != sizeof (nint)) {
string msg = $"Native type size mismatch between {AssemblyName} and the executing architecture. {AssemblyName} was built for {(IntPtr.Size == 4 ? 64 : 32)}-bit, while the current process is {(IntPtr.Size == 4 ? 32 : 64)}-bit.";
NSLog (msg);
throw ErrorHelper.CreateError (8010, msg);
}

if (System.Runtime.GCSettings.IsServerGC) {
var msg = $".NET for {PlatformName} does not support server garbage collection.";
NSLog (msg);
Expand Down Expand Up @@ -2545,9 +2539,6 @@ public string Description {
[BindingImpl (BindingImplOptions.Optimizable)]
static bool GetIsARM64CallingConvention ()
{
if (IntPtr.Size != 8)
return false;

unsafe {
return NXGetLocalArchInfo ()->Name.StartsWith ("arm64", StringComparison.OrdinalIgnoreCase);
}
Expand Down
6 changes: 3 additions & 3 deletions src/ObjCRuntime/TypeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ public static string ToNative (Type type)
if (type == typeof (string)) return "@"; // We handle NSString as MonoString automagicaly
if (type == typeof (Selector)) return ":";
if (type == typeof (Class)) return "#";
if (type == typeof (nfloat)) return IntPtr.Size == 8 ? "d" : "f";
if (type == typeof (nint)) return IntPtr.Size == 8 ? "q" : "i";
if (type == typeof (nuint)) return IntPtr.Size == 8 ? "Q" : "I";
if (type == typeof (nfloat)) return "d";
if (type == typeof (nint)) return "q";
if (type == typeof (nuint)) return "Q";
if (typeof (INativeObject).IsAssignableFrom (type)) return "@";
if (type.IsValueType && !type.IsEnum) {
// TODO: We should cache the results of this in a temporary hash that we destroy when we're done initializing/registrations
Expand Down
2 changes: 0 additions & 2 deletions src/WebKit/WKWindowFeatures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ public bool? AllowsResizing {
{
if (number is null)
return null;
else if (IntPtr.Size == 4)
return (nfloat) number.FloatValue;
else
return (nfloat) number.DoubleValue;
}
Expand Down