Skip to content

Commit aa4dc6a

Browse files
committed
Fixes Jsrt API C99/C++98 compatability
Fixed abuse of JsTTDMoveMode enum in call to JsTTDGetSnapTimeTopLevelEventMove() so that JsTTDMoveMode does not need to be 64-bit and thus incompatible with C99/C++98
1 parent d1e8d52 commit aa4dc6a

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

bin/ch/ChakraRtInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ class ChakraRTInterface
360360
static JsErrorCode WINAPI JsTTDNotifyYield() { return HOOK_JS_API(TTDNotifyYield()); }
361361
static JsErrorCode WINAPI JsTTDHostExit(int statusCode) { return HOOK_JS_API(TTDHostExit(statusCode)); }
362362

363-
static JsErrorCode WINAPI JsTTDGetSnapTimeTopLevelEventMove(JsRuntimeHandle runtimeHandle, JsTTDMoveMode moveMode, int64_t* targetEventTime, int64_t* targetStartSnapTime, int64_t* targetEndSnapTime) { return HOOK_JS_API(TTDGetSnapTimeTopLevelEventMove(runtimeHandle, moveMode, targetEventTime, targetStartSnapTime, targetEndSnapTime)); }
363+
static JsErrorCode WINAPI JsTTDGetSnapTimeTopLevelEventMove(JsRuntimeHandle runtimeHandle, JsTTDMoveMode moveMode, uint32_t kthEvent, int64_t* targetEventTime, int64_t* targetStartSnapTime, int64_t* targetEndSnapTime) { return HOOK_JS_API(TTDGetSnapTimeTopLevelEventMove(runtimeHandle, moveMode, kthEvent, targetEventTime, targetStartSnapTime, targetEndSnapTime)); }
364364
static JsErrorCode WINAPI JsTTDMoveToTopLevelEvent(JsRuntimeHandle runtimeHandle, JsTTDMoveMode moveMode, int64_t snapshotStartTime, int64_t eventTime) { return HOOK_JS_API(TTDMoveToTopLevelEvent(runtimeHandle, moveMode, snapshotStartTime, eventTime)); }
365365
static JsErrorCode WINAPI JsTTDReplayExecution(JsTTDMoveMode* moveMode, int64_t* rootEventTime) { return HOOK_JS_API(TTDReplayExecution(moveMode, rootEventTime)); }
366366

bin/ch/ch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,13 @@ HRESULT RunScript(const char* fileName, LPCSTR fileContents, BYTE *bcBuffer, cha
272272

273273
try
274274
{
275-
JsTTDMoveMode moveMode = (JsTTDMoveMode)(JsTTDMoveMode::JsTTDMoveKthEvent | ((int64) startEventCount) << 32);
275+
JsTTDMoveMode moveMode = JsTTDMoveMode::JsTTDMoveKthEvent;
276276
int64_t snapEventTime = -1;
277277
int64_t nextEventTime = -2;
278278

279279
while(true)
280280
{
281-
JsErrorCode error = ChakraRTInterface::JsTTDGetSnapTimeTopLevelEventMove(chRuntime, moveMode, &nextEventTime, &snapEventTime, nullptr);
281+
JsErrorCode error = ChakraRTInterface::JsTTDGetSnapTimeTopLevelEventMove(chRuntime, moveMode, startEventCount, &nextEventTime, &snapEventTime, nullptr);
282282

283283
if(error != JsNoError)
284284
{

lib/Jsrt/ChakraCommon.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ typedef BYTE* ChakraBytePtr;
7171
#define CHAKRA_API extern "C" SET_API_VISIBILITY JsErrorCode
7272
#else
7373
#define CHAKRA_API extern SET_API_VISIBILITY JsErrorCode
74+
#include <stdbool.h>
75+
#endif
76+
77+
#if !defined(__cplusplus) || (__cplusplus <= 199711L)
78+
#define nullptr 0
7479
#endif
7580

7681
#include <stddef.h> // for size_t

lib/Jsrt/ChakraDebug.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ typedef __int64 int64_t;
643643
/// <summary>
644644
/// TimeTravel move options as bit flag enum.
645645
/// </summary>
646-
typedef enum _JsTTDMoveModes : int64_t
646+
typedef enum _JsTTDMoveModes
647647
{
648648
/// <summary>
649649
/// Indicates no special actions needed for move.
@@ -966,13 +966,15 @@ typedef __int64 int64_t;
966966
/// </summary>
967967
/// <param name="runtimeHandle">The runtime handle that the script is executing in.</param>
968968
/// <param name="moveMode">Flags controlling the way the move it performed and how other parameters are interpreted.</param>
969+
/// <param name="kthEvent">When <c>moveMode == JsTTDMoveKthEvent</c> indicates which event, otherwise this parameter is ignored.</param>
969970
/// <param name="targetEventTime">The event time we want to move to or -1 if not relevant.</param>
970971
/// <param name="targetStartSnapTime">Out parameter with the event time of the snapshot that we should inflate from.</param>
971972
/// <param name="targetEndSnapTime">Optional Out parameter with the snapshot time following the event.</param>
972973
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns>
973974
CHAKRA_API JsTTDGetSnapTimeTopLevelEventMove(
974975
_In_ JsRuntimeHandle runtimeHandle,
975976
_In_ JsTTDMoveMode moveMode,
977+
_In_opt_ uint32_t kthEvent,
976978
_Inout_ int64_t* targetEventTime,
977979
_Out_ int64_t* targetStartSnapTime,
978980
_Out_opt_ int64_t* targetEndSnapTime);

lib/Jsrt/Jsrt.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3742,8 +3742,9 @@ CHAKRA_API JsTTDCheckAndAssertIfTTDRunning(_In_ const char* msg)
37423742
}
37433743

37443744
CHAKRA_API JsTTDGetSnapTimeTopLevelEventMove(_In_ JsRuntimeHandle runtimeHandle,
3745-
_In_ JsTTDMoveMode moveMode, _Inout_ int64_t* targetEventTime,
3746-
_Out_ int64_t* targetStartSnapTime, _Out_opt_ int64_t* targetEndSnapTime)
3745+
_In_ JsTTDMoveMode moveMode, _In_opt_ uint32_t kthEvent,
3746+
_Inout_ int64_t* targetEventTime, _Out_ int64_t* targetStartSnapTime,
3747+
_Out_opt_ int64_t* targetEndSnapTime)
37473748
{
37483749
#if !ENABLE_TTD
37493750
return JsErrorCategoryUsage;
@@ -3778,7 +3779,6 @@ CHAKRA_API JsTTDGetSnapTimeTopLevelEventMove(_In_ JsRuntimeHandle runtimeHandle,
37783779
}
37793780
else if((moveMode & JsTTDMoveMode::JsTTDMoveKthEvent) == JsTTDMoveMode::JsTTDMoveKthEvent)
37803781
{
3781-
uint32 kthEvent = (uint32)(((int64)moveMode) >> 32);
37823782
*targetEventTime = threadContext->TTDLog->GetKthEventTimeInLog(kthEvent);
37833783
if(*targetEventTime == -1)
37843784
{

0 commit comments

Comments
 (0)