source: trunk/ccl/lisp-kernel/macros.h @ 3730

Last change on this file since 3730 was 3730, checked in by gb, 15 years ago

I may have parenthesized nodeheader_tag_p and immheader_tag_p; several
versions of GCC generated code that looked wrong, but since it's
C it's hard to tell. Splitting the macros up (into "mask definition" and
"mask testing" seems to generate the right code (a bit test if optimization's
cranked up.)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1/*
2   Copyright (C) 1994-2001 Digitool, Inc
3   This file is part of OpenMCL. 
4
5   OpenMCL is licensed under the terms of the Lisp Lesser GNU Public
6   License , known as the LLGPL and distributed with OpenMCL as the
7   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
8   which is distributed with OpenMCL as the file "LGPL".  Where these
9   conflict, the preamble takes precedence. 
10
11   OpenMCL is referenced in the preamble as the "LIBRARY."
12
13   The LLGPL is also available online at
14   http://opensource.franz.com/preamble.html
15*/
16
17/* Totally different content than 'macros.s' */
18
19
20
21#ifndef __macros__
22#define __macros__
23
24#define ptr_to_lispobj(p) ((LispObj)((unsigned_of_pointer_size)(p)))
25#define ptr_from_lispobj(o) ((LispObj*)((unsigned_of_pointer_size)(o)))
26#define lisp_reg_p(reg)  ((reg) >= fn)
27
28#define fulltag_of(o)  ((o) & fulltagmask)
29#define tag_of(o) ((o) & tagmask)
30#define untag(o) ((o) & ~fulltagmask)
31
32#define deref(o,n) (*((LispObj*) (ptr_from_lispobj(untag((LispObj)o)))+(n)))
33#define header_of(o) deref(o,0)
34
35#define header_subtag(h) ((h) & subtagmask)
36#define header_element_count(h) ((h) >> num_subtag_bits)
37#define make_header(subtag,element_count) ((subtag)|((element_count)<<num_subtag_bits))
38
39#define unbox_fixnum(x) ((signed_natural)(((signed_natural)(x))>>fixnum_shift))
40#define box_fixnum(x) ((LispObj)((signed_natural)(x)<<fixnum_shift))
41
42#define car(x) (((cons *)ptr_from_lispobj(untag(x)))->car)
43#define cdr(x) (((cons *)ptr_from_lispobj(untag(x)))->cdr)
44
45/* "sym" is an untagged pointer to a symbol */
46#define BOUNDP(sym)  ((((lispsymbol *)(sym))->vcell) != undefined)
47
48/* Likewise. */
49#define FBOUNDP(sym) ((((lispsymbol *)(sym))->fcell) != nrs_UDF.vcell)
50
51#ifdef PPC
52#ifdef PPC64
53#define nodeheader_tag_p(tag) (((tag) & lowtag_mask) == lowtag_nodeheader)
54#define immheader_tag_p(tag) (((tag) & lowtag_mask) == lowtag_immheader)
55#else
56#define nodeheader_tag_p(tag) (tag == fulltag_nodeheader)
57#define immheader_tag_p(tag) (tag == fulltag_immheader)
58#endif
59#endif
60
61#ifdef X86
62#ifdef X8664
63#define NODEHEADER_MASK ((1<<(fulltag_nodeheader_0)) | \
64                         (1<<(fulltag_nodeheader_1)))
65#define nodeheader_tag_p(tag) ((1<<(tag)) &  NODEHEADER_MASK)
66
67#define IMMHEADER_MASK ((1<<fulltag_immheader_0) | \
68                        (1UL<<fulltag_immheader_1) |                    \
69                        (1UL<<fulltag_immheader_2))
70
71#define immheader_tag_p(tag) ((1<<(tag)) & IMMHEADER_MASK)
72#endif
73#endif
74
75
76
77/* lfuns */
78#define lfun_bits(f) (deref(f,header_element_count(header_of(f))))
79#define named_function_p(f) (!(lfun_bits(f)&(1<<(29+fixnum_shift))))
80#define named_function_name(f) (deref(f,-1+header_element_count(header_of(f))))
81
82#define TCR_INTERRUPT_LEVEL(tcr) \
83  (((signed_natural *)((tcr)->tlb_pointer))[INTERRUPT_LEVEL_BINDING_INDEX])
84#endif
Note: See TracBrowser for help on using the repository browser.