Enlightenment CVS committal
Author : rbdpngn
Project : e17
Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore
Modified Files:
Ecore_Data.h
Log Message:
Moved the locks into a struct so we can use semi-colons at the end of the
declaration macro.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore/Ecore_Data.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- Ecore_Data.h 18 Mar 2004 20:44:33 -0000 1.2
+++ Ecore_Data.h 18 Mar 2004 20:56:20 -0000 1.3
@@ -31,54 +31,56 @@
#include <pthread.h>
#define ECORE_DECLARE_LOCKS \
-int readers; \
-pthread_mutex_t readers_mutex; \
-pthread_mutex_t writers_mutex; \
-pthread_cond_t readers_cond;
+struct { \
+ int readers; \
+ pthread_mutex_t readers_mutex; \
+ pthread_mutex_t writers_mutex; \
+ pthread_cond_t readers_cond; \
+} locks
#define ECORE_INIT_LOCKS(structure) \
if (structure) { \
structure->readers = 0; \
- pthread_mutex_init(&structure->readers_mutex, NULL); \
- pthread_mutex_init(&structure->writers_mutex, NULL); \
- pthread_cond_init(&structure->readers_cond, NULL); \
+ pthread_mutex_init(&structure->locks.readers_mutex, NULL); \
+ pthread_mutex_init(&structure->locks.writers_mutex, NULL); \
+ pthread_cond_init(&structure->locks.readers_cond, NULL); \
}
#define ECORE_DESTROY_LOCKS(structure) \
if (structure) { \
- pthread_mutex_destroy(&structure->readers_mutex); \
- pthread_mutex_destroy(&structure->writers_mutex); \
+ pthread_mutex_destroy(&structure->locks.readers_mutex); \
+ pthread_mutex_destroy(&structure->locks.writers_mutex); \
pthread_cond_destroy(&structure->readers_cond); \
}
#define ECORE_READ_LOCK(structure) \
if (structure) { \
- pthread_mutex_lock(&structure->readers_mutex); \
- structure->readers++; \
- pthread_mutex_unlock(&structure->readers_mutex); \
+ pthread_mutex_lock(&structure->locks.readers_mutex); \
+ structure->locks.readers++; \
+ pthread_mutex_unlock(&structure->locks.readers_mutex); \
}
#define ECORE_READ_UNLOCK(structure) \
if (structure) { \
- pthread_mutex_lock(&structure->readers_mutex); \
- if (--structure->readers == 0) \
- pthread_cond_broadcast(&structure->readers_cond); \
- pthread_mutex_unlock(&structure->readers_mutex); \
+ pthread_mutex_lock(&structure->locks.readers_mutex); \
+ if (--structure->locks.readers == 0) \
+ pthread_cond_broadcast(&structure->locks.readers_cond); \
+ pthread_mutex_unlock(&structure->locks.readers_mutex); \
}
#define ECORE_WRITE_LOCK(structure) \
if (structure) { \
- pthread_mutex_lock(&structure->readers_mutex); \
- pthread_mutex_lock(&structure->writers_mutex); \
- while (structure->readers > 0) \
- pthread_cond_wait(&structure->readers_cond, \
- &structure->readers_mutex); \
- pthread_mutex_unlock(&structure->readers_mutex); \
+ pthread_mutex_lock(&structure->locks.readers_mutex); \
+ pthread_mutex_lock(&structure->locks.writers_mutex); \
+ while (structure->locks.readers > 0) \
+ pthread_cond_wait(&structure->locks.readers_cond, \
+ &structure->locks.readers_mutex); \
+ pthread_mutex_unlock(&structure->locks.readers_mutex); \
}
#define ECORE_WRITE_UNLOCK(structure) \
if (structure) \
- pthread_mutex_unlock(&structure->writers_mutex); \
+ pthread_mutex_unlock(&structure->locks.writers_mutex); \
#define ECORE_THREAD_CREATE(function, arg) \
if (function) { \
@@ -91,7 +93,7 @@
#else /* No pthreads available */
-#define ECORE_DECLARE_LOCKS
+#define ECORE_DECLARE_LOCKS struct { } locks
#define ECORE_INIT_LOCKS(structure)
#define ECORE_READ_LOCK(structure)
#define ECORE_READ_UNLOCK(structure)
@@ -114,7 +116,7 @@
void *data;
struct _ecore_list_node *next;
- ECORE_DECLARE_LOCKS
+ ECORE_DECLARE_LOCKS;
};
struct _ecore_list {
@@ -127,7 +129,7 @@
int nodes; /* The number of nodes in the list */
int index; /* The position from the front of the
list of current node */
- ECORE_DECLARE_LOCKS
+ ECORE_DECLARE_LOCKS;
};
@@ -252,7 +254,7 @@
void *key; /* The key for the data node */
void *value; /* The value associated with this node */
- ECORE_DECLARE_LOCKS
+ ECORE_DECLARE_LOCKS;
};
typedef struct _ecore_hash Ecore_Hash;
@@ -270,7 +272,7 @@
Ecore_Free_Cb free_key; /* The callback function to free key */
Ecore_Free_Cb free_value; /* The callback function to determine hash */
- ECORE_DECLARE_LOCKS
+ ECORE_DECLARE_LOCKS;
};
/* Create and initialize a hash */
@@ -468,7 +470,7 @@
int max_right;
int max_left;
- ECORE_DECLARE_LOCKS
+ ECORE_DECLARE_LOCKS;
};
typedef struct _Ecore_Tree Ecore_Tree;
@@ -483,7 +485,7 @@
/* Callback for freeing node data, default is NULL */
Ecore_Free_Cb free_func;
- ECORE_DECLARE_LOCKS
+ ECORE_DECLARE_LOCKS;
};
/* Some basic tree functions */
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs