~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-10 07:43:50 UTC
  • mto: (670.1.3 devel)
  • mto: This revision was merged to the branch mainline in revision 672.
  • Revision ID: monty@inaugust.com-20081210074350-wi2y2piv23ko707h
Removed more stuff from the headers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
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
 
 
20
#include <drizzled/global.h>
 
21
#include <mysys/my_sys.h>
 
22
#include <drizzled/definitions.h>
 
23
#include <drizzled/session.h>
 
24
#include <drizzled/error.h>
 
25
 
 
26
/****************************************************************************
 
27
        Check stack size; Send error if there isn't enough stack to continue
 
28
****************************************************************************/
 
29
#if STACK_DIRECTION < 0
 
30
#define used_stack(A,B) (long) (A - B)
 
31
#else
 
32
#define used_stack(A,B) (long) (B - A)
 
33
#endif
 
34
 
 
35
extern size_t my_thread_stack_size;
 
36
 
 
37
bool check_stack_overrun(Session *session, long margin, void *)
 
38
{
 
39
  long stack_used;
 
40
  assert(session == current_session);
 
41
  if ((stack_used=used_stack(session->thread_stack,(char*) &stack_used)) >=
 
42
      (long) (my_thread_stack_size - margin))
 
43
  {
 
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));
 
47
    return true;
 
48
  }
 
49
  return false;
 
50
}