OSDN Git Service

util: Add a virtual memory allocator
authorJason Ekstrand <jason.ekstrand@intel.com>
Sun, 7 Jan 2018 01:28:01 +0000 (17:28 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 31 May 2018 23:17:35 +0000 (16:17 -0700)
commitf19ad5d31fde8c447119c5483b3e3972922e9991
tree7d7d91d7ed9cd07b9d6f7cca6b51db4dd2366ad5
parentb9fb2c266a4b1058a1f7befd97320769d5d0a18b
util: Add a virtual memory allocator

This is simple linear-walk first-fit allocator roughly based on the
allocator in the radeon winsys code.  This allocator has two primary
functional differences:

 1) It cleanly returns 0 on allocation failure

 2) It allocates addresses top-down instead of bottom-up.

The second one is needed for Intel because high addresses (with bit 47
set) need to be canonicalized in order to work properly.  If we allocate
bottom-up, then high addresses will be very rare (if they ever happen).
We'd rather always have high addresses so that the canonicalization code
gets better testing.

v2: - [scott-ph] remove _heap_validate() if NDEBUG is defined (Jordan)

Reviewed-by: Scott D Phillips <scott.d.phillips@intel.com>
Tested-by: Scott D Phillips <scott.d.phillips@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/util/Makefile.sources
src/util/meson.build
src/util/vma.c [new file with mode: 0644]
src/util/vma.h [new file with mode: 0644]