Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ADIOS2 build on FreeBSD #2739

Merged
merged 1 commit into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/adios2/helper/adiosComm.inl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <numeric> //std::accumulate
#include <stdexcept> //std::runtime_error
#include <string> //std::to_string
#include <utility> //std::pair

namespace adios2
Expand Down
11 changes: 6 additions & 5 deletions source/adios2/helper/adiosNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
#include <iostream>
#include <thread>

#include <arpa/inet.h> //AvailableIpAddresses() inet_ntoa
#include <net/if.h> //AvailableIpAddresses() struct if_nameindex
#include <string.h> //AvailableIpAddresses() strncp
#include <sys/ioctl.h> //AvailableIpAddresses() ioctl
#include <unistd.h> //AvailableIpAddresses() close
#include <arpa/inet.h> //AvailableIpAddresses() inet_ntoa
#include <net/if.h> //AvailableIpAddresses() struct if_nameindex
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried to make it compile on FreeBSD very long time ago, but as far as I remember these socket header files did not exist on BSD systems. Just wondering if there is any tricks I didn't know, or do they actually exist on BSD?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: I didn't remove any include statements, I only changed the indentation of the comments, which is shown as both removal and addition of new lines.

I compiled the code for FreeBSD in a Docker container via BinaryBuilder. I did not set up the container myself, but I assume it's reasonably standard. I don't know about other BSDs, or about native BSD systems.

#include <netinet/in.h> //AvailableIpAddresses() struct sockaddr_in
#include <string.h> //AvailableIpAddresses() strncp
#include <sys/ioctl.h> //AvailableIpAddresses() ioctl
#include <unistd.h> //AvailableIpAddresses() close

#include <nlohmann/json.hpp>

Expand Down
16 changes: 12 additions & 4 deletions source/adios2/toolkit/profiling/taustubs/tautimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include <sys/types.h>
#include <thread>

#if defined(__FreeBSD__)
#include <pthread_np.h>
#endif

/* Clean assertion handling */
inline void _tautimer_assert(const char *expression, const char *file, int line)
{
Expand Down Expand Up @@ -199,12 +203,14 @@ thread_local bool TauTimer::thread_seen(false);
// constructor
TauTimer::TauTimer(void) : initialized(false)
{
// Confirm that we are instantializing this singleton on the main thread!
// Confirm that we are instantiating this singleton on the main thread!
mypid = getpid();
#if defined(__APPLE__) && defined(__MACH__)
// why should Apple support gettid? BE DIFFERENT, BABY!
pthread_threadid_np(NULL, &mytid);
#elif defined(__FreeBSD__)
mytid = pthread_getthreadid_np();
#else
// __NR_gettid is Linux-only
mytid = (uint64_t)syscall(__NR_gettid);
#endif
if (tau_stub_initialize_simple_() == 0)
Expand All @@ -228,11 +234,13 @@ inline void TauTimer::_RegisterThread(void)
{
if (!thread_seen)
{
// Confirm that we are NOT on the main thread!
// Confirm that we are NOT on the main thread!
#if defined(__APPLE__) && defined(__MACH__)
// why should Apple support gettid? BE DIFFERENT, BABY!
pthread_threadid_np(NULL, &mytid);
#elif defined(__FreeBSD__)
mytid = pthread_getthreadid_np();
#else
// __NR_gettid is Linux-only
mytid = (uint64_t)syscall(__NR_gettid);
#endif
my_Tau_register_thread();
Expand Down