aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-10 00:35:09 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-10 00:35:09 +0000
commitf8fd21a76914f014fbbd305c52143dbc5ca8d208 (patch)
treef7a2651dc85cb172ee02f3ae676bac9eab1b8c6c /include
parent8878f5e14d7b6bc35ba0f2cd194788cf9df9cc45 (diff)
Merge team/russell/sla_rewrite
This is a completely new implementation of the SLA functionality introduced in Asterisk 1.4. It is now functional and ready for testing. However, I will be adding some additional features over the next week, as well. For information on how to set this up, see configs/sla.conf.sample and doc/sla.txt. In addition to the changes in app_meetme.c for the SLA implementation itself, this merge brings in various other changes: chan_sip: - Add the ability to indicate HOLD state in NOTIFY messages. - Queue HOLD and UNHOLD control frames even if the channel is not bridged to another channel. linkedlists.h: - Add support for rwlock based linked lists. dial.c: - Add the ability to run ast_dial_start() without a reference channel to inherit information from. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@53810 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/app.h3
-rw-r--r--include/asterisk/dial.h2
-rw-r--r--include/asterisk/linkedlists.h205
-rw-r--r--include/asterisk/utils.h2
4 files changed, 211 insertions, 1 deletions
diff --git a/include/asterisk/app.h b/include/asterisk/app.h
index 88587acfa..3fac28d6b 100644
--- a/include/asterisk/app.h
+++ b/include/asterisk/app.h
@@ -306,6 +306,9 @@ struct ast_app_option {
unsigned int arg_index;
};
+#define BEGIN_OPTIONS {
+#define END_OPTIONS }
+
/*!
\brief Declares an array of options for an application.
\param holder The name of the array to be created
diff --git a/include/asterisk/dial.h b/include/asterisk/dial.h
index 71ce6cfc8..92220e8cb 100644
--- a/include/asterisk/dial.h
+++ b/include/asterisk/dial.h
@@ -42,7 +42,7 @@ enum ast_dial_option {
/*! \brief List of return codes for dial run API calls */
enum ast_dial_result {
- AST_DIAL_RESULT_INVALID = 0, /*!< Invalid options were passed to run function */
+ AST_DIAL_RESULT_INVALID, /*!< Invalid options were passed to run function */
AST_DIAL_RESULT_FAILED, /*!< Attempts to dial failed before reaching critical state */
AST_DIAL_RESULT_TRYING, /*!< Currently trying to dial */
AST_DIAL_RESULT_RINGING, /*!< Dial is presently ringing */
diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h
index 865fafe72..268f827aa 100644
--- a/include/asterisk/linkedlists.h
+++ b/include/asterisk/linkedlists.h
@@ -37,6 +37,28 @@
*/
#define AST_LIST_LOCK(head) \
ast_mutex_lock(&(head)->lock)
+
+/*!
+ \brief Write locks a list.
+ \param head This is a pointer to the list head structure
+
+ This macro attempts to place an exclusive write lock in the
+ list head structure pointed to by head.
+ Returns non-zero on success, 0 on failure
+*/
+#define AST_RWLIST_WRLOCK(head) \
+ ast_rwlock_wrlock(&(head)->lock)
+
+/*!
+ \brief Read locks a list.
+ \param head This is a pointer to the list head structure
+
+ This macro attempts to place a read lock in the
+ list head structure pointed to by head.
+ Returns non-zero on success, 0 on failure
+*/
+#define AST_RWLIST_RDLOCK(head) \
+ ast_rwlock_rdlock(&(head)->lock)
/*!
\brief Locks a list, without blocking if the list is locked.
@@ -48,6 +70,28 @@
*/
#define AST_LIST_TRYLOCK(head) \
ast_mutex_trylock(&(head)->lock)
+
+/*!
+ \brief Write locks a list, without blocking if the list is locked.
+ \param head This is a pointer to the list head structure
+
+ This macro attempts to place an exclusive write lock in the
+ list head structure pointed to by head.
+ Returns non-zero on success, 0 on failure
+*/
+#define AST_RWLIST_TRYWRLOCK(head) \
+ ast_rwlock_trywrlock(&(head)->lock)
+
+/*!
+ \brief Read locks a list, without blocking if the list is locked.
+ \param head This is a pointer to the list head structure
+
+ This macro attempts to place a read lock in the
+ list head structure pointed to by head.
+ Returns non-zero on success, 0 on failure
+*/
+#define AST_RWLIST_TRYRDLOCK(head) \
+ ast_rwlock_tryrdlock(&(head)->lock)
/*!
\brief Attempts to unlock a list.
@@ -61,6 +105,17 @@
ast_mutex_unlock(&(head)->lock)
/*!
+ \brief Attempts to unlock a read/write based list.
+ \param head This is a pointer to the list head structure
+
+ This macro attempts to remove a read or write lock from the
+ list head structure pointed to by head. If the list
+ was not locked by this thread, this macro has no effect.
+*/
+#define AST_RWLIST_UNLOCK(head) \
+ ast_rwlock_unlock(&(head)->lock)
+
+/*!
\brief Defines a structure to be used to hold a list of specified type.
\param name This will be the name of the defined structure.
\param type This is the type of each list entry.
@@ -87,6 +142,32 @@ struct name { \
}
/*!
+ \brief Defines a structure to be used to hold a read/write list of specified type.
+ \param name This will be the name of the defined structure.
+ \param type This is the type of each list entry.
+
+ This macro creates a structure definition that can be used
+ to hold a list of the entries of type \a type. It does not actually
+ declare (allocate) a structure; to do that, either follow this
+ macro with the desired name of the instance you wish to declare,
+ or use the specified \a name to declare instances elsewhere.
+
+ Example usage:
+ \code
+ static AST_RWLIST_HEAD(entry_list, entry) entries;
+ \endcode
+
+ This would define \c struct \c entry_list, and declare an instance of it named
+ \a entries, all intended to hold a list of type \c struct \c entry.
+*/
+#define AST_RWLIST_HEAD(name, type) \
+struct name { \
+ struct type *first; \
+ struct type *last; \
+ ast_rwlock_t lock; \
+}
+
+/*!
\brief Defines a structure to be used to hold a list of specified type (with no lock).
\param name This will be the name of the defined structure.
\param type This is the type of each list entry.
@@ -121,6 +202,15 @@ struct name { \
}
/*!
+ \brief Defines initial values for a declaration of AST_RWLIST_HEAD
+*/
+#define AST_RWLIST_HEAD_INIT_VALUE { \
+ .first = NULL, \
+ .last = NULL, \
+ .lock = AST_RWLOCK_INIT_VALUE, \
+ }
+
+/*!
\brief Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK
*/
#define AST_LIST_HEAD_NOLOCK_INIT_VALUE { \
@@ -171,6 +261,48 @@ struct name { \
#endif
/*!
+ \brief Defines a structure to be used to hold a read/write list of specified type, statically initialized.
+ \param name This will be the name of the defined structure.
+ \param type This is the type of each list entry.
+
+ This macro creates a structure definition that can be used
+ to hold a list of the entries of type \a type, and allocates an instance
+ of it, initialized to be empty.
+
+ Example usage:
+ \code
+ static AST_RWLIST_HEAD_STATIC(entry_list, entry);
+ \endcode
+
+ This would define \c struct \c entry_list, intended to hold a list of
+ type \c struct \c entry.
+*/
+#ifndef AST_RWLOCK_INIT_VALUE
+#define AST_RWLIST_HEAD_STATIC(name, type) \
+struct name { \
+ struct type *first; \
+ struct type *last; \
+ ast_rwlock_t lock; \
+} name; \
+static void __attribute__ ((constructor)) init_##name(void) \
+{ \
+ AST_RWLIST_HEAD_INIT(&name); \
+} \
+static void __attribute__ ((destructor)) fini_##name(void) \
+{ \
+ AST_RWLIST_HEAD_DESTROY(&name); \
+} \
+struct __dummy_##name
+#else
+#define AST_RWLIST_HEAD_STATIC(name, type) \
+struct name { \
+ struct type *first; \
+ struct type *last; \
+ ast_rwlock_t lock; \
+} name = AST_RWLIST_HEAD_INIT_VALUE
+#endif
+
+/*!
\brief Defines a structure to be used to hold a list of specified type, statically initialized.
This is the same as AST_LIST_HEAD_STATIC, except without the lock included.
@@ -196,6 +328,20 @@ struct name { \
} while (0)
/*!
+ \brief Initializes an rwlist head structure with a specified first entry.
+ \param head This is a pointer to the list head structure
+ \param entry pointer to the list entry that will become the head of the list
+
+ This macro initializes a list head structure by setting the head
+ entry to the supplied value and recreating the embedded lock.
+*/
+#define AST_RWLIST_HEAD_SET(head, entry) do { \
+ (head)->first = (entry); \
+ (head)->last = (entry); \
+ ast_rwlock_init(&(head)->lock); \
+} while (0)
+
+/*!
\brief Initializes a list head structure with a specified first entry.
\param head This is a pointer to the list head structure
\param entry pointer to the list entry that will become the head of the list
@@ -229,6 +375,8 @@ struct name { \
struct { \
struct type *next; \
}
+
+#define AST_RWLIST_ENTRY AST_LIST_ENTRY
/*!
\brief Returns the first entry contained in a list.
@@ -236,12 +384,16 @@ struct { \
*/
#define AST_LIST_FIRST(head) ((head)->first)
+#define AST_RWLIST_FIRST AST_LIST_FIRST
+
/*!
\brief Returns the last entry contained in a list.
\param head This is a pointer to the list head structure
*/
#define AST_LIST_LAST(head) ((head)->last)
+#define AST_RWLIST_LAST AST_LIST_LAST
+
/*!
\brief Returns the next entry in the list after the given entry.
\param elm This is a pointer to the current entry.
@@ -250,6 +402,8 @@ struct { \
*/
#define AST_LIST_NEXT(elm, field) ((elm)->field.next)
+#define AST_RWLIST_NEXT AST_LIST_NEXT
+
/*!
\brief Checks whether the specified list contains any entries.
\param head This is a pointer to the list head structure
@@ -258,6 +412,8 @@ struct { \
*/
#define AST_LIST_EMPTY(head) (AST_LIST_FIRST(head) == NULL)
+#define AST_RWLIST_EMPTY AST_LIST_EMPTY
+
/*!
\brief Loops over (traverses) the entries in a list.
\param head This is a pointer to the list head structure
@@ -297,6 +453,8 @@ struct { \
#define AST_LIST_TRAVERSE(head,var,field) \
for((var) = (head)->first; (var); (var) = (var)->field.next)
+#define AST_RWLIST_TRAVERSE AST_LIST_TRAVERSE
+
/*!
\brief Loops safely over (traverses) the entries in a list.
\param head This is a pointer to the list head structure
@@ -342,6 +500,8 @@ struct { \
__list_next = (var) ? (var)->field.next : NULL \
)
+#define AST_RWLIST_TRAVERSE_SAFE_BEGIN AST_LIST_TRAVERSE_SAFE_BEGIN
+
/*!
\brief Removes the \a current entry from a list during a traversal.
\param head This is a pointer to the list head structure
@@ -363,6 +523,8 @@ struct { \
if (!__list_next) \
(head)->last = __list_prev;
+#define AST_RWLIST_REMOVE_CURRENT AST_LIST_REMOVE_CURRENT
+
/*!
\brief Inserts a list entry before the current entry during a traversal.
\param head This is a pointer to the list head structure
@@ -384,11 +546,15 @@ struct { \
__new_prev = (elm); \
} while (0)
+#define AST_RWLIST_INSERT_BEFORE_CURRENT AST_LIST_INSERT_BEFORE_CURRENT
+
/*!
\brief Closes a safe loop traversal block.
*/
#define AST_LIST_TRAVERSE_SAFE_END }
+#define AST_RWLIST_TRAVERSE_SAFE_END AST_LIST_TRAVERSE_SAFE_END
+
/*!
\brief Initializes a list head structure.
\param head This is a pointer to the list head structure
@@ -403,6 +569,19 @@ struct { \
}
/*!
+ \brief Initializes an rwlist head structure.
+ \param head This is a pointer to the list head structure
+
+ This macro initializes a list head structure by setting the head
+ entry to \a NULL (empty list) and recreating the embedded lock.
+*/
+#define AST_RWLIST_HEAD_INIT(head) { \
+ (head)->first = NULL; \
+ (head)->last = NULL; \
+ ast_rwlock_init(&(head)->lock); \
+}
+
+/*!
\brief Destroys a list head structure.
\param head This is a pointer to the list head structure
@@ -417,6 +596,20 @@ struct { \
}
/*!
+ \brief Destroys an rwlist head structure.
+ \param head This is a pointer to the list head structure
+
+ This macro destroys a list head structure by setting the head
+ entry to \a NULL (empty list) and destroying the embedded lock.
+ It does not free the structure from memory.
+*/
+#define AST_RWLIST_HEAD_DESTROY(head) { \
+ (head)->first = NULL; \
+ (head)->last = NULL; \
+ ast_rwlock_destroy(&(head)->lock); \
+}
+
+/*!
\brief Initializes a list head structure.
\param head This is a pointer to the list head structure
@@ -445,6 +638,8 @@ struct { \
(head)->last = (elm); \
} while (0)
+#define AST_RWLIST_INSERT_AFTER AST_LIST_INSERT_AFTER
+
/*!
\brief Inserts a list entry at the head of a list.
\param head This is a pointer to the list head structure
@@ -459,6 +654,8 @@ struct { \
(head)->last = (elm); \
} while (0)
+#define AST_RWLIST_INSERT_HEAD AST_LIST_INSERT_HEAD
+
/*!
\brief Appends a list entry to the tail of a list.
\param head This is a pointer to the list head structure
@@ -480,6 +677,8 @@ struct { \
} \
} while (0)
+#define AST_RWLIST_INSERT_TAIL AST_LIST_INSERT_TAIL
+
/*!
\brief Appends a whole list to the tail of a list.
\param head This is a pointer to the list head structure
@@ -497,6 +696,8 @@ struct { \
} \
} while (0)
+#define AST_RWLIST_APPEND_LIST AST_LIST_APPEND_LIST
+
/*!
\brief Removes and returns the head entry from a list.
\param head This is a pointer to the list head structure
@@ -517,6 +718,8 @@ struct { \
cur; \
})
+#define AST_RWLIST_REMOVE_HEAD AST_LIST_REMOVE_HEAD
+
/*!
\brief Removes a specific entry from a list.
\param head This is a pointer to the list head structure
@@ -543,4 +746,6 @@ struct { \
(elm)->field.next = NULL; \
} while (0)
+#define AST_RWLIST_REMOVE AST_LIST_REMOVE
+
#endif /* _ASTERISK_LINKEDLISTS_H */
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index 0322e506b..1183876e9 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -553,4 +553,6 @@ int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, c
*/
void ast_enable_packet_fragmentation(int sock);
+#define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))
+
#endif /* _ASTERISK_UTILS_H */