Changeset 982 in svn for trunk/main/xc_utils.h


Ignore:
Timestamp:
2012-07-17T08:35:45Z (3 years ago)
Author:
Xuefer
Message:

move files to subdirs

Location:
trunk/main
Files:
1 added
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/main/xc_utils.h

    r976 r982  
    11#include "php.h"
    22#include "xcache.h"
    3 
    4 #ifdef XCACHE_DEBUG
    5 #   define IFDEBUG(x) (x)
    6 int xc_vtrace(const char *fmt, va_list args);
    7 int xc_trace(const char *fmt, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
    8 
    9 #   ifdef ZEND_WIN32
    10 static inline int TRACE(const char *fmt, ...)
    11 {
    12     va_list args;
    13     int ret;
    14 
    15     va_start(args, fmt);
    16     ret = xc_vtrace(fmt, args);
    17     va_end(args);
    18     return ret;
    19 }
    20 #   else
    21 #       define TRACE(fmt, ...) \
    22         xc_trace("%s:%d: " fmt "\r\n", __FILE__, __LINE__, __VA_ARGS__)
    23 #   endif /* ZEND_WIN32 */
    24 #   undef NDEBUG
    25 #   undef inline
    26 #   define inline
    27 #else /* XCACHE_DEBUG */
    28 
    29 #   ifdef ZEND_WIN32
    30 static inline int TRACE_DUMMY(const char *fmt, ...)
    31 {
    32     return 0;
    33 }
    34 #       define TRACE 1 ? 0 : TRACE_DUMMY
    35 #   else
    36 #       define TRACE(fmt, ...) do { } while (0)
    37 #   endif /* ZEND_WIN32 */
    38 
    39 #   define IFDEBUG(x) do { } while (0)
    40 #endif /* XCACHE_DEBUG */
    41 #include <assert.h>
    423
    434int xc_util_init(int module_number TSRMLS_DC);
     
    10869#define zend_atol xc_atol
    10970#endif
    110 
    111 typedef struct {
    112     zend_uint size;
    113     zend_uint cnt;
    114     void *data;
    115 } xc_vector_t;
    116 
    117 #define xc_vector_init(type, vector) do { \
    118     (vector)->cnt = 0;     \
    119     (vector)->size = 0;    \
    120     (vector)->data = NULL; \
    121 } while (0)
    122 
    123 #define xc_vector_add(type, vector, value) do { \
    124     if ((vector)->cnt == (vector)->size) { \
    125         if ((vector)->size) { \
    126             (vector)->size <<= 1; \
    127             (vector)->data = erealloc((vector)->data, sizeof(type) * (vector)->size); \
    128         } \
    129         else { \
    130             (vector)->size = 8; \
    131             (vector)->data = emalloc(sizeof(type) * (vector)->size); \
    132         } \
    133     } \
    134     ((type *) (vector)->data)[(vector)->cnt++] = value; \
    135 } while (0)
    136 
    137 static inline void *xc_vector_detach_impl(xc_vector_t *vector)
    138 {
    139     void *data = vector->data;
    140     vector->data = NULL;
    141     vector->size = 0;
    142     vector->cnt = 0;
    143     return data;
    144 }
    145 
    146 #define xc_vector_detach(type, vector) ((type *) xc_vector_detach_impl(vector))
    147 
    148 static inline void xc_vector_free_impl(xc_vector_t *vector TSRMLS_DC)
    149 {
    150     if (vector->data) {
    151         efree(vector->data);
    152     }
    153     vector->size = 0;
    154     vector->cnt = 0;
    155 }
    156 
    157 #define xc_vector_free(type, vector) xc_vector_free_impl(vector TSRMLS_CC)
    158 
Note: See TracChangeset for help on using the changeset viewer.