Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: src/ports/SkOSFile_win.cpp

Issue 198643004: Fixed cross compilation with mingw. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: try2: Use SkAtomics_sync.h on mingw Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkOSFile.h" 8 #include "SkOSFile.h"
9 9
10 #include "SkTFitsIn.h" 10 #include "SkTFitsIn.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 bool sk_fidentical(SkFILE* a, SkFILE* b) { 45 bool sk_fidentical(SkFILE* a, SkFILE* b) {
46 SkFILEID aID, bID; 46 SkFILEID aID, bID;
47 return sk_ino(a, &aID) && sk_ino(b, &bID) 47 return sk_ino(a, &aID) && sk_ino(b, &bID)
48 && aID.fLsbSize == bID.fLsbSize 48 && aID.fLsbSize == bID.fLsbSize
49 && aID.fMsbSize == bID.fMsbSize 49 && aID.fMsbSize == bID.fMsbSize
50 && aID.fVolume == bID.fVolume; 50 && aID.fVolume == bID.fVolume;
51 } 51 }
52 52
53 template <typename HandleType, HandleType InvalidValue, BOOL (WINAPI * Close)(Ha ndleType)> 53 template <typename HandleType, LONG_PTR InvalidValue, BOOL (WINAPI * Close)(Hand leType)>
bungeman-skia 2014/03/14 17:50:18 So I thought maybe I could replace this with some
54 class SkAutoTHandle : SkNoncopyable { 54 class SkAutoTHandle : SkNoncopyable {
55 public: 55 public:
56 SkAutoTHandle(HandleType handle) : fHandle(handle) { } 56 SkAutoTHandle(HandleType handle) : fHandle(handle) { }
57 ~SkAutoTHandle() { Close(fHandle); } 57 ~SkAutoTHandle() { Close(fHandle); }
58 operator HandleType() { return fHandle; } 58 operator HandleType() { return fHandle; }
59 bool isValid() { return InvalidValue != fHandle; } 59 bool isValid() { return HandleType(InvalidValue) != fHandle; }
60 private: 60 private:
61 HandleType fHandle; 61 HandleType fHandle;
62 }; 62 };
63 typedef SkAutoTHandle<HANDLE, INVALID_HANDLE_VALUE, CloseHandle> SkAutoWinFile; 63 typedef SkAutoTHandle<HANDLE, -1 /* INVALID_HANDLE_VALUE */, CloseHandle> SkAuto WinFile;
64 typedef SkAutoTHandle<HANDLE, NULL, CloseHandle> SkAutoWinMMap; 64 typedef SkAutoTHandle<HANDLE, 0 /* NULL */, CloseHandle> SkAutoWinMMap;
65 65
66 void sk_fmunmap(const void* addr, size_t) { 66 void sk_fmunmap(const void* addr, size_t) {
67 UnmapViewOfFile(addr); 67 UnmapViewOfFile(addr);
68 } 68 }
69 69
70 void* sk_fdmmap(int fileno, size_t* length) { 70 void* sk_fdmmap(int fileno, size_t* length) {
71 HANDLE file = (HANDLE)_get_osfhandle(fileno); 71 HANDLE file = (HANDLE)_get_osfhandle(fileno);
72 if (INVALID_HANDLE_VALUE == file) { 72 if (INVALID_HANDLE_VALUE == file) {
73 return NULL; 73 return NULL;
74 } 74 }
(...skipping 29 matching lines...) Expand all
104 } 104 }
105 105
106 void* sk_fmmap(SkFILE* f, size_t* length) { 106 void* sk_fmmap(SkFILE* f, size_t* length) {
107 int fileno = sk_fileno(f); 107 int fileno = sk_fileno(f);
108 if (fileno < 0) { 108 if (fileno < 0) {
109 return NULL; 109 return NULL;
110 } 110 }
111 111
112 return sk_fdmmap(fileno, length); 112 return sk_fdmmap(fileno, length);
113 } 113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698