small optimizations
This commit is contained in:
parent
41d0b1a8e5
commit
5e4a6dcf34
3 changed files with 10 additions and 15 deletions
4
Makefile
4
Makefile
|
@ -1,11 +1,11 @@
|
||||||
CC?=gcc
|
CC?=gcc
|
||||||
|
|
||||||
CFLAGS_DEV=-DJB_PRESET_DEBUG -ggdb -fsanitize=address -Og
|
CFLAGS_DEV=-DJB_PRESET_DEBUG -ggdb -fsanitize=address -Og
|
||||||
CFLAGS_RELEASE=-O2 -ggdb
|
CFLAGS_RELEASE=-O3 -march=native -mtune=native -fgraphite-identity -flto
|
||||||
|
|
||||||
CFLAGS+=-pipe -Wall -Wextra -Wshadow -pedantic -std=c99
|
CFLAGS+=-pipe -Wall -Wextra -Wshadow -pedantic -std=c99
|
||||||
|
|
||||||
CFLAGS+=$(CFLAGS_RELEASE)
|
CFLAGS+=$(CFLAGS_DEV)
|
||||||
|
|
||||||
jitterbug: util.c wire.c match.c server.c main.c
|
jitterbug: util.c wire.c match.c server.c main.c
|
||||||
$(CC) $(CFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) -o $@ $^
|
||||||
|
|
1
server.c
1
server.c
|
@ -696,7 +696,6 @@ int bus_client_process_message(bus_t *s, int i, wire_context_t *ctx)
|
||||||
wire_message_field_t *member_field = &msg.fields[DBUS_HEADER_FIELD_MEMBER];
|
wire_message_field_t *member_field = &msg.fields[DBUS_HEADER_FIELD_MEMBER];
|
||||||
|
|
||||||
uint8_t reply_data[8192];
|
uint8_t reply_data[8192];
|
||||||
memset(reply_data, 0, 8192);
|
|
||||||
wire_context_t reply_ctx = {
|
wire_context_t reply_ctx = {
|
||||||
.byte_cursor = 0,
|
.byte_cursor = 0,
|
||||||
.data = reply_data,
|
.data = reply_data,
|
||||||
|
|
20
wire.h
20
wire.h
|
@ -73,24 +73,20 @@ typedef struct wire_message_body_string {
|
||||||
M_type *wire_set_##M_mnemonic(wire_context_t *c, M_type val); \
|
M_type *wire_set_##M_mnemonic(wire_context_t *c, M_type val); \
|
||||||
|
|
||||||
#define _WIRE_DEF_BYTE_TYPE(M_mnemonic, M_type) \
|
#define _WIRE_DEF_BYTE_TYPE(M_mnemonic, M_type) \
|
||||||
M_type *wire_get_##M_mnemonic(wire_context_t *c) { \
|
M_type *wire_get_##M_mnemonic(wire_context_t *restrict c) { \
|
||||||
uint32_t new_cursor = c->byte_cursor + 1; \
|
if (c->byte_cursor + 1 >= c->data_len) return NULL; \
|
||||||
if (new_cursor >= c->data_len) return NULL; \
|
M_type *value = (M_type*)&c->data[c->byte_cursor++]; \
|
||||||
M_type *value = (M_type*)&c->data[c->byte_cursor]; \
|
|
||||||
c->byte_cursor = new_cursor; \
|
|
||||||
return value; \
|
return value; \
|
||||||
} \
|
} \
|
||||||
M_type *wire_set_##M_mnemonic(wire_context_t *c, M_type val) { \
|
M_type *wire_set_##M_mnemonic(wire_context_t *restrict c, M_type val) { \
|
||||||
uint32_t new_cursor = c->byte_cursor + 1; \
|
if (c->byte_cursor + 1 >= c->data_len) return NULL; \
|
||||||
if (new_cursor >= c->data_len) return NULL; \
|
M_type *dest = (M_type*)&c->data[c->byte_cursor++]; \
|
||||||
M_type *dest = (M_type*)&c->data[c->byte_cursor]; \
|
|
||||||
*dest = val; \
|
*dest = val; \
|
||||||
c->byte_cursor = new_cursor; \
|
|
||||||
return dest; \
|
return dest; \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
#define _WIRE_DEF_TYPE(M_mnemonic, M_type, M_alignment) \
|
#define _WIRE_DEF_TYPE(M_mnemonic, M_type, M_alignment) \
|
||||||
M_type *wire_get_##M_mnemonic(wire_context_t *c) { \
|
M_type *wire_get_##M_mnemonic(wire_context_t *restrict c) { \
|
||||||
if (!wire_align(c, M_alignment)) return NULL; \
|
if (!wire_align(c, M_alignment)) return NULL; \
|
||||||
uint32_t new_cursor = c->byte_cursor + sizeof(M_type); \
|
uint32_t new_cursor = c->byte_cursor + sizeof(M_type); \
|
||||||
if (new_cursor >= c->data_len) return NULL; \
|
if (new_cursor >= c->data_len) return NULL; \
|
||||||
|
@ -98,7 +94,7 @@ typedef struct wire_message_body_string {
|
||||||
c->byte_cursor = new_cursor; \
|
c->byte_cursor = new_cursor; \
|
||||||
return value; \
|
return value; \
|
||||||
} \
|
} \
|
||||||
M_type *wire_set_##M_mnemonic(wire_context_t *c, M_type val) { \
|
M_type *wire_set_##M_mnemonic(wire_context_t *restrict c, M_type val) { \
|
||||||
if (!wire_write_align(c, M_alignment)) return NULL; \
|
if (!wire_write_align(c, M_alignment)) return NULL; \
|
||||||
uint32_t new_cursor = c->byte_cursor + sizeof(M_type); \
|
uint32_t new_cursor = c->byte_cursor + sizeof(M_type); \
|
||||||
if (new_cursor >= c->data_len) return NULL; \
|
if (new_cursor >= c->data_len) return NULL; \
|
||||||
|
|
Loading…
Reference in a new issue