~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_init.cc

  • Committer: Brian Aker
  • Date: 2009-01-17 02:46:52 UTC
  • Revision ID: brian@gir-3.local-20090117024652-4ducefje08ajbs1q
Refactor append_identifier and remove dead OPTION_QUOTE_SHOW_CREATE option
(we always quote).

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 "config.h"
17
 
 
18
 
#include "drizzled/internal/my_sys.h"
 
16
#include "mysys_priv.h"
19
17
#include "my_static.h"
20
 
#include "drizzled/error.h"
21
 
#include "drizzled/internal/m_string.h"
22
 
#include "drizzled/charset_info.h"
23
 
#include "drizzled/charset.h"
24
 
#include <cstdio>
25
 
#include <cstdlib>
26
 
 
27
 
namespace drizzled
28
 
{
29
 
namespace internal
30
 
{
 
18
#include <mysys/mysys_err.h>
 
19
#include <mystrings/m_string.h>
 
20
#include <mystrings/m_ctype.h>
 
21
#include <stdio.h>
 
22
#include <stdlib.h>
31
23
 
32
24
bool my_init_done= 0;
33
25
uint    mysys_usage_id= 0;              /* Incremented for each my_init() */
37
29
  long int tmp;
38
30
  while (*str && my_isspace(&my_charset_utf8_general_ci, *str))
39
31
    str++;
40
 
  tmp= strtol(str, NULL, (*str == '0' ? 8 : 10));
 
32
  str2int(str,
 
33
          (*str == '0' ? 8 : 10),       /* Octalt or decimalt */
 
34
          0, INT_MAX, &tmp);
41
35
  return (uint32_t) tmp;
42
36
}
43
37
 
62
56
  mysys_usage_id++;
63
57
  my_umask= 0660;                       /* Default umask for new files */
64
58
  my_umask_dir= 0700;                   /* Default umask for new directories */
 
59
  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
65
66
#if defined(HAVE_PTHREAD_INIT)
66
67
  pthread_init();
67
68
#endif
87
88
 
88
89
        /* End my_sys */
89
90
 
90
 
void my_end()
 
91
void my_end(int infoflag)
91
92
{
 
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
  }
92
111
  free_charsets();
 
112
  my_error_unregister_all();
 
113
 
 
114
  if ((infoflag & MY_GIVE_INFO) || print_info)
 
115
  {
 
116
#ifdef HAVE_GETRUSAGE
 
117
    struct rusage rus;
 
118
#ifdef HAVE_purify
 
119
    /* Purify assumes that rus is uninitialized after getrusage call */
 
120
    memset(&rus, 0, sizeof(rus));
 
121
#endif
 
122
    if (!getrusage(RUSAGE_SELF, &rus))
 
123
      fprintf(info_file,"\n\
 
124
User time %.2f, System time %.2f\n\
 
125
Maximum resident set size %ld, Integral resident set size %ld\n\
 
126
Non-physical pagefaults %ld, Physical pagefaults %ld, Swaps %ld\n\
 
127
Blocks in %ld out %ld, Messages in %ld out %ld, Signals %ld\n\
 
128
Voluntary context switches %ld, Involuntary context switches %ld\n",
 
129
              (rus.ru_utime.tv_sec * SCALE_SEC +
 
130
               rus.ru_utime.tv_usec / SCALE_USEC) / 100.0,
 
131
              (rus.ru_stime.tv_sec * SCALE_SEC +
 
132
               rus.ru_stime.tv_usec / SCALE_USEC) / 100.0,
 
133
              rus.ru_maxrss, rus.ru_idrss,
 
134
              rus.ru_minflt, rus.ru_majflt,
 
135
              rus.ru_nswap, rus.ru_inblock, rus.ru_oublock,
 
136
              rus.ru_msgsnd, rus.ru_msgrcv, rus.ru_nsignals,
 
137
              rus.ru_nvcsw, rus.ru_nivcsw);
 
138
#endif
 
139
  }
 
140
  else if (infoflag & MY_CHECK_ERROR)
 
141
  {
 
142
    TERMINATE(stderr, 0);               /* Print memory leaks on screen */
 
143
  }
93
144
 
94
145
  my_thread_end();
95
146
  my_thread_global_end();
 
147
#if defined(SAFE_MUTEX)
 
148
  /*
 
149
    Check on destroying of mutexes. A few may be left that will get cleaned
 
150
    up by C++ destructors
 
151
  */
 
152
  safe_mutex_end();
 
153
 
 
154
#endif /* defined(SAFE_MUTEX) */
96
155
 
97
156
  my_init_done=0;
98
157
} /* my_end */
99
 
 
100
 
} /* namespace internal */
101
 
} /* namespace drizzled */