1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

Cleanup compile warnings.

2013-12-19  Paul Pluzhnikov  <ppluzhnikov@google.com>

	* elf/dl-misc.c (ptr_to_signal_safe_allocator_header): New function.
	(__signal_safe_memalign, __signal_safe_free): Use it.
	(__signal_safe_realloc): Likewise.
This commit is contained in:
Paul Pluzhnikov
2013-12-19 10:25:23 -08:00
parent 21fea2e228
commit 063b2acbce
2 changed files with 21 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2013-12-19 Paul Pluzhnikov <ppluzhnikov@google.com>
* elf/dl-misc.c (ptr_to_signal_safe_allocator_header): New function.
(__signal_safe_memalign, __signal_safe_free): Use it.
(__signal_safe_realloc): Likewise.
2013-12-19 Joseph Myers <joseph@codesourcery.com> 2013-12-19 Joseph Myers <joseph@codesourcery.com>
* manual/texinfo.tex: Update to version 2013-11-26.10 with * manual/texinfo.tex: Update to version 2013-11-26.10 with

View File

@ -380,15 +380,23 @@ struct __signal_safe_allocator_header
void *start; void *start;
}; };
static inline struct __signal_safe_allocator_header *
ptr_to_signal_safe_allocator_header (void *ptr)
{
return (struct __signal_safe_allocator_header *)
((char *) (ptr) - sizeof (struct __signal_safe_allocator_header));
}
void *weak_function void *weak_function
__signal_safe_memalign (size_t boundary, size_t size) __signal_safe_memalign (size_t boundary, size_t size)
{ {
struct __signal_safe_allocator_header *header; struct __signal_safe_allocator_header *header;
if (boundary < sizeof (*header)) if (boundary < sizeof (*header))
boundary = sizeof (*header); boundary = sizeof (*header);
/* Boundary must be a power of two. */ /* Boundary must be a power of two. */
if (boundary & (boundary - 1) == 0) if ((boundary & (boundary - 1)) == 0)
return NULL; return NULL;
size_t pg = GLRO (dl_pagesize); size_t pg = GLRO (dl_pagesize);
@ -432,9 +440,9 @@ __signal_safe_memalign (size_t boundary, size_t size)
actual = (void *) ((start_pg - 1) * pg); actual = (void *) ((start_pg - 1) * pg);
} }
char *start = (void *) (start_pg * pg); char *start = (void *) (start_pg * pg);
header = start - sizeof (*header); header = ptr_to_signal_safe_allocator_header (start);
} }
header->size = actual_size; header->size = actual_size;
header->start = actual; header->start = actual;
void *ptr = header; void *ptr = header;
@ -456,7 +464,8 @@ __signal_safe_free (void *ptr)
if (ptr == NULL) if (ptr == NULL)
return; return;
struct __signal_safe_allocator_header *header = ((char *) ptr) - sizeof (*header); struct __signal_safe_allocator_header *header
= ptr_to_signal_safe_allocator_header (ptr);
int ret = munmap (header->start, header->size); int ret = munmap (header->start, header->size);
assert (ret == 0); assert (ret == 0);
@ -473,7 +482,8 @@ __signal_safe_realloc (void *ptr, size_t size)
if (ptr == NULL) if (ptr == NULL)
return __signal_safe_malloc (size); return __signal_safe_malloc (size);
struct __signal_safe_allocator_header *header = ((char *) ptr) - sizeof (*header); struct __signal_safe_allocator_header *header
= ptr_to_signal_safe_allocator_header (ptr);
size_t old_size = header->size; size_t old_size = header->size;
if (old_size - sizeof (*header) >= size) if (old_size - sizeof (*header) >= size)
return ptr; return ptr;