--- /dev/null
+#ifndef CLIENTS_MS_ATOMIC_H
+#define CLIENTS_MS_ATOMIC_H
+
+#if defined(__SUNC)
+
+#define _KERNEL
+#include <atomic.h>
+#undef _KERNEL
+
+inline int32_t __sync_add_and_fetch(volatile int32_t* ptr, int32_t val)
+{
+ (val == 1) ? atomic_inc_32((volatile uint32_t*)ptr) : atomic_add_32((volatile uint32_t*)ptr, val);
+ return *ptr;
+}
+
+
+inline uint32_t __sync_sub_and_fetch(volatile uint32_t* ptr, uint32_t val)
+{
+ (val == 1) ? atomic_dec_32(ptr) : atomic_add_32(ptr, 0-(int32_t)val);
+ return *ptr;
+}
+
+#endif /* defined(__SUNC) */
+#endif /* CLIENTS_MS_ATOMIC_H */
#include <arpa/inet.h>
#include "ms_setting.h"
#include "ms_thread.h"
+#include "ms_atomic.h"
/* for network write */
#define TRANSMIT_COMPLETE 0
static uint64_t key_prefix_seq= KEY_PREFIX_BASE;
/* global increasing counter, generating request id for UDP */
-static int udp_request_id= 0;
+static int32_t udp_request_id= 0;
extern __thread ms_thread_t ms_thread;
#include "config.h"
#include <ctype.h>
+#include <strings.h>
+
#include "ms_setting.h"
#include "ms_conn.h"
int srv_port; /* server port */
/* for calculating how long the server disconnects */
- int disconn_cnt; /* number of disconnections count */
- int reconn_cnt; /* number of reconnections count */
+ int32_t disconn_cnt; /* number of disconnections count */
+ int32_t reconn_cnt; /* number of reconnections count */
struct timeval disconn_time; /* start time of disconnection */
struct timeval reconn_time; /* end time of reconnection */
} ms_mcd_server_t;
#include "ms_thread.h"
#include "ms_setting.h"
+#include "ms_atomic.h"
/* command distribution adjustment cycle */
#define CMD_DISTR_ADJUST_CYCLE 1000
#include "ms_thread.h"
#include "ms_setting.h"
+#include "ms_atomic.h"
/* global variable */
__thread ms_thread_t ms_thread; /* each thread with a private ms_thread structure */