#if defined(__SUNPRO_C)
# define _KERNEL
# include <atomic.h>
+# if defined(_INT64_TYPE)
+# define atomic_add_size(X, Y) atomic_add_64((X), (Y))
+# define atomic_add_size_nv(X, Y) atomic_add_64((X), (Y))
+# define atomic_dec_size(X, Y) atomic_add_64((X), (Y))
+# define atomic_dec_size_nv(X, Y) atomic_add_64((X), (Y))
+# else
+# define atomic_add_size(X, Y) atomic_add_32((X), (Y))
+# define atomic_add_size_nv(X, Y) atomic_add_32((X), (Y))
+# define atomic_dec_size(X, Y) atomic_add_32((X), (Y))
+# define atomic_dec_size_nv(X, Y) atomic_add_32((X), (Y))
+# endif
# undef _KERNEL
#else
# define atomic_add_8(X, Y) __sync_fetch_and_add((X), (Y))
# define atomic_add_16(X, Y) __sync_fetch_and_add((X), (Y))
# define atomic_add_32(X, Y) __sync_fetch_and_add((X), (Y))
-# define atomic_add_64(X, Y) __sync_fetch_and_add((X), (Y))
+# define atomic_add_size(X, Y) __sync_fetch_and_add((X), (Y))
# define atomic_dec_8(X) __sync_fetch_and_sub((X), 1)
# define atomic_dec_16(X) __sync_fetch_and_sub((X), 1)
# define atomic_dec_32(X) __sync_fetch_and_sub((X), 1)
-# define atomic_dec_64(X) __sync_fetch_and_sub((X), 1)
+# define atomic_dec_size(X) __sync_fetch_and_sub((X), 1)
/* The same as above, but these return the new value instead of void */
# define atomic_add_8_nv(X, Y) __sync_fetch_and_add((X), (Y))
# define atomic_add_16_nv(X, Y) __sync_fetch_and_add((X), (Y))
# define atomic_add_32_nv(X, Y) __sync_fetch_and_add((X), (Y))
-# define atomic_add_64_nv(X, Y) __sync_fetch_and_add((X), (Y))
+# define atomic_add_size_nv(X, Y) __sync_fetch_and_add((X), (Y))
# define atomic_dec_8_nv(X) __sync_fetch_and_sub((X), 1)
# define atomic_dec_16_nv(X) __sync_fetch_and_sub((X), 1)
# define atomic_dec_32_nv(X) __sync_fetch_and_sub((X), 1)
-# define atomic_dec_64_nv(X) __sync_fetch_and_sub((X), 1)
+# define atomic_dec_size_nv(X) __sync_fetch_and_sub((X), 1)
#endif /* defined(__SUNPRO_C) */
#endif /* CLIENTS_MS_ATOMIC_H */
if (res > 0)
{
- atomic_add_64(&ms_stats.bytes_read, res);
+ atomic_add_size(&ms_stats.bytes_read, res);
c->rudpbytes+= res;
rbytes+= res;
if (res == avail)
if (copybytes == -1)
{
- atomic_add_64(&ms_stats.pkt_disorder, 1);
+ atomic_add_size(&ms_stats.pkt_disorder, 1);
}
return copybytes;
{
if (! c->udp)
{
- atomic_add_64(&ms_stats.bytes_read, res);
+ atomic_add_size(&ms_stats.bytes_read, res);
}
gotdata= 1;
c->rbytes+= res;
if (curr_time.tv_sec - c->curr_task.item->client_time
> c->curr_task.item->exp_time + EXPIRE_TIME_ERROR)
{
- atomic_add_64(&ms_stats.exp_get, 1);
+ atomic_add_size(&ms_stats.exp_get, 1);
if (ms_setting.verbose)
{
if ((c->curr_task.item->value_size != vlen)
|| (memcmp(orignval, value, (size_t)vlen) != 0))
{
- atomic_add_64(&ms_stats.vef_failed, 1);
+ atomic_add_size(&ms_stats.vef_failed, 1);
if (ms_setting.verbose)
{
res= sendmsg(c->sfd, m, 0);
if (res > 0)
{
- atomic_add_64(&ms_stats.bytes_written, res);
+ atomic_add_size(&ms_stats.bytes_written, res);
/* We've written some of the data. Remove the completed
* iovec entries from the list of pending writes. */
}
}
- atomic_add_64(&ms_stats.obj_bytes,
- item->key_size + item->value_size);
- atomic_add_64(&ms_stats.cmd_set, 1);
+ atomic_add_size(&ms_stats.obj_bytes,
+ item->key_size + item->value_size);
+ atomic_add_size(&ms_stats.cmd_set, 1);
return 0;
} /* ms_mcd_set */
}
}
- atomic_add_64(&ms_stats.cmd_get, 1);
+ atomic_add_size(&ms_stats.cmd_get, 1);
return 0;
} /* ms_mcd_get */
for (int i= 0; i < c->mlget_task.mlget_num; i++)
{
item= c->mlget_task.mlget_item[i].item;
- atomic_add_64(&ms_stats.cmd_get, 1);
+ atomic_add_size(&ms_stats.cmd_get, 1);
}
return 0;
typedef struct stats
{
volatile uint32_t active_conns; /* active connections */
- uint64_t bytes_read; /* read bytes */
- uint64_t bytes_written; /* written bytes */
- uint64_t obj_bytes; /* object bytes */
- uint64_t pre_cmd_get; /* previous total get command count */
- uint64_t pre_cmd_set; /* previous total set command count */
- uint64_t cmd_get; /* current total get command count */
- uint64_t cmd_set; /* current total set command count */
- uint64_t get_misses; /* total objects of get miss */
- uint64_t vef_miss; /* total objects of verification miss */
- uint64_t vef_failed; /* total objects of verification failed */
- uint64_t unexp_unget; /* total objects which is unexpired but not get */
- uint64_t exp_get; /* total objects which is expired but get */
- volatile uint64_t pkt_disorder; /* disorder packages of UDP */
- uint64_t pkt_drop; /* packages dropped of UDP */
- uint64_t udp_timeout; /* how many times timeout of UDP happens */
+ size_t bytes_read; /* read bytes */
+ size_t bytes_written; /* written bytes */
+ size_t obj_bytes; /* object bytes */
+ size_t pre_cmd_get; /* previous total get command count */
+ size_t pre_cmd_set; /* previous total set command count */
+ size_t cmd_get; /* current total get command count */
+ size_t cmd_set; /* current total set command count */
+ size_t get_misses; /* total objects of get miss */
+ size_t vef_miss; /* total objects of verification miss */
+ size_t vef_failed; /* total objects of verification failed */
+ size_t unexp_unget; /* total objects which is unexpired but not get */
+ size_t exp_get; /* total objects which is expired but get */
+ volatile size_t pkt_disorder; /* disorder packages of UDP */
+ size_t pkt_drop; /* packages dropped of UDP */
+ size_t udp_timeout; /* how many times timeout of UDP happens */
} ms_stats_t;
/* lock adapter */
/* update get miss counter */
if (mlget_item->get_miss)
{
- atomic_add_64(&ms_stats.get_misses, 1);
+ atomic_add_size(&ms_stats.get_misses, 1);
}
/* get nothing from server for this task item */
if (curr_time.tv_sec - item->client_time
< item->exp_time - EXPIRE_TIME_ERROR)
{
- atomic_add_64(&ms_stats.unexp_unget, 1);
+ atomic_add_size(&ms_stats.unexp_unget, 1);
if (ms_setting.verbose)
{
}
else
{
- atomic_add_64(&ms_stats.vef_miss, 1);
+ atomic_add_size(&ms_stats.vef_miss, 1);
if (ms_setting.verbose)
{
/* update get miss counter */
if ((c->precmd.cmd == CMD_GET) && c->curr_task.get_miss)
{
- atomic_add_64(&ms_stats.get_misses, 1);
+ atomic_add_size(&ms_stats.get_misses, 1);
}
/* get nothing from server for this task item */
if (curr_time.tv_sec - item->client_time
< item->exp_time - EXPIRE_TIME_ERROR)
{
- atomic_add_64(&ms_stats.unexp_unget, 1);
+ atomic_add_size(&ms_stats.unexp_unget, 1);
if (ms_setting.verbose)
{
}
else
{
- atomic_add_64(&ms_stats.vef_miss, 1);
+ atomic_add_size(&ms_stats.vef_miss, 1);
if (ms_setting.verbose)
{
/* calculate dropped packets count */
if (c->recvpkt > 0)
{
- atomic_add_64(&ms_stats.pkt_drop, c->packets - c->recvpkt);
+ atomic_add_size(&ms_stats.pkt_drop, c->packets - c->recvpkt);
}
- atomic_add_64(&ms_stats.udp_timeout, 1);
+ atomic_add_size(&ms_stats.udp_timeout, 1);
ms_reset_conn(c, true);
}
}