~drizzle-trunk/drizzle/development

670.2.4 by Monty Taylor
Removed more stuff from the headers.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
670.2.4 by Monty Taylor
Removed more stuff from the headers.
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
20
#include <config.h>
21
#include <drizzled/internal/my_sys.h>
670.2.4 by Monty Taylor
Removed more stuff from the headers.
22
#include <drizzled/definitions.h>
23
#include <drizzled/session.h>
24
#include <drizzled/error.h>
1085.1.2 by Monty Taylor
Fixed -Wmissing-declarations
25
#include <drizzled/check_stack_overrun.h>
670.2.4 by Monty Taylor
Removed more stuff from the headers.
26
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
27
namespace drizzled
28
{
29
670.2.4 by Monty Taylor
Removed more stuff from the headers.
30
/****************************************************************************
31
	Check stack size; Send error if there isn't enough stack to continue
32
****************************************************************************/
1273.12.2 by Monty Taylor
pandora-build v0.103 - fix macros for cross-compiling. Fix stack direction check.
33
#if defined(STACK_DIRECTION) && (STACK_DIRECTION < 0)
1892.5.3 by Gustaf Thorslund
Replaced one more macro with a template.
34
static const bool stack_direction_negative = true;
670.2.4 by Monty Taylor
Removed more stuff from the headers.
35
#else
1892.5.3 by Gustaf Thorslund
Replaced one more macro with a template.
36
static const bool stack_direction_negative = false;
670.2.4 by Monty Taylor
Removed more stuff from the headers.
37
#endif
38
1892.5.3 by Gustaf Thorslund
Replaced one more macro with a template.
39
template <typename A_T, typename B_T>
40
inline static long used_stack(A_T A, B_T B)
41
{
42
  if (stack_direction_negative)
43
    return (long) (A - B);
44
  else
45
    return (long) (B - A);
46
}
47
670.2.4 by Monty Taylor
Removed more stuff from the headers.
48
extern size_t my_thread_stack_size;
49
50
bool check_stack_overrun(Session *session, long margin, void *)
51
{
52
  long stack_used;
53
  if ((stack_used=used_stack(session->thread_stack,(char*) &stack_used)) >=
54
      (long) (my_thread_stack_size - margin))
55
  {
998.2.1 by abg
Removing global errbuff and cleaning up two remaining instances that referenced it.
56
    my_printf_error(ER_STACK_OVERRUN_NEED_MORE, ER(ER_STACK_OVERRUN_NEED_MORE),
57
                    MYF(ME_FATALERROR),
58
                    stack_used,my_thread_stack_size,margin);
670.2.4 by Monty Taylor
Removed more stuff from the headers.
59
    return true;
60
  }
61
  return false;
62
}
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
63
64
} /* namespace drizzled */