Skip to content

Commit e1e8620

Browse files
authored
Merge pull request #1460 from RenZ0/0.10
Changes to allow build on FreeBSD
2 parents 3478fc6 + 5421eff commit e1e8620

File tree

5 files changed

+70
-4
lines changed

5 files changed

+70
-4
lines changed

common/network/PosixInterfacePicker.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#endif // HAVE_SYS_SOCKET_H
3939
#include <arpa/inet.h>
4040
#ifdef HAVE_NETINET_IN_H
41-
#include <netinet/in.h> // Required by FreeBSD
41+
#include <netinet/in.h> // Required by FreeBSD
4242
#endif // HAVE_NETINET_IN_H
4343
#include <errno.h>
4444
#include <net/if.h>
@@ -226,7 +226,7 @@ vector<Interface> PosixInterfacePicker::GetInterfaces(
226226
interface.index = ifrcopy.ifr_index;
227227
#else
228228
interface.index = ifrcopy.ifr_ifindex;
229-
#endif // SIOCGIFINDEX
229+
#endif // __FreeBSD__
230230
}
231231
}
232232
#elif defined(HAVE_IF_NAMETOINDEX)
@@ -235,7 +235,7 @@ vector<Interface> PosixInterfacePicker::GetInterfaces(
235235
if (index != 0) {
236236
interface.index = index;
237237
}
238-
#endif // defined(HAVE_IF_NAMETOINDEX)
238+
#endif // SIOCGIFINDEX
239239

240240
/* ok, if that all failed we should prob try and use sysctl to work out the
241241
* broadcast and hardware addresses

common/web/JsonTest.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,12 @@ void JsonTest::testLookups() {
556556
JsonString string1("foo");
557557
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(&string1),
558558
string1.LookupElement(empty_pointer));
559+
560+
#ifdef __FreeBSD__
561+
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(0),
562+
#else
559563
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(NULL),
564+
#endif // __FreeBSD__
560565
string1.LookupElement(invalid_pointer));
561566

562567
// Now try an object
@@ -571,7 +576,12 @@ void JsonTest::testLookups() {
571576
object.LookupElement(empty_pointer));
572577
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(name_value),
573578
object.LookupElement(name_pointer));
579+
580+
#ifdef __FreeBSD__
581+
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(0),
582+
#else
574583
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(NULL),
584+
#endif // __FreeBSD__
575585
object.LookupElement(invalid_pointer));
576586

577587
// Now try an array
@@ -591,17 +601,33 @@ void JsonTest::testLookups() {
591601

592602
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(array),
593603
array->LookupElement(empty_pointer));
604+
605+
#ifdef __FreeBSD__
606+
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(0),
607+
#else
594608
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(NULL),
609+
#endif // __FreeBSD__
595610
array->LookupElement(invalid_pointer));
611+
596612
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(string2),
597613
array->LookupElement(first));
598614
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(string3),
599615
array->LookupElement(middle));
600616
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(string4),
601617
array->LookupElement(last));
618+
619+
#ifdef __FreeBSD__
620+
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(0),
621+
#else
602622
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(NULL),
623+
#endif // __FreeBSD__
603624
array->LookupElement(one_past_last));
625+
626+
#ifdef __FreeBSD__
627+
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(0),
628+
#else
604629
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(NULL),
630+
#endif // __FreeBSD__
605631
array->LookupElement(invalid));
606632

607633
// now a nested case

config/resolv.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ AC_CHECK_HEADERS([resolv.h])
2727
am_save_LDFLAGS="$LDFLAGS"
2828
RESOLV_LIBS=""
2929
30-
acx_resolv_libs="-lresolv -resolv"
30+
acx_resolv_libs="-lresolv -resolv -lc"
3131
for lib in $acx_resolv_libs; do
3232
acx_resolv_ok=no
3333
LDFLAGS="$am_save_LDFLAGS $lib"

ola/AutoStart.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ TCPSocket *ConnectToServer(unsigned short port) {
110110
// Try to start the server, we pass --daemon (fork into background) and
111111
// --syslog (log to syslog).
112112
execlp("olad", "olad", "--daemon", "--syslog",
113+
#ifdef __FreeBSD__
114+
reinterpret_cast<char*>(0));
115+
#else
113116
reinterpret_cast<char*>(NULL));
117+
#endif // __FreeBSD__
114118
OLA_WARN << "Failed to exec: " << strerror(errno);
115119
_exit(1);
116120
}

olad/plugin_api/UniverseTest.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,11 @@ void UniverseTest::testRDMSend() {
632632
&UniverseTest::ConfirmRDM,
633633
__LINE__,
634634
ola::rdm::RDM_UNKNOWN_UID,
635+
#ifdef __FreeBSD__
636+
reinterpret_cast<const RDMResponse*>(0)));
637+
#else
635638
reinterpret_cast<const RDMResponse*>(NULL)));
639+
#endif // __FreeBSD__
636640

637641
// ok, now try something that returns a response from the port
638642
request = new ola::rdm::RDMGetRequest(
@@ -654,7 +658,11 @@ void UniverseTest::testRDMSend() {
654658
&UniverseTest::ConfirmRDM,
655659
__LINE__,
656660
ola::rdm::RDM_TIMEOUT,
661+
#ifdef __FreeBSD__
662+
reinterpret_cast<const RDMResponse*>(0)));
663+
#else
657664
reinterpret_cast<const RDMResponse*>(NULL)));
665+
#endif // __FreeBSD__
658666

659667
// now try a broadcast fan out
660668
UID vendorcast_uid = UID::VendorcastAddress(0x7a70);
@@ -683,7 +691,11 @@ void UniverseTest::testRDMSend() {
683691
&UniverseTest::ConfirmRDM,
684692
__LINE__,
685693
ola::rdm::RDM_WAS_BROADCAST,
694+
#ifdef __FreeBSD__
695+
reinterpret_cast<const RDMResponse*>(0)));
696+
#else
686697
reinterpret_cast<const RDMResponse*>(NULL)));
698+
#endif // __FreeBSD__
687699

688700
// now confirm that if one of the ports fails to send, we see this response
689701
request = new ola::rdm::RDMGetRequest(
@@ -707,7 +719,11 @@ void UniverseTest::testRDMSend() {
707719
&UniverseTest::ConfirmRDM,
708720
__LINE__,
709721
ola::rdm::RDM_FAILED_TO_SEND,
722+
#ifdef __FreeBSD__
723+
reinterpret_cast<const RDMResponse*>(0)));
724+
#else
710725
reinterpret_cast<const RDMResponse*>(NULL)));
726+
#endif // __FreeBSD__
711727

712728
// DUB responses are slightly different
713729
request = NewDiscoveryUniqueBranchRequest(source_uid, uid1, uid2, 0);
@@ -727,7 +743,11 @@ void UniverseTest::testRDMSend() {
727743
&UniverseTest::ConfirmRDM,
728744
__LINE__,
729745
ola::rdm::RDM_DUB_RESPONSE,
746+
#ifdef __FreeBSD__
747+
reinterpret_cast<const RDMResponse*>(0)));
748+
#else
730749
reinterpret_cast<const RDMResponse*>(NULL)));
750+
#endif // __FreeBSD__
731751

732752
// now check that we still get a RDM_DUB_RESPONSE even if one port returns an
733753
// RDM_TIMEOUT
@@ -744,7 +764,11 @@ void UniverseTest::testRDMSend() {
744764
&UniverseTest::ConfirmRDM,
745765
__LINE__,
746766
ola::rdm::RDM_DUB_RESPONSE,
767+
#ifdef __FreeBSD__
768+
reinterpret_cast<const RDMResponse*>(0)));
769+
#else
747770
reinterpret_cast<const RDMResponse*>(NULL)));
771+
#endif // __FreeBSD__
748772

749773
// and the same again but the second port returns
750774
// RDM_PLUGIN_DISCOVERY_NOT_SUPPORTED
@@ -761,7 +785,11 @@ void UniverseTest::testRDMSend() {
761785
&UniverseTest::ConfirmRDM,
762786
__LINE__,
763787
ola::rdm::RDM_DUB_RESPONSE,
788+
#ifdef __FreeBSD__
789+
reinterpret_cast<const RDMResponse*>(0)));
790+
#else
764791
reinterpret_cast<const RDMResponse*>(NULL)));
792+
#endif // __FreeBSD__
765793

766794
// now the first port returns a RDM_TIMEOUT
767795
request = NewDiscoveryUniqueBranchRequest(source_uid, uid1, uid2, 0);
@@ -777,7 +805,11 @@ void UniverseTest::testRDMSend() {
777805
&UniverseTest::ConfirmRDM,
778806
__LINE__,
779807
ola::rdm::RDM_TIMEOUT,
808+
#ifdef __FreeBSD__
809+
reinterpret_cast<const RDMResponse*>(0)));
810+
#else
780811
reinterpret_cast<const RDMResponse*>(NULL)));
812+
#endif // __FreeBSD__
781813

782814
// finally if neither ports support the DUB, we should return that
783815
request = NewDiscoveryUniqueBranchRequest(source_uid, uid1, uid2, 0);
@@ -793,7 +825,11 @@ void UniverseTest::testRDMSend() {
793825
&UniverseTest::ConfirmRDM,
794826
__LINE__,
795827
ola::rdm::RDM_PLUGIN_DISCOVERY_NOT_SUPPORTED,
828+
#ifdef __FreeBSD__
829+
reinterpret_cast<const RDMResponse*>(0)));
830+
#else
796831
reinterpret_cast<const RDMResponse*>(NULL)));
832+
#endif // __FreeBSD__
797833

798834
universe->RemovePort(&port1);
799835
universe->RemovePort(&port2);

0 commit comments

Comments
 (0)