Merge pull request #334 from lioncash/use-std-minmax

Remove the min/max functions in CommonFuncs.
This commit is contained in:
shuffle2
2014-05-29 20:10:01 -07:00
29 changed files with 104 additions and 99 deletions
+1
View File
@@ -12,6 +12,7 @@
#endif
*/
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define NOMINMAX // Don't include windows min/max definitions
#include <algorithm>
#include <functional>
-9
View File
@@ -158,15 +158,6 @@ extern "C" {
#endif // M_IX86
#endif // WIN32 ndef
// Dolphin's min and max functions
#undef min
#undef max
template<class T>
inline T min(const T& a, const T& b) {return a > b ? b : a;}
template<class T>
inline T max(const T& a, const T& b) {return a > b ? a : b;}
// Generic function to get last error message.
// Call directly after the command or use the error num.
// This function might change the error code.
+7 -7
View File
@@ -2,7 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <algorithm>
#include "Common/Hash.h"
#if _M_SSE >= 0x402
#include "Common/CPUDetect.h"
@@ -155,7 +155,7 @@ u64 GetMurmurHash3(const u8 *src, int len, u32 samples)
const u8 * data = (const u8*)src;
const int nblocks = len / 16;
u32 Step = (len / 8);
if (samples == 0) samples = max(Step, 1u);
if (samples == 0) samples = std::max(Step, 1u);
Step = Step / samples;
if (Step < 1) Step = 1;
@@ -233,7 +233,7 @@ u64 GetCRC32(const u8 *src, int len, u32 samples)
u32 Step = (len / 8);
const u64 *data = (const u64 *)src;
const u64 *end = data + Step;
if (samples == 0) samples = max(Step, 1u);
if (samples == 0) samples = std::max(Step, 1u);
Step = Step / samples;
if (Step < 1) Step = 1;
while (data < end)
@@ -265,7 +265,7 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
u32 Step = (len / 8);
const u64 *data = (const u64 *)src;
const u64 *end = data + Step;
if (samples == 0) samples = max(Step, 1u);
if (samples == 0) samples = std::max(Step, 1u);
Step = Step / samples;
if (Step < 1) Step = 1;
while (data < end)
@@ -308,7 +308,7 @@ u64 GetCRC32(const u8 *src, int len, u32 samples)
u32 Step = (len/4);
const u32 *data = (const u32 *)src;
const u32 *end = data + Step;
if (samples == 0) samples = max(Step, 1u);
if (samples == 0) samples = std::max(Step, 1u);
Step = Step / samples;
if (Step < 1) Step = 1;
while (data < end)
@@ -380,7 +380,7 @@ u64 GetMurmurHash3(const u8* src, int len, u32 samples)
u32 out[2];
const int nblocks = len / 8;
u32 Step = (len / 4);
if (samples == 0) samples = max(Step, 1u);
if (samples == 0) samples = std::max(Step, 1u);
Step = Step / samples;
if (Step < 1) Step = 1;
@@ -456,7 +456,7 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
u32 Step = (len / 8);
const u64 *data = (const u64 *)src;
const u64 *end = data + Step;
if (samples == 0) samples = max(Step, 1u);
if (samples == 0) samples = std::max(Step, 1u);
Step = Step / samples;
if (Step < 1) Step = 1;
while (data < end)
+2 -1
View File
@@ -4,6 +4,7 @@
#pragma once
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
@@ -58,7 +59,7 @@ struct SSysConfEntry
{
if (buffer)
{
memcpy(data, buffer, min<u16>(bufferSize, dataLength));
memcpy(data, buffer, std::min<u16>(bufferSize, dataLength));
return true;
}
return false;
+3 -1
View File
@@ -9,11 +9,13 @@
#define _WIN32_WINNT 0x501
#endif
#ifndef _WIN32_IE
#define _WIN32_IE 0x0500 // Default value is 0x0400
#define _WIN32_IE 0x0500 // Default value is 0x0400
#endif
*/
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define NOMINMAX // Don't include windows min/max definitions
/*
#define _CRT_SECURE_NO_DEPRECATE 1
#define _CRT_NONSTDC_NO_DEPRECATE 1
@@ -2,6 +2,8 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <algorithm>
#include "Core/Core.h"
#include "Core/FifoPlayer/FifoAnalyzer.h"
#include "Core/FifoPlayer/FifoRecordAnalyzer.h"
@@ -289,8 +291,8 @@ void FifoRecordAnalyzer::WriteTexMapMemory(int texMap, u32 &writtenTexMaps)
width >>= 1;
height >>= 1;
width = max(width, fmtWidth);
height = max(height, fmtHeight);
width = std::max(width, fmtWidth);
height = std::max(height, fmtHeight);
u32 size = (width * height * fmtDepth) >> 1;
textureSize += size;
+3 -1
View File
@@ -2,6 +2,8 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <algorithm>
#include "Common/ChunkFile.h"
#include "Common/Common.h"
@@ -544,7 +546,7 @@ int GetTicksToNextSIPoll()
else if (!g_Poll.Y)
return SystemTimers::GetTicksPerSecond() / 60;
return min(VideoInterface::GetTicksPerFrame() / g_Poll.Y, VideoInterface::GetTicksPerLine() * g_Poll.X);
return std::min(VideoInterface::GetTicksPerFrame() / g_Poll.Y, VideoInterface::GetTicksPerLine() * g_Poll.X);
}
} // end of namespace SerialInterface
@@ -2,6 +2,8 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <algorithm>
#include "Common/FileUtil.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h"
#include "Core/IPC_HLE/WII_Socket.h"
@@ -174,7 +176,7 @@ bool CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
ssl_set_authmode(&ssl->ctx, SSL_VERIFY_NONE);
ssl_set_renegotiation(&ssl->ctx, SSL_RENEGOTIATION_ENABLED);
memcpy(ssl->hostname, hostname, min((int)BufferOutSize2, NET_SSL_MAX_HOSTNAME_LEN));
memcpy(ssl->hostname, hostname, std::min((int)BufferOutSize2, NET_SSL_MAX_HOSTNAME_LEN));
ssl->hostname[NET_SSL_MAX_HOSTNAME_LEN-1] = '\0';
ssl_set_hostname(&ssl->ctx, ssl->hostname);
+3 -1
View File
@@ -2,6 +2,8 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <algorithm>
#include "Core/Movie.h"
#include "Core/NetPlayProto.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h"
@@ -589,7 +591,7 @@ void WiiSockMan::Update()
FD_SET(sock.fd, &read_fds);
FD_SET(sock.fd, &write_fds);
FD_SET(sock.fd, &except_fds);
nfds = max(nfds, sock.fd+1);
nfds = std::max(nfds, sock.fd+1);
}
else
{
+3 -1
View File
@@ -24,6 +24,8 @@ The register allocation is linear scan allocation.
#pragma warning(disable:4146) // unary minus operator applied to unsigned type, result still unsigned
#endif
#include <algorithm>
#include "Common/CPUDetect.h"
#include "Common/MathUtil.h"
#include "Core/HW/ProcessorInterface.h"
@@ -76,7 +78,7 @@ static void regMarkUse(RegInfo& R, InstLoc I, InstLoc Op, unsigned OpNum) {
unsigned& info = R.IInfo[Op - R.FirstI];
if (info == 0) R.IInfo[I - R.FirstI] |= 1 << (OpNum + 1);
if (info < 2) info++;
R.lastUsed[Op - R.FirstI] = max(R.lastUsed[Op - R.FirstI], I);
R.lastUsed[Op - R.FirstI] = std::max(R.lastUsed[Op - R.FirstI], I);
}
static unsigned regReadUse(RegInfo& R, InstLoc I) {
+3 -1
View File
@@ -2,6 +2,8 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <algorithm>
#include "Common/ArmEmitter.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
@@ -50,7 +52,7 @@ static void regMarkUse(RegInfo& R, InstLoc I, InstLoc Op, unsigned OpNum) {
unsigned& info = R.IInfo[Op - R.FirstI];
if (info == 0) R.IInfo[I - R.FirstI] |= 1 << (OpNum + 1);
if (info < 2) info++;
R.lastUsed[Op - R.FirstI] = max(R.lastUsed[Op - R.FirstI], I);
R.lastUsed[Op - R.FirstI] = std::max(R.lastUsed[Op - R.FirstI], I);
}
static void regClearInst(RegInfo& RI, InstLoc I) {
for (int i = 0; i < RegAllocSize; i++)
+2 -1
View File
@@ -6,9 +6,10 @@
#define _WIN32_WINNT 0x501
#ifndef _WIN32_IE
#define _WIN32_IE 0x0500 // Default value is 0x0400
#define _WIN32_IE 0x0500 // Default value is 0x0400
#endif
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define NOMINMAX // Don't include windows min/max definitions
#include <algorithm>
+2 -2
View File
@@ -193,7 +193,7 @@ bool CompressFileToBlob(const std::string& infile, const std::string& outfile, u
u64 position = 0;
int num_compressed = 0;
int num_stored = 0;
int progress_monitor = max<int>(1, header.num_blocks / 1000);
int progress_monitor = std::max<int>(1, header.num_blocks / 1000);
for (u32 i = 0; i < header.num_blocks; i++)
{
@@ -299,7 +299,7 @@ bool DecompressBlobToFile(const std::string& infile, const std::string& outfile,
const CompressedBlobHeader &header = reader->GetHeader();
u8* buffer = new u8[header.block_size];
int progress_monitor = max<int>(1, header.num_blocks / 100);
int progress_monitor = std::max<int>(1, header.num_blocks / 100);
for (u64 i = 0; i < header.num_blocks; i++)
{
+1 -1
View File
@@ -104,7 +104,7 @@ bool CFileSystemGCWii::ExportFile(const std::string& _rFullPath, const std::stri
while (remainingSize)
{
// Limit read size to 128 MB
size_t readSize = (size_t)min(remainingSize, (u64)0x08000000);
size_t readSize = std::min<size_t>(remainingSize, (u64)0x08000000);
std::vector<u8> buffer(readSize);
+2 -1
View File
@@ -8,7 +8,8 @@
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define NOMINMAX // Don't include windows min/max definitions
#ifndef _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
+3 -2
View File
@@ -12,8 +12,9 @@
#define _WIN32_IE 0x0500
#define _RICHEDIT_VER 0x0100
#define WIN32_LEAN_AND_MEAN
#include <wx/wx.h> // wxWidgets
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define NOMINMAX // Don't include windows min/max definitions
#include <wx/wx.h> // wxWidgets
#if _M_X86_32
+1
View File
@@ -10,5 +10,6 @@
#endif
*/
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define NOMINMAX // Don't include windows min/max definitions
#include <algorithm>
+3 -1
View File
@@ -5,8 +5,10 @@
#pragma once
#define _WIN32_WINNT 0x501
#ifndef _WIN32_IE
#define _WIN32_IE 0x0500 // Default value is 0x0400
#define _WIN32_IE 0x0500 // Default value is 0x0400
#endif
#define NOMINMAX // Don't include windows min/max definitions
#include <tchar.h>
#include <windows.h>
+3 -1
View File
@@ -5,8 +5,10 @@
#pragma once
#define _WIN32_WINNT 0x501
#ifndef _WIN32_IE
#define _WIN32_IE 0x0500 // Default value is 0x0400
#define _WIN32_IE 0x0500 // Default value is 0x0400
#endif
#define NOMINMAX // Don't include windows min/max definitions
#include <tchar.h>
#include <windows.h>
@@ -2,8 +2,9 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include "Common/Common.h"
#include <algorithm>
#include "Common/Common.h"
#include "VideoBackends/Software/BPMemLoader.h"
#include "VideoBackends/Software/EfbInterface.h"
#include "VideoBackends/Software/HwRasterizer.h"
@@ -231,12 +232,12 @@ inline void CalculateLOD(s32 &lod, bool &linear, u32 texmap, u32 texcoord)
float *uv1 = rasterBlock.Pixel[1][0].Uv[texcoord];
float *uv2 = rasterBlock.Pixel[0][1].Uv[texcoord];
sDelta = max(fabsf(uv0[0] - uv1[0]), fabsf(uv0[0] - uv2[0]));
tDelta = max(fabsf(uv0[1] - uv1[1]), fabsf(uv0[1] - uv2[1]));
sDelta = std::max(fabsf(uv0[0] - uv1[0]), fabsf(uv0[0] - uv2[0]));
tDelta = std::max(fabsf(uv0[1] - uv1[1]), fabsf(uv0[1] - uv2[1]));
}
// get LOD in s28.4
lod = FixedLog2(max(sDelta, tDelta));
lod = FixedLog2(std::max(sDelta, tDelta));
// bias is s2.5
int bias = tm0.lod_bias;
@@ -349,16 +350,16 @@ void DrawTriangleFrontFace(OutputVertexData *v0, OutputVertexData *v1, OutputVer
const s32 FDY31 = DY31 << 4;
// Bounding rectangle
s32 minx = (min(min(X1, X2), X3) + 0xF) >> 4;
s32 maxx = (max(max(X1, X2), X3) + 0xF) >> 4;
s32 miny = (min(min(Y1, Y2), Y3) + 0xF) >> 4;
s32 maxy = (max(max(Y1, Y2), Y3) + 0xF) >> 4;
s32 minx = (std::min(std::min(X1, X2), X3) + 0xF) >> 4;
s32 maxx = (std::max(std::max(X1, X2), X3) + 0xF) >> 4;
s32 miny = (std::min(std::min(Y1, Y2), Y3) + 0xF) >> 4;
s32 maxy = (std::max(std::max(Y1, Y2), Y3) + 0xF) >> 4;
// scissor
minx = max(minx, scissorLeft);
maxx = min(maxx, scissorRight);
miny = max(miny, scissorTop);
maxy = min(maxy, scissorBottom);
minx = std::max(minx, scissorLeft);
maxx = std::min(maxx, scissorRight);
miny = std::max(miny, scissorTop);
maxy = std::min(maxy, scissorBottom);
if (minx >= maxx || miny >= maxy)
return;

Some files were not shown because too many files have changed in this diff Show More