4 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
28 #define MICROSECONDS(tv) ((tv.tv_sec * 1000000ll) + tv.tv_usec)
32 #define AUTOLOCK(x) Autolock x##_autolock((x), #x, __MODULE__, __func__, __LINE__)
33 #define LOCK(x) (x).lock(#x, __MODULE__, __func__, __LINE__)
34 #define UNLOCK(x) (x).unlock()
36 #define AUTOLOCK(x) Autolock x##_autolock((x))
37 #define LOCK(x) (x).lock()
38 #define UNLOCK(x) (x).unlock()
47 void lock(const char* expr, const char *module, const char *func, int line);
53 int try_lock_impl(void);
54 int unlock_impl(void);
57 pthread_mutex_t m_mutex;
58 static const int OWNER_INFO_LEN = 256;
59 char m_owner_info[OWNER_INFO_LEN];
66 Autolock(cmutex &m, const char* expr, const char *module, const char *func, int line);
72 #endif /* _CMUTEX_H_ */