Skip to content

Commit bcdd9dd

Browse files
committed
cross platform: replace long to int32
1 parent 2740f5e commit bcdd9dd

75 files changed

Lines changed: 353 additions & 352 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bin/rl/rl.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -964,22 +964,22 @@ FormatString(
964964
else {
965965
switch (*++format) {
966966
case 'd':
967-
i += sprintf_s(&buf[i], BUFFER_SIZE + 32 - i, "%d", (long)NumDiffsTotal[RLS_TOTAL]);
967+
i += sprintf_s(&buf[i], BUFFER_SIZE + 32 - i, "%d", (int32)NumDiffsTotal[RLS_TOTAL]);
968968
break;
969969
case 'f':
970-
i += sprintf_s(&buf[i], BUFFER_SIZE + 32 - i, "%d", (long)NumFailuresTotal[RLS_TOTAL]);
970+
i += sprintf_s(&buf[i], BUFFER_SIZE + 32 - i, "%d", (int32)NumFailuresTotal[RLS_TOTAL]);
971971
break;
972972
case 't':
973-
i += sprintf_s(&buf[i], BUFFER_SIZE + 32 - i, "%d", (long)NumVariationsRun[RLS_TOTAL]);
973+
i += sprintf_s(&buf[i], BUFFER_SIZE + 32 - i, "%d", (int32)NumVariationsRun[RLS_TOTAL]);
974974
break;
975975
case 'T':
976-
i += sprintf_s(&buf[i], BUFFER_SIZE + 32 - i, "%d", (long)NumVariationsTotal[RLS_TOTAL]);
976+
i += sprintf_s(&buf[i], BUFFER_SIZE + 32 - i, "%d", (int32)NumVariationsTotal[RLS_TOTAL]);
977977
break;
978978
case 'p':
979-
if ((long)NumVariationsTotal[RLS_TOTAL]) {
979+
if ((int32)NumVariationsTotal[RLS_TOTAL]) {
980980
i += sprintf_s(&buf[i], BUFFER_SIZE + 32 - i, "%d",
981-
100 * (long)NumVariationsRun[RLS_TOTAL] /
982-
(long)NumVariationsTotal[RLS_TOTAL]);
981+
100 * (int32)NumVariationsRun[RLS_TOTAL] /
982+
(int32)NumVariationsTotal[RLS_TOTAL]);
983983
}
984984
else {
985985
i += sprintf_s(&buf[i], BUFFER_SIZE + 32 - i, "--");
@@ -3377,7 +3377,7 @@ IsTimeoutStringValid(char *strTimeout) {
33773377
char *end;
33783378
_set_errno(0);
33793379

3380-
unsigned long secTimeout = strtoul(strTimeout, &end, 10);
3380+
uint32 secTimeout = strtoul(strTimeout, &end, 10);
33813381

33823382
if (errno != 0 || *end != 0) {
33833383
return FALSE;
@@ -4602,9 +4602,9 @@ RegressDirectory(
46024602
if (FBaseDiff && !pDir->IsBaseline())
46034603
pDir->InitStats(0);
46044604

4605-
ASSERTNR((long)pDir->NumVariationsRun == 0);
4606-
ASSERTNR((long)pDir->NumDiffs == 0);
4607-
ASSERTNR((long)pDir->NumFailures == 0);
4605+
ASSERTNR((int32)pDir->NumVariationsRun == 0);
4606+
ASSERTNR((int32)pDir->NumDiffs == 0);
4607+
ASSERTNR((int32)pDir->NumFailures == 0);
46084608

46094609
if (!FNoDirName)
46104610
WriteLog("*** %s ***", dir);
@@ -5008,16 +5008,16 @@ main(int argc, char *argv[])
50085008

50095009
if (FRLFE) {
50105010
if (Mode == RM_EXE) {
5011-
RLFEAddRoot(RLS_EXE, (long)NumVariationsTotal[RLS_EXE]);
5011+
RLFEAddRoot(RLS_EXE, (int32)NumVariationsTotal[RLS_EXE]);
50125012
}
50135013
else {
50145014
if (FBaseline)
5015-
RLFEAddRoot(RLS_BASELINES, (long)NumVariationsTotal[RLS_BASELINES]);
5015+
RLFEAddRoot(RLS_BASELINES, (int32)NumVariationsTotal[RLS_BASELINES]);
50165016
if (FDiff)
5017-
RLFEAddRoot(RLS_DIFFS, (long)NumVariationsTotal[RLS_DIFFS]);
5017+
RLFEAddRoot(RLS_DIFFS, (int32)NumVariationsTotal[RLS_DIFFS]);
50185018
}
50195019

5020-
RLFEAddRoot(RLS_TOTAL, (long)NumVariationsTotal[RLS_TOTAL]);
5020+
RLFEAddRoot(RLS_TOTAL, (int32)NumVariationsTotal[RLS_TOTAL]);
50215021
}
50225022

50235023
DirectoryQueue.AdjustWaitForThreadCount();
@@ -5073,5 +5073,5 @@ main(int argc, char *argv[])
50735073
// The return code from RL is 0 for complete success, 1 for any failure.
50745074
// Note that diffs don't count as failures.
50755075

5076-
return ((long)NumFailuresTotal[RLS_TOTAL] == 0L) ? 0 : 1;
5076+
return ((int32)NumFailuresTotal[RLS_TOTAL] == 0L) ? 0 : 1;
50775077
}

bin/rl/rl.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#pragma warning(disable:4127) // expression is constant, e.g., while(TRUE)
2525

2626
#define LOCAL static
27+
typedef __int32 int32;
28+
typedef unsigned __int32 uint32;
2729

2830
#define BUFFER_SIZE 1024
2931
#define MAXQUEUE 10000
@@ -320,7 +322,7 @@ class COutputBuffer;
320322

321323
class CProtectedLong {
322324
CRITICAL_SECTION _cs;
323-
long _value;
325+
int32 _value;
324326

325327
public:
326328

@@ -334,31 +336,31 @@ class CProtectedLong {
334336
DeleteCriticalSection(&_cs);
335337
}
336338

337-
long operator++(int)
339+
int32 operator++(int)
338340
{
339341
EnterCriticalSection(&_cs);
340-
long tmp = _value++;
342+
int32 tmp = _value++;
341343
LeaveCriticalSection(&_cs);
342344
return tmp;
343345
}
344346

345-
long operator--(int)
347+
int32 operator--(int)
346348
{
347349
EnterCriticalSection(&_cs);
348-
long tmp = _value--;
350+
int32 tmp = _value--;
349351
LeaveCriticalSection(&_cs);
350352
return tmp;
351353
}
352354

353-
long operator+=(long incr)
355+
int32 operator+=(int32 incr)
354356
{
355357
EnterCriticalSection(&_cs);
356-
long tmp = (_value += incr);
358+
int32 tmp = (_value += incr);
357359
LeaveCriticalSection(&_cs);
358360
return tmp;
359361
}
360362

361-
long operator=(long val)
363+
int32 operator=(int32 val)
362364
{
363365
EnterCriticalSection(&_cs);
364366
_value = val;
@@ -371,7 +373,6 @@ class CProtectedLong {
371373
return _value == rhs._value;
372374
}
373375

374-
operator long() { return _value; }
375376
operator int() { return _value; }
376377
};
377378

@@ -620,9 +621,9 @@ class CDirectory : public WorkObject<CDirectory> {
620621
void SetDiffFlag() { _isDiffDirectory = true; }
621622

622623
void InitStats(int run);
623-
long IncRun(int inc = 1);
624-
long IncFailures(int inc = 1);
625-
long IncDiffs();
624+
int32 IncRun(int inc = 1);
625+
int32 IncFailures(int inc = 1);
626+
int32 IncDiffs();
626627

627628
// Trigger update of directory state.
628629
void UpdateState();

bin/rl/rlmp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,21 +141,21 @@ void CDirectory::InitStats(int num)
141141
NumVariationsRun = NumFailures = NumDiffs = 0;
142142
}
143143

144-
long CDirectory::IncRun(int inc)
144+
int32 CDirectory::IncRun(int inc)
145145
{
146146
::NumVariationsRun[RLS_TOTAL] += inc; // overall count
147147
::NumVariationsRun[stat] += inc; // mode stat
148148
return NumVariationsRun += inc; // per directory count
149149
}
150150

151-
long CDirectory::IncFailures(int inc)
151+
int32 CDirectory::IncFailures(int inc)
152152
{
153153
::NumFailuresTotal[RLS_TOTAL] += inc; // overall count
154154
::NumFailuresTotal[stat] += inc; // mode stat
155155
return NumFailures += inc; // per directory count
156156
}
157157

158-
long CDirectory::IncDiffs()
158+
int32 CDirectory::IncDiffs()
159159
{
160160
::NumDiffsTotal[RLS_TOTAL]++; // overall count
161161
::NumDiffsTotal[stat]++; // mode stat

bin/rl/rlrun.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ int
12821282
if (strTimeout) {
12831283
char *end;
12841284
_set_errno(0);
1285-
unsigned long secTimeout = strtoul(strTimeout, &end, 10);
1285+
uint32 secTimeout = strtoul(strTimeout, &end, 10);
12861286
millisecTimeout = 1000 * secTimeout;
12871287
// Validation has already occurred so this string should
12881288
// parse fine and the value shouldn't overflow the DWORD.

lib/Backend/arm/EncoderMD.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ EncoderMD::GetForm(IR::Instr *instr, int32 size)
892892
return (form);
893893
}
894894

895-
bool EncoderMD::EncodeImmediate16(long constant, DWORD * result)
895+
bool EncoderMD::EncodeImmediate16(int32 constant, DWORD * result)
896896
{
897897
if (constant > 0xFFFF)
898898
{
@@ -909,7 +909,7 @@ bool EncoderMD::EncodeImmediate16(long constant, DWORD * result)
909909
}
910910

911911
ENCODE_32
912-
EncoderMD::EncodeT2Immediate12(ENCODE_32 encode, long constant)
912+
EncoderMD::EncodeT2Immediate12(ENCODE_32 encode, int32 constant)
913913
{
914914
Assert((constant & 0xFFFFF000) == 0);
915915

@@ -987,7 +987,7 @@ EncoderMD::GenerateEncoding(IR::Instr* instr, IFORM iform, BYTE *pc, int32 size,
987987
bool fPost;
988988

989989
int done = false;
990-
long constant = 0; //UTC IVALTYPE
990+
int32 constant = 0; //UTC IVALTYPE
991991
bool constantValid = false;
992992
RegNum regNum;
993993
unsigned int iType = 0, SFlag = 0;
@@ -1438,7 +1438,7 @@ EncoderMD::GenerateEncoding(IR::Instr* instr, IFORM iform, BYTE *pc, int32 size,
14381438
if (!constant)
14391439
{
14401440
BVUnit32 registers = opndRD->AsRegBVOpnd()->GetValue();
1441-
unsigned long regenc;
1441+
uint32 regenc;
14421442
BVIndex index = registers.GetNextBit();
14431443

14441444
// Note: only the wide encoding distinguishes between

lib/Backend/arm/EncoderMD.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class EncoderMD
9999
static bool CanEncodeModConst12(DWORD constant);
100100
static bool CanEncodeLoadStoreOffset(int32 offset) { return IS_CONST_UINT12(offset); }
101101
static void BaseAndOffsetFromSym(IR::SymOpnd *symOpnd, RegNum *pBaseReg, int32 *pOffset, Func * func);
102-
static bool EncodeImmediate16(long constant, DWORD * result);
102+
static bool EncodeImmediate16(int32 constant, DWORD * result);
103103
static ENCODE_32 BranchOffset_T2_24(int x);
104104
void EncodeInlineeCallInfo(IR::Instr *instr, uint32 offset);
105105
private:
@@ -127,7 +127,7 @@ class EncoderMD
127127
bool IsWideMemInstr(IR::Opnd * memOpnd, IR::RegOpnd * regOpnd);
128128
bool IsWideAddSub(IR::Instr * instr);
129129

130-
static ENCODE_32 EncodeT2Immediate12(ENCODE_32 encode, long constant);
130+
static ENCODE_32 EncodeT2Immediate12(ENCODE_32 encode, int32 constant);
131131
static bool EncodeModConst12(DWORD constant, DWORD * result);
132132
static ENCODE_32 EncodeT2Offset(ENCODE_32 encode, IR::Instr *instr, int offset, int bitOffset);
133133

lib/Backend/arm64/EncoderMD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "ARMEncode.h"
77

88
bool
9-
EncoderMD::EncodeImmediate16(long constant, DWORD * result)
9+
EncoderMD::EncodeImmediate16(int32 constant, DWORD * result)
1010
{
1111
if (constant > 0xFFFF)
1212
{

lib/Backend/arm64/EncoderMD.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class EncoderMD
7474
static bool CanEncodeModConst12(DWORD constant) { __debugbreak(); return 0; }
7575
static bool CanEncodeLoadStoreOffset(int32 offset) { __debugbreak(); return 0; }
7676
static void BaseAndOffsetFromSym(IR::SymOpnd *symOpnd, RegNum *pBaseReg, int32 *pOffset, Func * func) { __debugbreak(); }
77-
static bool EncodeImmediate16(long constant, DWORD * result);
77+
static bool EncodeImmediate16(int32 constant, DWORD * result);
7878

7979
void EncodeInlineeCallInfo(IR::Instr *instr, uint32 offset) { __debugbreak(); }
8080

lib/Common/Common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ typedef _Return_type_success_(return >= 0) LONG NTSTATUS;
3434
namespace Js
3535
{
3636
typedef int32 PropertyId;
37-
typedef unsigned long ModuleID;
37+
typedef uint32 ModuleID;
3838
}
3939

4040
#define IsTrueOrFalse(value) ((value) ? _u("True") : _u("False"))

lib/Common/Common/NumberUtilities.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,15 +332,15 @@ namespace Js
332332
}
333333

334334

335-
long NumberUtilities::LwFromDblNearest(double dbl)
335+
int32 NumberUtilities::LwFromDblNearest(double dbl)
336336
{
337337
if (Js::NumberUtilities::IsNan(dbl))
338338
return 0;
339339
if (dbl > 0x7FFFFFFFL)
340340
return 0x7FFFFFFFL;
341-
if (dbl < (long)0x80000000L)
342-
return (long)0x80000000L;
343-
return (long)dbl;
341+
if (dbl < (int32)0x80000000L)
342+
return (int32)0x80000000L;
343+
return (int32)dbl;
344344
}
345345

346346
uint32 NumberUtilities::LuFromDblNearest(double dbl)
@@ -354,12 +354,12 @@ namespace Js
354354
return (uint32)dbl;
355355
}
356356

357-
BOOL NumberUtilities::FDblIsLong(double dbl, long *plw)
357+
BOOL NumberUtilities::FDblIsInt32(double dbl, int32 *plw)
358358
{
359359
AssertMem(plw);
360360
double dblT;
361361

362-
*plw = (long)dbl;
362+
*plw = (int32)dbl;
363363
dblT = (double)*plw;
364364
return Js::NumberUtilities::LuHiDbl(dblT) == Js::NumberUtilities::LuHiDbl(dbl) && Js::NumberUtilities::LuLoDbl(dblT) == Js::NumberUtilities::LuLoDbl(dbl);
365365
}

0 commit comments

Comments
 (0)