Merge pull request #2181 from lisr/os_inl_aix_fix
fix compiling errors on AIX
This commit is contained in:
		@@ -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)
 | 
					void bench_mt(int howmany, std::shared_ptr<spdlog::logger> logger, int thread_count)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    using std::chrono::high_resolution_clock;
 | 
					    using std::chrono::high_resolution_clock;
 | 
				
			||||||
    vector<thread> threads;
 | 
					    vector<std::thread> threads;
 | 
				
			||||||
    auto start = high_resolution_clock::now();
 | 
					    auto start = high_resolution_clock::now();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int msgs_per_thread = howmany / thread_count;
 | 
					    int msgs_per_thread = howmany / thread_count;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,7 +46,7 @@
 | 
				
			|||||||
#        include <sys/syscall.h> //Use gettid() syscall under linux to get thread id
 | 
					#        include <sys/syscall.h> //Use gettid() syscall under linux to get thread id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#    elif defined(_AIX)
 | 
					#    elif defined(_AIX)
 | 
				
			||||||
#        include <pthread.h> // for pthread_getthreadid_np
 | 
					#        include <pthread.h> // for pthread_getthrds_np
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#    elif defined(__DragonFly__) || defined(__FreeBSD__)
 | 
					#    elif defined(__DragonFly__) || defined(__FreeBSD__)
 | 
				
			||||||
#        include <pthread_np.h> // for pthread_getthreadid_np
 | 
					#        include <pthread_np.h> // for pthread_getthreadid_np
 | 
				
			||||||
@@ -230,8 +230,8 @@ SPDLOG_INLINE size_t filesize(FILE *f)
 | 
				
			|||||||
#    endif
 | 
					#    endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#else // unix
 | 
					#else // unix
 | 
				
			||||||
// OpenBSD doesn't compile with :: before the fileno(..)
 | 
					// OpenBSD and AIX doesn't compile with :: before the fileno(..)
 | 
				
			||||||
#    if defined(__OpenBSD__)
 | 
					#    if defined(__OpenBSD__) || defined(_AIX)
 | 
				
			||||||
    int fd = fileno(f);
 | 
					    int fd = fileno(f);
 | 
				
			||||||
#    else
 | 
					#    else
 | 
				
			||||||
    int fd = ::fileno(f);
 | 
					    int fd = ::fileno(f);
 | 
				
			||||||
@@ -336,7 +336,14 @@ SPDLOG_INLINE size_t _thread_id() SPDLOG_NOEXCEPT
 | 
				
			|||||||
#        define SYS_gettid __NR_gettid
 | 
					#        define SYS_gettid __NR_gettid
 | 
				
			||||||
#    endif
 | 
					#    endif
 | 
				
			||||||
    return static_cast<size_t>(::syscall(SYS_gettid));
 | 
					    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, ®_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());
 | 
					    return static_cast<size_t>(::pthread_getthreadid_np());
 | 
				
			||||||
#elif defined(__NetBSD__)
 | 
					#elif defined(__NetBSD__)
 | 
				
			||||||
    return static_cast<size_t>(::_lwp_self());
 | 
					    return static_cast<size_t>(::_lwp_self());
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user