From f50ae8a80f6dc8d8f0aabf2417b73da43d0dd38b Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Tue, 25 Feb 2014 15:25:57 +0100 Subject: [PATCH] Added support for OpenBSD --- mtproto-client.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mtproto-client.c b/mtproto-client.c index 19c9a9c..6ea6def 100644 --- a/mtproto-client.c +++ b/mtproto-client.c @@ -31,7 +31,7 @@ #include #include #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__OpenBSD__) #include #endif #include @@ -58,6 +58,10 @@ #define __builtin_bswap32(x) bswap32(x) #endif +#if defined(__OpenBSD__) +#define __builtin_bswap32(x) __swap32gen(x) +#endif + #define sha1 SHA1 #include "mtproto-common.h" @@ -1720,7 +1724,7 @@ int rpc_execute (struct connection *c, int op, int len) { logprintf ( "have %d Response bytes\n", Response_len); } -#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined (__CYGWIN__) +#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined (__CYGWIN__) setsockopt (c->fd, IPPROTO_TCP, TCP_QUICKACK, (int[]){0}, 4); #endif int o = c_state; @@ -1728,19 +1732,19 @@ int rpc_execute (struct connection *c, int op, int len) { switch (o) { case st_reqpq_sent: process_respq_answer (c, Response/* + 8*/, Response_len/* - 12*/); -#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined (__CYGWIN__) +#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined (__CYGWIN__) setsockopt (c->fd, IPPROTO_TCP, TCP_QUICKACK, (int[]){0}, 4); #endif return 0; case st_reqdh_sent: process_dh_answer (c, Response/* + 8*/, Response_len/* - 12*/); -#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined (__CYGWIN__) +#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined (__CYGWIN__) setsockopt (c->fd, IPPROTO_TCP, TCP_QUICKACK, (int[]){0}, 4); #endif return 0; case st_client_dh_sent: process_auth_complete (c, Response/* + 8*/, Response_len/* - 12*/); -#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined (__CYGWIN__) +#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined (__CYGWIN__) setsockopt (c->fd, IPPROTO_TCP, TCP_QUICKACK, (int[]){0}, 4); #endif return 0; @@ -1750,7 +1754,7 @@ int rpc_execute (struct connection *c, int op, int len) { } else { process_rpc_message (c, (void *)(Response/* + 8*/), Response_len/* - 12*/); } -#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined (__CYGWIN__) +#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined (__CYGWIN__) setsockopt (c->fd, IPPROTO_TCP, TCP_QUICKACK, (int[]){0}, 4); #endif return 0; @@ -1778,7 +1782,7 @@ int tc_becomes_ready (struct connection *c) { assert (write_out (c, &byte, 1) == 1); flush_out (c); -#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined (__CYGWIN__) +#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined (__CYGWIN__) setsockopt (c->fd, IPPROTO_TCP, TCP_QUICKACK, (int[]){0}, 4); #endif int o = c_state;