summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <idr@us.ibm.com>2006-08-16 17:06:08 +0000
committerIan Romanick <idr@us.ibm.com>2006-08-16 17:06:08 +0000
commita7d02567451f69445ef31181a41b16e86487093d (patch)
tree6e42bb8e124f17e6f5e8b0b5dcc76b0832d6e997
parentab6cf9dd622c4659aa5f47cb1b5f86b8e38d5a85 (diff)
When available, which is most of the time, use posix_memalign to implement
_mesa_align_malloc and friends.
-rw-r--r--configs/freebsd3
-rw-r--r--configs/freebsd-dri2
-rw-r--r--configs/linux2
-rw-r--r--configs/linux-dri2
-rw-r--r--configs/linux-dri-xcb2
-rw-r--r--configs/linux-indirect2
-rw-r--r--configs/linux-solo2
-rw-r--r--configs/linux-sparc2
-rw-r--r--src/mesa/main/imports.c24
9 files changed, 30 insertions, 11 deletions
diff --git a/configs/freebsd b/configs/freebsd
index f7f967169b..38806ab946 100644
--- a/configs/freebsd
+++ b/configs/freebsd
@@ -15,7 +15,8 @@ COPY_LIBS = cp -f
OPT_FLAGS = -O2
PIC_FLAGS = -fPIC
-DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -DUSE_XSHM -DHZ=100
+DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -DUSE_XSHM \
+ -DHZ=100 -DHAVE_POSIX_MEMALIGN
X11_INCLUDES = -I/usr/X11R6/include
diff --git a/configs/freebsd-dri b/configs/freebsd-dri
index 525ebd08b7..104e242289 100644
--- a/configs/freebsd-dri
+++ b/configs/freebsd-dri
@@ -14,7 +14,7 @@ OPT_FLAGS = -O
EXPAT_INCLUDES = -I/usr/local/include
X11_INCLUDES = -I/usr/X11R6/include
DEFINES = -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER \
- -DGLX_DIRECT_RENDERING -DHAVE_ALIAS
+ -DGLX_DIRECT_RENDERING -DHAVE_ALIAS -DHAVE_POSIX_MEMALIGN
CFLAGS = -Wmissing-prototypes -g -std=c99 -Wundef -fPIC -ffast-math \
$(ASM_FLAGS) $(X11_INCLUDES) $(DEFINES)
diff --git a/configs/linux b/configs/linux
index 2526bb7ebc..6736f14e0d 100644
--- a/configs/linux
+++ b/configs/linux
@@ -17,7 +17,7 @@ PIC_FLAGS = -fPIC
ARCH_FLAGS ?=
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
- -D_BSD_SOURCE -DPTHREADS -DUSE_XSHM
+ -D_BSD_SOURCE -DPTHREADS -DUSE_XSHM -DHAVE_POSIX_MEMALIGN
X11_INCLUDES = -I/usr/X11R6/include
diff --git a/configs/linux-dri b/configs/linux-dri
index 2a2b9e3f2c..1c3b404cf3 100644
--- a/configs/linux-dri
+++ b/configs/linux-dri
@@ -22,7 +22,7 @@ ARCH_FLAGS ?=
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
-D_BSD_SOURCE -D_GNU_SOURCE \
-DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER \
- -DGLX_DIRECT_RENDERING -DHAVE_ALIAS
+ -DGLX_DIRECT_RENDERING -DHAVE_ALIAS -DHAVE_POSIX_MEMALIGN
X11_INCLUDES = -I/usr/X11R6/include
diff --git a/configs/linux-dri-xcb b/configs/linux-dri-xcb
index 17270601b2..68acb2f2b1 100644
--- a/configs/linux-dri-xcb
+++ b/configs/linux-dri-xcb
@@ -22,7 +22,7 @@ ARCH_FLAGS ?=
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
-D_BSD_SOURCE -D_GNU_SOURCE \
-DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER \
- -DGLX_DIRECT_RENDERING -DHAVE_ALIAS -DUSE_XCB
+ -DGLX_DIRECT_RENDERING -DHAVE_ALIAS -DUSE_XCB -DHAVE_POSIX_MEMALIGN
X11_INCLUDES = `pkg-config --cflags-only-I x11` `pkg-config --cflags-only-I xcb` `pkg-config --cflags-only-I xcb-glx`
diff --git a/configs/linux-indirect b/configs/linux-indirect
index 21546b68dc..b764515786 100644
--- a/configs/linux-indirect
+++ b/configs/linux-indirect
@@ -23,7 +23,7 @@ ARCH_FLAGS ?=
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
-D_BSD_SOURCE -D_GNU_SOURCE \
- -DPTHREADS -DHAVE_ALIAS
+ -DPTHREADS -DHAVE_ALIAS -DHAVE_POSIX_MEMALIGN
X11_INCLUDES = -I/usr/X11R6/include
diff --git a/configs/linux-solo b/configs/linux-solo
index 112cdd2864..730c245d90 100644
--- a/configs/linux-solo
+++ b/configs/linux-solo
@@ -16,7 +16,7 @@ PIC_FLAGS = -fPIC
ARCH_FLAGS ?=
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
- -D_BSD_SOURCE -D_GNU_SOURCE \
+ -D_BSD_SOURCE -D_GNU_SOURCE -DHAVE_POSIX_MEMALIGN \
-DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DDRM_USE_MALLOC -DIN_DRI_DRIVER
CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
diff --git a/configs/linux-sparc b/configs/linux-sparc
index e3bc9eb3d6..d9552e8d89 100644
--- a/configs/linux-sparc
+++ b/configs/linux-sparc
@@ -12,7 +12,7 @@ WARN_FLAGS = -Wall
OPT_FLAGS = -O2
PIC_FLAGS = -fPIC
-DEFINES = -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM
+DEFINES = -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DHAVE_POSIX_MEMALIGN
X11_INCLUDES = -I/usr/X11R6/include
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index b506f856a6..08f44a8f88 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -131,6 +131,12 @@ _mesa_free(void *ptr)
void *
_mesa_align_malloc(size_t bytes, unsigned long alignment)
{
+#if defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE))
+ void *mem;
+
+ (void) posix_memalign(& mem, alignment, bytes);
+ return mem;
+#else
uintptr_t ptr, buf;
ASSERT( alignment > 0 );
@@ -151,6 +157,7 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment)
#endif
return (void *) buf;
+#endif /* defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE)) */
}
/**
@@ -160,6 +167,16 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment)
void *
_mesa_align_calloc(size_t bytes, unsigned long alignment)
{
+#if defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE))
+ void *mem;
+
+ mem = _mesa_align_malloc(bytes, alignment);
+ if (mem != NULL) {
+ (void) memset(mem, 0, bytes);
+ }
+
+ return mem;
+#else
uintptr_t ptr, buf;
ASSERT( alignment > 0 );
@@ -180,6 +197,7 @@ _mesa_align_calloc(size_t bytes, unsigned long alignment)
#endif
return (void *)buf;
+#endif /* defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE)) */
}
/**
@@ -192,13 +210,13 @@ _mesa_align_calloc(size_t bytes, unsigned long alignment)
void
_mesa_align_free(void *ptr)
{
-#if 0
- _mesa_free( (void *)(*(unsigned long *)((unsigned long)ptr - sizeof(void *))) );
+#if defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE))
+ free(ptr);
#else
void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
void *realAddr = *cubbyHole;
_mesa_free(realAddr);
-#endif
+#endif /* defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE)) */
}
/**