Commit 261f61a1 authored by Andrew Jeffery's avatar Andrew Jeffery

vpnor: Shuffle and rework includes for sanity

Include ordering and whether or not C linkage is forced by `extern "C"`
blocks can cause headaches at link time. Ensure that all C dependencies
are included in an `extern C` block before other includes occur. Also
include the C++ versions of string.h and assert.h

Change-Id: Ia96f6044d40c8eccb907b65924efcf62ac7a89c3
Signed-off-by: Andrew Jeffery's avatarAndrew Jeffery <andrew@aj.id.au>
parent 8e1d5dda
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
#include "vpnor/pnor_partition_table.hpp" #include "vpnor/pnor_partition_table.hpp"
#include <assert.h> #include <cassert>
#include <string.h> #include <cstring>
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
......
...@@ -3,11 +3,6 @@ ...@@ -3,11 +3,6 @@
#include "config.h" #include "config.h"
#include <assert.h>
#include <string.h>
#include "vpnor/mboxd_pnor_partition_table.h"
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
#include "test/system.h" #include "test/system.h"
...@@ -15,6 +10,11 @@ extern "C" { ...@@ -15,6 +10,11 @@ extern "C" {
#include "vpnor/test/tmpd.hpp" #include "vpnor/test/tmpd.hpp"
#include <cassert>
#include <cstring>
#include "vpnor/mboxd_pnor_partition_table.h"
const std::string toc[] = { const std::string toc[] = {
"partition01=HBB,00001000,00002000,80,ECC,READONLY", "partition01=HBB,00001000,00002000,80,ECC,READONLY",
}; };
......
...@@ -3,15 +3,6 @@ ...@@ -3,15 +3,6 @@
#include "config.h" #include "config.h"
#include <assert.h>
#include <string.h>
#include <experimental/filesystem>
#include <fstream>
#include <vector>
#include "vpnor/mboxd_pnor_partition_table.h"
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
#include "test/system.h" #include "test/system.h"
...@@ -19,6 +10,14 @@ extern "C" { ...@@ -19,6 +10,14 @@ extern "C" {
#include "vpnor/test/tmpd.hpp" #include "vpnor/test/tmpd.hpp"
#include <cassert>
#include <cstring>
#include <experimental/filesystem>
#include <fstream>
#include <vector>
#include "vpnor/mboxd_pnor_partition_table.h"
// A read window assumes that the toc is located at offset 0, // A read window assumes that the toc is located at offset 0,
// so create dummy partition at arbitrary offset 0x1000. // so create dummy partition at arbitrary offset 0x1000.
const std::string toc[] = { const std::string toc[] = {
......
...@@ -3,11 +3,6 @@ ...@@ -3,11 +3,6 @@
#include "config.h" #include "config.h"
#include <assert.h>
#include <string.h>
#include "vpnor/mboxd_pnor_partition_table.h"
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
#include "test/system.h" #include "test/system.h"
...@@ -15,6 +10,11 @@ extern "C" { ...@@ -15,6 +10,11 @@ extern "C" {
#include "vpnor/test/tmpd.hpp" #include "vpnor/test/tmpd.hpp"
#include <cassert>
#include <cstring>
#include "vpnor/mboxd_pnor_partition_table.h"
const std::string toc[] = { const std::string toc[] = {
"partition01=HBB,00002000,00003000,80,ECC,READONLY", "partition01=HBB,00002000,00003000,80,ECC,READONLY",
}; };
......
...@@ -3,15 +3,6 @@ ...@@ -3,15 +3,6 @@
#include "config.h" #include "config.h"
#include <assert.h>
#include <string.h>
#include <experimental/filesystem>
#include <fstream>
#include <vector>
#include "vpnor/mboxd_pnor_partition_table.h"
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
#include "test/system.h" #include "test/system.h"
...@@ -19,6 +10,14 @@ extern "C" { ...@@ -19,6 +10,14 @@ extern "C" {
#include "vpnor/test/tmpd.hpp" #include "vpnor/test/tmpd.hpp"
#include <cassert>
#include <cstring>
#include <experimental/filesystem>
#include <fstream>
#include <vector>
#include "vpnor/mboxd_pnor_partition_table.h"
static const auto BLOCK_SIZE = 4096; static const auto BLOCK_SIZE = 4096;
static const auto ERASE_SIZE = BLOCK_SIZE; static const auto ERASE_SIZE = BLOCK_SIZE;
static const auto WINDOW_SIZE = 16 * BLOCK_SIZE; static const auto WINDOW_SIZE = 16 * BLOCK_SIZE;
......
...@@ -3,18 +3,18 @@ ...@@ -3,18 +3,18 @@
#include "config.h" #include "config.h"
#include <assert.h>
#include <experimental/filesystem>
#include "vpnor/mboxd_pnor_partition_table.h"
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
#include "test/system.h" #include "test/system.h"
} }
#include "vpnor/test/tmpd.hpp" #include "vpnor/test/tmpd.hpp"
#include <cassert>
#include <experimental/filesystem>
#include "vpnor/mboxd_pnor_partition_table.h"
static const auto BLOCK_SIZE = 4096; static const auto BLOCK_SIZE = 4096;
static const auto ERASE_SIZE = BLOCK_SIZE; static const auto ERASE_SIZE = BLOCK_SIZE;
static const auto WINDOW_SIZE = 2 * BLOCK_SIZE; static const auto WINDOW_SIZE = 2 * BLOCK_SIZE;
......
...@@ -3,11 +3,6 @@ ...@@ -3,11 +3,6 @@
#include "config.h" #include "config.h"
#include <assert.h>
#include <string.h>
#include "vpnor/mboxd_pnor_partition_table.h"
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
#include "test/system.h" #include "test/system.h"
...@@ -15,6 +10,11 @@ extern "C" { ...@@ -15,6 +10,11 @@ extern "C" {
#include "vpnor/test/tmpd.hpp" #include "vpnor/test/tmpd.hpp"
#include <cassert>
#include <cstring>
#include "vpnor/mboxd_pnor_partition_table.h"
const std::string toc[] = { const std::string toc[] = {
"partition01=ONE,00001000,00002000,80,ECC,READONLY", "partition01=ONE,00001000,00002000,80,ECC,READONLY",
"partition02=TWO,00002000,00003000,80,ECC,READONLY", "partition02=TWO,00002000,00003000,80,ECC,READONLY",
......
...@@ -4,10 +4,11 @@ ...@@ -4,10 +4,11 @@
#include "vpnor/pnor_partition_table.hpp" #include "vpnor/pnor_partition_table.hpp"
#include <assert.h>
#include <string.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <cassert>
#include <cstring>
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
#include "test/system.h" #include "test/system.h"
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
#include "config.h" #include "config.h"
#include <assert.h>
#include "vpnor/mboxd_pnor_partition_table.h"
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
#include "test/system.h" #include "test/system.h"
...@@ -14,6 +10,10 @@ extern "C" { ...@@ -14,6 +10,10 @@ extern "C" {
#include "vpnor/test/tmpd.hpp" #include "vpnor/test/tmpd.hpp"
#include <cassert>
#include "vpnor/mboxd_pnor_partition_table.h"
const std::string toc[] = { const std::string toc[] = {
"partition01=HBB,00001000,00002000,80,ECC,READONLY", "partition01=HBB,00001000,00002000,80,ECC,READONLY",
}; };
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
#include "config.h" #include "config.h"
#include <assert.h>
#include "vpnor/mboxd_pnor_partition_table.h"
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
#include "test/system.h" #include "test/system.h"
...@@ -14,6 +10,10 @@ extern "C" { ...@@ -14,6 +10,10 @@ extern "C" {
#include "vpnor/test/tmpd.hpp" #include "vpnor/test/tmpd.hpp"
#include <cassert>
#include "vpnor/mboxd_pnor_partition_table.h"
const std::string toc[] = { const std::string toc[] = {
"partition01=HBB,00001000,00002000,80,ECC,READWRITE", "partition01=HBB,00001000,00002000,80,ECC,READWRITE",
}; };
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
#include "config.h" #include "config.h"
#include <assert.h>
#include "vpnor/mboxd_pnor_partition_table.h"
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
#include "test/system.h" #include "test/system.h"
...@@ -14,6 +10,10 @@ extern "C" { ...@@ -14,6 +10,10 @@ extern "C" {
#include "vpnor/test/tmpd.hpp" #include "vpnor/test/tmpd.hpp"
#include <cassert>
#include "vpnor/mboxd_pnor_partition_table.h"
static constexpr auto BLOCK_SIZE = 0x1000; static constexpr auto BLOCK_SIZE = 0x1000;
static constexpr auto ERASE_SIZE = BLOCK_SIZE; static constexpr auto ERASE_SIZE = BLOCK_SIZE;
static constexpr auto N_WINDOWS = 1; static constexpr auto N_WINDOWS = 1;
......
...@@ -3,19 +3,19 @@ ...@@ -3,19 +3,19 @@
#include "config.h" #include "config.h"
#include <assert.h>
#include <string.h>
#include "transport_mbox.h"
#include "vpnor/mboxd_pnor_partition_table.h"
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
#include "test/system.h" #include "test/system.h"
#include "transport_mbox.h"
} }
#include "vpnor/test/tmpd.hpp" #include "vpnor/test/tmpd.hpp"
#include <cassert>
#include <cstring>
#include "vpnor/mboxd_pnor_partition_table.h"
struct test_context struct test_context
{ {
uint8_t seq; uint8_t seq;
......
...@@ -4,11 +4,12 @@ ...@@ -4,11 +4,12 @@
#include "vpnor/pnor_partition_table.hpp" #include "vpnor/pnor_partition_table.hpp"
#include <assert.h>
#include <endian.h> #include <endian.h>
#include <string.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <cassert>
#include <cstring>
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
#include "test/system.h" #include "test/system.h"
......
...@@ -3,18 +3,18 @@ ...@@ -3,18 +3,18 @@
#include "config.h" #include "config.h"
#include <assert.h>
#include "common.h"
#include "vpnor/mboxd_pnor_partition_table.h"
extern "C" { extern "C" {
#include "common.h"
#include "test/mbox.h" #include "test/mbox.h"
#include "test/system.h" #include "test/system.h"
} }
#include "vpnor/test/tmpd.hpp" #include "vpnor/test/tmpd.hpp"
#include <cassert>
#include "vpnor/mboxd_pnor_partition_table.h"
static constexpr auto BLOCK_SIZE = 0x1000; static constexpr auto BLOCK_SIZE = 0x1000;
static constexpr auto ERASE_SIZE = BLOCK_SIZE; static constexpr auto ERASE_SIZE = BLOCK_SIZE;
static constexpr auto PART_SIZE = BLOCK_SIZE * 4; static constexpr auto PART_SIZE = BLOCK_SIZE * 4;
......
...@@ -3,17 +3,18 @@ ...@@ -3,17 +3,18 @@
#include "config.h" #include "config.h"
#include "vpnor/pnor_partition_table.hpp" extern "C" {
#include "mboxd.h"
}
#include <assert.h> #include "vpnor/pnor_partition_table.hpp"
#include <string.h>
#include <cassert>
#include <cstring>
#include <experimental/filesystem> #include <experimental/filesystem>
#include <fstream> #include <fstream>
#include <vector> #include <vector>
#include "mboxd.h"
namespace openpower namespace openpower
{ {
namespace virtual_pnor namespace virtual_pnor
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "vpnor/pnor_partition_table.hpp" #include "vpnor/pnor_partition_table.hpp"
#include <assert.h> #include <cassert>
#include "common.h" #include "common.h"
#include "vpnor/pnor_partition_defs.h" #include "vpnor/pnor_partition_defs.h"
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
#include "vpnor/pnor_partition_table.hpp" #include "vpnor/pnor_partition_table.hpp"
#include "xyz/openbmc_project/Common/error.hpp" #include "xyz/openbmc_project/Common/error.hpp"
#include <assert.h> #include <cassert>
#include <string.h> #include <cstring>
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
#include "vpnor/pnor_partition_table.hpp" #include "vpnor/pnor_partition_table.hpp"
#include <assert.h> #include <cassert>
#include <string.h> #include <cstring>
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
#include "vpnor/pnor_partition_table.hpp" #include "vpnor/pnor_partition_table.hpp"
#include <assert.h> #include <cassert>
#include <string.h> #include <cstring>
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "vpnor/pnor_partition_table.hpp" #include "vpnor/pnor_partition_table.hpp"
#include <assert.h> #include <cassert>
static constexpr auto BLOCK_SIZE = 4 * 1024; static constexpr auto BLOCK_SIZE = 4 * 1024;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "vpnor/pnor_partition_table.hpp" #include "vpnor/pnor_partition_table.hpp"
#include <assert.h> #include <cassert>
static constexpr auto BLOCK_SIZE = 4 * 1024; static constexpr auto BLOCK_SIZE = 4 * 1024;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "vpnor/pnor_partition_table.hpp" #include "vpnor/pnor_partition_table.hpp"
#include <assert.h> #include <cassert>
static constexpr auto BLOCK_SIZE = 4 * 1024; static constexpr auto BLOCK_SIZE = 4 * 1024;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "vpnor/pnor_partition_table.hpp" #include "vpnor/pnor_partition_table.hpp"
#include <assert.h> #include <cassert>
static constexpr auto BLOCK_SIZE = 4 * 1024; static constexpr auto BLOCK_SIZE = 4 * 1024;
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
#include "vpnor/pnor_partition_table.hpp" #include "vpnor/pnor_partition_table.hpp"
#include <assert.h> #include <cassert>
#include <string.h> #include <cstring>
extern "C" { extern "C" {
#include "test/mbox.h" #include "test/mbox.h"
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "vpnor/pnor_partition_table.hpp" #include "vpnor/pnor_partition_table.hpp"
#include <assert.h> #include <cassert>
static constexpr auto BLOCK_SIZE = 4 * 1024; static constexpr auto BLOCK_SIZE = 4 * 1024;
......
...@@ -3,23 +3,23 @@ ...@@ -3,23 +3,23 @@
#include "config.h" #include "config.h"
#include <assert.h> extern "C" {
#include "common.h"
#include "flash.h"
#include "mboxd.h"
}
#include "vpnor/test/tmpd.hpp"
#include <fcntl.h> #include <fcntl.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/syslog.h> #include <sys/syslog.h>
#include <unistd.h> #include <unistd.h>
#include <cassert>
#include <experimental/filesystem> #include <experimental/filesystem>
#include "common.h"
#include "mboxd.h"
extern "C" {
#include "flash.h"
}
#include "vpnor/test/tmpd.hpp"
static constexpr auto BLOCK_SIZE = 0x1000; static constexpr auto BLOCK_SIZE = 0x1000;
static constexpr auto DATA_SIZE = 8; static constexpr auto DATA_SIZE = 8;
......
...@@ -3,7 +3,14 @@ ...@@ -3,7 +3,14 @@
#include "config.h" #include "config.h"
#include <assert.h> extern "C" {
#include "common.h"
#include "flash.h"
#include "mboxd.h"
}
#include "vpnor/test/tmpd.hpp"
#include <fcntl.h> #include <fcntl.h>
#include <stdint.h> #include <stdint.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
...@@ -11,17 +18,9 @@ ...@@ -11,17 +18,9 @@
#include <sys/syslog.h> #include <sys/syslog.h>
#include <unistd.h> #include <unistd.h>
#include <cassert>
#include <experimental/filesystem> #include <experimental/filesystem>
#include "common.h"
#include "mboxd.h"
extern "C" {
#include "flash.h"
}
#include "vpnor/test/tmpd.hpp"
static constexpr auto BLOCK_SIZE = 0x1000; static constexpr auto BLOCK_SIZE = 0x1000;
static constexpr auto PART_SIZE = BLOCK_SIZE; static constexpr auto PART_SIZE = BLOCK_SIZE;
static constexpr auto PATCH_SIZE = BLOCK_SIZE / 2; static constexpr auto PATCH_SIZE = BLOCK_SIZE / 2;
......
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2018 IBM Corp. // Copyright (C) 2018 IBM Corp.
#include <assert.h> extern "C" {
#include "common.h"
#include "flash.h"
#include "mboxd.h"
}
#include "vpnor/test/tmpd.hpp"
#include <fcntl.h> #include <fcntl.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>