source: trunk/src/gcc/libobjc/objc/sarray.h@ 869

Last change on this file since 869 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 5.9 KB
Line 
1/* Sparse Arrays for Objective C dispatch tables
2 Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
3 Contributed by Kresten Krab Thorup.
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING. If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */
21
22/* As a special exception, if you link this library with files
23 compiled with GCC to produce an executable, this does not cause
24 the resulting executable to be covered by the GNU General Public License.
25 This exception does not however invalidate any other reasons why
26 the executable file might be covered by the GNU General Public License. */
27
28#ifndef __sarray_INCLUDE_GNU
29#define __sarray_INCLUDE_GNU
30
31#define OBJC_SPARSE2 /* 2-level sparse array */
32/* #define OBJC_SPARSE3 */ /* 3-level sparse array */
33
34#ifdef OBJC_SPARSE2
35extern const char* __objc_sparse2_id;
36#endif
37
38#ifdef OBJC_SPARSE3
39extern const char* __objc_sparse3_id;
40#endif
41
42#include <stddef.h>
43
44#include "objc/thr.h"
45
46extern int nbuckets; /* for stats */
47extern int nindices;
48extern int narrays;
49extern int idxsize;
50
51#include <assert.h>
52
53/* An unsigned integer of same size as a pointer */
54#define SIZET_BITS (sizeof(size_t)*8)
55
56#if defined(__sparc__) || defined(OBJC_SPARSE2)
57#define PRECOMPUTE_SELECTORS
58#endif
59
60#ifdef OBJC_SPARSE3
61
62/* Buckets are 8 words each */
63#define BUCKET_BITS 3
64#define BUCKET_SIZE (1<<BUCKET_BITS)
65#define BUCKET_MASK (BUCKET_SIZE-1)
66
67/* Indices are 16 words each */
68#define INDEX_BITS 4
69#define INDEX_SIZE (1<<INDEX_BITS)
70#define INDEX_MASK (INDEX_SIZE-1)
71
72#define INDEX_CAPACITY (BUCKET_SIZE*INDEX_SIZE)
73
74#else /* OBJC_SPARSE2 */
75
76/* Buckets are 32 words each */
77#define BUCKET_BITS 5
78#define BUCKET_SIZE (1<<BUCKET_BITS)
79#define BUCKET_MASK (BUCKET_SIZE-1)
80
81#endif /* OBJC_SPARSE2 */
82
83typedef size_t sidx;
84
85#ifdef PRECOMPUTE_SELECTORS
86
87struct soffset {
88#ifdef OBJC_SPARSE3
89 unsigned int unused : SIZET_BITS/4;
90 unsigned int eoffset : SIZET_BITS/4;
91 unsigned int boffset : SIZET_BITS/4;
92 unsigned int ioffset : SIZET_BITS/4;
93#else /* OBJC_SPARSE2 */
94#ifdef __sparc__
95 unsigned long boffset : (SIZET_BITS - 2) - BUCKET_BITS;
96 unsigned int eoffset : BUCKET_BITS;
97 unsigned int unused : 2;
98#else
99 unsigned int boffset : SIZET_BITS/2;
100 unsigned int eoffset : SIZET_BITS/2;
101#endif