summaryrefslogtreecommitdiff
path: root/source/api_wrappers/linux
diff options
context:
space:
mode:
authorXVSALGE <aleksandar.gerasimovski@seavus.com>2012-02-22 08:14:11 +0100
committerViktor Mladenovski <viktor.mladenovski@seavus.com>2012-05-25 14:44:00 +0200
commit9dc2897fef041426347e80385707b7c86324c63e (patch)
treeb7525770a2da28553426465f47a6d65efaa22c3b /source/api_wrappers/linux
parent828be7d08c886347641d8bba675993caf5a13d1a (diff)
Sync lcm with CC source
Synchronize loader_communication with clearcase source ST-Ericsson ID: 413947 ST-Ericsson FOSS-OUT ID: STETL-FOSS-OUT-10204 Change-Id: Ib23b84360b351a2598190d9d6b510895cc892436 Depends-On: I4b049943fc2acc63ed5f94dff6d4bc0e36fde1cf Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/48934 Reviewed-by: QABUILD Reviewed-by: QATEST Reviewed-by: Zoran ANCEVSKI <zoran.ancevski@seavus.com> Tested-by: Aleksandar GASOSKI <aleksandar.gasoski@seavus.com> Tested-by: Cvetko MLADENOVSKI <cvetko.mladenovski@seavus.com> Reviewed-by: Vlatko PISTOLOV <vlatko.pistolov@seavus.com> Tested-by: Vlatko PISTOLOV <vlatko.pistolov@seavus.com>
Diffstat (limited to 'source/api_wrappers/linux')
-rw-r--r--source/api_wrappers/linux/CEventObject.cpp11
-rw-r--r--source/api_wrappers/linux/CSemaphore.cpp10
-rw-r--r--source/api_wrappers/linux/CSemaphore.h2
3 files changed, 18 insertions, 5 deletions
diff --git a/source/api_wrappers/linux/CEventObject.cpp b/source/api_wrappers/linux/CEventObject.cpp
index 6c0f6c3..1a09fa9 100644
--- a/source/api_wrappers/linux/CEventObject.cpp
+++ b/source/api_wrappers/linux/CEventObject.cpp
@@ -20,13 +20,17 @@ CEventObject::CEventObject()
{
char sem_name[SEM_NAME_MAX_LENGTH];
int sem_nr = 1;
- while(sem_nr <= SEM_MAX_NR) {
+
+ while (sem_nr <= SEM_MAX_NR) {
snprintf(sem_name, SEM_NAME_MAX_LENGTH, "lcdriversem_%d", sem_nr);
/* open semaphore with "rw" permissions for everyone - 0666 */
m_sem = sem_open(sem_name, O_CREAT | O_EXCL, 0666 , 0);
- if (m_sem != SEM_FAILED)
+
+ if (m_sem != SEM_FAILED) {
break;
+ }
+
sem_nr++;
}
}
@@ -69,6 +73,7 @@ DWORD CEventObject::Wait(DWORD dwTimeout)
/* Try to lock the semaphore */
ret = sem_trywait(m_sem);
+
if (ret != 0) {
while (dwTimePassed < dwTimeout) {
/* Sleep 1ms */
@@ -76,6 +81,7 @@ DWORD CEventObject::Wait(DWORD dwTimeout)
/* Try to lock the semaphore again*/
ret = sem_trywait(m_sem);
+
if (ret == 0) {
return WAIT_OBJECT_0;
}
@@ -85,6 +91,7 @@ DWORD CEventObject::Wait(DWORD dwTimeout)
dwTimePassed = 1000 * (curr_time.tv_sec - start_time.tv_sec) + \
(curr_time.tv_usec - start_time.tv_usec) / 1000;
}
+
return WAIT_TIMEOUT;
}
}
diff --git a/source/api_wrappers/linux/CSemaphore.cpp b/source/api_wrappers/linux/CSemaphore.cpp
index 5dae856..166ab88 100644
--- a/source/api_wrappers/linux/CSemaphore.cpp
+++ b/source/api_wrappers/linux/CSemaphore.cpp
@@ -16,13 +16,17 @@ CSemaphore::CSemaphore(unsigned int initial_count)
{
char sem_name[SEM_NAME_MAX_LENGTH];
int sem_nr = 1;
- while(sem_nr <= SEM_MAX_NR) {
+
+ while (sem_nr <= SEM_MAX_NR) {
snprintf(sem_name, SEM_NAME_MAX_LENGTH, "lcdriversem_%d", sem_nr);
/* open semaphore with "rw" permissions for everyone - 0666 */
m_semaphore = sem_open(sem_name, O_CREAT | O_EXCL, 0666 , 0);
- if (m_semaphore != SEM_FAILED)
+
+ if (m_semaphore != SEM_FAILED) {
break;
+ }
+
sem_nr++;
}
}
@@ -60,6 +64,7 @@ DWORD CSemaphore::Wait(DWORD timeout)
/* Try to lock the semaphore */
ret = sem_trywait(m_semaphore);
+
if (ret != 0) {
while (dwTimePassed < timeout) {
/* Sleep 1ms */
@@ -67,6 +72,7 @@ DWORD CSemaphore::Wait(DWORD timeout)
/* Try to lock the semaphore again*/
ret = sem_trywait(m_semaphore);
+
if (ret == 0) {
return WAIT_OBJECT_0;
}
diff --git a/source/api_wrappers/linux/CSemaphore.h b/source/api_wrappers/linux/CSemaphore.h
index 0abe5dd..3d68b63 100644
--- a/source/api_wrappers/linux/CSemaphore.h
+++ b/source/api_wrappers/linux/CSemaphore.h
@@ -19,7 +19,7 @@ public:
DWORD Wait(DWORD timeout = INFINITE);
private:
- sem_t* m_semaphore;
+ sem_t *m_semaphore;
};
#endif /* _CSEMAPHORE_H */