unsigned long tcn_get_thread_id()

in native/src/jnilib.c [474:502]


unsigned long tcn_get_thread_id(void)
{
    /* OpenSSL needs this to return an unsigned long.  On OS/390, the pthread
     * id is a structure twice that big.  Use the TCB pointer instead as a
     * unique unsigned long.
     */
#ifdef __MVS__
    struct PSA {
        char unmapped[540];
        unsigned long PSATOLD;
    } *psaptr = 0;

    return psaptr->PSATOLD;
#elif defined(WIN32)
    return (unsigned long)GetCurrentThreadId();
#elif defined(DARWIN)
    uint64_t tid;
    pthread_threadid_np(NULL, &tid);
    return (unsigned long)tid;
#elif defined(__FreeBSD__)
    return (unsigned long)pthread_getthreadid_np();
#elif defined(__linux__)
    return (unsigned long)syscall(SYS_gettid);
#elif defined(__hpux)
    return (unsigned long)_lwp_self();
#else
    return (unsigned long)pthread_self();
#endif
}