Skip to content

Commit

Permalink
Merge pull request #222 from sifive/esat252-gcc10-fix
Browse files Browse the repository at this point in the history
Add missing 'extern'.
  • Loading branch information
bsousi5 committed May 27, 2020
2 parents d22d8f5 + 3670edb commit 8794925
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 8 deletions.
6 changes: 3 additions & 3 deletions metal_header/device.c++
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ std::string Device::platform_define_offset(node n, std::string suffix) {
* "__metal_" namespace */
void Device::emit_struct_decl(std::string type, const node &n) {
emit_comment(n);
os << "struct __metal_driver_" << type << " __metal_dt_" << n.handle()
os << "extern struct __metal_driver_" << type << " __metal_dt_" << n.handle()
<< ";\n\n";
}

void Device::emit_struct_decl(std::string type, std::string suffix,
const node &n) {
emit_comment(n);
os << "struct __metal_driver_" << type << "_" << suffix << " __metal_dt_"
<< n.handle() << "_" << suffix << ";\n\n";
os << "extern struct __metal_driver_" << type << "_" << suffix
<< " __metal_dt_" << n.handle() << "_" << suffix << ";\n\n";
}

void Device::emit_struct_begin(std::string type, const node &n) {
Expand Down
2 changes: 1 addition & 1 deletion metal_header/memory.c++
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void memory::include_headers() { os << "#include <metal/memory.h>\n"; }

void memory::declare_structs() {
auto declare = [&](node n) {
os << "struct metal_memory __metal_dt_mem_" << n.handle() << ";\n\n";
os << "extern struct metal_memory __metal_dt_mem_" << n.handle() << ";\n\n";
};

dtb.match(std::regex("sifive,sram0"), declare, std::regex("sifive,testram0"),
Expand Down
2 changes: 1 addition & 1 deletion metal_header/riscv_cpu_intc.c++
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ string riscv_cpu_intc::handle(node n) {

void riscv_cpu_intc::declare_structs() {
dtb.match(std::regex(compat_string), [&](node n) {
os << "struct __metal_driver_riscv_cpu_intc __metal_dt_" << handle(n)
os << "extern struct __metal_driver_riscv_cpu_intc __metal_dt_" << handle(n)
<< ";\n\n";
});
}
Expand Down
9 changes: 9 additions & 0 deletions metal_header/riscv_pmp.c++
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ riscv_pmp::riscv_pmp(std::ostream &os, const fdt &dtb)
void riscv_pmp::include_headers() { os << "#include <metal/pmp.h>\n"; }

void riscv_pmp::declare_structs() {
if (pmp_present) {
os << "extern struct metal_pmp __metal_dt_pmp;\n\n";
} else if (dtb.match(std::regex("riscv,pmp"), [](const node n) {}) != 0) {
/* This handles the old-style nodes with the riscv,pmp compat strings. */
os << "extern struct metal_pmp __metal_dt_pmp;\n\n";
}
}

void riscv_pmp::define_structs() {
if (pmp_present) {
os << "struct metal_pmp __metal_dt_pmp;\n\n";
} else if (dtb.match(std::regex("riscv,pmp"), [](const node n) {}) != 0) {
Expand Down
1 change: 1 addition & 0 deletions metal_header/riscv_pmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class riscv_pmp : public Device {
riscv_pmp(std::ostream &os, const fdt &dtb);
void include_headers();
void declare_structs();
void define_structs();
void create_handles();
};

Expand Down
2 changes: 1 addition & 1 deletion metal_header/sifive_buserror0.c++
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void sifive_buserror0::define_inlines() {
void sifive_buserror0::declare_structs() {
dtb.match(std::regex(compat_string), [&](node n) {
emit_comment(n);
os << "struct metal_buserror"
os << "extern struct metal_buserror"
" __metal_dt_"
<< n.handle() << ";\n\n";
});
Expand Down
4 changes: 2 additions & 2 deletions metal_header/sifive_rtc0.c++
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ void sifive_rtc0::define_inlines() {
void sifive_rtc0::declare_structs() {
dtb.match(std::regex(compat_string), [&](node n) {
emit_comment(n);
os << "struct __metal_driver_sifive_rtc0 __metal_dt_rtc_" << n.instance()
<< ";\n\n";
os << "extern struct __metal_driver_sifive_rtc0 __metal_dt_rtc_"
<< n.instance() << ";\n\n";
});
}

Expand Down

0 comments on commit 8794925

Please sign in to comment.