Reactos
at master 34 lines 920 B view raw
1/* 2 * PROJECT: ReactOS vcruntime library 3 * LICENSE: MIT (https://spdx.org/licenses/MIT) 4 * PURPOSE: Implementation of _get_purecall_handler, _set_purecall_handler and _purecall function 5 * COPYRIGHT: Copyright 2025 Timo Kreuzer <timo.kreuzer@reactos.org> 6 */ 7 8#include <stdlib.h> 9#include <intrin.h> 10 11static volatile _purecall_handler purecall_handler; 12 13extern "C" 14_purecall_handler _cdecl _get_purecall_handler(void) 15{ 16 return purecall_handler; 17} 18 19extern "C" 20_purecall_handler _cdecl _set_purecall_handler(_In_opt_ _purecall_handler _Handler) 21{ 22 return reinterpret_cast<_purecall_handler>( 23 _InterlockedExchangePointer(reinterpret_cast<void* volatile*>(&purecall_handler), 24 reinterpret_cast<void*>(_Handler))); 25} 26 27extern "C" 28int __cdecl _purecall(void) 29{ 30 _purecall_handler handler = purecall_handler; 31 if (handler) 32 handler(); 33 abort(); 34}