emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Override Windows default Win-* key combinations when using E


From: Yuri Khan
Subject: Re: [PATCH] Override Windows default Win-* key combinations when using Emacs
Date: Fri, 15 Jan 2016 15:23:56 +0600

On Fri, Jan 15, 2016 at 1:52 PM, Jussi Lahdenniemi <address@hidden> wrote:

> So, apparently, on Windows 98 HeapAlloc does not guarantee 8-byte alignment
> of memory.  Not that this would be documented anywhere...

By the Rules As Written, absence of a documented minimum alignment
should be interpreted as permission for the implementation to return
any unaligned addresses.

In practice, a particular implementation of HeapAlloc is likely to
satisfy the requirements of C’s malloc and C++’s operator new, which
guarantee alignment suitable for any object.

On a 32-bit x86 system, 4-byte alignment is not strictly required for
32-bit quantities, but gives a performance benefit, so HeapAlloc is
likely to yield 4-byte-aligned blocks.

> How should we fix this?  I can write and test the fix, but I'd like to hear
> your opinion on the preferred mechanism.

I have seen one library implement an aligned allocator this way:

* When a block of size N aligned to A bytes is requested, allocate an
unaligned block of size N + sizeof(void*) + (A - 1). Let’s call its
starting address P. Calculate the result address P' as (P +
sizeof(void*) + (A - 1)) & ~(A - 1). Store the value of P at address
P' - sizeof(void*). Return P'.

* When the aligned block at address P' is freed and P' is not null,
read the pointer value P from address P' - sizeof(void*). Free the
unaligned block starting at P.

(Obviously this scheme is not particularly efficient for small allocations.)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]