converted reentrance checker to c++