Skip to content

Commit 5ed210c

Browse files
Fix ep_rt_atomic_compare_exchange_size_t in Mono EventPipe shim. (#58369)
ep_rt_atomic_compare_exchange_size_t was always truncated to gint32 on Mono 64-bit platforms. This commit use 32 or 64-bit cas version depending on SIZEOF_SIZE_T. NOTE, CoreCLR used a template function for this and already picks 32 or 64 bit version depending on size of size_t. ep_rt_atomic_compare_exchange_size_t is currently used to reflect size of EventPipe buffer manager buffers and will most likely never need more than 2GB of data, but better to fix it and inline with CoreCLR shim implementation. Co-authored-by: lateralusX <[email protected]>
1 parent aaba084 commit 5ed210c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/mono/mono/eventpipe/ep-rt-mono.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,11 @@ inline
602602
size_t
603603
ep_rt_atomic_compare_exchange_size_t (volatile size_t *target, size_t expected, size_t value)
604604
{
605+
#if SIZEOF_SIZE_T == 8
606+
return (size_t)(mono_atomic_cas_i64((volatile gint64*)(target), (gint64)(value), (gint64)(expected)));
607+
#else
605608
return (size_t)(mono_atomic_cas_i32 ((volatile gint32 *)(target), (gint32)(value), (gint32)(expected)));
609+
#endif
606610
}
607611

608612
/*

0 commit comments

Comments
 (0)