blob: 4603809e4705e2dc8b42b4d445d6645efc0c54c5 [file] [log] [blame]
Luis Hector Chavezf7b20182018-10-28 21:39:32 -07001/* 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
17int main() {
18 std::cout << "{\n";
19 std::cout << " \"arch_nr\": " << ARCH_NR << ",\n";
Luis Hector Chavez06862d62018-11-02 19:07:55 -070020 std::cout << " \"arch_name\": \"" << ARCH_NAME << "\",\n";
Luis Hector Chavezf7b20182018-10-28 21:39:32 -070021 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}