Skip to content

Commit 82b7ad1

Browse files
casablancaras0219-msft
authored andcommitted
Added _pplx_cdecl macro to silence attribute ignored warnings
Conflicts: Release/src/json/json_parsing.cpp
1 parent 9af197e commit 82b7ad1

File tree

7 files changed

+19
-67
lines changed

7 files changed

+19
-67
lines changed

Release/include/pplx/pplx.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ namespace pplx
8585
/// <summary>
8686
/// Sets the ambient scheduler to be used by the PPL constructs.
8787
/// </summary>
88-
_PPLXIMP void __cdecl set_ambient_scheduler(std::shared_ptr<pplx::scheduler_interface> _Scheduler);
88+
_PPLXIMP void _pplx_cdecl set_ambient_scheduler(std::shared_ptr<pplx::scheduler_interface> _Scheduler);
8989

9090
/// <summary>
9191
/// Gets the ambient scheduler to be used by the PPL constructs
9292
/// </summary>
93-
_PPLXIMP std::shared_ptr<pplx::scheduler_interface> __cdecl get_ambient_scheduler();
93+
_PPLXIMP std::shared_ptr<pplx::scheduler_interface> _pplx_cdecl get_ambient_scheduler();
9494

9595
namespace details
9696
{
@@ -122,7 +122,7 @@ namespace details
122122
virtual ~_TaskProcHandle() {}
123123
virtual void invoke() const = 0;
124124

125-
static void __cdecl _RunChoreBridge(void * _Parameter)
125+
static void _pplx_cdecl _RunChoreBridge(void * _Parameter)
126126
{
127127
auto _PTaskHandle = static_cast<_TaskProcHandle *>(_Parameter);
128128
_AutoDeleter<_TaskProcHandle> _AutoDeleter(_PTaskHandle);
@@ -207,7 +207,7 @@ namespace details
207207
}
208208
}
209209

