44 #ifndef _ifc_socket_common_h_ 45 #define _ifc_socket_common_h_ 47 #define BUFFER_COUNT_PARAM_LENGTH 13 48 #define BUFFER_SIZE_PARAM_LENGTH 12 49 #define MAX_CLIENTS_PARAM_LENGTH 12 51 #define DEFAULT_MAX_DATA_LENGTH (sizeof(trap_buffer_header_t) + 1024) 53 #ifndef DEFAULT_BUFFER_COUNT 54 #define DEFAULT_BUFFER_COUNT 50 57 #ifndef DEFAULT_BUFFER_SIZE 58 #define DEFAULT_BUFFER_SIZE 100000 61 #ifndef DEFAULT_MAX_CLIENTS 62 #define DEFAULT_MAX_CLIENTS 64 65 #define NO_CLIENTS_SLEEP 100000 81 static uint64_t
mask[64] = {
82 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288,
83 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824,
84 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944,
85 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832,
86 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248,
87 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872,
88 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904, 9223372036854775808ULL
99 *bits = __sync_or_and_fetch(bits,
mask[i]);
110 *bits = __sync_and_and_fetch(bits, (0xffffffffffffffff -
mask[i]));
123 return (bits &
mask[i]);
135 uint16_t *msize = (uint16_t *)(buffer->
data + buffer->
wr_index);
136 (*msize) = htons(size);
137 memcpy((
void *)(msize + 1),
data, size);
138 buffer->
wr_index += (size +
sizeof(size));
static uint64_t mask[64]
Array containing constants used for operations with bit arrays.
static void set_index(uint64_t *bits, int i)
Set i-th element (one bit) of 'bits' to 1.
static void del_index(uint64_t *bits, int i)
Set i-th element (one bit) of 'bits' to 0.
static void insert_into_buffer(buffer_t *buffer, const void *data, uint16_t size)
Write data into buffer.
struct buffer_s buffer_t
Output buffer structure.
static uint64_t check_index(uint64_t bits, int i)
Return value of i-th element (one bit) in the 'bits' array.