OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [config/] [alpha/] [vms-gcc_shell_handler.c] - Blame information for rev 282

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 282 jeremybenn
/* Static condition handler for Alpha/VMS.
2
   Copyright (C) 2005-2009
3
   Free Software Foundation, Inc.
4
 
5
   This file is part of GCC.
6
 
7
   GCC is free software; you can redistribute it and/or modify it
8
   under the terms of the GNU General Public License as published
9
   by the Free Software Foundation; either version 3, or (at your
10
   option) any later version.
11
 
12
   GCC is distributed in the hope that it will be useful, but WITHOUT
13
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15
   License for more details.
16
 
17
   Under Section 7 of GPL version 3, you are granted additional
18
   permissions described in the GCC Runtime Library Exception, version
19
   3.1, as published by the Free Software Foundation.
20
 
21
   You should have received a copy of the GNU General Public License and
22
   a copy of the GCC Runtime Library Exception along with this program;
23
   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24
   <http://www.gnu.org/licenses/>.  */
25
 
26
/* This file implements __gcc_shell_handler, the static VMS condition handler
27
   used as the indirection wrapper around user level handlers installed with
28
   establish_vms_condition_handler GCC builtin.
29
 
30
   [ABI] in comments refers to the "HP OpenVMS calling standard" document
31
   dated January 2005.  */
32
 
33
#include <vms/chfdef.h>
34
#include <vms/pdscdef.h>
35
#include <vms/ssdef.h>
36
 
37
typedef void * ADDR;
38
typedef unsigned long long REG;
39
 
40
#define REG_AT(addr) (*(REG *)(addr))
41
 
42
/* Compute pointer to procedure descriptor (Procedure Value) from Frame
43
   Pointer FP, according to the rules in [ABI-3.5.1 Current Procedure].  */
44
#define PV_FOR(FP) \
45
  (((FP) != 0) \
46
    ? (((REG_AT (FP) & 0x7) == 0) ? *(PDSCDEF **)(FP) : (PDSCDEF *)(FP)) : 0)
47
 
48
long
49
__gcc_shell_handler (struct chf$signal_array *sig_arr,
50
                     struct chf$mech_array *mech_arr);
51
 
52
/* Helper for __gcc_shell_handler.  Fetch the pointer to procedure currently
53
   registered as the VMS condition handler for the live function with a frame
54
   pointer FP.  */
55
 
56
static ADDR
57
get_dyn_handler_pointer (REG fp)
58
{
59
  /* From the frame pointer we find the procedure descriptor, and fetch
60
     the handler_data field from there.  This field contains the offset
61
     from FP at which the address of the currently installed handler is
62
     to be found.  */
63
 
64
  PDSCDEF * pd = PV_FOR (fp);
65
  /* Procedure descriptor pointer for the live subprogram with FP as the frame
66
     pointer, and to which _gcc_shell_handler is attached as a condition
67
     handler.  */
68
 
69
  REG handler_slot_offset;
70
  /* Offset from FP at which the address of the currently established real
71
     condition handler is to be found.  This offset is available from the
72
     handler_data field of the procedure descriptor.  */
73
 
74
  REG handler_data_offset;
75
  /* The handler_data field position in the procedure descriptor, which
76
     depends on the kind of procedure at hand.  */
77
 
78
  switch (pd->pdsc$w_flags & 0xf)
79
    {
80
    case PDSC$K_KIND_FP_STACK:    /* [3.4.2 PD for stack frame procedures]  */
81
      handler_data_offset = 40;
82
      break;
83
 
84
    case PDSC$K_KIND_FP_REGISTER: /* [3.4.5 PD for reg frame procedures]  */
85
      handler_data_offset = 32;
86
      break;
87
 
88
    default:
89
      handler_data_offset = 0;
90
      break;
91
    }
92
 
93
  /* If we couldn't determine the handler_data field position, give up.  */
94
  if (handler_data_offset == 0)
95
    return 0;
96
 
97
  /* Otherwise, fetch the fp offset at which the real handler address is to be
98
     found, then fetch and return the latter in turn.  */
99
 
100
  handler_slot_offset = REG_AT ((REG)pd + handler_data_offset);
101
 
102
  return (ADDR) REG_AT (fp + handler_slot_offset);
103
}
104
 
105
/* The static VMS condition handler for GCC code.  Fetch the address of the
106
   currently established condition handler, then resignal if there is none or
107
   call the handler with the VMS condition arguments.  */
108
 
109
long
110
__gcc_shell_handler (struct chf$signal_array *sig_arr,
111
                     struct chf$mech_array *mech_arr)
112
{
113
  long ret;
114
  long (*user_handler) (struct chf$signal_array *, struct chf$mech_array *);
115
 
116
  user_handler = get_dyn_handler_pointer (mech_arr->chf$q_mch_frame);
117
  if (!user_handler)
118
    ret = SS$_RESIGNAL;
119
  else
120
    ret = user_handler (sig_arr, mech_arr);
121
 
122
  return ret;
123
}
124
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.