210-
static bool __cdecl _Is_cancellation_requested()
210+
static bool _pplx_cdecl _Is_cancellation_requested()
211211
{
212212
// We do not yet have the ability to determine the current task. So return false always
213213
return false;

Release/include/pplx/pplxinterface.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@
4848
#include <atomic>
4949
#endif
5050

51+
#if defined(ANDROID)
52+
// This prevents users from requiring -Wno-attributes when using gcc-4.8 with the android NDK.
53+
#define _pplx_cdecl
54+
#else
55+
#define _pplx_cdecl __cdecl
56+
#endif
57+
5158
namespace pplx
5259
{
5360

@@ -56,7 +63,7 @@ namespace pplx
5663
/// invoke the body of a task.
5764
/// </summary>
5865
/**/
59-
typedef void (__cdecl * TaskProc_t)(void *);
66+
typedef void (_pplx_cdecl * TaskProc_t)(void *);
6067

6168
/// <summary>
6269
/// Scheduler Interface

Release/include/pplx/pplxlinux.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ namespace platform
6565
/// <summary>
6666
/// Returns a unique identifier for the execution thread where this routine in invoked
6767
/// </summary>
68-
_PPLXIMP long __cdecl GetCurrentThreadId();
68+
_PPLXIMP long _pplx_cdecl GetCurrentThreadId();
6969

7070
/// <summary>
7171
/// Yields the execution of the current execution thread - typically when spin-waiting
7272
/// </summary>
73-
_PPLXIMP void __cdecl YieldExecution();
73+
_PPLXIMP void _pplx_cdecl YieldExecution();
7474

7575
/// <summary>
7676
/// Caputeres the callstack

Release/include/pplx/pplxtasks.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ template <> class task<void>;
201201
/// <seealso cref="cancellation_token Class"/>
202202
/// <seealso cref="cancel_current_task Function"/>
203203
/**/
204-
inline bool __cdecl is_task_cancellation_requested()
204+
inline bool _pplx_cdecl is_task_cancellation_requested()
205205
{
206206
return ::pplx::details::_TaskCollection_t::_Is_cancellation_requested();
207207
}
@@ -216,7 +216,7 @@ inline bool __cdecl is_task_cancellation_requested()
216216
/// </summary>
217217
/// <seealso cref="task Class"/>
218218
/**/
219-
inline __declspec(noreturn) void __cdecl cancel_current_task()
219+
inline __declspec(noreturn) void _pplx_cdecl cancel_current_task()
220220
{
221221
throw task_canceled();
222222
}
@@ -506,7 +506,7 @@ namespace details
506506
{
507507
}
508508

509-
static void __cdecl _Bridge(void *_PData)
509+
static void _pplx_cdecl _Bridge(void *_PData)
510510
{
511511
_TaskProcThunk *_PThunk = reinterpret_cast<_TaskProcThunk *>(_PData);
512512
_Holder _ThunkHolder(_PThunk);

Release/src/json/json_parsing.cpp

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,6 @@
2929
#include <vector>
3030
#include <cstdlib>
3131

32-
#if defined(ANDROID)
33-
34-
namespace crossplat
35-
{
36-
// These two are initialized in threadpool.cpp
37-
// HACK: This uses silently shared global variables. Revisit in the future if android
38-
// JNI code gets its own header and cpp file.
39-
extern jmethodID java_parseDouble;
40-
extern jclass java_lang_double;
41-
}
42-
#endif
43-
4432
#pragma warning(disable : 4127) // allow expressions like while(true) pass
4533
using namespace web;
4634
using namespace web::json;
@@ -405,44 +393,8 @@ namespace
405393
}
406394
#endif
407395

408-
#ifdef ANDROID
409-
static double anystod(const char* str)
410-
{
411-
// HACK: To work around issues with bionic's strtod() implementation, we ship
412-
// the string to parse into java, call the java function
413-
// java.lang.Double.parseDouble(), and bring it back down to native code.
414-
//
415-
// The strtod() bug causes problems when parsing large strings; furthermore, it
416-
// is arguable that it uses "locale" information, which is announced as being
417-
// off-limits for native code.
418-
//
419-
// It is highly unlikely this situation will be remedied due to ecosystem
420-
// fragmentation.
421-
if (str == nullptr)
422-
str = "";
423-
424-
auto env = crossplat::get_jvm_env();
425-
426-
jdouble parsed_double;
427-
428-
crossplat::java_local_ref<jstring> jstr{env->NewStringUTF(str)};
429-
parsed_double = env->CallStaticDoubleMethod(crossplat::java_lang_double,
430-
crossplat::java_parseDouble,
431-
jstr.get());
432-
433-
jthrowable exc = env->ExceptionOccurred();
434-
if (exc)
435-
{
436-
env->ExceptionClear();
437-
throw exc;
438-
}
439-
return parsed_double;
440-
}
441-
442-
#else
443396
static double anystod(const char* str) { return strtod(str, nullptr); }
444397
static double anystod(const wchar_t* str) { return wcstod(str, nullptr); }
445-
#endif
446398
}
447399

448400
template <typename CharType>

Release/src/pplx/pplx.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ static struct _pplx_g_sched_t
144144
sched_ptr m_scheduler;
145145
} _pplx_g_sched;
146146

147-
_PPLXIMP std::shared_ptr<pplx::scheduler_interface> __cdecl get_ambient_scheduler()
147+
_PPLXIMP std::shared_ptr<pplx::scheduler_interface> _pplx_cdecl get_ambient_scheduler()
148148
{
149149
return _pplx_g_sched.get_scheduler();
150150
}
151151

152-
_PPLXIMP void __cdecl set_ambient_scheduler(std::shared_ptr<pplx::scheduler_interface> _Scheduler)
152+
_PPLXIMP void _pplx_cdecl set_ambient_scheduler(std::shared_ptr<pplx::scheduler_interface> _Scheduler)
153153
{
154154
_pplx_g_sched.set_scheduler(std::move(_Scheduler));
155155
}

Release/src/pplx/threadpool.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ JNIEnv* get_jvm_env()
4646
return JVM_ENV;
4747
}
4848

49-
jmethodID java_parseDouble;
50-
jclass java_lang_double;
5149
#endif
5250

5351
}
@@ -61,11 +59,6 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved)
6159
return -1;
6260
}
6361

64-
crossplat::java_local_ref<jclass> local_java_lang_double{env->FindClass("java/lang/Double")};
65-
crossplat::java_lang_double = static_cast<jclass>(env->NewGlobalRef(local_java_lang_double.get()));
66-
67-
crossplat::java_parseDouble = env->GetStaticMethodID(crossplat::java_lang_double, "parseDouble", "(Ljava/lang/String;)D");
68-
6962
crossplat::JVM = vm;
7063
return JNI_VERSION_1_6;
7164
}

0 commit comments

Comments
 (0)