OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef CORE_FXCRT_INCLUDE_FX_SYSTEM_H_ | 7 #ifndef CORE_FXCRT_INCLUDE_FX_SYSTEM_H_ |
8 #define CORE_FXCRT_INCLUDE_FX_SYSTEM_H_ | 8 #define CORE_FXCRT_INCLUDE_FX_SYSTEM_H_ |
9 | 9 |
10 #include <assert.h> | 10 #include <assert.h> |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 151 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
152 | 152 |
153 #ifdef __cplusplus | 153 #ifdef __cplusplus |
154 } // extern "C" | 154 } // extern "C" |
155 | 155 |
156 #include "third_party/base/numerics/safe_conversions.h" | 156 #include "third_party/base/numerics/safe_conversions.h" |
157 | 157 |
158 #define FXSYS_strlen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(strlen(ptr)) | 158 #define FXSYS_strlen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(strlen(ptr)) |
159 #define FXSYS_wcslen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(wcslen(ptr)) | 159 #define FXSYS_wcslen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(wcslen(ptr)) |
160 | 160 |
| 161 // Overloaded functions for C++ templates |
| 162 inline FX_STRSIZE FXSYS_len(const FX_CHAR* ptr) { |
| 163 return FXSYS_strlen(ptr); |
| 164 } |
| 165 |
| 166 inline FX_STRSIZE FXSYS_len(const FX_WCHAR* ptr) { |
| 167 return FXSYS_wcslen(ptr); |
| 168 } |
| 169 |
| 170 inline int FXSYS_cmp(const FX_CHAR* ptr1, const FX_CHAR* ptr2, size_t len) { |
| 171 return memcmp(ptr1, ptr2, len); |
| 172 } |
| 173 |
| 174 inline int FXSYS_cmp(const FX_WCHAR* ptr1, const FX_WCHAR* ptr2, size_t len) { |
| 175 return wmemcmp(ptr1, ptr2, len); |
| 176 } |
| 177 |
| 178 inline const FX_CHAR* FXSYS_chr(const FX_CHAR* ptr, FX_CHAR ch, size_t len) { |
| 179 return reinterpret_cast<const FX_CHAR*>(memchr(ptr, ch, len)); |
| 180 } |
| 181 |
| 182 inline const FX_WCHAR* FXSYS_chr(const FX_WCHAR* ptr, FX_WCHAR ch, size_t len) { |
| 183 return wmemchr(ptr, ch, len); |
| 184 } |
| 185 |
161 extern "C" { | 186 extern "C" { |
162 #else | 187 #else |
163 #define FXSYS_strlen(ptr) ((FX_STRSIZE)strlen(ptr)) | 188 #define FXSYS_strlen(ptr) ((FX_STRSIZE)strlen(ptr)) |
164 #define FXSYS_wcslen(ptr) ((FX_STRSIZE)wcslen(ptr)) | 189 #define FXSYS_wcslen(ptr) ((FX_STRSIZE)wcslen(ptr)) |
165 #endif | 190 #endif |
166 | 191 |
167 #define FXSYS_wcscmp wcscmp | 192 #define FXSYS_wcscmp wcscmp |
168 #define FXSYS_wcsstr wcsstr | 193 #define FXSYS_wcsstr wcsstr |
169 #define FXSYS_wcsncmp wcsncmp | 194 #define FXSYS_wcsncmp wcsncmp |
170 #define FXSYS_vswprintf vswprintf | 195 #define FXSYS_vswprintf vswprintf |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 326 |
302 // Prevent a function from ever being inlined, typically because we'd | 327 // Prevent a function from ever being inlined, typically because we'd |
303 // like it to appear in stack traces. | 328 // like it to appear in stack traces. |
304 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 329 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
305 #define NEVER_INLINE __declspec(noinline) | 330 #define NEVER_INLINE __declspec(noinline) |
306 #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 331 #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
307 #define NEVER_INLINE __attribute__((__noinline__)) | 332 #define NEVER_INLINE __attribute__((__noinline__)) |
308 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 333 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
309 | 334 |
310 #endif // CORE_FXCRT_INCLUDE_FX_SYSTEM_H_ | 335 #endif // CORE_FXCRT_INCLUDE_FX_SYSTEM_H_ |
OLD | NEW |