aboutsummaryrefslogtreecommitdiffstats
path: root/src/gmalloc.c
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2007-08-09 03:07:07 +0000
committerYAMAMOTO Mitsuharu2007-08-09 03:07:07 +0000
commit72359c326537cd6986b5f6ba9c8833b268d24c93 (patch)
tree46ff4808e54c2ecb96044dae7a4882262f85e3b9 /src/gmalloc.c
parent22ce475b428311f8c7cfb07dbf12103097ab7d02 (diff)
downloademacs-72359c326537cd6986b5f6ba9c8833b268d24c93.tar.gz
emacs-72359c326537cd6986b5f6ba9c8833b268d24c93.zip
(posix_memalign): New function.
Diffstat (limited to 'src/gmalloc.c')
-rw-r--r--src/gmalloc.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/gmalloc.c b/src/gmalloc.c
index ea6ccc4bf1f..ccc08e1ff68 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -129,6 +129,8 @@ extern FREE_RETURN_TYPE free PP ((__ptr_t __ptr));
129#if ! (defined (_MALLOC_INTERNAL) && __DJGPP__ - 0 == 1) /* Avoid conflict. */ 129#if ! (defined (_MALLOC_INTERNAL) && __DJGPP__ - 0 == 1) /* Avoid conflict. */
130extern __ptr_t memalign PP ((__malloc_size_t __alignment, 130extern __ptr_t memalign PP ((__malloc_size_t __alignment,
131 __malloc_size_t __size)); 131 __malloc_size_t __size));
132extern int posix_memalign PP ((__ptr_t *, __malloc_size_t,
133 __malloc_size_t size));
132#endif 134#endif
133 135
134/* Allocate SIZE bytes on a page boundary. */ 136/* Allocate SIZE bytes on a page boundary. */
@@ -1857,6 +1859,36 @@ memalign (alignment, size)
1857 return result; 1859 return result;
1858} 1860}
1859 1861
1862#ifndef ENOMEM
1863#define ENOMEM 12
1864#endif
1865
1866#ifndef EINVAL
1867#define EINVAL 22
1868#endif
1869
1870int
1871posix_memalign (memptr, alignment, size)
1872 __ptr_t *memptr;
1873 __malloc_size_t alignment;
1874 __malloc_size_t size;
1875{
1876 __ptr_t mem;
1877
1878 if (alignment == 0
1879 || alignment % sizeof (__ptr_t) != 0
1880 || (alignment & (alignment - 1)) != 0)
1881 return EINVAL;
1882
1883 mem = memalign (alignment, size);
1884 if (mem == NULL)
1885 return ENOMEM;
1886
1887 *memptr = mem;
1888
1889 return 0;
1890}
1891
1860#endif /* Not DJGPP v1 */ 1892#endif /* Not DJGPP v1 */
1861/* Allocate memory on a page boundary. 1893/* Allocate memory on a page boundary.
1862 Copyright (C) 1991, 92, 93, 94, 96 Free Software Foundation, Inc. 1894 Copyright (C) 1991, 92, 93, 94, 96 Free Software Foundation, Inc.