[gegl] buffer: align stack allocation on 16bytes
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: align stack allocation on 16bytes
- Date: Tue, 30 Jan 2018 16:30:26 +0000 (UTC)
commit 95ecbebb87b0c81201554fe09a9c3123ecd4e792
Author: Øyvind Kolås <pippin gimp org>
Date: Tue Jan 30 17:26:05 2018 +0100
buffer: align stack allocation on 16bytes
gegl/buffer/gegl-buffer-access.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index fa7063d..1b9b3b8 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -1882,6 +1882,14 @@ _gegl_get_required_for_scale (const Babl *format,
}
}
+#define ALIGN 16
+static void inline *align_16 (unsigned char *ret)
+{
+ int offset = ALIGN - ((uintptr_t) ret) % ALIGN;
+ ret = ret + offset;
+ return ret;
+}
+
static inline void
_gegl_buffer_get_unlocked (GeglBuffer *buffer,
gdouble scale,
@@ -1981,11 +1989,11 @@ _gegl_buffer_get_unlocked (GeglBuffer *buffer,
chunk_height = 4;
allocated = max_bytes_per_row * ((chunk_height+1) * 2);
- if (allocated > GEGL_ALLOCA_THRESHOLD)
+ if (allocated > GEGL_ALLOCA_THRESHOLD || 1)
sample_buf = g_malloc (allocated);
else
{
- sample_buf = alloca (allocated);
+ sample_buf = align_16 (alloca (allocated + 16));
allocated = 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]