diff options
author | David Walter Seikel | 2012-01-23 23:30:42 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-23 23:30:42 +1000 |
commit | 825a3d837a33f226c879cd02ad15c3fba57e8b2c (patch) | |
tree | 75f57bd9c4253508d338dc79ba8e57a7abc42255 /libraries/eina/src/include/eina_inline_lock_posix.x | |
parent | Add ability to disable the test harness, or the Lua compile test. (diff) | |
download | SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.zip SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.gz SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.bz2 SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.xz |
Update the EFL to what I'm actually using, coz I'm using some stuff not yet released.
Diffstat (limited to 'libraries/eina/src/include/eina_inline_lock_posix.x')
-rw-r--r-- | libraries/eina/src/include/eina_inline_lock_posix.x | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/libraries/eina/src/include/eina_inline_lock_posix.x b/libraries/eina/src/include/eina_inline_lock_posix.x index 77f5b8b..64e049a 100644 --- a/libraries/eina/src/include/eina_inline_lock_posix.x +++ b/libraries/eina/src/include/eina_inline_lock_posix.x | |||
@@ -19,6 +19,15 @@ | |||
19 | #ifndef EINA_INLINE_LOCK_POSIX_X_ | 19 | #ifndef EINA_INLINE_LOCK_POSIX_X_ |
20 | #define EINA_INLINE_LOCK_POSIX_X_ | 20 | #define EINA_INLINE_LOCK_POSIX_X_ |
21 | 21 | ||
22 | #ifdef EINA_UNUSED | ||
23 | # undef EINA_UNUSED | ||
24 | #endif | ||
25 | #ifdef __GNUC__ | ||
26 | # define EINA_UNUSED __attribute__((unused)) | ||
27 | #else | ||
28 | # define EINA_UNUSED | ||
29 | #endif | ||
30 | |||
22 | #include <errno.h> | 31 | #include <errno.h> |
23 | #ifndef __USE_UNIX98 | 32 | #ifndef __USE_UNIX98 |
24 | # define __USE_UNIX98 | 33 | # define __USE_UNIX98 |
@@ -28,7 +37,10 @@ | |||
28 | # include <pthread.h> | 37 | # include <pthread.h> |
29 | #endif | 38 | #endif |
30 | 39 | ||
40 | #include <semaphore.h> | ||
41 | |||
31 | #include <sys/time.h> | 42 | #include <sys/time.h> |
43 | #include <stdio.h> | ||
32 | 44 | ||
33 | #ifdef EINA_HAVE_DEBUG_THREADS | 45 | #ifdef EINA_HAVE_DEBUG_THREADS |
34 | #include <stdlib.h> | 46 | #include <stdlib.h> |
@@ -45,6 +57,7 @@ typedef struct _Eina_Lock Eina_Lock; | |||
45 | typedef struct _Eina_RWLock Eina_RWLock; | 57 | typedef struct _Eina_RWLock Eina_RWLock; |
46 | typedef struct _Eina_Condition Eina_Condition; | 58 | typedef struct _Eina_Condition Eina_Condition; |
47 | typedef pthread_key_t Eina_TLS; | 59 | typedef pthread_key_t Eina_TLS; |
60 | typedef sem_t Eina_Semaphore; | ||
48 | 61 | ||
49 | struct _Eina_Lock | 62 | struct _Eina_Lock |
50 | { | 63 | { |
@@ -77,8 +90,6 @@ struct _Eina_RWLock | |||
77 | EAPI extern Eina_Bool _eina_threads_activated; | 90 | EAPI extern Eina_Bool _eina_threads_activated; |
78 | 91 | ||
79 | #ifdef EINA_HAVE_DEBUG_THREADS | 92 | #ifdef EINA_HAVE_DEBUG_THREADS |
80 | # include <sys/time.h> | ||
81 | |||
82 | EAPI extern int _eina_threads_debug; | 93 | EAPI extern int _eina_threads_debug; |
83 | EAPI extern pthread_t _eina_main_loop; | 94 | EAPI extern pthread_t _eina_main_loop; |
84 | EAPI extern pthread_mutex_t _eina_tracking_lock; | 95 | EAPI extern pthread_mutex_t _eina_tracking_lock; |
@@ -506,4 +517,40 @@ eina_tls_set(Eina_TLS key, const void *data) | |||
506 | return EINA_TRUE; | 517 | return EINA_TRUE; |
507 | } | 518 | } |
508 | 519 | ||
520 | static inline Eina_Bool | ||
521 | eina_semaphore_new(Eina_Semaphore *sem, int count_init) | ||
522 | { | ||
523 | if (!sem || (count_init <= 0)) | ||
524 | return EINA_FALSE; | ||
525 | |||
526 | return (sem_init(sem, count_init, 1) == 0) ? EINA_TRUE : EINA_FALSE; | ||
527 | } | ||
528 | |||
529 | static inline Eina_Bool | ||
530 | eina_semaphore_free(Eina_Semaphore *sem) | ||
531 | { | ||
532 | if (!sem) | ||
533 | return EINA_FALSE; | ||
534 | |||
535 | return (sem_destroy(sem) == 0) ? EINA_TRUE : EINA_FALSE; | ||
536 | } | ||
537 | |||
538 | static inline Eina_Bool | ||
539 | eina_semaphore_lock(Eina_Semaphore *sem) | ||
540 | { | ||
541 | if (!sem) | ||
542 | return EINA_FALSE; | ||
543 | |||
544 | return (sem_wait(sem) == 0) ? EINA_TRUE : EINA_FALSE; | ||
545 | } | ||
546 | |||
547 | static inline Eina_Bool | ||
548 | eina_semaphore_release(Eina_Semaphore *sem, int count_release EINA_UNUSED) | ||
549 | { | ||
550 | if (!sem) | ||
551 | return EINA_FALSE; | ||
552 | |||
553 | return (sem_post(sem) == 0) ? EINA_TRUE : EINA_FALSE; | ||
554 | } | ||
555 | |||
509 | #endif | 556 | #endif |