static void protocol_entry (unsigned char type, gpointer data, int size) { int index; BinaryProtocolBuffer *buffer; if (!binary_protocol_file) return; lock_recursive (); retry: buffer = binary_protocol_get_buffer (size + 1); retry_same_buffer: index = buffer->index; if (index + 1 + size > BINARY_PROTOCOL_BUFFER_SIZE) goto retry; if (InterlockedCompareExchange (&buffer->index, index + 1 + size, index) != index) goto retry_same_buffer; /* FIXME: if we're interrupted at this point, we have a buffer entry that contains random data. */ buffer->buffer [index++] = type; memcpy (buffer->buffer + index, data, size); index += size; g_assert (index <= BINARY_PROTOCOL_BUFFER_SIZE); unlock_recursive (); }
static void protocol_entry (unsigned char type, gpointer data, int size) { #ifdef HAVE_UNISTD_H int index; BinaryProtocolBuffer *buffer; if (binary_protocol_file == -1) return; if (sgen_thread_pool_is_thread_pool_thread (mono_native_thread_id_get ())) type |= 0x80; lock_recursive (); retry: buffer = binary_protocol_get_buffer (size + 1); retry_same_buffer: index = buffer->index; if (index + 1 + size > BINARY_PROTOCOL_BUFFER_SIZE) goto retry; if (InterlockedCompareExchange (&buffer->index, index + 1 + size, index) != index) goto retry_same_buffer; /* FIXME: if we're interrupted at this point, we have a buffer entry that contains random data. */ buffer->buffer [index++] = type; memcpy (buffer->buffer + index, data, size); index += size; g_assert (index <= BINARY_PROTOCOL_BUFFER_SIZE); unlock_recursive (); #endif }