fix build with clang
PATCH v2 1/1 fix build with clang
clang will never support 'variable length array in structure', and there does not seem to be a reason for this weird construct.
---v1->v2:
* fix algorithm
--- testsuite/smokey/memcheck/memcheck.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
testsuite/smokey/memcheck/memcheck.c +2 -4
@@ -80,9 +80,7 @@ static inline void swap(void *left, void *right, const size_t size)static void random_shuffle (void *vbase,size_t nmemb,const size_t size) { -struct { -char x[size]; - } __attribute__((packed)) *base = vbase; +char *base = (char *)vbase;unsigned int j, k;double u;
@@ -92,7 +90,7 @@ static void random_shuffle(void *vbase, size_t nmemb, const size_t size) k = (unsigned int )(j * u) +1 ;if (j == k)continue ; -swap (&base[j -1 ], &base[k -1 ], size); +swap (base + (j -1 ) * size, base + (k -1 ) * size, size); } }
Signature · 1 line
2.35.1
Jan Kiszka
AppliedQuoted 27 lines · Norbert Lange
clang will never support 'variable length array in structure', and there does not seem to be a reason for this weird construct.
Signed-off-by Norbert Lange <[email protected]>---
v1->v2:
* fix algorithm--- testsuite/smokey/memcheck/memcheck.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)testsuite/smokey/memcheck/memcheck.c +1
-3@@ -80,9 +80,7 @@ static inline void swap(void *left, void *right, const size_t size)static void random_shuffle (void *vbase,size_t nmemb,const size_t size) { -struct { -char x[size]; - } __attribute__((packed)) *base = vbase; +char *base = (char *)vbase;unsigned int j, k;double u;
testsuite/smokey/memcheck/memcheck.c static void random_shuffle(void *vbase, size_t nmemb, const size_t size) · line 96
Quoted 8 lines
testsuite/smokey/memcheck/memcheck.c +1
-1@@ -92,7 +90,7 @@ static void random_shuffle(void *vbase, size_t nmemb, const size_t size) k = (unsigned int )(j * u) +1 ;if (j == k)continue ; -swap (&base[j -1 ], &base[k -1 ], size); +swap (base + (j -1 ) * size, base + (k -1 ) * size, size); } }
Thanks, applied.
Jan
Signature · 2 lines
Siemens AG, Technology Competence Center Embedded Linux
Am Mo., 25. Juli 2022 um 19:22 Uhr schrieb Jan Kiszka <[email protected]>:
Quoted 40 lines · Norbert Lange
Quoted 27 lines
clang will never support 'variable length array in structure', and there does not seem to be a reason for this weird construct.
Signed-off-by Norbert Lange <[email protected]>---
v1->v2:
* fix algorithm--- testsuite/smokey/memcheck/memcheck.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)testsuite/smokey/memcheck/memcheck.c +1
-3@@ -80,9 +80,7 @@ static inline void swap(void *left, void *right, const size_t size)static void random_shuffle (void *vbase,size_t nmemb,const size_t size) { -struct { -char x[size]; - } __attribute__((packed)) *base = vbase; +char *base = (char *)vbase;unsigned int j, k;double u;testsuite/smokey/memcheck/memcheck.c static void random_shuffle(void *vbase, size_t nmemb, const size_t size) · line 96
Quoted 8 lines
testsuite/smokey/memcheck/memcheck.c +1
-1@@ -92,7 +90,7 @@ static void random_shuffle(void *vbase, size_t nmemb, const size_t size) k = (unsigned int )(j * u) +1 ;if (j == k)continue ; -swap (&base[j -1 ], &base[k -1 ], size); +swap (base + (j -1 ) * size, base + (k -1 ) * size, size); } }Thanks, applied.
Quoted 5 lines
Jan
--
Siemens AG, Technology
Competence Center Embedded Linux
Could you cherry-pick this commit to 3.0.x and 3.1.x aswell please?
Norbert
Quoted 41 lines · Norbert Lange
Am Mo., 25. Juli 2022 um 19:22 Uhr schrieb Jan Kiszka <[email protected]>:
Quoted 40 lines · Norbert Lange
Quoted 27 lines
clang will never support 'variable length array in structure', and there does not seem to be a reason for this weird construct.
Signed-off-by Norbert Lange <[email protected]>---
v1->v2:
* fix algorithm--- testsuite/smokey/memcheck/memcheck.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)testsuite/smokey/memcheck/memcheck.c +1
-3@@ -80,9 +80,7 @@ static inline void swap(void *left, void *right, const size_t size)static void random_shuffle (void *vbase,size_t nmemb,const size_t size) { -struct { -char x[size]; - } __attribute__((packed)) *base = vbase; +char *base = (char *)vbase;unsigned int j, k;double u;testsuite/smokey/memcheck/memcheck.c static void random_shuffle(void *vbase, size_t nmemb, const size_t size) · line 96
Quoted 8 lines
testsuite/smokey/memcheck/memcheck.c +1
-1@@ -92,7 +90,7 @@ static void random_shuffle(void *vbase, size_t nmemb, const size_t size) k = (unsigned int )(j * u) +1 ;if (j == k)continue ; -swap (&base[j -1 ], &base[k -1 ], size); +swap (base + (j -1 ) * size, base + (k -1 ) * size, size); } }Thanks, applied.
Quoted 8 lines
Quoted 5 lines
Jan
--
Siemens AG, Technology
Competence Center Embedded LinuxCould you cherry-pick this commit to 3.0.x and 3.1.x aswell please?
I can. I was just not expecting someone starting something new with clang on these old versions now. If you change something as fundamental as the compiler, why sticking with that versions?
Jan
Signature · 2 lines
Siemens AG, Technology Competence Center Embedded Linux
Am Fr., 5. Aug. 2022 um 15:45 Uhr schrieb Jan Kiszka <[email protected]>:
Quoted 49 lines · Norbert Lange
Quoted 47 lines
Am Mo., 25. Juli 2022 um 19:22 Uhr schrieb Jan Kiszka <[email protected]>:
Quoted 45 lines · Norbert Lange
Quoted 27 lines
clang will never support 'variable length array in structure', and there does not seem to be a reason for this weird construct.
Signed-off-by Norbert Lange <[email protected]>---
v1->v2:
* fix algorithm--- testsuite/smokey/memcheck/memcheck.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)testsuite/smokey/memcheck/memcheck.c +1
-3@@ -80,9 +80,7 @@ static inline void swap(void *left, void *right, const size_t size)static void random_shuffle (void *vbase,size_t nmemb,const size_t size) { -struct { -char x[size]; - } __attribute__((packed)) *base = vbase; +char *base = (char *)vbase;unsigned int j, k;double u;testsuite/smokey/memcheck/memcheck.c static void random_shuffle(void *vbase, size_t nmemb, const size_t size) · line 96
Quoted 8 lines
testsuite/smokey/memcheck/memcheck.c +1
-1@@ -92,7 +90,7 @@ static void random_shuffle(void *vbase, size_t nmemb, const size_t size) k = (unsigned int )(j * u) +1 ;if (j == k)continue ; -swap (&base[j -1 ], &base[k -1 ], size); +swap (base + (j -1 ) * size, base + (k -1 ) * size, size); } }Thanks, applied.
Jan
--
Siemens AG, Technology
Competence Center Embedded Linux
Quoted 6 lines
Quoted 2 lines
Could you cherry-pick this commit to 3.0.x and 3.1.x aswell please?
I can. I was just not expecting someone starting something new with clang on these old versions now. If you change something as fundamental as the compiler, why sticking with that versions?
I am trying to setup a build-server which uses clang, for using sanitzers, codecoverage
and code-quality. We wont change the compiler and don't want to change the xenomai version.
I guess I could just use a newer version of xenomai for the tests without adverse effects,
but so far I only have one xenomai version for everything.
Norbert
Am Fr., 5. Aug. 2022 um 16:00 Uhr schrieb Norbert Lange <[email protected]>:
Quoted 54 lines
Am Fr., 5. Aug. 2022 um 15:45 Uhr schrieb Jan Kiszka <[email protected]>:
Quoted 52 lines · Norbert Lange
Quoted 49 lines
Am Mo., 25. Juli 2022 um 19:22 Uhr schrieb Jan Kiszka <[email protected]>:
Quoted 40 lines · Norbert Lange
Quoted 27 lines
clang will never support 'variable length array in structure', and there does not seem to be a reason for this weird construct.
Signed-off-by Norbert Lange <[email protected]>---
v1->v2:
* fix algorithm--- testsuite/smokey/memcheck/memcheck.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)testsuite/smokey/memcheck/memcheck.c +1
-3@@ -80,9 +80,7 @@ static inline void swap(void *left, void *right, const size_t size)static void random_shuffle (void *vbase,size_t nmemb,const size_t size) { -struct { -char x[size]; - } __attribute__((packed)) *base = vbase; +char *base = (char *)vbase;unsigned int j, k;double u;testsuite/smokey/memcheck/memcheck.c static void random_shuffle(void *vbase, size_t nmemb, const size_t size) · line 96
Quoted 8 lines
testsuite/smokey/memcheck/memcheck.c +1
-1@@ -92,7 +90,7 @@ static void random_shuffle(void *vbase, size_t nmemb, const size_t size) k = (unsigned int )(j * u) +1 ;if (j == k)continue ; -swap (&base[j -1 ], &base[k -1 ], size); +swap (base + (j -1 ) * size, base + (k -1 ) * size, size); } }Thanks, applied.
Quoted 5 lines
Jan
--
Siemens AG, Technology
Competence Center Embedded LinuxCould you cherry-pick this commit to 3.0.x and 3.1.x aswell please?
Quoted 8 lines
Quoted 3 lines
I can. I was just not expecting someone starting something new with clang on these old versions now. If you change something as fundamental as the compiler, why sticking with that versions?
I am trying to setup a build-server which uses clang, for using sanitzers, codecoverage
and code-quality. We wont change the compiler and don't want to change the xenomai version.
(We wont change anything for our *productive software*)
Norbert
Quoted 57 lines · Norbert Lange
Am Fr., 5. Aug. 2022 um 15:45 Uhr schrieb Jan Kiszka <[email protected]>:
Quoted 49 lines · Norbert Lange
Quoted 47 lines
Am Mo., 25. Juli 2022 um 19:22 Uhr schrieb Jan Kiszka <[email protected]>:
Quoted 45 lines · Norbert Lange
Quoted 27 lines
clang will never support 'variable length array in structure', and there does not seem to be a reason for this weird construct.
Signed-off-by Norbert Lange <[email protected]>---
v1->v2:
* fix algorithm--- testsuite/smokey/memcheck/memcheck.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)testsuite/smokey/memcheck/memcheck.c +1
-3@@ -80,9 +80,7 @@ static inline void swap(void *left, void *right, const size_t size)static void random_shuffle (void *vbase,size_t nmemb,const size_t size) { -struct { -char x[size]; - } __attribute__((packed)) *base = vbase; +char *base = (char *)vbase;unsigned int j, k;double u;testsuite/smokey/memcheck/memcheck.c static void random_shuffle(void *vbase, size_t nmemb, const size_t size) · line 96
Quoted 8 lines
testsuite/smokey/memcheck/memcheck.c +1
-1@@ -92,7 +90,7 @@ static void random_shuffle(void *vbase, size_t nmemb, const size_t size) k = (unsigned int )(j * u) +1 ;if (j == k)continue ; -swap (&base[j -1 ], &base[k -1 ], size); +swap (base + (j -1 ) * size, base + (k -1 ) * size, size); } }Thanks, applied.
Jan
--
Siemens AG, Technology
Competence Center Embedded LinuxQuoted 6 lines
Quoted 2 lines
Could you cherry-pick this commit to 3.0.x and 3.1.x aswell please?
I can. I was just not expecting someone starting something new with clang on these old versions now. If you change something as fundamental as the compiler, why sticking with that versions?
Quoted 9 lines
I am trying to setup a build-server which uses clang, for using sanitzers, codecoverage
and code-quality. We wont change the compiler and don't want to change the xenomai version.I guess I could just use a newer version of xenomai for the tests without adverse effects,
but so far I only have one xenomai version for everything.
Ok, point taken, 3.1.x updated. 3.0.x didn't have that testcase. If something else is broken /wrt clang in that version, please send a specific patch.
Jan
Signature · 2 lines
Siemens AG, Technology Competence Center Embedded Linux