~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/internal/my_init.cc

  • Committer: Brian Aker
  • Date: 2010-01-22 00:53:13 UTC
  • Revision ID: brian@gaz-20100122005313-jmizcbcdi1lt4tcx
Revert db patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#include "mysys_priv.h"
 
16
#include "drizzled/internal/mysys_priv.h"
17
17
#include "my_static.h"
18
 
#include <mysys/mysys_err.h>
19
 
#include <mystrings/m_string.h>
20
 
#include <mystrings/m_ctype.h>
21
 
#include <signal.h>
 
18
#include "drizzled/my_error.h"
 
19
#include "drizzled/internal/m_string.h"
 
20
#include "drizzled/charset_info.h"
 
21
#include "drizzled/charset.h"
 
22
#include <cstdio>
 
23
#include <cstdlib>
22
24
 
23
25
bool my_init_done= 0;
24
26
uint    mysys_usage_id= 0;              /* Incremented for each my_init() */
25
 
uint32_t   my_thread_stack_size= 65536;
26
27
 
27
28
static uint32_t atoi_octal(const char *str)
28
29
{
29
30
  long int tmp;
30
 
  while (*str && my_isspace(&my_charset_latin1, *str))
 
31
  while (*str && my_isspace(&my_charset_utf8_general_ci, *str))
31
32
    str++;
32
 
  str2int(str,
33
 
          (*str == '0' ? 8 : 10),       /* Octalt or decimalt */
34
 
          0, INT_MAX, &tmp);
 
33
  tmp= strtol(str, NULL, (*str == '0' ? 8 : 10));
35
34
  return (uint32_t) tmp;
36
35
}
37
36
 
57
56
  my_umask= 0660;                       /* Default umask for new files */
58
57
  my_umask_dir= 0700;                   /* Default umask for new directories */
59
58
  init_glob_errs();
60
 
#if defined(SAFE_MUTEX)
61
 
  safe_mutex_global_init();             /* Must be called early */
62
 
#endif
63
 
#if defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX)
64
 
  fastmutex_global_init();              /* Must be called early */
65
 
#endif
66
59
#if defined(HAVE_PTHREAD_INIT)
67
60
  pthread_init();
68
61
#endif
88
81
 
89
82
        /* End my_sys */
90
83
 
91
 
void my_end(int infoflag)
 
84
void my_end()
92
85
{
93
 
  /*
94
 
    this code is suboptimal to workaround a bug in
95
 
    Sun CC: Sun C++ 5.6 2004/06/02 for x86, and should not be
96
 
    optimized until this compiler is not in use anymore
97
 
  */
98
 
  FILE *info_file= stderr;
99
 
  bool print_info= 0;
100
 
 
101
 
  if ((infoflag & MY_CHECK_ERROR) || print_info)
102
 
 
103
 
  {                                     /* Test if some file is left open */
104
 
    if (my_file_opened | my_stream_opened)
105
 
    {
106
 
      sprintf(errbuff[0],EE(EE_OPEN_WARNING),my_file_opened,my_stream_opened);
107
 
      (void) my_message_no_curses(EE_OPEN_WARNING,errbuff[0],ME_BELL);
108
 
      my_print_open_files();
109
 
    }
110
 
  }
111
86
  free_charsets();
112
87
  my_error_unregister_all();
113
 
  my_once_free();
114
 
 
115
 
  if ((infoflag & MY_GIVE_INFO) || print_info)
116
 
  {
117
 
#ifdef HAVE_GETRUSAGE
118
 
    struct rusage rus;
119
 
#ifdef HAVE_purify
120
 
    /* Purify assumes that rus is uninitialized after getrusage call */
121
 
    memset(&rus, 0, sizeof(rus));
122
 
#endif
123
 
    if (!getrusage(RUSAGE_SELF, &rus))
124
 
      fprintf(info_file,"\n\
125
 
User time %.2f, System time %.2f\n\
126
 
Maximum resident set size %ld, Integral resident set size %ld\n\
127
 
Non-physical pagefaults %ld, Physical pagefaults %ld, Swaps %ld\n\
128
 
Blocks in %ld out %ld, Messages in %ld out %ld, Signals %ld\n\
129
 
Voluntary context switches %ld, Involuntary context switches %ld\n",
130
 
              (rus.ru_utime.tv_sec * SCALE_SEC +
131
 
               rus.ru_utime.tv_usec / SCALE_USEC) / 100.0,
132
 
              (rus.ru_stime.tv_sec * SCALE_SEC +
133
 
               rus.ru_stime.tv_usec / SCALE_USEC) / 100.0,
134
 
              rus.ru_maxrss, rus.ru_idrss,
135
 
              rus.ru_minflt, rus.ru_majflt,
136
 
              rus.ru_nswap, rus.ru_inblock, rus.ru_oublock,
137
 
              rus.ru_msgsnd, rus.ru_msgrcv, rus.ru_nsignals,
138
 
              rus.ru_nvcsw, rus.ru_nivcsw);
139
 
#endif
140
 
  }
141
 
  else if (infoflag & MY_CHECK_ERROR)
142
 
  {
143
 
    TERMINATE(stderr, 0);               /* Print memory leaks on screen */
144
 
  }
145
88
 
146
89
  my_thread_end();
147
90
  my_thread_global_end();
148
 
#if defined(SAFE_MUTEX)
149
 
  /*
150
 
    Check on destroying of mutexes. A few may be left that will get cleaned
151
 
    up by C++ destructors
152
 
  */
153
 
  safe_mutex_end((infoflag & (MY_GIVE_INFO | MY_CHECK_ERROR)) ? stderr :
154
 
                 (FILE *) 0);
155
 
#endif /* defined(SAFE_MUTEX) */
156
91
 
157
92
  my_init_done=0;
158
93
} /* my_end */