aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2015-08-26 05:15:46 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-26 05:15:46 -0700
commit60e0fee6d4acff638ccc9670c4055aced529a7a0 (patch)
tree8f73b02cd0bfbb7d6d64982ed4ebd8776d4a5a28
parent8d624bd44ef9e6d4ab7b768c4cbaa41cba830eda (diff)
Remove include of stdlib.h from SkTypes.h.
Unfortunately, immintrin.h (which is also included by SkTypes) includes xmmintrin.h which includes mm_malloc.h which includes stdlib.h for malloc even though, from the implementation, it is difficult to see why. Fortunately, arm_neon.h does not seem to be involved in such shenanigans, so building for Android will keep things sane. TBR=reed@google.com Doesn't change Skia API, just moves an include. Review URL: https://codereview.chromium.org/1313203003
-rw-r--r--bench/SortBench.cpp2
-rw-r--r--bench/nanobench.cpp2
-rw-r--r--dm/DM.cpp2
-rw-r--r--include/core/SkTypes.h1
-rw-r--r--samplecode/SamplePath.cpp2
-rw-r--r--src/core/SkGraphics.cpp2
-rw-r--r--src/core/SkRegion_path.cpp15
-rw-r--r--src/core/SkResourceCache.cpp1
-rw-r--r--src/core/SkTime.cpp4
-rw-r--r--src/pathops/SkOpAngle.cpp2
-rw-r--r--src/pathops/SkOpSegment.cpp10
-rwxr-xr-xsrc/pathops/SkOpSpan.cpp4
-rw-r--r--src/pathops/SkPathOpsDebug.h2
-rw-r--r--src/pathops/SkPathOpsTypes.cpp2
-rw-r--r--src/utils/SkEventTracer.cpp2
-rw-r--r--src/utils/SkParse.cpp2
-rw-r--r--src/utils/SkRTConf.cpp2
-rw-r--r--tests/PathOpsAngleTest.cpp4
-rw-r--r--tests/PathOpsCubicIntersectionTest.cpp2
-rw-r--r--tests/PathOpsExtendedTest.cpp2
-rw-r--r--tests/PathOpsQuadLineIntersectionThreadedTest.cpp2
-rwxr-xr-xtests/PathOpsSkpClipTest.cpp2
-rw-r--r--tests/RTConfRegistryTest.cpp2
-rw-r--r--tests/SortTest.cpp2
-rw-r--r--tests/Time.cpp2
-rw-r--r--tools/PictureRenderingFlags.cpp2
-rw-r--r--tools/PictureResultsWriter.h2
-rw-r--r--tools/dump_record.cpp2
-rw-r--r--tools/flags/SkCommandLineFlags.cpp2
-rw-r--r--tools/flatten.cpp2
-rw-r--r--tools/lua/lua_app.cpp2
-rw-r--r--tools/lua/lua_pictures.cpp2
-rw-r--r--tools/render_pictures_main.cpp6
-rw-r--r--tools/skdiff_main.cpp2
-rw-r--r--tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp12
-rw-r--r--tools/skpmaker.cpp2
36 files changed, 80 insertions, 31 deletions
diff --git a/bench/SortBench.cpp b/bench/SortBench.cpp
index 4cf91ba82e..9d22a45bf8 100644
--- a/bench/SortBench.cpp
+++ b/bench/SortBench.cpp
@@ -10,6 +10,8 @@
#include "SkString.h"
#include "SkTSort.h"
+#include <stdlib.h>
+
static const int N = 1000;
static void rand_proc(int array[N]) {
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 2720b6f2de..550a35f3bc 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -41,6 +41,8 @@
#include "SkSurface.h"
#include "SkTaskGroup.h"
+#include <stdlib.h>
+
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
#include "nanobenchAndroid.h"
#endif
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 870b97a4ef..983a8704ae 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -34,6 +34,8 @@
#endif
#include "png.h"
+#include <stdlib.h>
+
DEFINE_string(src, "tests gm skp image", "Source types to test.");
DEFINE_bool(nameByHash, false,
"If true, write to FLAGS_writePath[0]/<hash>.png instead of "
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index 8eeffb5894..45a5a8a376 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -23,7 +23,6 @@
#endif
// IWYU pragma: end_exports
-#include <stdlib.h>
#include <string.h>
/** \file SkTypes.h
diff --git a/samplecode/SamplePath.cpp b/samplecode/SamplePath.cpp
index 313abcaf1a..c09ff20206 100644
--- a/samplecode/SamplePath.cpp
+++ b/samplecode/SamplePath.cpp
@@ -26,6 +26,8 @@
#include "SkGeometry.h"
+#include <stdlib.h>
+
// http://code.google.com/p/skia/issues/detail?id=32
static void test_cubic() {
SkPoint src[4] = {
diff --git a/src/core/SkGraphics.cpp b/src/core/SkGraphics.cpp
index 093e7a6f3b..f8d8b09db4 100644
--- a/src/core/SkGraphics.cpp
+++ b/src/core/SkGraphics.cpp
@@ -28,6 +28,8 @@
#include "SkUtils.h"
#include "SkXfermode.h"
+#include <stdlib.h>
+
void SkGraphics::GetVersion(int32_t* major, int32_t* minor, int32_t* patch) {
if (major) {
*major = SKIA_VERSION_MAJOR;
diff --git a/src/core/SkRegion_path.cpp b/src/core/SkRegion_path.cpp
index ad01cacfba..b07d679aa1 100644
--- a/src/core/SkRegion_path.cpp
+++ b/src/core/SkRegion_path.cpp
@@ -8,6 +8,7 @@
#include "SkRegionPriv.h"
#include "SkBlitter.h"
#include "SkScan.h"
+#include "SkTSort.h"
#include "SkTDArray.h"
#include "SkPath.h"
@@ -476,11 +477,11 @@ static int extract_path(Edge* edge, Edge* stop, SkPath* path) {
return count;
}
-#include "SkTSearch.h"
-
-static int EdgeProc(const Edge* a, const Edge* b) {
- return (a->fX == b->fX) ? a->top() - b->top() : a->fX - b->fX;
-}
+struct EdgeLT {
+ bool operator()(const Edge& a, const Edge& b) const {
+ return (a.fX == b.fX) ? a.top() < b.top() : a.fX < b.fX;
+ }
+};
bool SkRegion::getBoundaryPath(SkPath* path) const {
// path could safely be NULL if we're empty, but the caller shouldn't
@@ -508,13 +509,13 @@ bool SkRegion::getBoundaryPath(SkPath* path) const {
edge[0].set(r.fLeft, r.fBottom, r.fTop);
edge[1].set(r.fRight, r.fTop, r.fBottom);
}
- qsort(edges.begin(), edges.count(), sizeof(Edge), SkCastForQSort(EdgeProc));
int count = edges.count();
Edge* start = edges.begin();
Edge* stop = start + count;
- Edge* e;
+ SkTQSort<Edge>(start, stop - 1, EdgeLT());
+ Edge* e;
for (e = start; e != stop; e++) {
find_link(e, stop);
}
diff --git a/src/core/SkResourceCache.cpp b/src/core/SkResourceCache.cpp
index 70dc8f97d8..922fc7ee0a 100644
--- a/src/core/SkResourceCache.cpp
+++ b/src/core/SkResourceCache.cpp
@@ -13,6 +13,7 @@
#include "SkResourceCache.h"
#include <stddef.h>
+#include <stdlib.h>
DECLARE_SKMESSAGEBUS_MESSAGE(SkResourceCache::PurgeSharedIDMessage)
diff --git a/src/core/SkTime.cpp b/src/core/SkTime.cpp
index b8e42365ef..fa6c04447d 100644
--- a/src/core/SkTime.cpp
+++ b/src/core/SkTime.cpp
@@ -12,8 +12,8 @@ void SkTime::DateTime::toISO8601(SkString* dst) const {
if (dst) {
int timeZoneMinutes = SkToInt(fTimeZoneMinutes);
char timezoneSign = timeZoneMinutes >= 0 ? '+' : '-';
- int timeZoneHours = abs(timeZoneMinutes) / 60;
- timeZoneMinutes = abs(timeZoneMinutes) % 60;
+ int timeZoneHours = SkTAbs(timeZoneMinutes) / 60;
+ timeZoneMinutes = SkTAbs(timeZoneMinutes) % 60;
dst->printf("%04u-%02u-%02uT%02u:%02u:%02u%c%02d:%02d",
static_cast<unsigned>(fYear), static_cast<unsigned>(fMonth),
static_cast<unsigned>(fDay), static_cast<unsigned>(fHour),
diff --git a/src/pathops/SkOpAngle.cpp b/src/pathops/SkOpAngle.cpp
index 36c0dd90f7..ac596fd408 100644
--- a/src/pathops/SkOpAngle.cpp
+++ b/src/pathops/SkOpAngle.cpp
@@ -809,7 +809,7 @@ bool SkOpAngle::midToSide(const SkOpAngle* rh, bool* inside) const {
}
bool SkOpAngle::oppositePlanes(const SkOpAngle* rh) const {
- int startSpan = abs(rh->fSectorStart - fSectorStart);
+ int startSpan = SkTAbs(rh->fSectorStart - fSectorStart);
return startSpan >= 8;
}
diff --git a/src/pathops/SkOpSegment.cpp b/src/pathops/SkOpSegment.cpp
index fc32643558..a52ef4ace1 100644
--- a/src/pathops/SkOpSegment.cpp
+++ b/src/pathops/SkOpSegment.cpp
@@ -1479,7 +1479,7 @@ void SkOpSegment::setUpWindings(SkOpSpanBase* start, SkOpSpanBase* end, int* sum
int deltaSum = SpanSign(start, end);
*maxWinding = *sumMiWinding;
*sumWinding = *sumMiWinding -= deltaSum;
- SkASSERT(!DEBUG_LIMIT_WIND_SUM || abs(*sumWinding) <= DEBUG_LIMIT_WIND_SUM);
+ SkASSERT(!DEBUG_LIMIT_WIND_SUM || SkTAbs(*sumWinding) <= DEBUG_LIMIT_WIND_SUM);
}
void SkOpSegment::setUpWindings(SkOpSpanBase* start, SkOpSpanBase* end, int* sumMiWinding,
@@ -1498,8 +1498,8 @@ void SkOpSegment::setUpWindings(SkOpSpanBase* start, SkOpSpanBase* end, int* sum
*oppMaxWinding = *sumSuWinding;
*oppSumWinding = *sumSuWinding -= oppDeltaSum;
}
- SkASSERT(!DEBUG_LIMIT_WIND_SUM || abs(*sumWinding) <= DEBUG_LIMIT_WIND_SUM);
- SkASSERT(!DEBUG_LIMIT_WIND_SUM || abs(*oppSumWinding) <= DEBUG_LIMIT_WIND_SUM);
+ SkASSERT(!DEBUG_LIMIT_WIND_SUM || SkTAbs(*sumWinding) <= DEBUG_LIMIT_WIND_SUM);
+ SkASSERT(!DEBUG_LIMIT_WIND_SUM || SkTAbs(*oppSumWinding) <= DEBUG_LIMIT_WIND_SUM);
}
void SkOpSegment::sortAngles() {
@@ -1774,8 +1774,8 @@ int SkOpSegment::updateWindingReverse(const SkOpAngle* angle) {
bool SkOpSegment::UseInnerWinding(int outerWinding, int innerWinding) {
SkASSERT(outerWinding != SK_MaxS32);
SkASSERT(innerWinding != SK_MaxS32);
- int absOut = abs(outerWinding);
- int absIn = abs(innerWinding);
+ int absOut = SkTAbs(outerWinding);
+ int absIn = SkTAbs(innerWinding);
bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn;
return result;
}
diff --git a/src/pathops/SkOpSpan.cpp b/src/pathops/SkOpSpan.cpp
index 5c89c736fb..df3ef3c9b3 100755
--- a/src/pathops/SkOpSpan.cpp
+++ b/src/pathops/SkOpSpan.cpp
@@ -369,7 +369,7 @@ void SkOpSpan::setOppSum(int oppSum) {
this->globalState()->setWindingFailed();
return;
}
- SkASSERT(!DEBUG_LIMIT_WIND_SUM || abs(oppSum) <= DEBUG_LIMIT_WIND_SUM);
+ SkASSERT(!DEBUG_LIMIT_WIND_SUM || SkTAbs(oppSum) <= DEBUG_LIMIT_WIND_SUM);
fOppSum = oppSum;
}
@@ -379,6 +379,6 @@ void SkOpSpan::setWindSum(int windSum) {
this->globalState()->setWindingFailed();
return;
}
- SkASSERT(!DEBUG_LIMIT_WIND_SUM || abs(windSum) <= DEBUG_LIMIT_WIND_SUM);
+ SkASSERT(!DEBUG_LIMIT_WIND_SUM || SkTAbs(windSum) <= DEBUG_LIMIT_WIND_SUM);
fWindSum = windSum;
}
diff --git a/src/pathops/SkPathOpsDebug.h b/src/pathops/SkPathOpsDebug.h
index ee2c291869..969a9907d5 100644
--- a/src/pathops/SkPathOpsDebug.h
+++ b/src/pathops/SkPathOpsDebug.h
@@ -9,6 +9,8 @@
#include "SkPathOps.h"
#include "SkTypes.h"
+
+#include <stdlib.h>
#include <stdio.h>
#ifdef SK_RELEASE
diff --git a/src/pathops/SkPathOpsTypes.cpp b/src/pathops/SkPathOpsTypes.cpp
index c3de93a94a..bf43c14659 100644
--- a/src/pathops/SkPathOpsTypes.cpp
+++ b/src/pathops/SkPathOpsTypes.cpp
@@ -160,7 +160,7 @@ int UlpsDistance(float a, float b) {
return a == b ? 0 : SK_MaxS32;
}
// Find the difference in ULPs.
- return abs(floatIntA.fSignBitInt - floatIntB.fSignBitInt);
+ return SkTAbs(floatIntA.fSignBitInt - floatIntB.fSignBitInt);
}
// cube root approximation using bit hack for 64-bit float
diff --git a/src/utils/SkEventTracer.cpp b/src/utils/SkEventTracer.cpp
index d9f925852e..6176e1c44b 100644
--- a/src/utils/SkEventTracer.cpp
+++ b/src/utils/SkEventTracer.cpp
@@ -9,6 +9,8 @@
#include "SkEventTracer.h"
#include "SkLazyPtr.h"
+#include <stdlib.h>
+
class SkDefaultEventTracer : public SkEventTracer {
SkEventTracer::Handle
addTraceEvent(char phase,
diff --git a/src/utils/SkParse.cpp b/src/utils/SkParse.cpp
index f6e2a438e8..446f9d444a 100644
--- a/src/utils/SkParse.cpp
+++ b/src/utils/SkParse.cpp
@@ -9,6 +9,8 @@
#include "SkParse.h"
+#include <stdlib.h>
+
static inline bool is_between(int c, int min, int max)
{
return (unsigned)(c - min) <= (unsigned)(max - min);
diff --git a/src/utils/SkRTConf.cpp b/src/utils/SkRTConf.cpp
index 20b8b43b89..5c99d2706c 100644
--- a/src/utils/SkRTConf.cpp
+++ b/src/utils/SkRTConf.cpp
@@ -8,6 +8,8 @@
#include "SkRTConf.h"
#include "SkOSFile.h"
+#include <stdlib.h>
+
SkRTConfRegistry::SkRTConfRegistry(): fConfs(100) {
SkFILE *fp = sk_fopen(configFileLocation(), kRead_SkFILE_Flag);
diff --git a/tests/PathOpsAngleTest.cpp b/tests/PathOpsAngleTest.cpp
index 9f9c321a42..cec8dde68a 100644
--- a/tests/PathOpsAngleTest.cpp
+++ b/tests/PathOpsAngleTest.cpp
@@ -51,7 +51,7 @@ DEF_TEST(PathOpsAngleFindCrossEpsilon, reporter) {
float p2 = SkDoubleToScalar(line[1].fY * test.fX);
int p1Bits = SkFloatAs2sCompliment(p1);
int p2Bits = SkFloatAs2sCompliment(p2);
- int epsilon = abs(p1Bits - p2Bits);
+ int epsilon = SkTAbs(p1Bits - p2Bits);
if (maxEpsilon < epsilon) {
SkDebugf("line={{0, 0}, {%1.7g, %1.7g}} t=%1.7g pt={%1.7g, %1.7g}"
" epsilon=%d\n",
@@ -104,7 +104,7 @@ DEF_TEST(PathOpsAngleFindQuadEpsilon, reporter) {
float p2 = SkDoubleToScalar(line[1].fY * last.fX);
int p1Bits = SkFloatAs2sCompliment(p1);
int p2Bits = SkFloatAs2sCompliment(p2);
- int epsilon = abs(p1Bits - p2Bits);
+ int epsilon = SkTAbs(p1Bits - p2Bits);
if (maxEpsilon < epsilon) {
SkDebugf("line={{0, 0}, {%1.7g, %1.7g}} t=%1.7g/%1.7g/%1.7g moveT=%1.7g"
" pt={%1.7g, %1.7g} epsilon=%d\n",
diff --git a/tests/PathOpsCubicIntersectionTest.cpp b/tests/PathOpsCubicIntersectionTest.cpp
index 75a5cc3ef4..d45ec06d55 100644
--- a/tests/PathOpsCubicIntersectionTest.cpp
+++ b/tests/PathOpsCubicIntersectionTest.cpp
@@ -12,6 +12,8 @@
#include "SkReduceOrder.h"
#include "Test.h"
+#include <stdlib.h>
+
const int firstCubicIntersectionTest = 9;
static void standardTestCases(skiatest::Reporter* reporter) {
diff --git a/tests/PathOpsExtendedTest.cpp b/tests/PathOpsExtendedTest.cpp
index d458c41e97..1401290f83 100644
--- a/tests/PathOpsExtendedTest.cpp
+++ b/tests/PathOpsExtendedTest.cpp
@@ -16,6 +16,8 @@
#include "SkRTConf.h"
#include "SkStream.h"
+#include <stdlib.h>
+
#ifdef SK_BUILD_FOR_MAC
#include <sys/sysctl.h>
#endif
diff --git a/tests/PathOpsQuadLineIntersectionThreadedTest.cpp b/tests/PathOpsQuadLineIntersectionThreadedTest.cpp
index 7e33b7b374..a4f87dfea1 100644
--- a/tests/PathOpsQuadLineIntersectionThreadedTest.cpp
+++ b/tests/PathOpsQuadLineIntersectionThreadedTest.cpp
@@ -91,7 +91,7 @@ static void testQuadLineIntersectMain(PathOpsThreadState* data)
SkDPoint xy = quad.ptAtT(tIndex / 4.0);
for (int h = -2; h <= 2; ++h) {
for (int v = -2; v <= 2; ++v) {
- if (h == v && abs(h) != 1) {
+ if (h == v && SkTAbs(h) != 1) {
continue;
}
double x = xy.fX;
diff --git a/tests/PathOpsSkpClipTest.cpp b/tests/PathOpsSkpClipTest.cpp
index 6f3d014a2f..95421fca30 100755
--- a/tests/PathOpsSkpClipTest.cpp
+++ b/tests/PathOpsSkpClipTest.cpp
@@ -32,6 +32,8 @@
#include "SkTemplates.h"
#include "SkTime.h"
+#include <stdlib.h>
+
__SK_FORCE_IMAGE_DECODER_LINKING;
/* add local exceptions here */
diff --git a/tests/RTConfRegistryTest.cpp b/tests/RTConfRegistryTest.cpp
index 59fb3e9142..84ce942bf6 100644
--- a/tests/RTConfRegistryTest.cpp
+++ b/tests/RTConfRegistryTest.cpp
@@ -8,6 +8,8 @@
#include "SkRTConf.h"
#include "Test.h"
+#include <stdlib.h>
+
// Friended proxy for SkRTConfRegistry::parse()
template <typename T>
bool test_rt_conf_parse(SkRTConfRegistry* reg, const char* key, T* value) {
diff --git a/tests/SortTest.cpp b/tests/SortTest.cpp
index e8713dd4d2..d544ebd665 100644
--- a/tests/SortTest.cpp
+++ b/tests/SortTest.cpp
@@ -9,6 +9,8 @@
#include "SkTSort.h"
#include "Test.h"
+#include <stdlib.h>
+
extern "C" {
static int compare_int(const void* a, const void* b) {
return *(const int*)a - *(const int*)b;
diff --git a/tests/Time.cpp b/tests/Time.cpp
index 60dcd5527c..cf4f80f9da 100644
--- a/tests/Time.cpp
+++ b/tests/Time.cpp
@@ -44,7 +44,7 @@ DEF_TEST(Time_GetDateTime, r) {
// The westernmost timezone is -12:00.
// The easternmost timezone is +14:00.
- REPORTER_ASSERT(r, abs(SkToInt(dateTime.fTimeZoneMinutes)) <= 14 * 60);
+ REPORTER_ASSERT(r, SkTAbs(SkToInt(dateTime.fTimeZoneMinutes)) <= 14 * 60);
SkString timeStamp;
dateTime.toISO8601(&timeStamp);
diff --git a/tools/PictureRenderingFlags.cpp b/tools/PictureRenderingFlags.cpp
index 26d15911d1..bd718a0ca8 100644
--- a/tools/PictureRenderingFlags.cpp
+++ b/tools/PictureRenderingFlags.cpp
@@ -19,6 +19,8 @@
#include "SkImageDecoder.h"
#include "SkString.h"
+#include <stdlib.h>
+
// Alphabetized list of flags used by this file or bench_ and render_pictures.
DEFINE_string(bbh, "none", "bbhType [width height]: Set the bounding box hierarchy type to "
"be used. Accepted values are: none, rtree, grid. "
diff --git a/tools/PictureResultsWriter.h b/tools/PictureResultsWriter.h
index 67371024e3..c9aaed0b35 100644
--- a/tools/PictureResultsWriter.h
+++ b/tools/PictureResultsWriter.h
@@ -20,6 +20,8 @@
#include "SkTArray.h"
#include "TimerData.h"
+#include <stdlib.h>
+
/**
* Base class for writing picture bench results.
*/
diff --git a/tools/dump_record.cpp b/tools/dump_record.cpp
index 885046a1d1..69cdffff31 100644
--- a/tools/dump_record.cpp
+++ b/tools/dump_record.cpp
@@ -17,6 +17,8 @@
#include "DumpRecord.h"
#include "LazyDecodeBitmap.h"
+#include <stdlib.h>
+
DEFINE_string2(skps, r, "", ".SKPs to dump.");
DEFINE_string(match, "", "The usual filters on file names to dump.");
DEFINE_bool2(optimize, O, false, "Run SkRecordOptimize before dumping.");
diff --git a/tools/flags/SkCommandLineFlags.cpp b/tools/flags/SkCommandLineFlags.cpp
index 3c57d00f0d..ec9949bafc 100644
--- a/tools/flags/SkCommandLineFlags.cpp
+++ b/tools/flags/SkCommandLineFlags.cpp
@@ -9,6 +9,8 @@
#include "SkTDArray.h"
#include "SkTSort.h"
+#include <stdlib.h>
+
DEFINE_bool(undefok, false, "Silently ignore unknown flags instead of crashing.");
template <typename T> static void ignore_result(const T&) {}
diff --git a/tools/flatten.cpp b/tools/flatten.cpp
index 832bd1426d..80579df48f 100644
--- a/tools/flatten.cpp
+++ b/tools/flatten.cpp
@@ -11,6 +11,8 @@
#include "SkPicture.h"
#include "SkPictureRecorder.h"
#include "SkStream.h"
+
+#include <stdlib.h>
#include <stdio.h>
__SK_FORCE_IMAGE_DECODER_LINKING;
diff --git a/tools/lua/lua_app.cpp b/tools/lua/lua_app.cpp
index 023ddaeaca..f24570a829 100644
--- a/tools/lua/lua_app.cpp
+++ b/tools/lua/lua_app.cpp
@@ -11,6 +11,8 @@
#include "SkData.h"
#include "SkOSFile.h"
+#include <stdlib.h>
+
extern "C" {
#include "lua.h"
#include "lualib.h"
diff --git a/tools/lua/lua_pictures.cpp b/tools/lua/lua_pictures.cpp
index d579f2e630..315e4bfb89 100644
--- a/tools/lua/lua_pictures.cpp
+++ b/tools/lua/lua_pictures.cpp
@@ -17,6 +17,8 @@
#include "SkOSFile.h"
#include "SkImageDecoder.h"
+#include <stdlib.h>
+
extern "C" {
#include "lua.h"
#include "lualib.h"
diff --git a/tools/render_pictures_main.cpp b/tools/render_pictures_main.cpp
index 2624a6e0fe..392083197e 100644
--- a/tools/render_pictures_main.cpp
+++ b/tools/render_pictures_main.cpp
@@ -25,6 +25,8 @@
#include "PictureRenderingFlags.h"
#include "picture_utils.h"
+#include <stdlib.h>
+
// Flags used by this file, alphabetically:
DEFINE_bool(bench_record, false, "If true, drop into an infinite loop of recording the picture.");
DECLARE_bool(deferImageDecoding);
@@ -219,8 +221,8 @@ static inline int getByte(uint32_t value, int index) {
}
static int MaxByteDiff(uint32_t v1, uint32_t v2) {
- return SkMax32(SkMax32(abs(getByte(v1, 0) - getByte(v2, 0)), abs(getByte(v1, 1) - getByte(v2, 1))),
- SkMax32(abs(getByte(v1, 2) - getByte(v2, 2)), abs(getByte(v1, 3) - getByte(v2, 3))));
+ return SkMax32(SkMax32(SkTAbs(getByte(v1, 0) - getByte(v2, 0)), SkTAbs(getByte(v1, 1) - getByte(v2, 1))),
+ SkMax32(SkTAbs(getByte(v1, 2) - getByte(v2, 2)), SkTAbs(getByte(v1, 3) - getByte(v2, 3))));
}
class AutoRestoreBbhType {
diff --git a/tools/skdiff_main.cpp b/tools/skdiff_main.cpp
index 4646b1f906..4e360a8e49 100644
--- a/tools/skdiff_main.cpp
+++ b/tools/skdiff_main.cpp
@@ -17,6 +17,8 @@
#include "SkTDArray.h"
#include "SkTSearch.h"
+#include <stdlib.h>
+
__SK_FORCE_IMAGE_DECODER_LINKING;
/**
diff --git a/tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp b/tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp
index 7194e805bf..a96da7c6b6 100644
--- a/tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp
+++ b/tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp
@@ -73,14 +73,14 @@ bool SkDifferentPixelsMetric::diff(SkBitmap* baseline, SkBitmap* test,
if (baselinePixel != testPixel) {
result->poiCount++;
- int redDiff = abs(static_cast<int>(SkColorGetR(baselinePixel) -
- SkColorGetR(testPixel)));
+ int redDiff = SkTAbs(static_cast<int>(SkColorGetR(baselinePixel) -
+ SkColorGetR(testPixel)));
if (redDiff > maxRedDiff) {maxRedDiff = redDiff;}
- int greenDiff = abs(static_cast<int>(SkColorGetG(baselinePixel) -
- SkColorGetG(testPixel)));
+ int greenDiff = SkTAbs(static_cast<int>(SkColorGetG(baselinePixel) -
+ SkColorGetG(testPixel)));
if (greenDiff > maxGreenDiff) {maxGreenDiff = greenDiff;}
- int blueDiff = abs(static_cast<int>(SkColorGetB(baselinePixel) -
- SkColorGetB(testPixel)));
+ int blueDiff = SkTAbs(static_cast<int>(SkColorGetB(baselinePixel) -
+ SkColorGetB(testPixel)));
if (blueDiff > maxBlueDiff) {maxBlueDiff = blueDiff;}
if (bitmapsToCreate.alphaMask) {
diff --git a/tools/skpmaker.cpp b/tools/skpmaker.cpp
index 03f720f392..0e378ed088 100644
--- a/tools/skpmaker.cpp
+++ b/tools/skpmaker.cpp
@@ -16,6 +16,8 @@
#include "SkScalar.h"
#include "SkStream.h"
+#include <stdlib.h>
+
// Flags used by this file, alphabetically:
DEFINE_int32(blue, 128, "Value of blue color channel in image, 0-255.");
DEFINE_int32(border, 4, "Width of the black border around the image.");