Skip to content

Support natural size data types in the CLR #4233

Closed
@migueldeicaza

Description

There are cases (in particular on OSX) where native APIs are defined in terms of the natural size of the platform. This means that APIs use 32-bit integers on 32-bit platforms and 64-bit integers in 64-bit platforms.

Mono uses a poor man's approach to solve this problem, and we introduce the structures System.nint, System.nuint and System.nfloat that stand for native integer, native unsigned integer, and native float. These data types will be 32 bits or 64 bits depending on the platform.

The usual set of operators on ints, uints and floats are defined on those structures.

The Mono runtime then has special support to turn sequences that would invoke those operators into the native representation for it.

This means that code that would pass two nint structures, and call the addition operator on it are turned into a regular integer addition operation with no performance loss.

This is the poor man's way of introducing a new data type that is not part of the CIL spec.

This is what we published on the subject:

http://developer.xamarin.com/guides/cross-platform/macios/nativetypes/

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions