fio: factor out endian_check
[fio.git] / fio.c
1 /*
2  * fio - the flexible io tester
3  *
4  * Copyright (C) 2005 Jens Axboe <axboe@suse.de>
5  * Copyright (C) 2006-2012 Jens Axboe <axboe@kernel.dk>
6  *
7  * The license below covers all files distributed with fio unless otherwise
8  * noted in the file itself.
9  *
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License version 2 as
12  *  published by the Free Software Foundation.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  *
23  */
24 #include <unistd.h>
25 #include <locale.h>
26 #include <time.h>
27
28 #include "fio.h"
29 #include "hash.h"
30 #include "smalloc.h"
31 #include "verify.h"
32 #include "trim.h"
33 #include "diskutil.h"
34 #include "profile.h"
35 #include "lib/rand.h"
36 #include "memalign.h"
37 #include "client.h"
38 #include "server.h"
39 #include "endian_check.h"
40
41 unsigned long page_mask;
42 unsigned long page_size;
43
44 int main(int argc, char *argv[], char *envp[])
45 {
46         long ps;
47
48         if (endian_check()) {
49                 log_err("fio: endianness settings appear wrong.\n");
50                 log_err("fio: please report this to fio@vger.kernel.org\n");
51                 return 1;
52         }
53
54         arch_init(envp);
55
56         sinit();
57
58         /*
59          * We need locale for number printing, if it isn't set then just
60          * go with the US format.
61          */
62         if (!getenv("LC_NUMERIC"))
63                 setlocale(LC_NUMERIC, "en_US");
64
65         ps = sysconf(_SC_PAGESIZE);
66         if (ps < 0) {
67                 log_err("Failed to get page size\n");
68                 return 1;
69         }
70
71         page_size = ps;
72         page_mask = ps - 1;
73
74         fio_keywords_init();
75
76         if (parse_options(argc, argv))
77                 return 1;
78
79         if (nr_clients)
80                 return fio_handle_clients(&fio_client_ops);
81         else
82                 return fio_backend();
83 }