|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Name : wsd_init.cpp |
|
15 // Part of : PThread library |
|
16 // File for the writable static data in the library. |
|
17 // Version: |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 #include "threadglobals.h" |
|
23 |
|
24 #ifdef __WINSCW__ |
|
25 #include <pls.h> // For emulator WSD API |
|
26 const TUid KLibPthreadUid3 = {0x10275065}; |
|
27 |
|
28 |
|
29 #else |
|
30 _global_data_t glbData; |
|
31 #endif |
|
32 |
|
33 _global_data_t::_global_data_t() |
|
34 { |
|
35 //Initialize global data structure |
|
36 start = NULL; |
|
37 threadCount = 0; //First thread |
|
38 if (lockThreadTable.CreateLocal() != KErrNone) |
|
39 { |
|
40 THR_PRINTF("[pthread] FATAL :Mutex create failed"); |
|
41 } |
|
42 if (globalLockForMutex.CreateLocal() != KErrNone) |
|
43 { |
|
44 THR_PRINTF("[pthread] FATAL :Mutex create failed"); |
|
45 } |
|
46 |
|
47 // Initialize all keys in pthread_key_list to NOT USED |
|
48 for (int loopvar = 0; loopvar < PTHREAD_KEYS_MAX; loopvar++) |
|
49 { |
|
50 // Set it to unused |
|
51 pthread_key_list[loopvar].destr = NULL; |
|
52 } |
|
53 |
|
54 for (int loopvar = 0; loopvar < STAT_FLAG_SIZE; loopvar++) |
|
55 { |
|
56 // Set it to unused |
|
57 statusflag[loopvar] = _KEY_UNUSED; |
|
58 } |
|
59 |
|
60 //Sem table initializations |
|
61 semStart = NULL; |
|
62 if (lockSemTable.CreateLocal() != KErrNone) |
|
63 { |
|
64 globalLockForMutex.Close(); |
|
65 lockThreadTable.Close(); |
|
66 THR_PRINTF("[pthread] FATAL :Mutex create failed"); |
|
67 } |
|
68 } |
|
69 |
|
70 // Destructor to supress warnings |
|
71 _global_data_t::~_global_data_t() |
|
72 { |
|
73 } |
|
74 |
|
75 _global_data_t* GetGlobals() |
|
76 { |
|
77 #ifdef __WINSCW__ |
|
78 _global_data_t* glbDataPtr = Pls<_global_data_t>(KLibPthreadUid3); |
|
79 return glbDataPtr; |
|
80 |
|
81 #else |
|
82 return &glbData; |
|
83 #endif |
|
84 } |