From 8ac7c4ca17c0ce5a462e994a28771dc78a8895ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Y=C4=B1ld=C4=B1r=C4=B1m?=
<25794892+barisyild@users.noreply.github.com>
Date: Mon, 14 Oct 2024 12:17:19 +0300
Subject: [PATCH 1/3] Fix sys stat size integer overflow
---
src/hx/libs/std/Sys.cpp | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/hx/libs/std/Sys.cpp b/src/hx/libs/std/Sys.cpp
index 371addf93..f85f8ac78 100644
--- a/src/hx/libs/std/Sys.cpp
+++ b/src/hx/libs/std/Sys.cpp
@@ -415,7 +415,8 @@ void _hx_std_sys_rename( String path, String newname )
hx::Throw(HX_CSTRING("Could not rename"));
}
-#define STATF(f) o->Add(HX_CSTRING(#f),(int)(s.st_##f))
+#define STATF32(f) o->Add(HX_CSTRING(#f),(int)(s.st_##f))
+#define STATF64(f) o->Add(HX_CSTRING(#f),(long)(s.st_##f))
/**
sys_stat : string -> {
@@ -429,7 +430,7 @@ void _hx_std_sys_rename( String path, String newname )
nlink => int,
rdev => int,
mode => int,
- size => int
+ size => long
}
Run the [stat] command on the given file or directory.
**/
@@ -465,18 +466,17 @@ Dynamic _hx_std_sys_stat( String path )
return null();
hx::Anon o = hx::Anon_obj::Create();
- STATF(gid);
- STATF(uid);
- STATF(atime);
- STATF(mtime);
- STATF(ctime);
- STATF(dev);
- STATF(ino);
- STATF(mode);
- STATF(nlink);
- STATF(rdev);
- STATF(size);
- STATF(mode);
+ STATF32(gid);
+ STATF32(uid);
+ STATF32(atime);
+ STATF32(mtime);
+ STATF32(ctime);
+ STATF32(dev);
+ STATF32(ino);
+ STATF32(nlink);
+ STATF32(rdev);
+ STATF32(mode);
+ STATF64(size);
return o;
#endif
From a427d1f4c5b78d35f65a21de31950f11d3aeb95f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Y=C4=B1ld=C4=B1r=C4=B1m?=
<25794892+barisyild@users.noreply.github.com>
Date: Mon, 14 Oct 2024 13:30:43 +0300
Subject: [PATCH 2/3] Fix apple build
---
src/hx/libs/std/Sys.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/hx/libs/std/Sys.cpp b/src/hx/libs/std/Sys.cpp
index f85f8ac78..5bba5a47b 100644
--- a/src/hx/libs/std/Sys.cpp
+++ b/src/hx/libs/std/Sys.cpp
@@ -416,7 +416,11 @@ void _hx_std_sys_rename( String path, String newname )
}
#define STATF32(f) o->Add(HX_CSTRING(#f),(int)(s.st_##f))
+#ifdef __APPLE__
+#define STATF64(f) o->Add(HX_CSTRING(#f),static_cast(s.st_##f))
+#else
#define STATF64(f) o->Add(HX_CSTRING(#f),(long)(s.st_##f))
+#endif
/**
sys_stat : string -> {
From 193b3d1632b72c9ba2832f51b6839a5e0d0a6c92 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Y=C4=B1ld=C4=B1r=C4=B1m?=
<25794892+barisyild@users.noreply.github.com>
Date: Mon, 14 Oct 2024 19:13:33 +0300
Subject: [PATCH 3/3] Guarantee that the size is 64 bit
---
src/hx/libs/std/Sys.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/hx/libs/std/Sys.cpp b/src/hx/libs/std/Sys.cpp
index 5bba5a47b..6479bc4d3 100644
--- a/src/hx/libs/std/Sys.cpp
+++ b/src/hx/libs/std/Sys.cpp
@@ -416,10 +416,10 @@ void _hx_std_sys_rename( String path, String newname )
}
#define STATF32(f) o->Add(HX_CSTRING(#f),(int)(s.st_##f))
-#ifdef __APPLE__
-#define STATF64(f) o->Add(HX_CSTRING(#f),static_cast(s.st_##f))
+#if defined(HXCPP_M64) || defined(HXCPP_ARM64)
+#define STATF64(f) o->Add(HX_CSTRING(#f), static_cast(s.st_##f))
#else
-#define STATF64(f) o->Add(HX_CSTRING(#f),(long)(s.st_##f))
+#define STATF64 STATF32
#endif
/**