[complement-svn] SF.net SVN: complement: [1421] trunk/complement/explore
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2006-11-29 08:05:30
|
Revision: 1421 http://svn.sourceforge.net/complement/?rev=1421&view=rev Author: complement Date: 2006-11-29 00:05:27 -0800 (Wed, 29 Nov 2006) Log Message: ----------- added xmt::getpid() and xmt:getppid(); ::getpid() really return cached value, so returned pid may be parent's pid really. I use syscall here and rewrite appropriate var during Thread::fork() Modified Paths: -------------- trunk/complement/explore/include/mt/xmt.h trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/Makefile.inc trunk/complement/explore/lib/mt/xmt.cc Modified: trunk/complement/explore/include/mt/xmt.h =================================================================== --- trunk/complement/explore/include/mt/xmt.h 2006-11-28 19:10:41 UTC (rev 1420) +++ trunk/complement/explore/include/mt/xmt.h 2006-11-29 08:05:27 UTC (rev 1421) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/27 10:30:33 ptr> +// -*- C++ -*- Time-stamp: <06/11/29 01:50:24 ptr> /* * Copyright (c) 1997-1999, 2002-2006 @@ -1810,6 +1810,9 @@ #endif } +pid_t getpid(); +pid_t getppid(); + } // namespace xmt namespace __impl = xmt; // compatibility Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2006-11-28 19:10:41 UTC (rev 1420) +++ trunk/complement/explore/lib/mt/ChangeLog 2006-11-29 08:05:27 UTC (rev 1421) @@ -1,3 +1,12 @@ +2006-11-29 Petr Ovtchenkov <pt...@is...> + + * xmt.h, xmt.cc: added xmt::getpid() and xmt:getppid(); ::getpid() + really return cached value, so returned pid may be parent's pid + really. I use syscall here and rewrite appropriate var during + Thread::fork(). + + * libxmt: version 1.9.3 + 2006-11-23 Petr Ovtchenkov <pt...@is...> * uid.h, uid.cc: return hostid on Linux Modified: trunk/complement/explore/lib/mt/Makefile.inc =================================================================== --- trunk/complement/explore/lib/mt/Makefile.inc 2006-11-28 19:10:41 UTC (rev 1420) +++ trunk/complement/explore/lib/mt/Makefile.inc 2006-11-29 08:05:27 UTC (rev 1421) @@ -1,8 +1,8 @@ -# -*- Makefile -*- Time-stamp: <06/11/23 17:32:14 ptr> +# -*- Makefile -*- Time-stamp: <06/11/29 01:59:50 ptr> LIBNAME = xmt MAJOR = 1 MINOR = 9 -PATCH = 2 +PATCH = 3 SRC_CC = xmt.cc thr_mgr.cc time.cc uid.cc SRC_C = fl.c Modified: trunk/complement/explore/lib/mt/xmt.cc =================================================================== --- trunk/complement/explore/lib/mt/xmt.cc 2006-11-28 19:10:41 UTC (rev 1420) +++ trunk/complement/explore/lib/mt/xmt.cc 2006-11-29 08:05:27 UTC (rev 1421) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/10/24 09:32:17 ptr> +// -*- C++ -*- Time-stamp: <06/11/29 03:10:16 ptr> /* * Copyright (c) 1997-1999, 2002-2006 @@ -46,6 +46,7 @@ #endif #include <stdio.h> +#include <syscall.h> #include <cmath> // for time operations @@ -79,6 +80,12 @@ int Init_count = 0; +// problem: ::getpid() really return cached value, so pid returned may be +// parent's pid really. I use syscall here and rewrite it during Thread::fork(). + +static pid_t _pid = syscall( SYS_getpid ); +static pid_t _ppid = syscall( SYS_getppid ); + #ifdef __FIT_NOVELL_THREADS xmt::Thread::thread_key_type _mt_key = 0; #else // !__FIT_NOVELL_THREADS @@ -227,12 +234,7 @@ } char *Init_buf[32]; -// int Thread::Init::_count = 0; -#if defined(_MSC_VER) && (_MSC_VER <= 1200) -int& Thread::Init::_count = detail::Init_count; // trick to avoid friend declarations -#else int& Thread::Init::_count( detail::Init_count ); // trick to avoid friend declarations -#endif const std::string msg1( "Can't create thread" ); const std::string msg2( "Can't fork" ); @@ -311,11 +313,7 @@ const Thread::thread_id_type Thread::bad_thread_id = EFAILURE; #endif // __FIT_NOVELL_THREADS -#if defined(_MSC_VER) && (_MSC_VER <= 1200) -Thread::thread_key_type& Thread::_mt_key = detail::_mt_key; -#else Thread::thread_key_type& Thread::_mt_key( detail::_mt_key ); -#endif __FIT_DECLSPEC void Thread::_dealloc_uw() @@ -724,6 +722,8 @@ if ( f.pid() == -1 ) { throw std::runtime_error( msg2 ); } + detail::_ppid = detail::_pid; + detail::_pid = syscall( SYS_getpid ); #endif } @@ -1004,4 +1004,14 @@ return _idx++; } +pid_t getpid() +{ + return detail::_pid; +} + +pid_t getppid() +{ + return detail::_ppid; +} + } // namespace xmt This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |