diff options
| author | YAMAMOTO Mitsuharu | 2007-08-09 03:08:25 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2007-08-09 03:08:25 +0000 |
| commit | e575132a04bbe03469d5a1048dbc620414d6fe9c (patch) | |
| tree | ec91df8ec85b2c6790471fdf07937a7a61c99d43 /src/gmalloc.c | |
| parent | 6e4a68d2b8e03f4a2f74c73a2af640f84e94b929 (diff) | |
| download | emacs-e575132a04bbe03469d5a1048dbc620414d6fe9c.tar.gz emacs-e575132a04bbe03469d5a1048dbc620414d6fe9c.zip | |
(posix_memalign): New function.
Diffstat (limited to 'src/gmalloc.c')
| -rw-r--r-- | src/gmalloc.c | 32 |
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. */ |
| 130 | extern __ptr_t memalign PP ((__malloc_size_t __alignment, | 130 | extern __ptr_t memalign PP ((__malloc_size_t __alignment, |
| 131 | __malloc_size_t __size)); | 131 | __malloc_size_t __size)); |
| 132 | extern 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 | |||
| 1870 | int | ||
| 1871 | posix_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. |