~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/check_stack_overrun.cc

  • Committer: Monty Taylor
  • Date: 2008-12-18 07:24:54 UTC
  • mto: This revision was merged to the branch mainline in revision 714.
  • Revision ID: monty@bitters-20081218072454-8pnep622damjgqli
Fixed one more my_time thing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
#include "drizzled/internal/my_sys.h"
 
20
#include <drizzled/global.h>
 
21
#include <mysys/my_sys.h>
22
22
#include <drizzled/definitions.h>
23
23
#include <drizzled/session.h>
24
24
#include <drizzled/error.h>
25
 
#include <drizzled/check_stack_overrun.h>
26
 
 
27
 
namespace drizzled
28
 
{
29
25
 
30
26
/****************************************************************************
31
27
        Check stack size; Send error if there isn't enough stack to continue
32
28
****************************************************************************/
33
 
#if defined(STACK_DIRECTION) && (STACK_DIRECTION < 0)
34
 
static const bool stack_direction_negative = true;
 
29
#if STACK_DIRECTION < 0
 
30
#define used_stack(A,B) (long) (A - B)
35
31
#else
36
 
static const bool stack_direction_negative = false;
 
32
#define used_stack(A,B) (long) (B - A)
37
33
#endif
38
34
 
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
 
 
48
35
extern size_t my_thread_stack_size;
49
36
 
50
37
bool check_stack_overrun(Session *session, long margin, void *)
51
38
{
52
39
  long stack_used;
 
40
  assert(session == current_session);
53
41
  if ((stack_used=used_stack(session->thread_stack,(char*) &stack_used)) >=
54
42
      (long) (my_thread_stack_size - margin))
55
43
  {
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);
 
44
    sprintf(errbuff[0],ER(ER_STACK_OVERRUN_NEED_MORE),
 
45
            stack_used,my_thread_stack_size,margin);
 
46
    my_message(ER_STACK_OVERRUN_NEED_MORE,errbuff[0],MYF(ME_FATALERROR));
59
47
    return true;
60
48
  }
61
49
  return false;
62
50
}
63
 
 
64
 
} /* namespace drizzled */