source: trunk/source/lisp-kernel/lisptypes.h @ 10565

Last change on this file since 10565 was 10565, checked in by gb, 11 years ago

Merge changes from branches/win64.

As well as the expected low-level exception/suspend/interrupt stuff,
these changes also include changes to [f]printf format strings. Note
that on win64, a 'long' is 32-bits wide, which complicates matters:

  • an address (viewed as an integer) or a natural-sized integer isn't

(portably) a long, and so can't be printed with %l.

  • an address (viewed as an integer) or a natural-sized integer isn't

(portably) a long long, and so can't be printed with %ll.

  • an address (viewed as an integer) or a natural-sized integer can be

portably printed with '%p', but implementations differ as to whether
or not '%p' prepends a gratuitous '0x' to the hex address. (Linux
does, other current platforms seem not to.)

The approach that seems to work is to cast arguments to natural, then
to u64_t, then use %ll. That approach probably isn't taken consistently
(yet), so some debugging information printed by the kernel may be
incorrect.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 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#ifndef __lisptypes__
18#define __lisptypes__
19
20#include <sys/types.h>
21#define WORD_SIZE 32
22#ifdef PPC64
23#undef WORD_SIZE
24#define WORD_SIZE 64
25#endif
26#ifdef X8664
27#undef WORD_SIZE
28#define WORD_SIZE 64
29#endif
30
31
32#ifdef WIN64
33#include <windows.h>
34typedef long long s64_t;
35typedef unsigned long long u64_t;
36typedef signed long s32_t;
37typedef unsigned long u32_t;
38typedef signed short s16_t;
39typedef unsigned short u16_t;
40typedef signed char s8_t;
41typedef unsigned char u8_t;
42#else
43
44#include <stdint.h>
45
46#ifdef SOLARIS
47/* Solaris doesn't laugh and play like the other children */
48typedef int64_t s64_t;
49typedef uint64_t u64_t;
50typedef int32_t s32_t;
51typedef uint32_t u32_t;
52typedef int16_t s16_t;
53typedef uint16_t u16_t;
54typedef int8_t s8_t;
55typedef uint8_t u8_t;
56#else
57typedef int64_t s64_t;
58typedef u_int64_t u64_t;
59typedef int32_t s32_t;
60typedef u_int32_t u32_t;
61typedef int16_t s16_t;
62typedef u_int16_t u16_t;
63typedef int8_t s8_t;
64typedef u_int8_t u8_t;
65#endif
66#endif
67
68#if WORD_SIZE == 64
69typedef u64_t LispObj;
70typedef u64_t natural;
71typedef s64_t signed_natural;
72typedef u64_t unsigned_of_pointer_size;
73#else
74typedef u32_t LispObj;
75typedef u32_t natural;
76typedef s32_t signed_natural;
77typedef u32_t unsigned_of_pointer_size;
78#endif
79
80
81#ifdef DARWIN
82#include <sys/signal.h>
83#include <sys/ucontext.h>
84
85#ifdef PPC
86#if WORD_SIZE == 64
87#ifdef _STRUCT_UCONTEXT64
88typedef _STRUCT_UCONTEXT64 ExceptionInformation;
89typedef _STRUCT_MCONTEXT64 *MCONTEXT_T;
90#else /* _STRUCT_UCONTEXT64 */
91typedef struct ucontext64 ExceptionInformation;
92typedef struct mcontext64 *MCONTEXT_T;
93#endif /* _STRUCT_UCONTEXT64 */
94#define UC_MCONTEXT(UC) UC->uc_mcontext64
95#else /* WORD_SIZE */
96#ifdef _STRUCT_UCONTEXT
97typedef _STRUCT_UCONTEXT ExceptionInformation;
98typedef _STRUCT_MCONTEXT *MCONTEXT_T;
99#else
100typedef struct ucontext ExceptionInformation;
101typedef struct mcontext *MCONTEXT_T;
102#endif
103#define UC_MCONTEXT(UC) UC->uc_mcontext
104#endif /* WORD_SIZE */
105
106
107
108#endif /* PPC */
109
110#ifdef X8664
111/* Broken <i386/ucontext.h> in xcode 2.4 */
112#ifndef _STRUCT_MCONTEXT64 /* A guess at what'll be defined when this is fixed */
113struct mcontext64 {
114        x86_exception_state64_t __es;
115        x86_thread_state64_t    __ss;   
116        x86_float_state64_t     __fs;
117};
118
119typedef struct mcontext64 *MCONTEXT_T;
120typedef ucontext64_t ExceptionInformation;
121#define UC_MCONTEXT(UC) UC->uc_mcontext64
122#define __rax rax
123#define __fpu_mxcsr fpu_mxcsr
124#define __fpu_xmm0 fpu_xmm0
125#define __rsp rsp
126#define __faultvaddr faultvaddr
127#define __err err
128#define __rip rip
129#define __rsi rsi
130#define __rdi rdi
131#define __rdx rdx
132#define __rcx rcx
133#define __r8 r8
134#define __rflags rflags
135#else
136typedef mcontext_t MCONTEXT_T;
137typedef ucontext_t ExceptionInformation;
138#define UC_MCONTEXT(UC) UC->uc_mcontext
139#endif /* _STRUCT_MCONTEXT64 */
140#endif /* X86_64 */
141
142#ifdef X8632
143/* Assume rational <i386/ucontext.h> */
144#define UC_MCONTEXT(UC) UC->uc_mcontext
145typedef mcontext_t MCONTEXT_T;
146typedef ucontext_t ExceptionInformation;
147#endif
148
149#endif /* #ifdef DARWIN */
150
151#ifdef LINUX
152typedef struct ucontext ExceptionInformation;
153#endif
154
155#ifdef FREEBSD
156typedef struct __ucontext ExceptionInformation;
157#endif
158
159#ifdef SOLARIS
160typedef struct ucontext ExceptionInformation;
161#endif
162
163#ifdef WIN64
164typedef CONTEXT ExceptionInformation;
165#endif
166
167typedef u32_t lisp_char_code;
168
169typedef int OSStatus, OSErr;
170#define noErr ((OSErr) 0)
171typedef int Boolean;
172typedef void *LogicalAddress;
173typedef char *Ptr, *BytePtr, *StringPtr;
174typedef unsigned int UInt32;
175
176
177
178#define true 1
179#define false 0
180
181#endif /*__lisptypes__ */
Note: See TracBrowser for help on using the repository browser.