diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 396c39616c4..cfbfeee3574 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -662,6 +662,9 @@ Release 2.7.0 - UNRELEASED HADOOP-11558. Fix dead links to doc of hadoop-tools. (Jean-Pierre Matsumoto via ozawa) + HADOOP-11638. OpensslSecureRandom.c pthreads_thread_id should support FreeBSD + and Solaris in addition to Linux. (Kiran Kumar M R via cnauroth) + Release 2.6.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/crypto/random/OpensslSecureRandom.c b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/crypto/random/OpensslSecureRandom.c index 6c31d10599c..8f0c06d17a1 100644 --- a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/crypto/random/OpensslSecureRandom.c +++ b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/crypto/random/OpensslSecureRandom.c @@ -29,6 +29,10 @@ #include #endif +#if defined(__FreeBSD__) +#include +#endif + #ifdef WINDOWS #include #endif @@ -274,7 +278,19 @@ static void pthreads_locking_callback(int mode, int type, char *file, int line) static unsigned long pthreads_thread_id(void) { - return (unsigned long)syscall(SYS_gettid); + unsigned long thread_id = 0; +#if defined(__linux__) + thread_id = (unsigned long)syscall(SYS_gettid); +#elif defined(__FreeBSD__) + thread_id = (unsigned long)pthread_getthreadid_np(); +#elif defined(__sun) + thread_id = (unsigned long)pthread_self(); +#elif defined(__APPLE__) + (void)pthread_threadid_np(pthread_self(), &thread_id); +#else +#error "Platform not supported" +#endif + return thread_id; } #endif /* UNIX */