source: trunk/source/lisp-kernel/macros.h @ 13589

Last change on this file since 13589 was 13589, checked in by rme, 11 years ago

Put the #endif for "#ifndef macros" at the end of the file.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1/*
2   Copyright (C) 2009 Clozure Associates
3   Copyright (C) 1994-2001 Digitool, Inc
4   This file is part of Clozure CL. 
5
6   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public
7   License , known as the LLGPL and distributed with Clozure CL as the
8   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
9   which is distributed with Clozure CL as the file "LGPL".  Where these
10   conflict, the preamble takes precedence. 
11
12   Clozure CL is referenced in the preamble as the "LIBRARY."
13
14   The LLGPL is also available online at
15   http://opensource.franz.com/preamble.html
16*/
17
18/* Totally different content than 'macros.s' */
19
20
21
22#ifndef __macros__
23#define __macros__
24
25#define ptr_to_lispobj(p) ((LispObj)(p))
26#define ptr_from_lispobj(o) ((LispObj*)(o))
27#define lisp_reg_p(reg)  ((reg) >= fn)
28
29#define fulltag_of(o)  ((o) & fulltagmask)
30#define tag_of(o) ((o) & tagmask)
31#define untag(o) ((o) & ~fulltagmask)
32#define node_aligned(o) ((o) & ~tagmask)
33#define indirect_node(o) (*(LispObj *)(node_aligned(o)))
34
35#define deref(o,n) ((((LispObj*) (untag((LispObj)o))))[(n)])
36#define header_of(o) deref(o,0)
37
38#define header_subtag(h) ((h) & subtagmask)
39#define header_element_count(h) ((h) >> num_subtag_bits)
40#define make_header(subtag,element_count) ((subtag)|((element_count)<<num_subtag_bits))
41
42#define unbox_fixnum(x) ((signed_natural)(((signed_natural)(x))>>fixnum_shift))
43#define box_fixnum(x) ((LispObj)((signed_natural)(x)<<fixnum_shift))
44
45#define car(x) (((cons *)ptr_from_lispobj(untag(x)))->car)
46#define cdr(x) (((cons *)ptr_from_lispobj(untag(x)))->cdr)
47
48/* "sym" is an untagged pointer to a symbol */
49#define BOUNDP(sym)  ((((lispsymbol *)(sym))->vcell) != undefined)
50
51/* Likewise. */
52#define FBOUNDP(sym) ((((lispsymbol *)(sym))->fcell) != nrs_UDF.vcell)
53
54#ifdef PPC
55#ifdef PPC64
56#define nodeheader_tag_p(tag) (((tag) & lowtag_mask) == lowtag_nodeheader)
57#define immheader_tag_p(tag) (((tag) & lowtag_mask) == lowtag_immheader)
58#else
59#define nodeheader_tag_p(tag) (tag == fulltag_nodeheader)
60#define immheader_tag_p(tag) (tag == fulltag_immheader)
61#endif
62#endif
63
64#ifdef X86
65#ifdef X8664
66#define NODEHEADER_MASK ((1<<(fulltag_nodeheader_0)) | \
67                         (1<<(fulltag_nodeheader_1)))
68#define nodeheader_tag_p(tag) ((1<<(tag)) &  NODEHEADER_MASK)
69
70#define IMMHEADER_MASK ((1<<fulltag_immheader_0) | \
71                        (1UL<<fulltag_immheader_1) |                    \
72                        (1UL<<fulltag_immheader_2))
73
74#define immheader_tag_p(tag) ((1<<(tag)) & IMMHEADER_MASK)
75#else
76#define nodeheader_tag_p(tag) (tag == fulltag_nodeheader)
77#define immheader_tag_p(tag) (tag == fulltag_immheader)
78#endif
79#endif
80
81#ifdef VC
82#define inline
83#define __attribute__(x)
84#endif
85
86/* lfuns */
87#define lfun_bits(f) (deref(f,header_element_count(header_of(f))))
88#define named_function_p(f) (!(lfun_bits(f)&(1<<(29+fixnum_shift))))
89#define named_function_name(f) (deref(f,-1+header_element_count(header_of(f))))
90
91#define TCR_INTERRUPT_LEVEL(tcr) \
92  (((signed_natural *)((tcr)->tlb_pointer))[INTERRUPT_LEVEL_BINDING_INDEX])
93
94#ifdef WINDOWS
95#define LSEEK(fd,offset,how) _lseeki64(fd,offset,how)
96#else
97#define LSEEK(fd,offset,how) lseek(fd,offset,how)
98#endif
99
100/* We can't easily and unconditionally use format strings like "0x%lx"
101   to print lisp objects: the "l" might not match the word size, and
102   neither would (necessarily) something like "0x%llx".  We can at
103   least exploit the fact that on all current platforms, "ll" ("long long")
104   is the size of a 64-bit lisp object and "l" ("long") is the size of
105   a 32-bit lisp object. */
106
107#if (WORD_SIZE == 64)
108#define LISP "%llx"
109#define ZLISP "%016llx"
110#define DECIMAL "%lld"
111#else
112#define LISP "%lx"
113#define ZLISP "%08x"
114#define DECIMAL "%ld"
115#endif
116
117#endif /* __macros __ */
Note: See TracBrowser for help on using the repository browser.