2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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 express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef DOWNLOAD_PROVIDER2_PTHREAD_H
18 #define DOWNLOAD_PROVIDER2_PTHREAD_H
28 // download-provider use default style mutex.
30 #define CLIENT_MUTEX_LOCK(mutex_add) {\
32 ret = pthread_mutex_lock(mutex_add);\
34 TRACE_STRERROR("ERR:pthread_mutex_lock FAIL with EINVAL.");\
35 } else if (EDEADLK == ret) {\
36 TRACE_STRERROR("ERR:pthread_mutex_lock FAIL with EDEADLK.");\
37 } else if (ret != 0) {\
38 TRACE_STRERROR("ERR:pthread_mutex_lock FAIL with %d.", ret);\
42 #define CLIENT_MUTEX_UNLOCK(mutex_add) {\
44 ret = pthread_mutex_unlock(mutex_add);\
46 TRACE_STRERROR("ERR:pthread_mutex_unlock FAIL with EINVAL.");\
47 } else if (EDEADLK == ret) {\
48 TRACE_STRERROR("ERR:pthread_mutex_unlock FAIL with EDEADLK.");\
49 } else if (ret != 0) {\
50 TRACE_STRERROR("ERR:pthread_mutex_unlock FAIL with %d.", ret);\
54 #define CLIENT_MUTEX_DESTROY(mutex_add) { \
56 ret = pthread_mutex_destroy(mutex_add); \
58 TRACE_STRERROR("ERR:pthread_mutex_destroy FAIL with EINVAL."); \
59 } else if(ENOMEM == ret) {\
60 TRACE_STRERROR("ERR:pthread_mutex_destroy FAIL with ENOMEM."); \
61 } else if(EBUSY == ret) {\
62 TRACE_STRERROR("ERR:pthread_mutex_destroy FAIL with EBUSY."); \
63 if (pthread_mutex_unlock(mutex_add) == 0) \
64 pthread_mutex_destroy(mutex_add); \
65 } else if (ret != 0) {\
66 TRACE_STRERROR("ERR:pthread_mutex_destroy FAIL with %d.", ret); \
70 #define CLIENT_MUTEX_INIT(mutex_add, attr) { \
74 ret = pthread_mutex_init(mutex_add, attr); \
77 } else if(EINVAL == ret) { \
78 TRACE_STRERROR("ERR:pthread_mutex_init FAIL with EINVAL."); \
79 } else if(ENOMEM == ret) { \
80 TRACE_STRERROR("ERR:pthread_mutex_init FAIL with ENOMEM."); \
82 } else if(EBUSY == ret) {\
83 TRACE_STRERROR("ERR:pthread_mutex_destroy FAIL with EBUSY."); \
84 if (pthread_mutex_unlock(mutex_add) == 0) \
85 pthread_mutex_destroy(mutex_add); \
86 } else if (ret != 0) { \
87 TRACE_STRERROR("ERR:pthread_mutex_init FAIL with %d.", ret); \