Skip to content

Commit d564bf5

Browse files
committed
Merge branch 'master' into cne-master
2 parents 9b5b91d + ec7dfe1 commit d564bf5

File tree

177 files changed

+4994
-2897
lines changed

Some content is hidden

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

177 files changed

+4994
-2897
lines changed

Changes.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,40 @@
11

2+
4.3.xx
3+
------------------------------------------------------------
4+
5+
* Added support for killing processes on OS' other than Windows, Apple TV, and Apple Watch
6+
* Added register capturing on Linux
7+
* Added HXCPP_CPP17 define
8+
* Added ASM and NASM support to build xml
9+
* Added support for name and value entries to build xml
10+
* Added tracy profiler
11+
* Added support for Android NDKs higher than 21
12+
* Added x86_64 support to older Android NDKs
13+
* Added optional detaching of main thread
14+
15+
* Updated mbedtls to 2.28.2
16+
* Updated sqlite to 3.40.1
17+
* Updated zlib to 1.2.13
18+
19+
* Fixed SSL socket non blocking handshake throwing an exception on 64bit Windows
20+
* Fixed Windows 64bit architecture detection
21+
* Fixed critial error handler returning the wrong callstack
22+
* Fixed ARM64 library names on Mac
23+
* Fixed generational GC when used with HXCPP_ALIGN_ALLOC
24+
* Fixed pthread structured being unaligned
25+
* Fixed cppia crash on functions with empty bodies
26+
* Fixed regression parsing integers which wrap around
27+
* Fixed compilation with HXCPP_GC_DEBUG_LEVEL define
28+
* Fixed compilation with MinGW
29+
* Fixed enum parameters potentially returning null
30+
* Fixed HXCPP_CLANG not being set when using clang
31+
* Fixed pcre2 and mbedtls not being compiled with the c99 standard
32+
* Fixed behaviour of indexOf and lastIndexOf on empty strings not aligning with other targets
33+
* Fixed behaviour of directory reading function not aligning with other targets
34+
* Fixed haxelib not being invoked with the current working directory
35+
36+
* Removed Haxe 3 support
37+
238
4.3
339
------------------------------------------------------------
440

docs/build_xml/Defines.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Defines affecting how the code is compiled. These can be on the command line wh
3838
| *HXCPP_PROFILER* | Add profiler support |
3939
| *HXCPP_TELEMETRY* | Add telemetry support |
4040
| *HXCPP_CPP11* | Use c++11 features and link libraries |
41+
| *HXCPP_CPP17* | Use c++17 features and link libraries |
4142
| *exe_link* | Generate executable file (rather than dynamic library on android) |
4243
| *static_link* | Generate static library |
4344
| *dll_link* | Generate dynamic library |
@@ -67,7 +68,7 @@ Defines affecting target architecture.
6768
| *HXCPP_LINUX_ARM64* | Run on a linux ARM64 device |
6869
| *winrt* | Compile for windowsRt/windows UWP |
6970
| *android* | Compile for android |
70-
| *PLATFORM* | Specify the android platform for NDK compilation |
71+
| *HXCPP_ANDROID_PLATFORM* | Specify the android platform for NDK compilation |
7172
| *ANDROID_NDK_ROOT* | Specify the location of the android NDK toolchain |
7273
| *ANDROID_NDK_DIR* | Specify the search location for finding the android NDK toolchain |
7374
| *HXCPP_X86* | Compile android for x86 architecture |

hxcpp.n

1.66 KB
Binary file not shown.

include/hx/CFFIPrime.h

Lines changed: 69 additions & 64 deletions
Large diffs are not rendered by default.

include/hx/Debug.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ class StackCatchable
216216
bool (*mTestFunction)(Dynamic e);
217217
};
218218

219+
#if defined(HXCPP_SCRIPTABLE) && (HXCPP_API_LEVEL >= 500)
220+
// This is the function to call when a new script has been loaded.
221+
// Signature: Void -> Void
222+
extern Dynamic g_onScriptLoadedFunction;
223+
#endif
219224

220225

221226
#endif // HXCPP_DEBUGGER
@@ -298,6 +303,9 @@ void __hxcpp_dbg_setNewStackFrameFunction(Dynamic function);
298303
void __hxcpp_dbg_setNewThreadInfoFunction(Dynamic function);
299304
void __hxcpp_dbg_setAddParameterToStackFrameFunction(Dynamic function);
300305
void __hxcpp_dbg_setAddStackFrameToThreadInfoFunction(Dynamic function);
306+
#if defined(HXCPP_SCRIPTABLE) && (HXCPP_API_LEVEL >= 500)
307+
void __hxcpp_dbg_setOnScriptLoadedFunction(Dynamic function);
308+
#endif
301309

