1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2001-2009 Oracle. All rights reserved. 5 * 6 * $Id$ 7 */ 8 9#include "db_config.h" 10 11#include "db_int.h" 12 13/* 14 * __os_id -- 15 * Return the current process ID. 16 * 17 * PUBLIC: void __os_id __P((DB_ENV *, pid_t *, db_threadid_t*)); 18 */ 19void 20__os_id(dbenv, pidp, tidp) 21 DB_ENV *dbenv; 22 pid_t *pidp; 23 db_threadid_t *tidp; 24{ 25 /* 26 * We can't depend on dbenv not being NULL, this routine is called 27 * from places where there's no DB_ENV handle. 28 * 29 * We cache the pid in the ENV handle, getting the process ID is a 30 * fairly slow call on lots of systems. 31 */ 32 if (pidp != NULL) { 33 if (dbenv == NULL) { 34#if defined(HAVE_VXWORKS) 35 *pidp = taskIdSelf(); 36#else 37 *pidp = getpid(); 38#endif 39 } else 40 *pidp = dbenv->env->pid_cache; 41 } 42 43 if (tidp != NULL) { 44#if defined(DB_WIN32) 45 *tidp = GetCurrentThreadId(); 46#elif defined(HAVE_MUTEX_UI_THREADS) 47 *tidp = thr_self(); 48#elif defined(HAVE_PTHREAD_SELF) 49 *tidp = pthread_self(); 50#else 51 /* 52 * Default to just getpid. 53 */ 54 *tidp = 0; 55#endif 56 } 57} 58