1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 19 #include "oscl_base.h" 20 #include "oscl_defalloc.h" 21 #include "oscl_dll.h" 22 #include "oscl_tls.h" 23 #include "oscl_singleton.h" 24 #include "oscl_base_alloc.h" 25 26 27 Init()28OSCL_EXPORT_REF int32 OsclBase::Init() 29 { 30 { 31 _OsclBasicAllocator alloc; 32 int32 error; 33 OsclTLSRegistry::initialize(alloc, error); 34 //exit on error 35 if (error) 36 return error; 37 } 38 #if (OSCL_HAS_SINGLETON_SUPPORT) 39 { 40 _OsclBasicAllocator alloc; 41 int32 error; 42 OsclSingletonRegistry::initialize(alloc, error); 43 //exit on error 44 if (error) 45 return error; 46 } 47 #endif 48 return 0; 49 } 50 Cleanup()51OSCL_EXPORT_REF int32 OsclBase::Cleanup() 52 { 53 int32 result = 0; 54 #if (OSCL_HAS_SINGLETON_SUPPORT) 55 { 56 _OsclBasicAllocator alloc; 57 int32 error; 58 OsclSingletonRegistry::cleanup(alloc, error); 59 //continue if error 60 if (error) 61 result = error; 62 } 63 #endif 64 { 65 _OsclBasicAllocator alloc; 66 int32 error; 67 OsclTLSRegistry::cleanup(alloc, error); 68 //continue if error 69 if (error) 70 result = error; 71 } 72 //return the last error encountered. 73 return result; 74 } 75 PVOsclBase_Init()76void PVOsclBase_Init() 77 { 78 OsclBase::Init(); 79 } 80 PVOsclBase_Cleanup()81void PVOsclBase_Cleanup() 82 { 83 OsclBase::Cleanup(); 84 } 85 OSCL_DLL_ENTRY_POINT_DEFAULT()86OSCL_DLL_ENTRY_POINT_DEFAULT() 87 88 89 #if(OSCL_HAS_BASIC_LOCK) 90 // 91 // _OsclBasicLock 92 // 93 #include "oscl_lock_base.h" 94 95 OSCL_EXPORT_REF _OsclBasicLock::_OsclBasicLock() 96 { 97 iError = 0; 98 99 100 int result = pthread_mutex_init(&ObjLock, NULL); 101 if (result != 0) 102 iError = result; 103 104 } 105 ~_OsclBasicLock()106OSCL_EXPORT_REF _OsclBasicLock::~_OsclBasicLock() 107 { 108 109 int result = pthread_mutex_destroy(&ObjLock); 110 if (result != 0) 111 iError = result; 112 113 } 114 115 Lock()116OSCL_EXPORT_REF void _OsclBasicLock::Lock() 117 { 118 119 int result = pthread_mutex_lock(&ObjLock); 120 if (result != 0) 121 iError = result; 122 123 } 124 125 Unlock()126OSCL_EXPORT_REF void _OsclBasicLock::Unlock() 127 { 128 129 130 int result = pthread_mutex_unlock(&ObjLock); 131 if (result != 0) 132 iError = result; 133 134 } 135 #endif //OSCL_HAS_BASIC_LOCK 136 137 138 139