~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_init.c

  • Committer: Monty Taylor
  • Date: 2008-10-16 06:32:30 UTC
  • mto: (511.1.5 codestyle)
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: monty@inaugust.com-20081016063230-4brxsra0qsmsg84q
Added -Wunused-macros.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
#include "mysys_priv.h"
17
17
#include "my_static.h"
18
 
#include "mysys_err.h"
19
 
#include <m_string.h>
20
 
#include <m_ctype.h>
 
18
#include <mysys/mysys_err.h>
 
19
#include <mystrings/m_string.h>
 
20
#include <mystrings/m_ctype.h>
21
21
#include <signal.h>
22
22
 
23
23
bool my_init_done= 0;
24
24
uint    mysys_usage_id= 0;              /* Incremented for each my_init() */
25
 
ulong   my_thread_stack_size= 65536;
 
25
uint32_t   my_thread_stack_size= 65536;
26
26
 
27
 
static ulong atoi_octal(const char *str)
 
27
static uint32_t atoi_octal(const char *str)
28
28
{
29
29
  long int tmp;
30
 
  while (*str && my_isspace(&my_charset_latin1, *str))
 
30
  while (*str && my_isspace(&my_charset_utf8_general_ci, *str))
31
31
    str++;
32
32
  str2int(str,
33
33
          (*str == '0' ? 8 : 10),       /* Octalt or decimalt */
34
34
          0, INT_MAX, &tmp);
35
 
  return (ulong) tmp;
 
35
  return (uint32_t) tmp;
36
36
}
37
37
 
38
38
 
64
64
  fastmutex_global_init();              /* Must be called early */
65
65
#endif
66
66
#if defined(HAVE_PTHREAD_INIT)
67
 
  pthread_init();                       /* Must be called before DBUG_ENTER */
 
67
  pthread_init();
68
68
#endif
69
69
  if (my_thread_global_init())
70
70
    return 1;
71
71
  sigfillset(&my_signals);              /* signals blocked by mf_brkhant */
72
72
  {
73
 
    DBUG_ENTER("my_init");
74
 
    DBUG_PROCESS((char*) (my_progname ? my_progname : "unknown"));
75
73
    if (!home_dir)
76
74
    {                                   /* Don't initialize twice */
77
75
      if ((home_dir=getenv("HOME")) != 0)
82
80
        /* Default creation of new dir's */
83
81
      if ((str=getenv("UMASK_DIR")) != 0)
84
82
        my_umask_dir=(int) (atoi_octal(str) | 0700);
85
 
      DBUG_PRINT("exit",("home: '%s'",home_dir));
86
83
    }
87
 
    DBUG_RETURN(0);
 
84
    return(0);
88
85
  }
89
86
} /* my_init */
90
87
 
98
95
    Sun CC: Sun C++ 5.6 2004/06/02 for x86, and should not be
99
96
    optimized until this compiler is not in use anymore
100
97
  */
101
 
  FILE *info_file= DBUG_FILE;
102
 
  bool print_info= (info_file != stderr);
103
 
  /*
104
 
    We do not use DBUG_ENTER here, as after cleanup DBUG is no longer
105
 
    operational, so we cannot use DBUG_RETURN.
106
 
  */
107
 
  DBUG_PRINT("info",("Shutting down: infoflag: %d  print_info: %d",
108
 
                     infoflag, print_info));
109
 
  if (!info_file)
110
 
  {
111
 
    info_file= stderr;
112
 
    print_info= 0;
113
 
  }
 
98
  FILE *info_file= stderr;
 
99
  bool print_info= 0;
114
100
 
115
101
  if ((infoflag & MY_CHECK_ERROR) || print_info)
116
102
 
119
105
    {
120
106
      sprintf(errbuff[0],EE(EE_OPEN_WARNING),my_file_opened,my_stream_opened);
121
107
      (void) my_message_no_curses(EE_OPEN_WARNING,errbuff[0],ME_BELL);
122
 
      DBUG_PRINT("error",("%s",errbuff[0]));
123
108
      my_print_open_files();
124
109
    }
125
110
  }
133
118
    struct rusage rus;
134
119
#ifdef HAVE_purify
135
120
    /* Purify assumes that rus is uninitialized after getrusage call */
136
 
    bzero((char*) &rus, sizeof(rus));
 
121
    memset(&rus, 0, sizeof(rus));
137
122
#endif
138
123
    if (!getrusage(RUSAGE_SELF, &rus))
139
124
      fprintf(info_file,"\n\
158
143
    TERMINATE(stderr, 0);               /* Print memory leaks on screen */
159
144
  }
160
145
 
161
 
  if (!(infoflag & MY_DONT_FREE_DBUG))
162
 
  {
163
 
    DBUG_END();                /* Must be done before my_thread_end */
164
 
  }
165
146
  my_thread_end();
166
147
  my_thread_global_end();
167
148
#if defined(SAFE_MUTEX)