Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Bug_1495_Regression / tid_to_int.h
blob89cb1b38fb6c9f087ed8793ab9493cd689f15600
1 // -*- C++ -*-
3 /**
4 * @file tid_to_int.h
6 * Convert an ACE_thread_t to an integer in a way that doesn't rely
7 * heavily on platform-specific configuration.
9 * @author Ossama Othman
12 namespace
14 template<typename thread_id_type, typename ace_thread_id_type>
15 struct ACE_thread_t_to_integer_i
17 thread_id_type operator() (ace_thread_id_type tid)
19 // We assume sizeof(thread_id_type) >= sizeof(ace_thread_id_type).
20 return (thread_id_type) (tid);
24 template<typename thread_id_type, typename ace_thread_id_type>
25 struct ACE_thread_t_to_integer_i<thread_id_type, ace_thread_id_type*>
27 thread_id_type operator() (ace_thread_id_type* tid)
29 // ACE_thread_t is a pointer. Cast to an intermediate integer
30 // type large enough to hold a pointer.
31 #if defined (ACE_OPENVMS) && (!defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64))
32 int const tmp = reinterpret_cast<int> (tid);
33 #else
34 intptr_t const tmp = reinterpret_cast<intptr_t> (tid);
35 #endif
37 // We assume sizeof(thread_id_type) >= sizeof(ace_thread_id_type).
38 return (thread_id_type) tmp;
42 template<typename thread_id_type>
43 thread_id_type
44 ACE_thread_t_to_integer (ACE_thread_t tid)
46 return ACE_thread_t_to_integer_i<thread_id_type, ACE_thread_t>() (tid);