302310
bool __hxcpp_dbg_fix_critical_error(String inErr);
303311

@@ -351,6 +359,9 @@ inline void __hxcpp_dbg_setNewStackFrameFunction(Dynamic) { }
351359
inline void __hxcpp_dbg_setNewThreadInfoFunction(Dynamic) { }
352360
inline void __hxcpp_dbg_setAddParameterToStackFrameFunction(Dynamic) { }
353361
inline void __hxcpp_dbg_setAddStackFrameToThreadInfoFunction(Dynamic) { }
362+
#if defined(HXCPP_SCRIPTABLE) && (HXCPP_API_LEVEL >= 500)
363+
inline void __hxcpp_dbg_setOnScriptLoadedFunction(Dynamic) { }
364+
#endif
354365

355366
// The following functions are called by Thread.cpp to notify of thread
356367
// created and terminated

include/hx/HxcppMain.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,22 @@
9494
}
9595
catch (Dynamic e)
9696
{
97-
__hx_dump_stack();
98-
#ifdef HX_WIN_MAIN
99-
MessageBoxA(0, e==null() ? "null" : e->toString().__CStr(), "Error", 0);
100-
#else
101-
printf("Error : %s\n",e==null() ? "null" : e->toString().__CStr());
102-
#endif
103-
return -1;
97+
auto customStack = e->__Field(HX_CSTRING("_hx_customStack"), HX_PROP_DYNAMIC).asString();
98+
if (::hx::IsNotNull(customStack))
99+
{
100+
printf("%s\n", customStack.utf8_str());
101+
}
102+
else
103+
{
104+
__hx_dump_stack();
105+
}
106+
107+
#ifdef HX_WIN_MAIN
108+
MessageBoxA(0, e == null() ? "null" : e->toString().__CStr(), "Error", 0);
109+
#else
110+
printf("Error : %s\n", e == null() ? "null" : e->toString().__CStr());
111+
#endif
112+
return -1;
104113
}
105114
return 0;
106115
}

include/hx/StdLibs.h

Lines changed: 91 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Array<unsigned char> __hxcpp_resource_bytes(String inName);
4343
// System access
4444
Array<String> __get_args();
4545
double __time_stamp();
46+
::cpp::Int64 __time_stamp_ms();
4647

