Commit | Line | Data |
---|---|---|
ebac4655 JA |
1 | /* |
2 | * fio - the flexible io tester | |
3 | * | |
4 | * Copyright (C) 2005 Jens Axboe <axboe@suse.de> | |
2e1df07d | 5 | * Copyright (C) 2006-2012 Jens Axboe <axboe@kernel.dk> |
ebac4655 | 6 | * |
8e9fe637 JA |
7 | * The license below covers all files distributed with fio unless otherwise |
8 | * noted in the file itself. | |
9 | * | |
ebac4655 | 10 | * This program is free software; you can redistribute it and/or modify |
8e9fe637 JA |
11 | * it under the terms of the GNU General Public License version 2 as |
12 | * published by the Free Software Foundation. | |
ebac4655 JA |
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 | */ | |
ebac4655 | 24 | #include <unistd.h> |
dbe1125e | 25 | #include <locale.h> |
a5b01f1b | 26 | #include <time.h> |
ebac4655 JA |
27 | |
28 | #include "fio.h" | |
2e5cdb11 | 29 | #include "smalloc.h" |
ebac4655 | 30 | |
5be4c944 JA |
31 | uintptr_t page_mask = 0; |
32 | uintptr_t page_size = 0; | |
d529ee19 | 33 | |
0ad5edcc JA |
34 | static int endian_check(void) |
35 | { | |
36 | union { | |
37 | uint8_t c[8]; | |
38 | uint64_t v; | |
39 | } u; | |
40 | int le = 0, be = 0; | |
41 | ||
42 | u.v = 0x12; | |
43 | if (u.c[7] == 0x12) | |
44 | be = 1; | |
45 | else if (u.c[0] == 0x12) | |
46 | le = 1; | |
47 | ||
0dcebdf4 | 48 | #if defined(CONFIG_LITTLE_ENDIAN) |
0ad5edcc JA |
49 | if (be) |
50 | return 1; | |
0dcebdf4 | 51 | #elif defined(CONFIG_BIG_ENDIAN) |
0ad5edcc JA |
52 | if (le) |
53 | return 1; | |
54 | #else | |
55 | return 1; | |
56 | #endif | |
57 | ||
58 | if (!le && !be) | |
59 | return 1; | |
60 | ||
61 | return 0; | |
62 | } | |
63 | ||
50d16976 JA |
64 | int main(int argc, char *argv[], char *envp[]) |
65 | { | |
66 | long ps; | |
67 | ||
0ad5edcc JA |
68 | if (endian_check()) { |
69 | log_err("fio: endianness settings appear wrong.\n"); | |
70 | log_err("fio: please report this to fio@vger.kernel.org\n"); | |
71 | return 1; | |
72 | } | |
73 | ||
67bf9823 JA |
74 | #if !defined(CONFIG_GETTIMEOFDAY) && !defined(CONFIG_CLOCK_GETTIME) |
75 | #error "No available clock source!" | |
76 | #endif | |
77 | ||
50d16976 JA |
78 | arch_init(envp); |
79 | ||
80 | sinit(); | |
81 | ||
82 | /* | |
83 | * We need locale for number printing, if it isn't set then just | |
84 | * go with the US format. | |
85 | */ | |
86 | if (!getenv("LC_NUMERIC")) | |
87 | setlocale(LC_NUMERIC, "en_US"); | |
88 | ||
89 | ps = sysconf(_SC_PAGESIZE); | |
90 | if (ps < 0) { | |
91 | log_err("Failed to get page size\n"); | |
92 | return 1; | |
93 | } | |
94 | ||
95 | page_size = ps; | |
96 | page_mask = ps - 1; | |
97 | ||
98 | fio_keywords_init(); | |
99 | ||
100 | if (parse_options(argc, argv)) | |
101 | return 1; | |
102 | ||
fa80feae JA |
103 | fio_time_init(); |
104 | ||
2e1df07d JA |
105 | if (nr_clients) |
106 | return fio_handle_clients(); | |
107 | else | |
108 | return fio_backend(); | |
50d16976 | 109 | } |