Patchwork libobjc: remove deprecated API (patch 5)

login
register
mail settings
Submitter Nicola Pero
Date June 3, 2011, 5:59 p.m.
Message ID <1307123970.1166115@www2.webmail.us>
Download mbox | patch
Permalink /patch/98616/
State New
Headers show

Comments

Nicola Pero - June 3, 2011, 5:59 p.m.
This patch removes objc/hash.h and objc/sarray.h, which had been deprecated in GCC 4.6.0.

Of course, libobjc still has its own private versions, but they are (finally!) private
so we have made another step towards being able to change the libobjc internals at will
without having to change the public API. :-)

Committed to trunk.

Thanks

Patch

Index: libobjc/Makefile.in
===================================================================
--- libobjc/Makefile.in (revision 174594)
+++ libobjc/Makefile.in (working copy)
@@ -122,10 +122,7 @@  OBJC_H = \
   objc-api.h \
   objc-decls.h \
   runtime.h \
-  thr.h \
-  \
-  hash.h \
-  sarray.h
+  thr.h
 
 # User-visible header files containing deprecated APIs, from the
 # objc/deprecated directory
@@ -135,14 +132,12 @@  OBJC_DEPRECATED_H = \
   Object.h \
   Protocol.h \
   STR.h \
-  hash.h \
   objc_get_uninstalled_dtable.h \
   objc_malloc.h \
   objc_msg_sendv.h \
   objc_object_alloc.h \
   objc_unexpected_exception.h \
   objc_valloc.h \
-  sarray.h \
   struct_objc_category.h \
   struct_objc_class.h \
   struct_objc_ivar.h \
Index: libobjc/objc-private/common.h
===================================================================
--- libobjc/objc-private/common.h       (revision 174593)
+++ libobjc/objc-private/common.h       (working copy)
@@ -28,11 +28,6 @@  see the files COPYING3 and COPYING.RUNTIME respect
 /* This file contains definitions that should be included by all .c
    and .m files in libobjc.  */
 
-/* This variable allows the public headers to determine when they are
-   being included by a file inside libobjc itself, or when they are
-   being included by an external file.  */
-#define GNU_LIBOBJC_COMPILING_LIBOBJC_ITSELF 1
-
 /* When debugging libobjc, add
 
    #define DEBUG 1
Index: libobjc/libobjc.def
===================================================================
--- libobjc/libobjc.def (revision 174593)
+++ libobjc/libobjc.def (working copy)
@@ -23,8 +23,6 @@  LIBRARY libobjc
 EXPORTS
 search_for_method_in_list
 objc_get_uninstalled_dtable
-objc_hash_is_key_in_hash
-hash_is_key_in_hash
 _objc_load_callback
 objc_malloc
 objc_atomic_malloc
@@ -106,22 +104,3 @@  objc_get_class
 objc_get_meta_class
 objc_lookup_class
 objc_next_class
-sarray_at_put
-sarray_at_put_safe
-sarray_free
-sarray_lazy_copy
-sarray_new
-sarray_realloc
-sarray_remove_garbage
-objc_hash_add
-hash_add
-objc_hash_delete
-hash_delete
-objc_hash_new
-hash_new
-objc_hash_next
-hash_next
-objc_hash_remove
-hash_remove
-objc_hash_value_for_key
-hash_value_for_key
Index: libobjc/ChangeLog
===================================================================
--- libobjc/ChangeLog   (revision 174607)
+++ libobjc/ChangeLog   (working copy)
@@ -1,5 +1,25 @@ 
 2011-06-03  Nicola Pero  <nicola.pero@meta-innovation.com>
 
+       * Makefile.in (OBJC_H): Removed hash.h and sarray.h.
+       (OBJC_DEPRECATED_H): Likewise.
+       * libobjc.def (objc_hash_new, objc_hash_delete, objc_hash_add,
+       objc_hash_remove, objc_hash_next, objc_hash_value_for_key,
+       objc_hash_is_key_in_hash, hash_add, hash_delete, hash_new,
+       hash_next, hash_remove, hash_value_for_key, hash_is_key_in_hash,
+       sarray_at_put, sarray_at_put_safe, sarray_free, sarray_lazy_copy,
+       sarray_new, sarray_realloc, sarray_remove_garbage): Removed.
+       * objc/sarray.h: Removed.
+       * objc/hash.h: Removed.
+       * objc/deprecated/sarray.h: Removed.
+       * objc/deprecated/hash.h: Removed.
+       * objc/Object.h: Do not include objc/deprecated/hash.h
+       * Object.m: Include string.h.
+       * objc/objc-api.h: Do not include objc/deprecated/hash.h.
+       * objc-private/common.h (GNU_LIBOBJC_COMPILING_LIBOBJC_ITSELF):
+       Removed.
+
+2011-06-03  Nicola Pero  <nicola.pero@meta-innovation.com>
+
        * Object.m ([-forward::]): Removed.
        * objc/deprecated/Object.h ([-forward::]): Removed.
        * sendmsg.c (__objc_forward): Updated comments.
Index: libobjc/Object.m
===================================================================
--- libobjc/Object.m    (revision 174607)
+++ libobjc/Object.m    (working copy)
@@ -25,6 +25,7 @@  see the files COPYING3 and COPYING.RUNTIME respect
 
 #include "objc-private/common.h"
 #include <stdarg.h>
+#include <string.h> /* For strcmp.  */
 #include <errno.h>
 #include "objc/Object.h"
 #include "objc/Protocol.h"
