2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 // $XConsortium: Destructable.C /main/8 1996/10/04 12:48:45 cde-hal $
24 #ifndef NATIVE_EXCEPTIONS
25 #include "Exceptions.hh"
28 void *Destructable::g_stack_start;
29 unsigned short Destructable::g_size;
32 NEW_AND_DELETE_BODIES_SIMPLE(Destructable)
47 // /////////////////////////////////////////////////////////////////
48 // in_stack - return true if ptr is in stack memory
49 // /////////////////////////////////////////////////////////////////
52 Destructable::in_stack()
55 PRINTF (("In_stack : %p -- %p | %p ",
56 g_stack_start, &stack_end, this));
58 if (((void *) this > &stack_end && (void *) this < g_stack_start) ||
59 ((void *) this < &stack_end && (void *) this > g_stack_start))
61 PRINTF (("(stack)\n"));
66 PRINTF (("(heap)\n"));
72 // /////////////////////////////////////////////////////////////////
73 // in_stack_set_size - return 1 if in the stack, set size as well
74 // /////////////////////////////////////////////////////////////////
77 Destructable::in_stack_set_size()
80 PRINTF (("In_stack_size : %p -- %p | %p ",
81 g_stack_start, &stack_end, this));
83 // Handle stack grows down case.
84 if ((void *) this > (void *) &stack_end &&
85 (void *) this < (void *) g_stack_start)
87 PRINTF (("(stack)\n"));
88 // Size unknown, also used to indicate stack grows down.
89 Destructable::g_size = 0;
92 // Handle stack grows up case.
93 else if ((void *) this > (void *) g_stack_start &&
94 (void *) this < (void *) &stack_end)
96 // stack_end is just past this, so size is space between them.
97 Destructable::g_size = (unsigned long) &stack_end - (unsigned long) this;
101 PRINTF (("(stack)\n"));
102 PRINTF ((" obj start = %p, end = %p, size = %d\n",
103 this, &stack_end, g_size));
109 PRINTF (("(heap)\n"));
114 #endif /* NATIVE_EXCEPTIONS */