~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_init.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-08-07 14:14:58 UTC
  • mfrom: (1112 staging)
  • mto: (1115.3.4 captain)
  • mto: This revision was merged to the branch mainline in revision 1117.
  • Revision ID: osullivan.padraig@gmail.com-20090807141458-qrc3don58s304ore
Merge from trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
 
 
16
 
#include "config.h"
17
 
 
18
 
#include "drizzled/internal/my_sys.h"
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#include "mysys/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() */
62
54
  mysys_usage_id++;
63
55
  my_umask= 0660;                       /* Default umask for new files */
64
56
  my_umask_dir= 0700;                   /* Default umask for new directories */
 
57
  init_glob_errs();
65
58
#if defined(HAVE_PTHREAD_INIT)
66
59
  pthread_init();
67
60
#endif
87
80
 
88
81
        /* End my_sys */
89
82
 
90
 
void my_end()
 
83
void my_end(int infoflag)
91
84
{
 
85
  /*
 
86
    this code is suboptimal to workaround a bug in
 
87
    Sun CC: Sun C++ 5.6 2004/06/02 for x86, and should not be
 
88
    optimized until this compiler is not in use anymore
 
89
  */
 
90
  FILE *info_file= stderr;
 
91
  bool print_info= 0;
 
92
 
 
93
  if ((infoflag & MY_CHECK_ERROR) || print_info)
 
94
 
 
95
  {                                     /* Test if some file is left open */
 
96
    if (my_file_opened | my_stream_opened)
 
97
    {
 
98
      /* TODO: Mark... look at replacement here
 
99
       * (void) my_message_no_curses(EE_OPEN_WARNING,errbuff[0],ME_BELL);
 
100
       */
 
101
      (void) fflush(stdout);
 
102
      
 
103
      my_print_open_files();
 
104
    }
 
105
  }
92
106
  free_charsets();
 
107
  my_error_unregister_all();
 
108
 
 
109
  if ((infoflag & MY_GIVE_INFO) || print_info)
 
110
  {
 
111
#ifdef HAVE_GETRUSAGE
 
112
    struct rusage rus;
 
113
#ifdef HAVE_purify
 
114
    /* Purify assumes that rus is uninitialized after getrusage call */
 
115
    memset(&rus, 0, sizeof(rus));
 
116
#endif
 
117
    if (!getrusage(RUSAGE_SELF, &rus))
 
118
      fprintf(info_file,"\n\
 
119
User time %.2f, System time %.2f\n\
 
120
Maximum resident set size %ld, Integral resident set size %ld\n\
 
121
Non-physical pagefaults %ld, Physical pagefaults %ld, Swaps %ld\n\
 
122
Blocks in %ld out %ld, Messages in %ld out %ld, Signals %ld\n\
 
123
Voluntary context switches %ld, Involuntary context switches %ld\n",
 
124
              (rus.ru_utime.tv_sec * SCALE_SEC +
 
125
               rus.ru_utime.tv_usec / SCALE_USEC) / 100.0,
 
126
              (rus.ru_stime.tv_sec * SCALE_SEC +
 
127
               rus.ru_stime.tv_usec / SCALE_USEC) / 100.0,
 
128
              rus.ru_maxrss, rus.ru_idrss,
 
129
              rus.ru_minflt, rus.ru_majflt,
 
130
              rus.ru_nswap, rus.ru_inblock, rus.ru_oublock,
 
131
              rus.ru_msgsnd, rus.ru_msgrcv, rus.ru_nsignals,
 
132
              rus.ru_nvcsw, rus.ru_nivcsw);
 
133
#endif
 
134
  }
 
135
  else if (infoflag & MY_CHECK_ERROR)
 
136
  {
 
137
    TERMINATE(stderr, 0);               /* Print memory leaks on screen */
 
138
  }
93
139
 
94
140
  my_thread_end();
95
141
  my_thread_global_end();
96
142
 
97
143
  my_init_done=0;
98
144
} /* my_end */
99
 
 
100
 
} /* namespace internal */
101
 
} /* namespace drizzled */