forked from enlightenment/efl
Eina: fix compilation errors in Eina_RWLock code when building code on Windows > XP
SVN revision: 67545
This commit is contained in:
parent
8ca2f1bcaa
commit
fcd0b658cf
|
@ -202,3 +202,7 @@
|
||||||
2012-01-20 Gustavo Barbieri
|
2012-01-20 Gustavo Barbieri
|
||||||
|
|
||||||
* Add eina_model data type (generic hierarchy data access).
|
* Add eina_model data type (generic hierarchy data access).
|
||||||
|
|
||||||
|
2011-12-30 Vincent Torri
|
||||||
|
|
||||||
|
* Fix Eina_RWLock code on Windows > XP.
|
||||||
|
|
|
@ -16,7 +16,12 @@ Additions:
|
||||||
* Added eina_value data type (generic value storage)
|
* Added eina_value data type (generic value storage)
|
||||||
* Added eina_model data type (generic hierarchy data access)
|
* Added eina_model data type (generic hierarchy data access)
|
||||||
|
|
||||||
Eina 1.1.0
|
Fixes:
|
||||||
|
|
||||||
|
* compilation errors in Eina_RWLock code when building code on Windows > XP
|
||||||
|
|
||||||
|
|
||||||
|
Eina 1.1.0 (2011-12-02)
|
||||||
|
|
||||||
Changes since Eina 1.0.0:
|
Changes since Eina 1.0.0:
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
|
|
||||||
typedef CRITICAL_SECTION Eina_Lock;
|
typedef CRITICAL_SECTION Eina_Lock;
|
||||||
typedef struct _Eina_Condition Eina_Condition;
|
typedef struct _Eina_Condition Eina_Condition;
|
||||||
|
typedef struct _Eina_RWLock Eina_RWLock;
|
||||||
|
typedef DWORD Eina_TLS;
|
||||||
|
typedef HANDLE Eina_Semaphore;
|
||||||
|
|
||||||
#if _WIN32_WINNT >= 0x0600
|
#if _WIN32_WINNT >= 0x0600
|
||||||
struct _Eina_Condition
|
struct _Eina_Condition
|
||||||
|
@ -30,6 +33,13 @@ struct _Eina_Condition
|
||||||
CRITICAL_SECTION *mutex;
|
CRITICAL_SECTION *mutex;
|
||||||
CONDITION_VARIABLE condition;
|
CONDITION_VARIABLE condition;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _Eina_RWLock
|
||||||
|
{
|
||||||
|
SRWLOCK mutex;
|
||||||
|
|
||||||
|
Eina_Bool is_read_mode : 1;
|
||||||
|
};
|
||||||
#else
|
#else
|
||||||
struct _Eina_Condition
|
struct _Eina_Condition
|
||||||
{
|
{
|
||||||
|
@ -40,28 +50,24 @@ struct _Eina_Condition
|
||||||
HANDLE waiters_done;
|
HANDLE waiters_done;
|
||||||
Eina_Bool was_broadcast;
|
Eina_Bool was_broadcast;
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct _Eina_Win32_RWLock Eina_RWLock;
|
struct _Eina_RWLock
|
||||||
|
|
||||||
struct _Eina_Win32_RWLock
|
|
||||||
{
|
{
|
||||||
LONG readers_count;
|
LONG readers_count;
|
||||||
LONG writers_count;
|
LONG writers_count;
|
||||||
int readers;
|
int readers;
|
||||||
int writers;
|
int writers;
|
||||||
|
|
||||||
Eina_Lock mutex;
|
Eina_Lock mutex;
|
||||||
Eina_Condition cond_read;
|
Eina_Condition cond_read;
|
||||||
Eina_Condition cond_write;
|
Eina_Condition cond_write;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef DWORD Eina_TLS;
|
|
||||||
|
|
||||||
typedef HANDLE Eina_Semaphore;
|
|
||||||
|
|
||||||
EAPI extern Eina_Bool _eina_threads_activated;
|
EAPI extern Eina_Bool _eina_threads_activated;
|
||||||
|
|
||||||
|
|
||||||
static inline Eina_Bool
|
static inline Eina_Bool
|
||||||
eina_lock_new(Eina_Lock *mutex)
|
eina_lock_new(Eina_Lock *mutex)
|
||||||
{
|
{
|
||||||
|
@ -143,9 +149,9 @@ eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex)
|
||||||
CloseHandle(cond->semaphore);
|
CloseHandle(cond->semaphore);
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
@ -153,6 +159,7 @@ eina_condition_free(Eina_Condition *cond)
|
||||||
{
|
{
|
||||||
#if _WIN32_WINNT >= 0x0600
|
#if _WIN32_WINNT >= 0x0600
|
||||||
/* Nothing to do */
|
/* Nothing to do */
|
||||||
|
(void)cond;
|
||||||
#else
|
#else
|
||||||
CloseHandle(cond->waiters_done);
|
CloseHandle(cond->waiters_done);
|
||||||
DeleteCriticalSection(&cond->waiters_count_lock);
|
DeleteCriticalSection(&cond->waiters_count_lock);
|
||||||
|
@ -309,14 +316,18 @@ eina_condition_signal(Eina_Condition *cond)
|
||||||
if (!ReleaseSemaphore(cond->semaphore, 1, 0))
|
if (!ReleaseSemaphore(cond->semaphore, 1, 0))
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Eina_Bool
|
static inline Eina_Bool
|
||||||
eina_rwlock_new(Eina_RWLock *mutex)
|
eina_rwlock_new(Eina_RWLock *mutex)
|
||||||
{
|
{
|
||||||
|
#if _WIN32_WINNT >= 0x0600
|
||||||
|
InitializeSRWLock(mutex->mutex);
|
||||||
|
return EINA_TRUE;
|
||||||
|
#else
|
||||||
if (!eina_lock_new(&(mutex->mutex))) return EINA_FALSE;
|
if (!eina_lock_new(&(mutex->mutex))) return EINA_FALSE;
|
||||||
if (!eina_condition_new(&(mutex->cond_read), &(mutex->mutex)))
|
if (!eina_condition_new(&(mutex->cond_read), &(mutex->mutex)))
|
||||||
goto on_error1;
|
goto on_error1;
|
||||||
|
@ -330,19 +341,28 @@ eina_rwlock_new(Eina_RWLock *mutex)
|
||||||
on_error1:
|
on_error1:
|
||||||
eina_lock_free(&(mutex->mutex));
|
eina_lock_free(&(mutex->mutex));
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
eina_rwlock_free(Eina_RWLock *mutex)
|
eina_rwlock_free(Eina_RWLock *mutex)
|
||||||
{
|
{
|
||||||
|
#if _WIN32_WINNT >= 0x0600
|
||||||
|
(void)mutex;
|
||||||
|
#else
|
||||||
eina_condition_free(&(mutex->cond_read));
|
eina_condition_free(&(mutex->cond_read));
|
||||||
eina_condition_free(&(mutex->cond_write));
|
eina_condition_free(&(mutex->cond_write));
|
||||||
eina_lock_free(&(mutex->mutex));
|
eina_lock_free(&(mutex->mutex));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Eina_Lock_Result
|
static inline Eina_Lock_Result
|
||||||
eina_rwlock_take_read(Eina_RWLock *mutex)
|
eina_rwlock_take_read(Eina_RWLock *mutex)
|
||||||
{
|
{
|
||||||
|
#if _WIN32_WINNT >= 0x0600
|
||||||
|
AcquireSRWLockShared(mutex->mutex);
|
||||||
|
mutex->is_read_mode = EINA_TRUE;
|
||||||
|
#else
|
||||||
DWORD res;
|
DWORD res;
|
||||||
|
|
||||||
if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL)
|
if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL)
|
||||||
|
@ -364,6 +384,7 @@ eina_rwlock_take_read(Eina_RWLock *mutex)
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
mutex->readers++;
|
mutex->readers++;
|
||||||
eina_lock_release(&(mutex->mutex));
|
eina_lock_release(&(mutex->mutex));
|
||||||
|
#endif
|
||||||
|
|
||||||
return EINA_LOCK_SUCCEED;
|
return EINA_LOCK_SUCCEED;
|
||||||
}
|
}
|
||||||
|
@ -371,6 +392,10 @@ eina_rwlock_take_read(Eina_RWLock *mutex)
|
||||||
static inline Eina_Lock_Result
|
static inline Eina_Lock_Result
|
||||||
eina_rwlock_take_write(Eina_RWLock *mutex)
|
eina_rwlock_take_write(Eina_RWLock *mutex)
|
||||||
{
|
{
|
||||||
|
#if _WIN32_WINNT >= 0x0600
|
||||||
|
AcquireSRWLockExclusive(mutex->mutex);
|
||||||
|
mutex->is_read_mode = EINA_FALSE;
|
||||||
|
#else
|
||||||
DWORD res;
|
DWORD res;
|
||||||
|
|
||||||
if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL)
|
if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL)
|
||||||
|
@ -391,6 +416,7 @@ eina_rwlock_take_write(Eina_RWLock *mutex)
|
||||||
}
|
}
|
||||||
if (res == 0) mutex->writers_count = 1;
|
if (res == 0) mutex->writers_count = 1;
|
||||||
eina_lock_release(&(mutex->mutex));
|
eina_lock_release(&(mutex->mutex));
|
||||||
|
#endif
|
||||||
|
|
||||||
return EINA_LOCK_SUCCEED;
|
return EINA_LOCK_SUCCEED;
|
||||||
}
|
}
|
||||||
|
@ -398,6 +424,12 @@ eina_rwlock_take_write(Eina_RWLock *mutex)
|
||||||
static inline Eina_Lock_Result
|
static inline Eina_Lock_Result
|
||||||
eina_rwlock_release(Eina_RWLock *mutex)
|
eina_rwlock_release(Eina_RWLock *mutex)
|
||||||
{
|
{
|
||||||
|
#if _WIN32_WINNT >= 0x0600
|
||||||
|
if (mutex->is_read_mode)
|
||||||
|
ReleaseSRWLockShared(mutex->mutex);
|
||||||
|
else
|
||||||
|
ReleaseSRWLockExclusive(mutex->mutex);
|
||||||
|
#else
|
||||||
if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL)
|
if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL)
|
||||||
return EINA_LOCK_FAIL;
|
return EINA_LOCK_FAIL;
|
||||||
|
|
||||||
|
@ -433,6 +465,7 @@ eina_rwlock_release(Eina_RWLock *mutex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
eina_lock_release(&(mutex->mutex));
|
eina_lock_release(&(mutex->mutex));
|
||||||
|
#endif
|
||||||
|
|
||||||
return EINA_LOCK_SUCCEED;
|
return EINA_LOCK_SUCCEED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue