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

fix compiling errors on AIX #2181

Merged
merged 3 commits into from
Nov 20, 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
2 changes: 1 addition & 1 deletion bench/async_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void thread_fun(std::shared_ptr<spdlog::logger> logger, int howmany)
void bench_mt(int howmany, std::shared_ptr<spdlog::logger> logger, int thread_count)
{
using std::chrono::high_resolution_clock;
vector<thread> threads;
vector<std::thread> threads;
auto start = high_resolution_clock::now();

int msgs_per_thread = howmany / thread_count;
Expand Down
15 changes: 11 additions & 4 deletions include/spdlog/details/os-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
# include <sys/syscall.h> //Use gettid() syscall under linux to get thread id

# elif defined(_AIX)
# include <pthread.h> // for pthread_getthreadid_np
# include <pthread.h> // for pthread_getthrds_np

# elif defined(__DragonFly__) || defined(__FreeBSD__)
# include <pthread_np.h> // for pthread_getthreadid_np
Expand Down Expand Up @@ -230,8 +230,8 @@ SPDLOG_INLINE size_t filesize(FILE *f)
# endif

#else // unix
// OpenBSD doesn't compile with :: before the fileno(..)
# if defined(__OpenBSD__)
// OpenBSD and AIX doesn't compile with :: before the fileno(..)
# if defined(__OpenBSD__) || defined(_AIX)
int fd = fileno(f);
# else
int fd = ::fileno(f);
Expand Down Expand Up @@ -336,7 +336,14 @@ SPDLOG_INLINE size_t _thread_id() SPDLOG_NOEXCEPT
# define SYS_gettid __NR_gettid
# endif
return static_cast<size_t>(::syscall(SYS_gettid));
#elif defined(_AIX) || defined(__DragonFly__) || defined(__FreeBSD__)
#elif defined(_AIX)
struct __pthrdsinfo buf;
int reg_size = 0;
pthread_t pt = pthread_self();
int retval = pthread_getthrds_np(&pt, PTHRDSINFO_QUERY_TID, &buf, sizeof(buf), NULL, &reg_size);
int tid = (!retval) ? buf.__pi_tid : 0;
return static_cast<size_t>(tid);
#elif defined(__DragonFly__) || defined(__FreeBSD__)
return static_cast<size_t>(::pthread_getthreadid_np());
#elif defined(__NetBSD__)
return static_cast<size_t>(::_lwp_self());
Expand Down