1995-12-20 02:41:22 -08:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Objective Caml */
|
1995-12-20 02:41:22 -08:00
|
|
|
/* */
|
|
|
|
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
1999-11-17 10:59:06 -08:00
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
2001-12-07 05:41:02 -08:00
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../LICENSE. */
|
1995-12-20 02:41:22 -08:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
1997-11-20 07:31:10 -08:00
|
|
|
/* Machine-dependent interface with the asm code */
|
1995-12-20 02:41:22 -08:00
|
|
|
|
2003-12-16 10:09:44 -08:00
|
|
|
#ifndef CAML_STACK_H
|
|
|
|
#define CAML_STACK_H
|
1995-12-20 02:41:22 -08:00
|
|
|
|
1997-11-20 07:31:10 -08:00
|
|
|
/* Macros to access the stack frame */
|
1995-12-20 02:41:22 -08:00
|
|
|
#ifdef TARGET_alpha
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Saved_return_address(sp) *((intnat *)((sp) - 8))
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Already_scanned(sp, retaddr) ((retaddr) & 1L)
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Mark_scanned(sp, retaddr) (*((intnat *)((sp) - 8)) = (retaddr) | 1L)
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Mask_already_scanned(retaddr) ((retaddr) & ~1L)
|
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) + 16))
|
1995-12-20 02:41:22 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_sparc
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Saved_return_address(sp) *((intnat *)((sp) + 92))
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) + 104))
|
1995-12-20 02:41:22 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_i386
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Saved_return_address(sp) *((intnat *)((sp) - 4))
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) + 8))
|
1995-12-20 02:41:22 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_mips
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Saved_return_address(sp) *((intnat *)((sp) - 4))
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) + 16))
|
1995-12-20 02:41:22 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_hppa
|
|
|
|
#define Stack_grows_upwards
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Saved_return_address(sp) *((intnat *)(sp))
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) - 24))
|
1995-12-20 02:41:22 -08:00
|
|
|
#endif
|
|
|
|
|
1996-01-06 10:56:39 -08:00
|
|
|
#ifdef TARGET_power
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Saved_return_address(sp) *((intnat *)((sp) - 4))
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Already_scanned(sp, retaddr) ((retaddr) & 1)
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Mark_scanned(sp, retaddr) (*((intnat *)((sp) - 4)) = (retaddr) | 1)
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Mask_already_scanned(retaddr) ((retaddr) & ~1)
|
1996-07-03 11:39:36 -07:00
|
|
|
#ifdef SYS_aix
|
2003-06-20 08:17:52 -07:00
|
|
|
#define Trap_frame_size 32
|
1996-07-03 11:39:36 -07:00
|
|
|
#else
|
2003-06-20 08:17:52 -07:00
|
|
|
#define Trap_frame_size 16
|
1996-07-03 11:39:36 -07:00
|
|
|
#endif
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) + Trap_frame_size))
|
1996-01-06 10:56:39 -08:00
|
|
|
#endif
|
1995-12-20 02:41:22 -08:00
|
|
|
|
1996-10-24 09:14:57 -07:00
|
|
|
#ifdef TARGET_m68k
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Saved_return_address(sp) *((intnat *)((sp) - 4))
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) + 8))
|
1996-10-24 09:14:57 -07:00
|
|
|
#endif
|
|
|
|
|
1998-10-15 09:10:53 -07:00
|
|
|
#ifdef TARGET_arm
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Saved_return_address(sp) *((intnat *)((sp) - 4))
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) + 8))
|
1998-10-15 09:10:53 -07:00
|
|
|
#endif
|
|
|
|
|
2000-06-30 09:37:42 -07:00
|
|
|
#ifdef TARGET_ia64
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Saved_return_address(sp) *((intnat *)((sp) + 8))
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Already_scanned(sp, retaddr) ((retaddr) & 1L)
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Mark_scanned(sp, retaddr) (*((intnat *)((sp) + 8)) = (retaddr) | 1L)
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Mask_already_scanned(retaddr) ((retaddr) & ~1L)
|
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) + 32))
|
2000-06-30 09:37:42 -07:00
|
|
|
#endif
|
|
|
|
|
2003-06-30 01:28:48 -07:00
|
|
|
#ifdef TARGET_amd64
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Saved_return_address(sp) *((intnat *)((sp) - 8))
|
2003-06-30 01:28:48 -07:00
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) + 16))
|
|
|
|
#endif
|
|
|
|
|
1997-11-27 08:28:40 -08:00
|
|
|
/* Structure of Caml callback contexts */
|
1997-11-21 05:46:23 -08:00
|
|
|
|
|
|
|
struct caml_context {
|
1997-11-27 08:28:40 -08:00
|
|
|
char * bottom_of_stack; /* beginning of Caml stack chunk */
|
2005-09-22 07:21:50 -07:00
|
|
|
uintnat last_retaddr; /* last return address in Caml code */
|
1997-11-27 08:28:40 -08:00
|
|
|
value * gc_regs; /* pointer to register block */
|
1997-11-21 05:46:23 -08:00
|
|
|
};
|
|
|
|
|
1997-11-27 08:28:40 -08:00
|
|
|
/* Declaration of variables used in the asm code */
|
|
|
|
extern char * caml_bottom_of_stack;
|
2005-09-22 07:21:50 -07:00
|
|
|
extern uintnat caml_last_return_address;
|
1997-11-27 08:28:40 -08:00
|
|
|
extern value * caml_gc_regs;
|
1997-11-21 05:46:23 -08:00
|
|
|
extern char * caml_exception_pointer;
|
|
|
|
extern value caml_globals[];
|
2005-09-22 07:21:50 -07:00
|
|
|
extern intnat caml_globals_inited;
|
|
|
|
extern intnat * caml_frametable[];
|
1997-11-21 05:46:23 -08:00
|
|
|
|
1996-01-07 08:58:44 -08:00
|
|
|
|
2003-12-16 10:09:44 -08:00
|
|
|
#endif /* CAML_STACK_H */
|