]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[contrib][linux-kernel] Fix stack detection for newer gcc
authorNick Terrell <terrelln@fb.com>
Tue, 13 Dec 2022 23:03:23 +0000 (15:03 -0800)
committerNick Terrell <nickrterrell@gmail.com>
Tue, 13 Dec 2022 23:56:53 +0000 (15:56 -0800)
Newer gcc versions were getting smart and omitting the `memset()`.
Get around this issue by outlining the `memset()` into a different
function. This test is still hacky, but it works...

contrib/linux-kernel/test/test.c

index 6cd1730bb3a23293cdc9749be0e5f0384ae2988a..67d248e0cbf34c30f3731f189209612b4c14f1bc 100644 (file)
@@ -186,11 +186,14 @@ static void __attribute__((noinline)) use(void *x) {
   asm volatile("" : "+r"(x));
 }
 
+static void __attribute__((noinline)) fill_stack(void) {
+  memset(g_stack, 0x33, 8192);
+}
+
 static void __attribute__((noinline)) set_stack(void) {
 
   char stack[8192];
   g_stack = stack;
-  memset(g_stack, 0x33, 8192);
   use(g_stack);
 }
 
@@ -208,6 +211,7 @@ static void __attribute__((noinline)) check_stack(void) {
 
 static void test_stack_usage(test_data_t const *data) {
   set_stack();
+  fill_stack();
   test_f2fs();
   test_btrfs(data);
   test_decompress_unzstd(data);