Skip to content

Commit 05b5421

Browse files
committed
Cleaning up *_compat.h mess into one understandable file.
1 parent 6b4000c commit 05b5421

51 files changed

Lines changed: 223 additions & 422 deletions

Some content is hidden

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

Release/include/cpprest/astreambuf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ namespace streams
6666
/// <returns>An <c>int_type</c> value which implies that an asynchronous call is required.</returns>
6767
static typename std::char_traits<_CharType>::int_type requires_async() { return std::char_traits<_CharType>::eof()-1; }
6868
};
69-
#if !defined(_MS_WINDOWS)
69+
#if !defined(_WIN32)
7070
template<>
7171
struct char_traits<unsigned char> : private std::char_traits<char>
7272
{

Release/include/cpprest/asyncrt_utils.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,13 @@
3535
#include <locale.h>
3636

3737
#include "pplx/pplxtasks.h"
38-
#include "cpprest/details/xxpublic.h"
3938
#include "cpprest/basic_types.h"
4039

41-
#if !defined(_MS_WINDOWS) || (_MSC_VER >= 1700)
40+
#if !defined(_WIN32) || (_MSC_VER >= 1700)
4241
#include <chrono>
4342
#endif
4443

45-
#ifndef _MS_WINDOWS
44+
#ifndef _WIN32
4645
#include <boost/algorithm/string.hpp>
4746
#if !defined(ANDROID) && !defined(__ANDROID__) // CodePlex 269
4847
#include <xlocale.h>
@@ -168,7 +167,7 @@ namespace details
168167
_ASYNCRTIMP ~scoped_c_thread_locale();
169168

170169
#if !defined(ANDROID) && !defined(__ANDROID__) // CodePlex 269
171-
#ifdef _MS_WINDOWS
170+
#ifdef _WIN32
172171
typedef _locale_t xplat_locale;
173172
#else
174173
typedef locale_t xplat_locale;
@@ -177,7 +176,7 @@ namespace details
177176
static _ASYNCRTIMP xplat_locale __cdecl c_locale();
178177
#endif
179178
private:
180-
#ifdef _MS_WINDOWS
179+
#ifdef _WIN32
181180
std::string m_prevLocale;
182181
int m_prevThreadSetting;
183182
#elif !(defined(ANDROID) || defined(__ANDROID__))
@@ -230,14 +229,14 @@ namespace details
230229
/// <returns>true if the strings are equivalent, false otherwise</returns>
231230
inline bool str_icmp(const utility::string_t &left, const utility::string_t &right)
232231
{
233-
#ifdef _MS_WINDOWS
232+
#ifdef _WIN32
234233
return _wcsicmp(left.c_str(), right.c_str()) == 0;
235234
#else
236235
return boost::iequals(left, right);
237236
#endif
238237
}
239238

240-
#ifdef _MS_WINDOWS
239+
#ifdef _WIN32
241240

242241
/// <summary>
243242
/// Category error type for Windows OS errors.
@@ -420,7 +419,7 @@ class datetime
420419
static const interval_type _dayTicks = 24*60*60*_secondTicks;
421420

422421

423-
#ifdef _MS_WINDOWS
422+
#ifdef _WIN32
424423
// void* to avoid pulling in windows.h
425424
static _ASYNCRTIMP bool __cdecl datetime::system_type_to_datetime(/*SYSTEMTIME*/ void* psysTime, uint64_t seconds, datetime * pdt);
426425
#else
@@ -435,7 +434,7 @@ class datetime
435434
interval_type m_interval;
436435
};
437436

438-
#ifndef _MS_WINDOWS
437+
#ifndef _WIN32
439438

440439
// temporary workaround for the fact that
441440
// utf16char is not fully supported in GCC

Release/include/cpprest/base_uri.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include <functional>
3535

3636
#include "cpprest/asyncrt_utils.h"
37-
#include "cpprest/details/xxpublic.h"
3837
#include "cpprest/basic_types.h"
3938

