mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
mjit.c: use InterlockedExchangePointer
for Windows, if it's available. Before this commit, Windows builds printed following warnings. mjit.c ../mjit.c(802) : warning C4047: 'function' : 'volatile LONG *' differs in levels of indirection from 'void **' ../mjit.c(802) : warning C4024: '_InterlockedExchange' : different types for formal and actual parameter 1 ../mjit.c(802) : warning C4047: 'function' : 'LONG' differs in levels of indirection from 'void *' ../mjit.c(802) : warning C4024: '_InterlockedExchange' : different types for formal and actual parameter 2 ATOMIC_SET is using InterlockedExchange which takes LONG as its value. As InterlockedExchangePointer takes PVOID, we should use this to set function pointer atomically. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
328666a6c2
commit
329776cd3d
1 changed files with 12 additions and 1 deletions
13
mjit.c
13
mjit.c
|
@ -118,6 +118,17 @@ typedef intptr_t pid_t;
|
||||||
#define va_copy(dest, src) ((dest) = (src))
|
#define va_copy(dest, src) ((dest) = (src))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Atomically set function pointer if possible. */
|
||||||
|
#ifdef _WIN32
|
||||||
|
# ifdef InterlockedExchangePointer
|
||||||
|
# define MJIT_ATOMIC_SET(var, val) InterlockedExchangePointer(&(var), val)
|
||||||
|
# else
|
||||||
|
# define MJIT_ATOMIC_SET(var, val) (void)((var) = (val))
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define MJIT_ATOMIC_SET(var, val) ATOMIC_SET(var, val)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* A copy of MJIT portion of MRI options since MJIT initialization. We
|
/* A copy of MJIT portion of MRI options since MJIT initialization. We
|
||||||
need them as MJIT threads still can work when the most MRI data were
|
need them as MJIT threads still can work when the most MRI data were
|
||||||
freed. */
|
freed. */
|
||||||
|
@ -800,7 +811,7 @@ worker(void)
|
||||||
CRITICAL_SECTION_START(3, "in jit func replace");
|
CRITICAL_SECTION_START(3, "in jit func replace");
|
||||||
if (node->unit->iseq) { /* Check whether GCed or not */
|
if (node->unit->iseq) { /* Check whether GCed or not */
|
||||||
/* Usage of jit_code might be not in a critical section. */
|
/* Usage of jit_code might be not in a critical section. */
|
||||||
ATOMIC_SET(node->unit->iseq->body->jit_func, func);
|
MJIT_ATOMIC_SET(node->unit->iseq->body->jit_func, func);
|
||||||
}
|
}
|
||||||
remove_from_list(node, &unit_queue);
|
remove_from_list(node, &unit_queue);
|
||||||
CRITICAL_SECTION_FINISH(3, "in jit func replace");
|
CRITICAL_SECTION_FINISH(3, "in jit func replace");
|
||||||
|
|
Loading…
Add table
Reference in a new issue