[SR-Users] What is the alignment of shm_malloc and friends?

Richard Chan shihping.chan at gmail.com
Wed Jun 22 02:25:12 CEST 2022


Hello Daniel,

On Mon, 20 Jun 2022 at 19:09, Daniel-Constantin Mierla <miconda at gmail.com>
wrote:

> Hello,
>
> iirc, the alignment is to sizeof(void*), which is 8.
>

The qm allocator naturally returns 16-byte aligned memory. However the
definition
of DBG_SR_MEMORY(from 'make cfg' with all the defaults.) causes 16 to drop
to 8.

Is this intentional?

Regards
S-P
//qm naturally aligns on 16 bytes without DBG_QM_MALLOC!

#ifdef DBG_QM_MALLOC
#if defined(__CPU_sparc64) || defined(__CPU_sparc)
/* tricky, on sun in 32 bits mode long long must be 64 bits aligned
 * but long can be 32 bits aligned => malloc should return long long
 * aligned memory */
        #define ROUNDTO         sizeof(long long)
#else
        #define ROUNDTO         sizeof(void*) /* minimum possible ROUNDTO

    * ->heavy debugging*/
#endif
#else /* DBG_QM_MALLOC */
        #define ROUNDTO         16UL /* size we round to, must be = 2^n
 and also
                                                        *
sizeof(qm_frag)+sizeof(qm_frag_end)
                                                        * must be multiple
of ROUNDTO!
                                                        */
#endif
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20220622/37a7082c/attachment.htm>


More information about the sr-users mailing list