4039
namespace web {

Release/include/cpprest/basic_types.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
#include <fstream>
3232
#include <iostream>
3333
#include <sstream>
34-
#include "cpprest/details/xxpublic.h"
34+
#include "cpprest/details/cpprest_compat.h"
3535

36-
#ifndef _MS_WINDOWS
36+
#ifndef _WIN32
3737
# define __STDC_LIMIT_MACROS
3838
# include <stdint.h>
3939
#else
@@ -46,15 +46,15 @@ typedef SafeInt<size_t> SafeSize;
4646
namespace utility
4747
{
4848

49-
#ifdef _MS_WINDOWS
49+
#ifdef _WIN32
5050
#define _UTF16_STRINGS
5151
#endif
5252

5353
// We should be using a 64-bit size type for most situations that do
5454
// not involve specifying the size of a memory allocation or buffer.
5555
typedef uint64_t size64_t;
5656

57-
#ifndef _MS_WINDOWS
57+
#ifndef _WIN32
5858
typedef uint32_t HRESULT; // Needed for PPLX
5959
#endif
6060

Release/include/cpprest/containerstream.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,12 @@ namespace Concurrency { namespace streams {
450450
auto readBegin = begin(m_data) + m_current_position;
451451
auto readEnd = begin(m_data) + newPos;
452452

453-
#ifdef _MS_WINDOWS
453+
#ifdef _WIN32
454454
// Avoid warning C4996: Use checked iterators under SECURE_SCL
455455
std::copy(readBegin, readEnd, stdext::checked_array_iterator<_CharType *>(ptr, count));
456456
#else
457457
std::copy(readBegin, readEnd, ptr);
458-
#endif // _MS_WINDOWS
458+
#endif // _WIN32
459459

460460
if (advance)
461461
{

Release/include/cpprest/details/apple_compat.h

Lines changed: 0 additions & 53 deletions
This file was deleted.

Release/include/cpprest/details/linux_compat.h renamed to Release/include/cpprest/details/cpprest_compat.h

Lines changed: 61 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,86 @@
1414
* limitations under the License.
1515
*
1616
* ==--==
17+
* =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
18+
*
19+
* Standard macros and definitions.
20+
* This header has minimal dependency on windows headers and is safe for use in the public API
1721
*
1822
* For the latest on this and related APIs, please see http://casablanca.codeplex.com.
1923
*
20-
* =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
21-
***/
24+
* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
25+
****/
2226

2327
#pragma once
24-
#include <cstdint>
25-
#include <sstream>
26-
#include <iostream>
2728

28-
#if (defined(ANDROID) || defined(__ANDROID__)) && defined(__arm__)
29-
// Cdecl is not used on ARM
30-
#define __cdecl
29+
#if defined(_WIN32) // Settings specific to Windows
30+
31+
#if _MSC_VER >= 1900
32+
#define CPPREST_NOEXCEPT noexcept
3133
#else
32-
#define __cdecl __attribute__ ((cdecl))
34+
#define CPPREST_NOEXCEPT
3335
#endif
3436

37+
#define CASABLANCA_UNREFERENCED_PARAMETER(x) (x)
38+
39+
#if _MSC_VER >= 1700
40+
// Support VS2012 SAL syntax only
41+
#include <sal.h>
42+
#else
3543
#include "cpprest/details/nosal.h"
44+
#endif
3645

37-
#define CPPREST_NOEXCEPT noexcept
46+
#else // End settings specific to Windows
3847

39-
#define novtable /* no novtable equivalent */
40-
#define __declspec(x) __attribute__ ((x))
48+
// Settings common to all but Windows
4149

42-
// ignore these:
50+
#define __declspec(x) __attribute__ ((x))
4351
#define dllimport
44-
#ifdef __LP64__ // ignore cdecl on 64-bit
45-
#define cdecl
46-
#endif
52+
#define novtable /* no novtable equivalent */
53+
#define __assume(x) do { if (!(x)) __builtin_unreachable(); } while (false)
54+
#define CASABLANCA_UNREFERENCED_PARAMETER(x) (void)x
55+
#define CPPREST_NOEXCEPT noexcept
4756

48-
#include <stdint.h>
4957
#include <assert.h>
58+
#define _ASSERTE(x) assert(x)
5059

51-
#define __assume(x) do { if (!(x)) __builtin_unreachable(); } while (false)
60+
// No SAL on non Windows platforms
61+
#include "cpprest/details/nosal.h"
5262

53-
#define CASABLANCA_UNREFERENCED_PARAMETER(x) (void)x
54-
#define _ASSERTE(x) assert(x)
63+
#if defined(__APPLE__) // Settings specific to Apple
64+
#define __cdecl
65+
#else
5566

56-
#ifdef CASABLANCA_DEPRECATION_NO_WARNINGS
57-
#define CASABLANCA_DEPRECATED(x)
67+
// Settings specific to Linux and Android
68+
69+
// Ignore cdecl on ANDROID ARM and 64bit
70+
#if defined(__ANDROID__) && defined(__arm__) || defined(__LP64__)
71+
#define __cdecl
72+
#else
73+
#define __cdecl __attribute__ ((cdecl))
74+
#endif
75+
76+
#ifdef __clang__
77+
#include <cstdio>
78+
#endif
79+
80+
#endif // defined(__APPLE__)
81+
82+
#endif
83+
84+
85+
#ifdef _NO_ASYNCRTIMP
86+
#define _ASYNCRTIMP
5887
#else
59-
#define CASABLANCA_DEPRECATED(x) __attribute__((deprecated(x)))
88+
#ifdef _ASYNCRT_EXPORT
89+
#define _ASYNCRTIMP __declspec(dllexport)
90+
#else
91+
#define _ASYNCRTIMP __declspec(dllimport)
92+
#endif
6093
#endif
6194

95+
#ifdef CASABLANCA_DEPRECATION_NO_WARNINGS
96+
#define CASABLANCA_DEPRECATED(x)
97+
#else
98+
#define CASABLANCA_DEPRECATED(x) __declspec(deprecated(x))
99+
#endif

Release/include/cpprest/details/fileio.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@
3131
****/
3232
#pragma once
3333

34-
#ifdef _MS_WINDOWS
34+
#ifdef _WIN32
3535
#include <cstdint>
3636
#endif
3737

3838
#include "pplx/pplxtasks.h"
39-
#include "cpprest/details/xxpublic.h"
4039
#include "cpprest/basic_types.h"
4140

4241
namespace Concurrency { namespace streams

Release/include/cpprest/details/globals.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@
2626
****/
2727
#pragma once
2828

29-
#include "cpprest/details/xxpublic.h"
30-
31-
#ifdef _MS_WINDOWS
32-
29+
#ifdef _WIN32
3330
extern volatile long g_isProcessTerminating;
34-
35-
#endif // _MS_WINDOWS
31+
#endif

Release/include/cpprest/details/http_client_impl.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "cpprest/basic_types.h"
2828
#include "cpprest/details/http_helpers.h"
2929

30-
#ifdef _MS_WINDOWS
30+
#ifdef _WIN32
3131
#if !defined(__cplusplus_winrt)
3232
#include <winhttp.h>
3333
#else
@@ -50,7 +50,7 @@ using namespace concurrency;
5050
#include <boost/algorithm/string.hpp>
5151
#endif
5252

53-
#ifdef _MS_WINDOWS
53+
#ifdef _WIN32
5454
# define CRLF _XPLATSTR("\r\n")
5555
#else
5656
# define CRLF std::string("\r\n")
@@ -61,7 +61,7 @@ using namespace web::http::details;
6161
namespace web { namespace http { namespace client { namespace details
6262
{
6363

64-
#ifdef _MS_WINDOWS
64+
#ifdef _WIN32
6565
static const utility::char_t * get_with_body = _XPLATSTR("A GET or HEAD request should not have an entity body.");
6666

6767
// Helper function to trim leading and trailing null characters from a string.
@@ -90,7 +90,7 @@ static utility::string_t flatten_http_headers(const http_headers &headers)
9090
return flattened_headers;
9191
}
9292

93-
#ifdef _MS_WINDOWS
93+
#ifdef _WIN32
9494
/// <summary>
9595
/// Parses a string containing Http headers.
9696
/// </summary>
@@ -151,7 +151,7 @@ class request_context
151151
report_exception(http_exception(static_cast<int>(error_code), errorMessage));
152152
}
153153

154-
#ifdef _MS_WINDOWS
154+
#ifdef _WIN32
155155
void report_error(unsigned long error_code, const std::wstring &errorMessage)
156156
{
157157
report_exception(http_exception(static_cast<int>(error_code), errorMessage));

0 commit comments

Comments
 (0)