1 /* Copyright 2018 The Chromium OS Authors. All rights reserved.
2  * Use of this source code is governed by a BSD-style license that can be
3  * found in the LICENSE file.
4  */
5 
6 // Generate a .json file with all the architecture-specific constants.
7 
8 #include <cstdint>
9 #include <iomanip>
10 #include <iostream>
11 #include <string>
12 
13 #include "arch.h"
14 #include "libconstants.h"
15 #include "libsyscalls.h"
16 
main()17 int main() {
18   std::cout << "{\n";
19   std::cout << "  \"arch_nr\": " << ARCH_NR << ",\n";
20   std::cout << "  \"arch_name\": \"" << ARCH_NAME << "\",\n";
21   std::cout << "  \"bits\": " << (sizeof(uintptr_t) * 8) << ",\n";
22   std::cout << "  \"syscalls\": {\n";
23   bool first = true;
24   for (const struct syscall_entry* entry = syscall_table; entry->name;
25        ++entry) {
26     if (first)
27       first = false;
28     else
29       std::cout << ",\n";
30     std::cout << "    \"" << entry->name << "\": " << entry->nr;
31   }
32   std::cout << "\n  },\n";
33   std::cout << "  \"constants\": {\n";
34   first = true;
35   for (const struct constant_entry* entry = constant_table; entry->name;
36        ++entry) {
37     if (first)
38       first = false;
39     else
40       std::cout << ",\n";
41     std::cout << "    \"" << entry->name << "\": " << entry->value;
42   }
43   std::cout << "\n  }\n";
44   std::cout << "}\n";
45 
46   return 0;
47 }
48