Index: libobjc/objc/sarray.h
===================================================================
--- libobjc/objc/sarray.h       (revision 174593)
+++ libobjc/objc/sarray.h       (working copy)
@@ -1,2 +0,0 @@ 
-#include "deprecated/sarray.h"
-
Index: libobjc/objc/Object.h
===================================================================
--- libobjc/objc/Object.h       (revision 174593)
+++ libobjc/objc/Object.h       (working copy)
@@ -57,7 +57,6 @@  extern "C" {
 
 /* All of the following includes were deprecated in GCC 4.6 and will
    be removed in the next release.  */
-#include "deprecated/hash.h"
 #include "deprecated/Object.h"
 
 #ifdef __cplusplus
Index: libobjc/objc/deprecated/sarray.h
===================================================================
--- libobjc/objc/deprecated/sarray.h    (revision 174593)
+++ libobjc/objc/deprecated/sarray.h    (working copy)
@@ -1,240 +0,0 @@ 
-/* Sparse Arrays for Objective C dispatch tables
-   Copyright (C) 1993, 1995, 1996, 2004, 2009 Free Software Foundation, Inc.
-   Contributed by Kresten Krab Thorup.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-Under Section 7 of GPL version 3, you are granted additional
-permissions described in the GCC Runtime Library Exception, version
-3.1, as published by the Free Software Foundation.
-
-You should have received a copy of the GNU General Public License and
-a copy of the GCC Runtime Library Exception along with this program;
-see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
-<http://www.gnu.org/licenses/>.  */
-
-
-#ifndef __sarray_INCLUDE_GNU
-#define __sarray_INCLUDE_GNU
-
-#define OBJC_SPARSE2           /* 2-level sparse array */
-/* #define OBJC_SPARSE3 */      /* 3-level sparse array */
-
-#ifdef OBJC_SPARSE2
-extern const char* __objc_sparse2_id;
-#endif
-
-#ifdef OBJC_SPARSE3
-extern const char* __objc_sparse3_id;
-#endif
-
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-extern int nbuckets;           /* for stats */
-extern int nindices;
-extern int narrays;
-extern int idxsize;
-
-/* An unsigned integer of same size as a pointer */
-#define SIZET_BITS (sizeof(size_t)*8)
-
-#if defined(__sparc__) || defined(OBJC_SPARSE2)
-#define PRECOMPUTE_SELECTORS
-#endif
-
-#ifdef OBJC_SPARSE3
-
-/* Buckets are 8 words each */
-#define BUCKET_BITS 3
-#define BUCKET_SIZE (1<<BUCKET_BITS)
-#define BUCKET_MASK (BUCKET_SIZE-1)
-
-/* Indices are 16 words each */
-#define INDEX_BITS 4
-#define INDEX_SIZE (1<<INDEX_BITS)
-#define INDEX_MASK (INDEX_SIZE-1)
-
-#define INDEX_CAPACITY (BUCKET_SIZE*INDEX_SIZE)
-
-#else /* OBJC_SPARSE2 */
-
-/* Buckets are 32 words each */
-#define BUCKET_BITS 5
-#define BUCKET_SIZE (1<<BUCKET_BITS)
-#define BUCKET_MASK (BUCKET_SIZE-1)
-
-#endif /* OBJC_SPARSE2 */
-
-typedef size_t sidx;
-
-#ifdef PRECOMPUTE_SELECTORS
-
-struct soffset {
-#ifdef OBJC_SPARSE3
-  unsigned int unused : SIZET_BITS/4;
-  unsigned int eoffset : SIZET_BITS/4;
-  unsigned int boffset : SIZET_BITS/4;
-  unsigned int ioffset : SIZET_BITS/4;
-#else /* OBJC_SPARSE2 */
-#ifdef __sparc__
-  unsigned long boffset : (SIZET_BITS - 2) - BUCKET_BITS;
-  unsigned int eoffset : BUCKET_BITS;
-  unsigned int unused  : 2;
-#else
-  unsigned int boffset : SIZET_BITS/2;
-  unsigned int eoffset : SIZET_BITS/2;
-#endif
-#endif /* OBJC_SPARSE2 */
-};
-
-union sofftype {
-  struct soffset off;
-  sidx idx;
-};
-
-#endif /* not PRECOMPUTE_SELECTORS */
-
-union sversion {
-  int  version;
-  void *next_free;
-};
-
-struct sbucket {
-  void* elems[BUCKET_SIZE];    /* elements stored in array */
-  union sversion       version;                /* used for copy-on-write */
-};
-
-#ifdef OBJC_SPARSE3
-
-struct sindex {
-  struct sbucket* buckets[INDEX_SIZE];
-  union sversion       version;                /* used for copy-on-write */
-};
-
-#endif /* OBJC_SPARSE3 */
-
-struct sarray {
-#ifdef OBJC_SPARSE3
-  struct sindex** indices;
-  struct sindex* empty_index;
-#else /* OBJC_SPARSE2 */
-  struct sbucket** buckets;
-#endif  /* OBJC_SPARSE2 */
-  struct sbucket* empty_bucket;
-  union sversion       version;                /* used for copy-on-write */
-  short ref_count;
-  struct sarray* is_copy_of;
-  size_t capacity;
-};
-
-struct sarray* sarray_new(int, void* default_element);
-void sarray_free(struct sarray*);
-struct sarray* sarray_lazy_copy(struct sarray*);
-void sarray_realloc(struct sarray*, int new_size);
-void sarray_at_put(struct sarray*, sidx indx, void* elem);
-void sarray_at_put_safe(struct sarray*, sidx indx, void* elem);
-
-struct sarray* sarray_hard_copy(struct sarray*); /* ... like the name? */
-void sarray_remove_garbage(void);
-^L
-
-#ifdef PRECOMPUTE_SELECTORS
-/* Transform soffset values to ints and vica verca */
-static inline unsigned int
-soffset_decode(sidx indx)
-{
-  union sofftype x;
-  x.idx = indx;
-#ifdef OBJC_SPARSE3
-  return x.off.eoffset
-    + (x.off.boffset*BUCKET_SIZE)
-      + (x.off.ioffset*INDEX_CAPACITY);
-#else /* OBJC_SPARSE2 */
-  return x.off.eoffset + (x.off.boffset*BUCKET_SIZE);
-#endif /* OBJC_SPARSE2 */
-}
-
-static inline sidx
-soffset_encode(size_t offset)
-{
-  union sofftype x;
-  x.off.eoffset = offset%BUCKET_SIZE;
-#ifdef OBJC_SPARSE3
-  x.off.boffset = (offset/BUCKET_SIZE)%INDEX_SIZE;
-  x.off.ioffset = offset/INDEX_CAPACITY;
-#else /* OBJC_SPARSE2 */
-  x.off.boffset = offset/BUCKET_SIZE;
-#endif
-  return (sidx)x.idx;
-}
-
-#else /* not PRECOMPUTE_SELECTORS */
-
-static inline size_t
-soffset_decode(sidx indx)
-{
-  return indx;
-}
-
-static inline sidx
-soffset_encode(size_t offset)
-{
-  return offset;
-}
-#endif /* not PRECOMPUTE_SELECTORS */
-
-/* Get element from the Sparse array `array' at offset `indx' */
-
-static inline void* sarray_get(struct sarray* array, sidx indx)
-{
-#ifdef PRECOMPUTE_SELECTORS
-  union sofftype x;
-  x.idx = indx;
-#ifdef OBJC_SPARSE3
-  return 
-    array->
-      indices[x.off.ioffset]->
-       buckets[x.off.boffset]->
-         elems[x.off.eoffset];
-#else /* OBJC_SPARSE2 */
-  return array->buckets[x.off.boffset]->elems[x.off.eoffset];
-#endif /* OBJC_SPARSE2 */
-#else /* not PRECOMPUTE_SELECTORS */
-#ifdef OBJC_SPARSE3
-  return array->
-    indices[indx/INDEX_CAPACITY]->
-      buckets[(indx/BUCKET_SIZE)%INDEX_SIZE]->
-       elems[indx%BUCKET_SIZE];
-#else /* OBJC_SPARSE2 */
-  return array->buckets[indx/BUCKET_SIZE]->elems[indx%BUCKET_SIZE];
-#endif /* not OBJC_SPARSE3 */
-#endif /* not PRECOMPUTE_SELECTORS */
-}
-
-static inline void* sarray_get_safe(struct sarray* array, sidx indx)
-{
-  if(soffset_decode(indx) < array->capacity)
-    return sarray_get(array, indx);
-  else
-    return (array->empty_bucket->elems[0]);
-}
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __sarray_INCLUDE_GNU */
Index: libobjc/objc/deprecated/hash.h
===================================================================
--- libobjc/objc/deprecated/hash.h      (revision 174593)
+++ libobjc/objc/deprecated/hash.h      (working copy)
@@ -1,211 +0,0 @@ 
-/* Hash tables for Objective C method dispatch.
-   Copyright (C) 1993, 1995, 1996, 2004, 2009 Free Software Foundation, Inc.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-Under Section 7 of GPL version 3, you are granted additional
-permissions described in the GCC Runtime Library Exception, version
-3.1, as published by the Free Software Foundation.
-
-You should have received a copy of the GNU General Public License and
-a copy of the GCC Runtime Library Exception along with this program;
-see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
-<http://www.gnu.org/licenses/>.  */
-
-
-
-#ifndef __hash_INCLUDE_GNU
-#define __hash_INCLUDE_GNU
-
-#include <stddef.h>
-#include <string.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*
- * This data structure is used to hold items
- *  stored in a hash table.  Each node holds 
- *  a key/value pair.
- *
- * Items in the cache are really of type void *.
- */
-typedef struct cache_node
-{
-  struct cache_node *next;     /* Pointer to next entry on the list.
-                                  NULL indicates end of list. */
-  const void *key;             /* Key used to locate the value.  Used
-                                  to locate value when more than one
-                                  key computes the same hash
-                                  value. */
-  void *value;                 /* Value stored for the key. */
-} *node_ptr;
-
-
-/*
- * This data type is the function that computes a hash code given a key.
- * Therefore, the key can be a pointer to anything and the function specific
- * to the key type. 
- *
- * Unfortunately there is a mutual data structure reference problem with this
- * typedef.  Therefore, to remove compiler warnings the functions passed to
- * objc_hash_new will have to be casted to this type. 
- */
-typedef unsigned int (*hash_func_type) (void *, const void *);
-
-/*
- * This data type is the function that compares two hash keys and returns an
- * integer greater than, equal to, or less than 0, according as the first
- * parameter is lexicographically greater than, equal to, or less than the
- * second. 
- */
-
-typedef int (*compare_func_type) (const void *, const void *);
-
-
-/*
- * This data structure is the cache.
- *
- * It must be passed to all of the hashing routines
- *   (except for new).
- */
-typedef struct cache
-{
-  /* Variables used to implement the hash itself.  */
-  node_ptr *node_table; /* Pointer to an array of hash nodes.  */
-  /* Variables used to track the size of the hash table so to determine
-    when to resize it.  */
-  unsigned int size; /* Number of buckets allocated for the hash table
-                       (number of array entries allocated for
-                       "node_table").  Must be a power of two.  */
-  unsigned int used; /* Current number of entries in the hash table.  */
-  unsigned int mask; /* Precomputed mask.  */
-
-  /* Variables used to implement indexing through the hash table.  */
-
-  unsigned int last_bucket; /* Tracks which entry in the array where
-                              the last value was returned.  */
-  /* Function used to compute a hash code given a key. 
-     This function is specified when the hash table is created.  */
-  hash_func_type    hash_func;
-  /* Function used to compare two hash keys to see if they are equal.  */
-  compare_func_type compare_func;
-} *cache_ptr;
-
-
-/* Allocate and initialize a hash table.  */ 
-
-cache_ptr objc_hash_new (unsigned int size,
-                        hash_func_type hash_func,
-                        compare_func_type compare_func);
-                       
-/* Deallocate all of the hash nodes and the cache itself.  */
-
-void objc_hash_delete (cache_ptr cache);
-
-/* Add the key/value pair to the hash table.  If the
-   hash table reaches a level of fullness then it will be resized. 
-                                                   
-   assert if the key is already in the hash.  */
-
-void objc_hash_add (cache_ptr *cachep, const void *key, void *value);
-     
-/* Remove the key/value pair from the hash table.  
-   assert if the key isn't in the table.  */
-
-void objc_hash_remove (cache_ptr cache, const void *key);
-
-/* Used to index through the hash table.  Start with NULL
-   to get the first entry.
-                                                  
-   Successive calls pass the value returned previously.
-   ** Don't modify the hash during this operation *** 
-                                                  
-   Cache nodes are returned such that key or value can
-   be extracted.  */
-
-node_ptr objc_hash_next (cache_ptr cache, node_ptr node);
-
-/* Used to return a value from a hash table using a given key.  */
-
-void *objc_hash_value_for_key (cache_ptr cache, const void *key);
-
-/* Used to determine if the given key exists in the hash table */
-
-BOOL objc_hash_is_key_in_hash (cache_ptr cache, const void *key);
-
-/************************************************
-
-        Useful hashing functions.  
-        
-        Declared inline for your pleasure.
-        
-************************************************/
-
-/* Calculate a hash code by performing some 
-   manipulation of the key pointer.  (Use the lowest bits
-   except for those likely to be 0 due to alignment.)  */
-
-static inline unsigned int
-objc_hash_ptr (cache_ptr cache, const void *key)
-{
-  return ((size_t)key / sizeof (void *)) & cache->mask;
-}
-
-
-/* Calculate a hash code by iterating over a NULL 
-   terminate string.  */
-static inline unsigned int 
-objc_hash_string (cache_ptr cache, const void *key)
-{
-  unsigned int ret = 0;
-  unsigned int ctr = 0;
-  const char *ckey = (const char *) key;
-        
-  while (*ckey) {
-    ret ^= *ckey++ << ctr;
-    ctr = (ctr + 1) % sizeof (void *);
-  }
-
-  return ret & cache->mask;
-}
-
-
-/* Compare two pointers for equality.  */
-static inline int 
-objc_compare_ptrs (const void *k1, const void *k2)
-{
-  return (k1 == k2);
-}
-
-
-/* Compare two strings.  */
-static inline int 
-objc_compare_strings (const void *k1, const void *k2)
-{
-  if (k1 == k2)
-    return 1;
-  else if (k1 == 0 || k2 == 0)
-    return 0;
-  else
-    return ! strcmp ((const char *) k1, (const char *) k2);
-}
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* not __hash_INCLUDE_GNU */
Index: libobjc/objc/hash.h
===================================================================
--- libobjc/objc/hash.h (revision 174593)
+++ libobjc/objc/hash.h (working copy)
@@ -1,3 +0,0 @@ 
-#include "objc.h"
-#include "deprecated/hash.h"
-
Index: libobjc/objc/objc-api.h
===================================================================
--- libobjc/objc/objc-api.h     (revision 174593)
+++ libobjc/objc/objc-api.h     (working copy)
@@ -49,9 +49,6 @@  see the files COPYING3 and COPYING.RUNTIME respect
 /* TODO: A deprecation warning any time the file is included ? */
 
 #include "objc.h"
-#ifndef GNU_LIBOBJC_COMPILING_LIBOBJC_ITSELF
-# include "deprecated/hash.h"
-#endif
 #include "thr.h"
 #include "objc-decls.h"
 #include <stdio.h>
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog     (revision 174608)
+++ gcc/testsuite/ChangeLog     (working copy)
@@ -1,5 +1,9 @@ 
 2011-06-03  Nicola Pero  <nicola.pero@meta-innovation.com>
 
+       * objc.dg/headers.m: Do not include sarray.h and hash.h.
+
+2011-06-03  Nicola Pero  <nicola.pero@meta-innovation.com>
+
        * objc.dg/headers.m: Do not include objc-list.h.
 
 2011-06-03  Nicola Pero  <nicola.pero@meta-innovation.com>
Index: gcc/testsuite/objc.dg/headers.m
===================================================================
--- gcc/testsuite/objc.dg/headers.m     (revision 174608)
+++ gcc/testsuite/objc.dg/headers.m     (working copy)
@@ -14,13 +14,11 @@ 
 #include <objc/objc-runtime.h>
 #else
 #include <objc/encoding.h>
-#include <objc/hash.h>
 #endif
 
 #include <objc/objc-api.h>
 #include <objc/objc.h>
 
 #ifndef __NEXT_RUNTIME__
-#include <objc/sarray.h>
 #include <objc/thr.h>
 #endif