1 /*
2 * Disktest
3 * Copyright (c) International Business Machines Corp., 2001
4 *
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; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 *
20 * Please send e-mail to yardleyb@us.ibm.com if you have
21 * questions or comments.
22 *
23 * Project Website: TBD
24 *
25 * $Id: globals.c,v 1.6 2009/02/26 12:02:22 subrata_modak Exp $
26 *
27 */
28
29 #ifdef WINDOWS
30 #include <windows.h>
31 #else
32 #include <sys/types.h>
33 #include <unistd.h>
34 #include <pthread.h>
35 #endif
36 #include <time.h>
37 #include <string.h>
38
39 #include "defs.h"
40 #include "globals.h"
41 #include "main.h"
42 #include "threading.h"
43 #include "sfunc.h"
44
45 /* Globals */
46 unsigned int gbl_dbg_lvl; /* the global debugging level */
47 unsigned long glb_flags; /* global flags GLB_FLG_xxx */
48 time_t global_start_time; /* global start time */
49 unsigned short glb_run = 1; /* global run flag */
50
init_gbl_data(test_env_t * env)51 void init_gbl_data(test_env_t * env)
52 {
53 env->kids = 0;
54 env->shared_mem = NULL;
55 env->data_buffer = NULL;
56 env->bmp_siz = 0;
57 env->pThreads = NULL;
58 env->bContinue = TRUE;
59 env->pass_count = 0;
60 env->start_time = time(NULL); /* overall start time of test */
61 env->end_time = 0; /* overall end time of test */
62 memset(&env->global_stats, 0, sizeof(stats_t));
63 memset(&env->cycle_stats, 0, sizeof(stats_t));
64 }
65
66 #ifdef WINDOWS
67 /*
68 void PrintLastSystemError(unsigned long ulErrorNum)
69 {
70 LPVOID lpMsgBuf;
71 FormatMessage(
72 FORMAT_MESSAGE_ALLOCATE_BUFFER |
73 FORMAT_MESSAGE_FROM_SYSTEM |
74 FORMAT_MESSAGE_IGNORE_INSERTS,
75 NULL,
76 ulErrorNum,
77 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
78 (LPTSTR) &lpMsgBuf,
79 0,
80 NULL
81 );
82 pMsg(INFO,"%s",lpMsgBuf);
83 LocalFree(lpMsgBuf);
84 }
85 */
86
GetSystemErrorString(unsigned long ulErrorNum,void * buffer)87 void GetSystemErrorString(unsigned long ulErrorNum, void *buffer)
88 {
89 /* Use Default language */
90 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
91 FORMAT_MESSAGE_IGNORE_INSERTS,
92 NULL,
93 ulErrorNum,
94 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
95 (LPTSTR) & buffer, 0, NULL);
96 }
97 #endif
98