source: trunk/src/gcc/libobjc/gc.c@ 218

Last change on this file since 218 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: 11.4 KB
RevLine 
[2]1/* Basic data types for Objective C.
2 Copyright (C) 1998 Free Software Foundation, Inc.
3 Contributed by Ovidiu Predescu.
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#include "tconfig.h"
29#include "objc.h"
30#include "encoding.h"
31
32#include <assert.h>
33#include <string.h>
34
35#if OBJC_WITH_GC
36
37#include <gc.h>
38
39/* gc_typed.h uses the following but doesn't declare them */
40typedef GC_word word;
41typedef GC_signed_word signed_word;
42
43#if BITS_PER_WORD == 32
44# define LOGWL 5
45# define modWORDSZ(n) ((n) & 0x1f) /* n mod size of word */
46#endif
47
48#if BITS_PER_WORD == 64
49# define LOGWL 6
50# define modWORDSZ(n) ((n) & 0x3f) /* n mod size of word */
51#endif
52
53#define divWORDSZ(n) ((n) >> LOGWL) /* divide n by size of word */
54
55#include <gc_typed.h>
56
57/* The following functions set up in `mask` the corresponding pointers.
58 The offset is incremented with the size of the type. */
59
60#define ROUND(V, A) \
61 ({ typeof(V) __v=(V); typeof(A) __a=(A); \
62 __a*((__v+__a-1)/__a); })
63
64#define SET_BIT_FOR_OFFSET(mask, offset) \
65 GC_set_bit(mask, offset / sizeof (void*))
66
67/* Some prototypes */
68static void
69__objc_gc_setup_struct (GC_bitmap mask, const char *type, int offset);
70static void
71__objc_gc_setup_union (GC_bitmap mask, const char *type, int offset);
72
73
74static void
75__objc_gc_setup_array (GC_bitmap mask, const char *type, int offset)
76{
77 int i, len = atoi(type + 1);
78
79 while (isdigit(*++type))
80 /* do nothing */; /* skip the size of the array */
81
82 switch (*type) {
83 case _C_ARY_B:
84 for (i = 0; i < len; i++)