Commit 0b87e18e by David Chad Committed by Loren J. Rittle

(in libobjc:)

	libobjc/8562
(in libobjc:)
	* objc/hash.h (hash_string): Constify correctly.
	(compare_ptrs): Use direct compare.
	* objc/objc-list.h (list_nth): Rename index to indx to avoid shadow.
	* objc/sarray.h: Global rename index to indx to avoid shadow.

(in gcc/testsuite:)
	* objc.dg/headers.m: New test.

Co-Authored-By: Loren J. Rittle <ljrittle@acm.org>

From-SVN: r65461
parent 339a28b9
2003-04-11 David Chad <davidc@freebsd.org>
Loren J. Rittle <ljrittle@acm.org>
libobjc/8562
* objc.dg/headers.m: New test.
2003-04-10 Zack Weinberg <zack@codesourcery.com> 2003-04-10 Zack Weinberg <zack@codesourcery.com>
* gcc.c-torture/execute/builtin-noret-2.c: New. * gcc.c-torture/execute/builtin-noret-2.c: New.
......
// Test for obscure conflicts with the system headers (inspired by similar
// test in libstdc++-v3). Author: Loren J. Rittle <ljrittle@acm.org>.
// { dg-options "-Wall -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wshadow" }
// { dg-do compile }
#include <objc/NXConstStr.h>
#include <objc/Object.h>
#include <objc/Protocol.h>
#include <objc/encoding.h>
#include <objc/hash.h>
#include <objc/objc-api.h>
#include <objc/objc-list.h>
#include <objc/objc.h>
#include <objc/sarray.h>
#include <objc/thr.h>
#include <objc/typedstream.h>
2003-04-11 David Chad <davidc@freebsd.org>
Loren J. Rittle <ljrittle@acm.org>
libobjc/8562
* objc/hash.h (hash_string): Constify correctly.
(compare_ptrs): Use direct compare.
* objc/objc-list.h (list_nth): Rename index to indx to avoid shadow.
* objc/sarray.h: Global rename index to indx to avoid shadow.
2003-03-12 Andreas Schwab <schwab@suse.de> 2003-03-12 Andreas Schwab <schwab@suse.de>
* aclocal.m4 (GLIBCPP_EXPORT_INSTALL_INFO): Avoid trailing /. in * aclocal.m4 (GLIBCPP_EXPORT_INSTALL_INFO): Avoid trailing /. in
......
...@@ -174,8 +174,8 @@ hash_string (cache_ptr cache, const void *key) ...@@ -174,8 +174,8 @@ hash_string (cache_ptr cache, const void *key)
unsigned int ctr = 0; unsigned int ctr = 0;
while (*(char *) key) { while (*(const char *) key) {
ret ^= *(char *) key++ << ctr; ret ^= *((const char *) key)++ << ctr;
ctr = (ctr + 1) % sizeof (void *); ctr = (ctr + 1) % sizeof (void *);
} }
...@@ -187,7 +187,7 @@ hash_string (cache_ptr cache, const void *key) ...@@ -187,7 +187,7 @@ hash_string (cache_ptr cache, const void *key)
static inline int static inline int
compare_ptrs (const void *k1, const void *k2) compare_ptrs (const void *k1, const void *k2)
{ {
return ! (k1 - k2); return (k1 == k2);
} }
......
...@@ -64,9 +64,9 @@ list_length(struct objc_list* list) ...@@ -64,9 +64,9 @@ list_length(struct objc_list* list)
larger than the list length, NULL is returned */ larger than the list length, NULL is returned */
static inline void* static inline void*
list_nth(int index, struct objc_list* list) list_nth(int indx, struct objc_list* list)
{ {
while(index-- != 0) while(indx-- != 0)
{ {
if(list->tail) if(list->tail)
list = list->tail; list = list->tail;
......
...@@ -146,8 +146,8 @@ struct sarray* sarray_new(int, void* default_element); ...@@ -146,8 +146,8 @@ struct sarray* sarray_new(int, void* default_element);
void sarray_free(struct sarray*); void sarray_free(struct sarray*);
struct sarray* sarray_lazy_copy(struct sarray*); struct sarray* sarray_lazy_copy(struct sarray*);
void sarray_realloc(struct sarray*, int new_size); void sarray_realloc(struct sarray*, int new_size);
void sarray_at_put(struct sarray*, sidx index, void* elem); void sarray_at_put(struct sarray*, sidx indx, void* elem);
void sarray_at_put_safe(struct sarray*, sidx index, void* elem); void sarray_at_put_safe(struct sarray*, sidx indx, void* elem);
struct sarray* sarray_hard_copy(struct sarray*); /* ... like the name? */ struct sarray* sarray_hard_copy(struct sarray*); /* ... like the name? */
void sarray_remove_garbage(void); void sarray_remove_garbage(void);
...@@ -156,10 +156,10 @@ void sarray_remove_garbage(void); ...@@ -156,10 +156,10 @@ void sarray_remove_garbage(void);
#ifdef PRECOMPUTE_SELECTORS #ifdef PRECOMPUTE_SELECTORS
/* Transform soffset values to ints and vica verca */ /* Transform soffset values to ints and vica verca */
static inline unsigned int static inline unsigned int
soffset_decode(sidx index) soffset_decode(sidx indx)
{ {
union sofftype x; union sofftype x;
x.idx = index; x.idx = indx;
#ifdef OBJC_SPARSE3 #ifdef OBJC_SPARSE3
return x.off.eoffset return x.off.eoffset
+ (x.off.boffset*BUCKET_SIZE) + (x.off.boffset*BUCKET_SIZE)
...@@ -186,9 +186,9 @@ soffset_encode(size_t offset) ...@@ -186,9 +186,9 @@ soffset_encode(size_t offset)
#else /* not PRECOMPUTE_SELECTORS */ #else /* not PRECOMPUTE_SELECTORS */
static inline size_t static inline size_t
soffset_decode(sidx index) soffset_decode(sidx indx)
{ {
return index; return indx;
} }
static inline sidx static inline sidx
...@@ -198,13 +198,13 @@ soffset_encode(size_t offset) ...@@ -198,13 +198,13 @@ soffset_encode(size_t offset)
} }
#endif /* not PRECOMPUTE_SELECTORS */ #endif /* not PRECOMPUTE_SELECTORS */
/* Get element from the Sparse array `array' at offset `index' */ /* Get element from the Sparse array `array' at offset `indx' */
static inline void* sarray_get(struct sarray* array, sidx index) static inline void* sarray_get(struct sarray* array, sidx indx)
{ {
#ifdef PRECOMPUTE_SELECTORS #ifdef PRECOMPUTE_SELECTORS
union sofftype x; union sofftype x;
x.idx = index; x.idx = indx;
#ifdef OBJC_SPARSE3 #ifdef OBJC_SPARSE3
return return
array-> array->
...@@ -217,19 +217,19 @@ static inline void* sarray_get(struct sarray* array, sidx index) ...@@ -217,19 +217,19 @@ static inline void* sarray_get(struct sarray* array, sidx index)
#else /* not PRECOMPUTE_SELECTORS */ #else /* not PRECOMPUTE_SELECTORS */
#ifdef OBJC_SPARSE3 #ifdef OBJC_SPARSE3
return array-> return array->
indices[index/INDEX_CAPACITY]-> indices[indx/INDEX_CAPACITY]->
buckets[(index/BUCKET_SIZE)%INDEX_SIZE]-> buckets[(indx/BUCKET_SIZE)%INDEX_SIZE]->
elems[index%BUCKET_SIZE]; elems[indx%BUCKET_SIZE];
#else /* OBJC_SPARSE2 */ #else /* OBJC_SPARSE2 */
return array->buckets[index/BUCKET_SIZE]->elems[index%BUCKET_SIZE]; return array->buckets[indx/BUCKET_SIZE]->elems[indx%BUCKET_SIZE];
#endif /* not OBJC_SPARSE3 */ #endif /* not OBJC_SPARSE3 */
#endif /* not PRECOMPUTE_SELECTORS */ #endif /* not PRECOMPUTE_SELECTORS */
} }
static inline void* sarray_get_safe(struct sarray* array, sidx index) static inline void* sarray_get_safe(struct sarray* array, sidx indx)
{ {
if(soffset_decode(index) < array->capacity) if(soffset_decode(indx) < array->capacity)
return sarray_get(array, index); return sarray_get(array, indx);
else else
return (array->empty_bucket->elems[0]); return (array->empty_bucket->elems[0]);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment