# Native plug-in and internal call support


To call native functions, use [`[DllImport]`](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.dllimportattribute?view=net-6.0):

```lang-cs
[DllImport("MyNativeLibrary")]
public static extern int Foo(int arg);
```

Burst also supports internal calls implemented inside Unity:

```lang-cs
// In UnityEngine.Mathf
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern int ClosestPowerOfTwo(int value);
```

`DllImport` is only supported for [native plug-ins](/engine/6000.6/manual/programming-environment/plug-ins/native.md), not platform-dependent libraries like `kernel32.dll`.

For all `DllImport` and internal calls, you can only use the following types as parameter or return types:

| **Type**                     | **Supported type**                                                                                                                                                                                            |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Built-in and intrinsic types | `byte` / `sbyte``short` / `ushort``int` / `uint``long` / `ulong``float``double``System.IntPtr` / `System.UIntPtr``Unity.Burst.Intrinsics.v64` / `Unity.Burst.Intrinsics.v128` / `Unity.Burst.Intrinsics.v256` |
| Pointers and references      | `sometype*` : Pointer to any of the other types in this list`ref sometype` : Reference to any of the other types in this list                                                                                 |
| Handle structs               | `unsafe struct MyStruct { void* Ptr; }` : Struct containing a single pointer field`unsafe struct MyStruct { int Value; }` : Struct containing a single integer field                                          |

> **Note:**
>
> Passing structs by value isn't supported; you need to pass them through a pointer or reference. The only exception is that handle structs are supported. These are structs that contain a single field of pointer or integer type.

## Additional resources

* [HPC# overview](/engine/6000.6/manual/programming-environment/script-compilation/burst/csharp-language-support/csharp-hpc-overview.md)
* [Burst intrinsics overview](/engine/6000.6/manual/programming-environment/script-compilation/burst/csharp-burst-intrinsics.md)
