[multiple changes]

2009-06-27  Kai Tietz  <kai.tietz@onevision.com>

	Merged from trunk rev/148061
	2009-06-01  Jakub Jelinek  <jakub@redhat.com>
	PR other/40024
	* emutls.c (__emutls_get_address): Change arr->size to mean number
	of allocated arr->data entries instead of # of slots + 1.

From-SVN: r149016
This commit is contained in:
Kai Tietz 2009-06-27 17:52:29 +00:00 committed by Kai Tietz
parent cde14f663c
commit cd18959eef
2 changed files with 13 additions and 5 deletions

View File

@ -1,3 +1,11 @@
2009-06-27 Kai Tietz <kai.tietz@onevision.com>
Merged from trunk rev/148061
2009-06-01 Jakub Jelinek <jakub@redhat.com>
PR other/40024
* emutls.c (__emutls_get_address): Change arr->size to mean number
of allocated arr->data entries instead of # of slots + 1.
2009-06-22 Steven Bosscher <steven@gcc.gnu.org>
Matthias Klose <doko@ubuntu.com>

View File

@ -155,23 +155,23 @@ __emutls_get_address (struct __emutls_object *obj)
if (__builtin_expect (arr == NULL, 0))
{
pointer size = offset + 32;
arr = calloc (size, sizeof (void *));
arr = calloc (size + 1, sizeof (void *));
if (arr == NULL)
abort ();
arr->size = size;
__gthread_setspecific (emutls_key, (void *) arr);
}
else if (__builtin_expect (offset >= arr->size, 0))
else if (__builtin_expect (offset > arr->size, 0))
{
pointer orig_size = arr->size;
pointer size = orig_size * 2;
if (offset >= size)
if (offset > size)
size = offset + 32;
arr = realloc (arr, size * sizeof (void *));
arr = realloc (arr, (size + 1) * sizeof (void *));
if (arr == NULL)
abort ();
arr->size = size;
memset (arr->data + orig_size - 1, 0,
memset (arr->data + orig_size, 0,
(size - orig_size) * sizeof (void *));
__gthread_setspecific (emutls_key, (void *) arr);
}