Skip to content

Commit fb52aa3

Browse files
committed
Try using ulong and long
1 parent 5421a85 commit fb52aa3

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/embed_tests/TestInterrupt.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void Dispose()
3131
public void InterruptTest()
3232
{
3333
int runSimpleStringReturnValue = int.MinValue;
34-
uint nativeThreadID = uint.MinValue;
34+
ulong nativeThreadID = uint.MinValue;
3535
Task.Factory.StartNew(() =>
3636
{
3737
using (Py.GIL())

src/runtime/pythonengine.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public class PythonEngine : IDisposable
1616
private static extern uint GetCurrentThreadId();
1717

1818
[DllImport("libc", EntryPoint = "pthread_self")]
19-
private static extern UIntPtr pthread_selfLinux();
19+
private static extern ulong pthread_selfLinux();
2020

2121
[DllImport("pthread", EntryPoint = "pthread_self", CallingConvention = CallingConvention.Cdecl)]
22-
private static extern uint pthread_selfOSX();
22+
private static extern ulong pthread_selfOSX();
2323

2424
public static ShutdownMode ShutdownMode
2525
{
@@ -580,7 +580,7 @@ public static void Exec(string code, IntPtr? globals = null, IntPtr? locals = nu
580580
/// Gets the native thread ID.
581581
/// </summary>
582582
/// <returns>The native thread ID.</returns>
583-
public static uint GetNativeThreadID()
583+
public static ulong GetNativeThreadID()
584584
{
585585
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
586586
{
@@ -589,7 +589,7 @@ public static uint GetNativeThreadID()
589589

590590
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
591591
{
592-
return pthread_selfLinux().ToUInt32();
592+
return pthread_selfLinux();
593593
}
594594

595595
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
@@ -605,24 +605,24 @@ public static uint GetNativeThreadID()
605605
/// </summary>
606606
/// <param name="nativeThreadID">The native thread ID.</param>
607607
/// <returns>The number of thread states modified; this is normally one, but will be zero if the thread id isn’t found.</returns>
608-
public static int Interrupt(uint nativeThreadID)
608+
public static int Interrupt(ulong nativeThreadID)
609609
{
610610
if (Runtime.PyVersion >= new Version(3, 7))
611611
{
612612
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
613613
{
614-
return Runtime.PyThreadState_SetAsyncExc37Windows(nativeThreadID, Exceptions.KeyboardInterrupt);
614+
return Runtime.PyThreadState_SetAsyncExc37Windows((uint)nativeThreadID, Exceptions.KeyboardInterrupt);
615615
}
616616

617-
return Runtime.PyThreadState_SetAsyncExc37NonWindows(new UIntPtr(nativeThreadID), Exceptions.KeyboardInterrupt);
617+
return Runtime.PyThreadState_SetAsyncExc37NonWindows(nativeThreadID, Exceptions.KeyboardInterrupt);
618618
}
619619

620620
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
621621
{
622622
return Runtime.PyThreadState_SetAsyncExc36Windows((int)nativeThreadID, Exceptions.KeyboardInterrupt);
623623
}
624624

625-
return Runtime.PyThreadState_SetAsyncExc36NonWindows(new IntPtr(nativeThreadID), Exceptions.KeyboardInterrupt);
625+
return Runtime.PyThreadState_SetAsyncExc36NonWindows((long)nativeThreadID, Exceptions.KeyboardInterrupt);
626626
}
627627

628628
/// <summary>

src/runtime/runtime.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,10 +2150,10 @@ internal static void Py_CLEAR(ref IntPtr ob)
21502150
internal static extern int PyThreadState_SetAsyncExc36Windows(int id, IntPtr exc);
21512151

21522152
[DllImport(_PythonDll, EntryPoint = "PyThreadState_SetAsyncExc", CallingConvention = CallingConvention.Cdecl)]
2153-
internal static extern int PyThreadState_SetAsyncExc37NonWindows(UIntPtr id, IntPtr exc);
2153+
internal static extern int PyThreadState_SetAsyncExc37NonWindows(ulong id, IntPtr exc);
21542154

21552155
[DllImport(_PythonDll, EntryPoint = "PyThreadState_SetAsyncExc", CallingConvention = CallingConvention.Cdecl)]
2156-
internal static extern int PyThreadState_SetAsyncExc36NonWindows(IntPtr id, IntPtr exc);
2156+
internal static extern int PyThreadState_SetAsyncExc36NonWindows(long id, IntPtr exc);
21572157

21582158
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
21592159
internal static extern int Py_MakePendingCalls();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy