Commit 9bb7bc15 authored by Pekka Pessi's avatar Pekka Pessi

su_tagarg.h: ta_start() initializes all of ta_list in all cases.

darcs-hash:20060912172419-65a35-0120747d84dff39062f09edc473ff6ee040d1151.gz
parent 1299925a
......@@ -210,6 +210,8 @@ struct nua_handle_s
tagi_t *nh_tags; /**< Default tags */
nua_handle_t *nh_identity; /**< Identity */
#if HAVE_PTHREAD_H
#if __CYGWIN__
pthread_mutex_t sup_reflock[1];
......
......@@ -94,28 +94,59 @@ typedef struct {
* @hideinitializer
*/
#if SU_HAVE_TAGSTACK
#define ta_start(ta, t, v) \
do { \
va_start((ta).ap, v); \
(ta).tl->t_tag = (t); (ta).tl->t_value = (v); \
if ((t) && (t) != tag_null && (t) != tag_next) { \
(ta).tl[1].t_tag = tag_next; \
(ta).tl[1].t_value = (tag_value_t)(&(v) + 1); } } while(0)
/* All arguments are saved into stack (left-to-right) */
#define ta_start(ta, t, v) \
do { \
tag_type_t ta_start__tag = (t); tag_value_t ta_start__value = (v); \
va_start((ta).ap, (v)); \
while ((ta_start__tag) == tag_next && (ta_start__value) != 0) { \
ta_start__tag = ((tagi_t *)ta_start__value)->t_tag; \
if (ta_start__tag == tag_null || ta_start__tag == NULL) \
break; \
if (ta_start__tag == tag_next) { \
ta_start__value = ((tagi_t *)ta_start__value)->t_value; } \
else { \
ta_start__tag = tag_next; \
break; \
} \
} \
(ta).tl->t_tag = ta_start__tag; (ta).tl->t_value = ta_start__value; \
if (ta_start__tag != NULL && \
ta_start__tag != tag_null && \
ta_start__tag != tag_next) { \
(ta).tl[1].t_tag = tag_next; \
(ta).tl[1].t_value = (tag_value_t)(&(v) + 1); \
} else { \
(ta).tl[1].t_value = 0; (ta).tl[1].t_value = (tag_value_t)0; \
} \
} while(0)
#else
#define ta_start(ta, t, v) \
do { \
va_start((ta).ap, (v)); \
while ((t) == tag_next && (v)) { \
(t) = ((tagi_t *)(v))->t_tag; \
if ((t) == tag_null || (t) == NULL) break; \
if ((t) == tag_next) { (v) = ((tagi_t *)(v))->t_value; } \
else { (t) = tag_next; break; } \
} \
(ta).tl->t_tag = (t); (ta).tl->t_value = (v); \
((t) == NULL || (t) == tag_null || (t) == tag_next ? \
((ta).tl[1].t_value = 0) : \
((ta).tl[1].t_tag = tag_next, \
(ta).tl[1].t_value = (tag_value_t)tl_vlist((ta).ap))); } while(0)
/* Tagged arguments are in registers - copy all of them. */
#define ta_start(ta, t, v) \
do { \
tag_type_t ta_start__tag = (t); tag_value_t ta_start__value = (v); \
va_start((ta).ap, (v)); \
while ((ta_start__tag) == tag_next && (ta_start__value) != 0) { \
ta_start__tag = ((tagi_t *)ta_start__value)->t_tag; \
if (ta_start__tag == tag_null || ta_start__tag == NULL) \
break; \
if (ta_start__tag == tag_next) { \
ta_start__value = ((tagi_t *)ta_start__value)->t_value; \
} else { \
ta_start__tag = tag_next; \
break; \
} \
} \
(ta).tl->t_tag = ta_start__tag; (ta).tl->t_value = ta_start__value; \
if (ta_start__tag != NULL && \
ta_start__tag != tag_null && \
ta_start__tag != tag_next) { \
(ta).tl[1].t_tag = tag_next; \
(ta).tl[1].t_value = (tag_value_t)tl_vlist((ta).ap); \
} else { \
(ta).tl[1].t_value = 0; (ta).tl[1].t_value = (tag_value_t)0; \
} \
} while(0)
#endif
/**Macro accessing tagged argument list.
......@@ -148,8 +179,8 @@ typedef struct {
#if SU_HAVE_TAGSTACK
#define ta_end(ta) (va_end((ta).ap), (ta).tl->t_tag = NULL, 0)
#else
#define ta_end(ta) \
((((ta).tl[1].t_value) ? \
#define ta_end(ta) \
((((ta).tl[1].t_value) ? \
(tl_vfree((tagi_t *)((ta).tl[1].t_value))) : (void)0), \
(ta).tl[1].t_value = 0, va_end((ta).ap), 0)
#endif
......
......@@ -65,6 +65,9 @@
#define su_inline static __inline
#define SU_HAVE_INLINE (1)
/** Define this as 1 if we can use tags directly from stack. */
#define SU_HAVE_TAGSTACK (1)
#define SU_S64_T __int64
#define SU_U64_T unsigned __int64
#define SU_S32_T __int32
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment