[v2,1/8] gdb/testsuite: Add Windows replacement for aligned_alloc
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
Commit Message
_aligned_malloc has swapped arguments, and you have to use _aligned_free
to free the memory afterwards.
This is enough to make i386-sse.exp pass, and i386-avx.exp will pass at
the end of this series.
---
v2:
- Mention which test pass after the change in the commit message
---
gdb/testsuite/gdb.arch/i386-avx.c | 2 +-
gdb/testsuite/gdb.arch/i386-sse.c | 2 +-
gdb/testsuite/lib/precise-aligned-alloc.c | 20 ++++++++++++++++++++
3 files changed, 22 insertions(+), 2 deletions(-)
Comments
Hi,
Just wondering if there are any tests planned or if the current tests
are enough and what their results are.
On 27/07/2026 18:42, Hannes Domani wrote:
> _aligned_malloc has swapped arguments, and you have to use _aligned_free
> to free the memory afterwards.
>
> This is enough to make i386-sse.exp pass, and i386-avx.exp will pass at
> the end of this series.
> ---
> v2:
> - Mention which test pass after the change in the commit message
> ---
> gdb/testsuite/gdb.arch/i386-avx.c | 2 +-
> gdb/testsuite/gdb.arch/i386-sse.c | 2 +-
> gdb/testsuite/lib/precise-aligned-alloc.c | 20 ++++++++++++++++++++
> 3 files changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.arch/i386-avx.c b/gdb/testsuite/gdb.arch/i386-avx.c
> index b6cd89e5bea..229093e5164 100644
> --- a/gdb/testsuite/gdb.arch/i386-avx.c
> +++ b/gdb/testsuite/gdb.arch/i386-avx.c
> @@ -116,7 +116,7 @@ main (int argc, char **argv)
>
> puts ("Bye!"); /* second breakpoint here */
>
> - free (allocated_ptr);
> + aligned_free (allocated_ptr);
>
> return 0;
> }
> diff --git a/gdb/testsuite/gdb.arch/i386-sse.c b/gdb/testsuite/gdb.arch/i386-sse.c
> index 21264ed74e7..5210aee12c3 100644
> --- a/gdb/testsuite/gdb.arch/i386-sse.c
> +++ b/gdb/testsuite/gdb.arch/i386-sse.c
> @@ -134,7 +134,7 @@ main (int argc, char **argv)
> puts ("Bye!"); /* second breakpoint here */
> }
>
> - free (allocated_ptr);
> + aligned_free (allocated_ptr);
>
> return 0;
> }
> diff --git a/gdb/testsuite/lib/precise-aligned-alloc.c b/gdb/testsuite/lib/precise-aligned-alloc.c
> index 888814f12ef..1db35528bc8 100644
> --- a/gdb/testsuite/lib/precise-aligned-alloc.c
> +++ b/gdb/testsuite/lib/precise-aligned-alloc.c
> @@ -21,6 +21,26 @@
> #include <string.h>
> #include <stdint.h>
>
> +#ifdef _WIN32
> +static void *
> +aligned_alloc (size_t alignment, size_t size)
> +{
> + return _aligned_malloc (size, alignment);
> +}
> +
> +static void
> +aligned_free (void *ptr)
> +{
> + _aligned_free (ptr);
> +}
> +#else
> +static void
> +aligned_free (void *ptr)
> +{
> + free (ptr);
> +}
> +#endif
> +
> /* Return true if address P is ALIGNMENT-byte aligned. */
>
> static int
Am Donnerstag, 13. August 2026 um 00:00:55 MESZ hat Luis <luis.machado.foss@gmail.com> Folgendes geschrieben:
> Hi,
>
> Just wondering if there are any tests planned or if the current tests
> are enough and what their results are.
Planned tests for what?
And what exactly do you want to know of the mentioned tests besides that they pass?
Hannes
@@ -116,7 +116,7 @@ main (int argc, char **argv)
puts ("Bye!"); /* second breakpoint here */
- free (allocated_ptr);
+ aligned_free (allocated_ptr);
return 0;
}
@@ -134,7 +134,7 @@ main (int argc, char **argv)
puts ("Bye!"); /* second breakpoint here */
}
- free (allocated_ptr);
+ aligned_free (allocated_ptr);
return 0;
}
@@ -21,6 +21,26 @@
#include <string.h>
#include <stdint.h>
+#ifdef _WIN32
+static void *
+aligned_alloc (size_t alignment, size_t size)
+{
+ return _aligned_malloc (size, alignment);
+}
+
+static void
+aligned_free (void *ptr)
+{
+ _aligned_free (ptr);
+}
+#else
+static void
+aligned_free (void *ptr)
+{
+ free (ptr);
+}
+#endif
+
/* Return true if address P is ALIGNMENT-byte aligned. */
static int