Specify the alignment of all structs

This commit is contained in:
Max Lv
2019-07-01 13:14:50 +08:00
parent f0205e7f13
commit d0285d6b4f
6 changed files with 26 additions and 26 deletions
+4 -4
View File
@@ -92,7 +92,7 @@ typedef struct buffer {
size_t len;
size_t capacity;
char *data;
} buffer_t;
} __attribute__((aligned(4))) buffer_t;
typedef struct {
int method;
@@ -102,7 +102,7 @@ typedef struct {
size_t key_len;
size_t tag_len;
uint8_t key[MAX_KEY_LENGTH];
} cipher_t;
} __attribute__((aligned(4))) cipher_t;
typedef struct {
uint32_t init;
@@ -114,7 +114,7 @@ typedef struct {
uint8_t salt[MAX_KEY_LENGTH];
uint8_t skey[MAX_KEY_LENGTH];
uint8_t nonce[MAX_NONCE_LENGTH];
} cipher_ctx_t;
} __attribute__((aligned(4))) cipher_ctx_t;
typedef struct crypto {
cipher_t *cipher;
@@ -126,7 +126,7 @@ typedef struct crypto {
void(*const ctx_init) (cipher_t *, cipher_ctx_t *, int);
void(*const ctx_release) (cipher_ctx_t *);
} crypto_t;
} __attribute__((aligned(4))) crypto_t;
int balloc(buffer_t *, size_t);
int brealloc(buffer_t *, size_t, size_t);
+5 -5
View File
@@ -49,13 +49,13 @@ typedef struct listen_ctx {
int fd;
int mptcp;
struct sockaddr **remote_addr;
} listen_ctx_t;
} __attribute__((aligned(4))) listen_ctx_t;
typedef struct server_ctx {
ev_io io;
int connected;
struct server *server;
} server_ctx_t;
} __attribute__((aligned(4))) server_ctx_t;
typedef struct server {
int fd;
@@ -74,7 +74,7 @@ typedef struct server {
ev_timer delayed_connect_watcher;
struct cork_dllist_item entries;
} server_t;
} __attribute__((aligned(4))) server_t;
typedef struct remote_ctx {
ev_io io;
@@ -82,7 +82,7 @@ typedef struct remote_ctx {
int connected;
struct remote *remote;
} remote_ctx_t;
} __attribute__((aligned(4))) remote_ctx_t;
typedef struct remote {
int fd;
@@ -100,6 +100,6 @@ typedef struct remote {
struct remote_ctx *send_ctx;
struct server *server;
struct sockaddr_storage addr;
} remote_t;
} __attribute__((aligned(4))) remote_t;
#endif // _LOCAL_H
+2 -2
View File
@@ -63,7 +63,7 @@ struct manager_ctx {
#ifdef HAVE_SETRLIMIT
int nofile;
#endif
};
} __attribute__((aligned(4)));
struct server {
char port[8];
@@ -75,6 +75,6 @@ struct server {
char *plugin;
char *plugin_opts;
uint64_t traffic;
};
} __attribute__((aligned(4)));
#endif // _MANAGER_H
+5 -5
View File
@@ -39,13 +39,13 @@ typedef struct listen_ctx {
int mptcp;
int tos;
struct sockaddr **remote_addr;
} listen_ctx_t;
} __attribute__((aligned(4))) listen_ctx_t;
typedef struct server_ctx {
ev_io io;
int connected;
struct server *server;
} server_ctx_t;
} __attribute__((aligned(4))) server_ctx_t;
typedef struct server {
int fd;
@@ -60,14 +60,14 @@ typedef struct server {
struct sockaddr_storage destaddr;
ev_timer delayed_connect_watcher;
} server_t;
} __attribute__((aligned(4))) server_t;
typedef struct remote_ctx {
ev_io io;
ev_timer watcher;
int connected;
struct remote *remote;
} remote_ctx_t;
} __attribute__((aligned(4))) remote_ctx_t;
typedef struct remote {
int fd;
@@ -77,6 +77,6 @@ typedef struct remote {
struct server *server;
uint32_t counter;
struct sockaddr *addr;
} remote_t;
} __attribute__((aligned(4))) remote_t;
#endif // _REDIR_H
+7 -7
View File
@@ -49,14 +49,14 @@ typedef struct listen_ctx {
int timeout;
char *iface;
struct ev_loop *loop;
} listen_ctx_t;
} __attribute__((aligned(4))) listen_ctx_t;
typedef struct server_ctx {
ev_io io;
ev_timer watcher;
int connected;
struct server *server;
} server_ctx_t;
} __attribute__((aligned(4))) server_ctx_t;
#ifdef USE_NFCONNTRACK_TOS
@@ -68,7 +68,7 @@ struct dscptracker {
long unsigned int mark;
unsigned int dscp;
unsigned int packet_count;
};
} __attribute__((aligned(4)));
#endif
@@ -94,18 +94,18 @@ typedef struct server {
#ifdef USE_NFCONNTRACK_TOS
struct dscptracker *tracker;
#endif
} server_t;
} __attribute__((aligned(4))) server_t;
typedef struct query {
server_t *server;
char hostname[MAX_HOSTNAME_LEN];
} query_t;
} __attribute__((aligned(4))) query_t;
typedef struct remote_ctx {
ev_io io;
int connected;
struct remote *remote;
} remote_ctx_t;
} __attribute__((aligned(4))) remote_ctx_t;
typedef struct remote {
int fd;
@@ -117,6 +117,6 @@ typedef struct remote {
struct remote_ctx *recv_ctx;
struct remote_ctx *send_ctx;
struct server *server;
} remote_t;
} __attribute__((aligned(4))) remote_t;
#endif // _SERVER_H
+3 -3
View File
@@ -65,7 +65,7 @@ typedef struct server_ctx {
#ifdef MODULE_REMOTE
struct ev_loop *loop;
#endif
} server_ctx_t;
} __attribute__((aligned(4))) server_ctx_t;
#ifdef MODULE_REMOTE
typedef struct query_ctx {
@@ -75,7 +75,7 @@ typedef struct query_ctx {
char addr_header[MAX_ADDR_HEADER_SIZE];
struct server_ctx *server_ctx;
struct remote_ctx *remote_ctx;
} query_ctx_t;
} __attribute__((aligned(4))) query_ctx_t;
#endif
typedef struct remote_ctx {
@@ -88,6 +88,6 @@ typedef struct remote_ctx {
struct sockaddr_storage dst_addr;
#endif
struct server_ctx *server_ctx;
} remote_ctx_t;
} __attribute__((aligned(4))) remote_ctx_t;
#endif // _UDPRELAY_H