p4lang / behavioral-model

The reference P4 software switch
Apache License 2.0
538 stars 328 forks source link

FreeBSD patches #1190

Closed outpaddling closed 1 year ago

outpaddling commented 1 year ago

FYI, the FreeBSD port was pretty straightforward. The only issue was that _assert() is defined in FreeBSD's standard headers, so I changed the name of the member function:

--- include/bm/bm_sim/_assert.h.orig    2023-04-25 15:37:20 UTC
+++ include/bm/bm_sim/_assert.h
@@ -25,14 +25,14 @@

 namespace bm {

-[[ noreturn ]] void _assert(const char* expr, const char* file, int line);
+[[ noreturn ]] void bm_assert(const char* expr, const char* file, int line);

 }  // namespace bm

 #define _BM_ASSERT(expr) \
-  ((expr) ? (void)0 : bm::_assert(#expr, __FILE__, __LINE__))
+  ((expr) ? (void)0 : bm::bm_assert(#expr, __FILE__, __LINE__))

-#define _BM_UNREACHABLE(msg) bm::_assert(msg, __FILE__, __LINE__)
+#define _BM_UNREACHABLE(msg) bm::bm_assert(msg, __FILE__, __LINE__)

 #define _BM_UNUSED(x) ((void)x)

--- src/bm_sim/_assert.cpp.orig 2023-04-25 19:10:08 UTC
+++ src/bm_sim/_assert.cpp
@@ -25,7 +25,7 @@

 namespace bm {

-void _assert(const char* expr, const char* file, int line) {
+void bm_assert(const char* expr, const char* file, int line) {
   std::cerr << "Assertion '" << expr << "' failed, file '" << file
             << "' line '" << line << "'.\n";
   std::abort();

The work-in-progress port is here: https://github.com/outpaddling/freebsd-ports-wip/tree/master/bmv2