4748
HXCPP_EXTERN_CLASS_ATTRIBUTES void __hxcpp_print_string(const String &inV);
4849
HXCPP_EXTERN_CLASS_ATTRIBUTES void __hxcpp_println_string(const String &inV);
@@ -161,7 +162,7 @@ HXCPP_EXTERN_CLASS_ATTRIBUTES String __hxcpp_utf8_string_to_char_bytes(String &i
161162

162163
// --- HashRoot ---------------------------------------------------------------------
163164

164-
HXCPP_EXTERN_CLASS_ATTRIBUTES int __root_hash_size(Dynamic *rtHash);
165+
HXCPP_EXTERN_CLASS_ATTRIBUTES int __root_hash_size(Dynamic &rtHash);
165166

166167
// --- IntHash ----------------------------------------------------------------------
167168

@@ -472,16 +473,102 @@ inline void* _hx_atomic_compare_exchange_ptr(volatile void **a, void *expected,
472473
#elif defined(HX_MSVC_ATOMICS)
473474
return _InterlockedCompareExchangePointer((void *volatile *)a, replacement, expected);
474475
#else
475-
void *old = *a;
476-
*a = replacement;
477-
return old;
476+
void *old = *a;
477+
if (old == expected) {
478+
*a = replacement;
479+
}
480+
return old;
478481
#endif
479482
}
480483

481484
inline void* _hx_atomic_compare_exchange_cast_ptr(void *a, void *expected, void *replacement) {
482485
return _hx_atomic_compare_exchange_ptr((volatile void **)a, expected, replacement);
483486
}
484487

488+
#include <atomic>
489+
490+
struct AtomicObject: hx::Object {
491+
std::atomic< ::hx::Object *> aPtr;
492+
493+
AtomicObject(Dynamic val) { aPtr = val.mPtr; }
494+
495+
void __Mark(hx::MarkContext *__inCtx) {
496+
Dynamic ptr = load();
497+
HX_MARK_MEMBER(ptr);
498+
}
499+
500+
#ifdef HXCPP_VISIT_ALLOCS
501+
void __Visit(hx::VisitContext *__inCtx) {
502+
hx::Object *obj = aPtr.load();
503+
HX_VISIT_MEMBER(obj);
504+
aPtr.store(obj);
505+
}
506+
#endif
507+
508+
Dynamic store(Dynamic val) {
509+
aPtr.store(val.mPtr);
510+
HX_OBJ_WB_GET(this, val.mPtr);
511+
return val;
512+
}
513+
514+
Dynamic load() {
515+
return aPtr.load();
516+
}
517+
518+
Dynamic exchange(Dynamic val) {
519+
Dynamic ret = aPtr.exchange(val.mPtr);
520+
HX_OBJ_WB_GET(this, val.mPtr);
521+
return ret;
522+
}
523+
524+
Dynamic compareExchange(Dynamic expected, Dynamic replacement) {
525+
// Note: using Dynamic instead of hx::Object* is important
526+
// Dynamic has an overloaded == operator, a raw pointer to hx::Object does not.
527+
Dynamic original = aPtr.load();
528+
while (original == expected) {
529+
if (aPtr.compare_exchange_weak(original.mPtr, replacement.mPtr)) {
530+
HX_OBJ_WB_GET(this, replacement.mPtr);
531+
return original;
532+
} else {
533+
continue;
534+
}
535+
}
536+
return original;
537+
}
538+
};
539+
540+
inline Dynamic __hxcpp_atomic_object_create(Dynamic value) {
541+
return new AtomicObject(value);
542+
}
543+
544+
inline Dynamic __hxcpp_atomic_object_store(Dynamic dynObj, Dynamic val) {
545+
AtomicObject *obj = dynamic_cast<AtomicObject *>(dynObj.mPtr);
546+
if (!obj)
547+
throw HX_INVALID_OBJECT;
548+
return obj->store(val);
549+
}
550+
551+
inline Dynamic __hxcpp_atomic_object_load(Dynamic dynObj) {
552+
AtomicObject *obj = dynamic_cast<AtomicObject *>(dynObj.mPtr);
553+
if (!obj)
554+
throw HX_INVALID_OBJECT;
555+
return obj->load();
556+
}
557+
558+
inline Dynamic __hxcpp_atomic_object_exchange(Dynamic dynObj, Dynamic newVal) {
559+
AtomicObject *obj = dynamic_cast<AtomicObject *>(dynObj.mPtr);
560+
if (!obj)
561+
throw HX_INVALID_OBJECT;
562+
return obj->exchange(newVal);
563+
}
564+
565+
inline Dynamic __hxcpp_atomic_object_compare_exchange(Dynamic dynObj, Dynamic expected, Dynamic replacement) {
566+
AtomicObject *obj = dynamic_cast<AtomicObject *>(dynObj.mPtr);
567+
if (!obj)
568+
throw HX_INVALID_OBJECT;
569+
return obj->compareExchange(expected, replacement);
570+
}
571+
485572
Array<String> __hxcpp_get_call_stack(bool inSkipLast);
486573
Array<String> __hxcpp_get_exception_stack();
487574
#define HXCPP_HAS_CLASSLIST

include/hx/TelemetryTracy.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
#define TRACY_ENABLE
99
#include <hxcpp.h>
10-
#include "../../project/thirdparty/tracy-0.11.1/tracy/TracyC.h"
11-
#include "../../project/thirdparty/tracy-0.11.1/tracy/Tracy.hpp"
10+
#include "../../project/thirdparty/tracy-0.12.0/tracy/TracyC.h"
11+
#include "../../project/thirdparty/tracy-0.12.0/tracy/Tracy.hpp"
1212

1313
#ifdef HXCPP_TRACY_MEMORY
1414
#ifdef HXCPP_GC_MOVING
@@ -30,10 +30,13 @@
3030
::hx::strbuf TracyConcat(_hx_tracy_str_buffer, TracyLine); \
3131
int TracyConcat(_hx_tracy_str_length, TracyLine); \
3232
const char *TracyConcat(_hx_tracy_str_buffer_ptr, TracyLine) = name.utf8_str(&TracyConcat(_hx_tracy_str_buffer, TracyLine), false, &TracyConcat(_hx_tracy_str_length, TracyLine)); \
33-
::tracy::ScopedZone TracyConcat(_hx_tracy_scoped_zone,TracyLine)(_hx_stackframe.lineNumber, _hx_stackframe.position->fileName, strlen(_hx_stackframe.position->fileName), _hx_stackframe.position->fullName, strlen(_hx_stackframe.position->fullName), TracyConcat(_hx_tracy_str_buffer_ptr, TracyLine), TracyConcat(_hx_tracy_str_length, TracyLine));
33+
::tracy::ScopedZone TracyConcat(_hx_tracy_scoped_zone,TracyLine)(_hx_stackframe.lineNumber, _hx_stackframe.position->fileName, strlen(_hx_stackframe.position->fileName), _hx_stackframe.position->fullName, strlen(_hx_stackframe.position->fullName), TracyConcat(_hx_tracy_str_buffer_ptr, TracyLine), TracyConcat(_hx_tracy_str_length, TracyLine), -1);
3434
#endif
3535

3636
void __hxcpp_tracy_framemark();
37+
void __hxcpp_tracy_framemark_named(::String name);
38+
void __hxcpp_tracy_framemark_start(::String name);
39+
void __hxcpp_tracy_framemark_end(::String name);
3740
void __hxcpp_tracy_plot(::String name, ::Float val);
3841
void __hxcpp_tracy_plot_config(::String name, uint8_t format, bool step, bool fill, int color);
3942
void __hxcpp_tracy_message(::String msg, int color);

include/hx/Thread.h

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ inline bool HxCreateDetachedThread(DWORD (WINAPI *func)(void *), void *param)
8686

8787
struct HxMutex
8888
{
89+
bool mValid;
90+
pthread_mutex_t *mMutex;
91+
8992
HxMutex()
9093
{
9194
pthread_mutexattr_t mta;
@@ -96,9 +99,7 @@ struct HxMutex
9699
}
97100
~HxMutex()
98101
{
99-
if (mValid)
100-
pthread_mutex_destroy(mMutex);
101-
delete mMutex;
102+
Clean();
102103
}
103104
void Lock() { pthread_mutex_lock(mMutex); }
104105
void Unlock() { pthread_mutex_unlock(mMutex); }
@@ -107,12 +108,16 @@ struct HxMutex
107108
void Clean()
108109
{
109110
if (mValid)
111+
{
110112
pthread_mutex_destroy(mMutex);
111-
mValid = 0;
113+
mValid = false;
114+
}
115+
if (mMutex)
116+
{
117+
delete mMutex;
118+
mMutex = nullptr;
119+
}
112120
}
113-
114-
bool mValid;
115-
pthread_mutex_t *mMutex;
116121
};
117122

118123
#define THREAD_FUNC_TYPE void *
@@ -198,19 +203,20 @@ struct HxSemaphore
198203

199204
struct HxSemaphore
200205
{
206+
HxMutex mMutex;
207+
pthread_cond_t *mCondition;
208+
bool mSet;
209+
210+
201211
HxSemaphore()
202212
{
203213
mSet = false;
204-
mValid = true;
205214
mCondition = new pthread_cond_t();
206215
pthread_cond_init(mCondition,0);
207216
}
208217
~HxSemaphore()
209218
{
210-
if (mValid)
211-
{
212-
pthread_cond_destroy(mCondition);
213-
}
219+
Clean();
214220
}
215221
// For autolock
216222
inline operator HxMutex &() { return mMutex; }
@@ -294,19 +300,14 @@ struct HxSemaphore
294300
void Clean()
295301
{
296302
mMutex.Clean();
297-
if (mValid)
303+
if (mCondition)
298304
{
299-
mValid = false;
300305
pthread_cond_destroy(mCondition);
306+
delete mCondition;
307+
mCondition = nullptr;
301308
}
302-
delete mCondition;
303309
}
304310

305-
306-
HxMutex mMutex;
307-
pthread_cond_t *mCondition;
308-
bool mSet;
309-
bool mValid;
310311
};
311312

312313

project/thirdparty/mbedtls-files.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<set name="MBEDTLS_DIR" value="${HXCPP}/project/thirdparty/mbedtls-2.28.2" />
44

5-
<files id="mbedtls">
5+
<files id="mbedtls" tags="" >
66
<depend name="${this_dir}/mbedtls-files.xml" dateOnly="true" />
77
<cache value="true" asLibrary="true" />
88

0 commit comments

Comments
 (0)