diff options
Diffstat (limited to 'src/mesa/main/imports.c')
-rw-r--r-- | src/mesa/main/imports.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 7d4b1200992..1aebb25163f 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -104,6 +104,8 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment) (void) posix_memalign(& mem, alignment, bytes); return mem; +#elif defined(_WIN32) && defined(_MSC_VER) + return _aligned_malloc(bytes, alignment); #else uintptr_t ptr, buf; @@ -144,6 +146,15 @@ _mesa_align_calloc(size_t bytes, unsigned long alignment) } return mem; +#elif defined(_WIN32) && defined(_MSC_VER) + void *mem; + + mem = _aligned_malloc(bytes, alignment); + if (mem != NULL) { + (void) memset(mem, 0, bytes); + } + + return mem; #else uintptr_t ptr, buf; @@ -180,6 +191,8 @@ _mesa_align_free(void *ptr) { #if defined(HAVE_POSIX_MEMALIGN) free(ptr); +#elif defined(_WIN32) && defined(_MSC_VER) + _aligned_free(ptr); #else void **cubbyHole = (void **) ((char *) ptr - sizeof(void *)); void *realAddr = *cubbyHole; @@ -194,6 +207,10 @@ void * _mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, unsigned long alignment) { +#if defined(_WIN32) && defined(_MSC_VER) + (void) oldSize; + return _aligned_realloc(oldBuffer, newSize, alignment); +#else const size_t copySize = (oldSize < newSize) ? oldSize : newSize; void *newBuf = _mesa_align_malloc(newSize, alignment); if (newBuf && oldBuffer && copySize > 0) { @@ -202,6 +219,7 @@ _mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, if (oldBuffer) _mesa_align_free(oldBuffer); return newBuf; +#endif } |