This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch v-1.28
in repository efl.

View the commit online.

commit ae7ff37e02ab579c73fd4112ea50e6457c514294
Author: Michael Karcher <enlightenm...@mkarcher.dialup.fu-berlin.de>
AuthorDate: Fri Mar 14 21:41:27 2025 +0100

    Ensure architecture-dependent alignement of thread queue messages in blocks
    
    This is a portable approximation to solving the alignment issue. While the documentation claims
    a general 8-byte alignment, this alignment was never provided, and it seems alignment for the
    standard C types is sufficient. This will still be insufficient for SSE types on x86 which may
    require 16-byte alignment, but this would involve deeper changes, at least increasing the
    allocation granularity from 8 to 16 bytes.
---
 src/lib/eina/eina_thread_queue.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/lib/eina/eina_thread_queue.c b/src/lib/eina/eina_thread_queue.c
index e0410185f1..37d54959ea 100644
--- a/src/lib/eina/eina_thread_queue.c
+++ b/src/lib/eina/eina_thread_queue.c
@@ -51,6 +51,17 @@ struct _Eina_Thread_Queue
    int                           fd; // optional fd to write byte to on msg
 };
 
+typedef union _Eina_Thread_Queue_Msg_Aligned Eina_Thread_Queue_Msg_Aligned;
+
+union _Eina_Thread_Queue_Msg_Aligned
+{
+   Eina_Thread_Queue_Msg         msg; // actual message
+   void*                         alignment_for_ptr;
+   long long                     alignment_for_integer;
+   double                        alignment_for_floating_point_1;
+   long double                   alignment_for_floating_point_2;
+};
+
 struct _Eina_Thread_Queue_Msg_Block
 {
    Eina_Thread_Queue_Msg_Block  *next; // next block in the list
@@ -64,11 +75,11 @@ struct _Eina_Thread_Queue_Msg_Block
    int                           first; // the byte pos of the first msg
    int                           last; // the byte pos just after the last msg
    Eina_Bool                     full : 1; // is this block full yet?
-   Eina_Thread_Queue_Msg         data[1]; // data in memory beyond struct end
+   Eina_Thread_Queue_Msg_Aligned data[1]; // data in memory beyond struct end
 };
 
 // the minimum size of any message block holding 1 or more messages
-#define MIN_SIZE ((int)(4096 - sizeof(Eina_Thread_Queue_Msg_Block) + sizeof(Eina_Thread_Queue_Msg)))
+#define MIN_SIZE ((int)(4096 - sizeof(Eina_Thread_Queue_Msg_Block) + sizeof(Eina_Thread_Queue_Msg_Aligned)))
 
 // a pool of spare message blocks that are only of the minimum size so we
 // avoid reallocation via malloc/free etc. to avoid free memory pages and
@@ -115,7 +126,7 @@ _eina_thread_queue_msg_block_new(int size)
    eina_spinlock_release(&(_eina_thread_queue_block_pool_lock));
 
    blk = malloc(sizeof(Eina_Thread_Queue_Msg_Block) -
-                sizeof(Eina_Thread_Queue_Msg) +
+                sizeof(Eina_Thread_Queue_Msg_Aligned) +
                 size);
    if (!blk)
      {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to