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 | |
| parent | 6e4a68d2b8e03f4a2f74c73a2af640f84e94b929 (diff) | |
| download | emacs-e575132a04bbe03469d5a1048dbc620414d6fe9c.tar.gz emacs-e575132a04bbe03469d5a1048dbc620414d6fe9c.zip | |
(posix_memalign): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/gmalloc.c | 32 |
2 files changed, 38 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index adef925992c..20469ca12e3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2007-08-09 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | ||
| 2 | |||
| 3 | * gmalloc.c (posix_memalign): New function. | ||
| 4 | |||
| 1 | 2007-08-08 Glenn Morris <rgm@gnu.org> | 5 | 2007-08-08 Glenn Morris <rgm@gnu.org> |
| 2 | 6 | ||
| 3 | * Replace `iff' in doc-strings and comments. | 7 | * Replace `iff' in doc-strings and comments. |
| @@ -31,8 +35,8 @@ | |||
| 31 | Call malloc_enable_thread on interactive startup. | 35 | Call malloc_enable_thread on interactive startup. |
| 32 | 36 | ||
| 33 | * gmalloc.c (_malloc_thread_enabled_p) [USE_PTHREAD]: New variable. | 37 | * gmalloc.c (_malloc_thread_enabled_p) [USE_PTHREAD]: New variable. |
| 34 | [USE_PTHREAD] (LOCK, UNLOCK, LOCK_ALIGNED_BLOCKS) | 38 | (LOCK, UNLOCK, LOCK_ALIGNED_BLOCKS, UNLOCK_ALIGNED_BLOCKS) |
| 35 | (UNLOCK_ALIGNED_BLOCKS): Conditionalize with it. | 39 | [USE_PTHREAD]: Conditionalize with it. |
| 36 | (malloc_atfork_handler_prepare, malloc_atfork_handler_parent) | 40 | (malloc_atfork_handler_prepare, malloc_atfork_handler_parent) |
| 37 | (malloc_atfork_handler_child, malloc_enable_thread) [USE_PTHREAD]: | 41 | (malloc_atfork_handler_child, malloc_enable_thread) [USE_PTHREAD]: |
| 38 | New functions. | 42 | New functions. |
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. |