diff --git a/common/arch.h b/common/arch.h index 4c1f0807..f7d7c335 100644 --- a/common/arch.h +++ b/common/arch.h @@ -22,7 +22,9 @@ #define ARCH_H /* check endianess */ -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if defined(__sparc__) +#define B_ENDIAN +#elif __BYTE_ORDER == __LITTLE_ENDIAN #define L_ENDIAN #elif __BYTE_ORDER == __BIG_ENDIAN #define B_ENDIAN diff --git a/libxrdp/libxrdp.c b/libxrdp/libxrdp.c index 263a99ae..5a8f3837 100644 --- a/libxrdp/libxrdp.c +++ b/libxrdp/libxrdp.c @@ -308,7 +308,7 @@ libxrdp_send_bitmap(struct xrdp_session* session, int width, int height, for (j = 0; j < lines_sending; j++) { q = q - line_size; - out_uint8a(s, q, line_size) + out_uint8a(s, q, line_size) /* B_ENDIAN doesn't work here, todo */ out_uint8s(s, e * Bpp); } s_mark_end(s); diff --git a/vnc/vnc.c b/vnc/vnc.c index 1e895b81..e68aa121 100644 --- a/vnc/vnc.c +++ b/vnc/vnc.c @@ -949,7 +949,11 @@ int lib_mod_connect(struct vnc* v) { out_uint8(pixel_format, 8); /* bits per pixel */ out_uint8(pixel_format, 8); /* depth */ +#if defined(B_ENDIAN) + out_uint8(pixel_format, 1); /* big endian */ +#else out_uint8(pixel_format, 0); /* big endian */ +#endif out_uint8(pixel_format, 0); /* true color flag */ out_uint16_be(pixel_format, 0); /* red max */ out_uint16_be(pixel_format, 0); /* green max */ @@ -963,7 +967,11 @@ int lib_mod_connect(struct vnc* v) { out_uint8(pixel_format, 16); /* bits per pixel */ out_uint8(pixel_format, 16); /* depth */ +#if defined(B_ENDIAN) + out_uint8(pixel_format, 1); /* big endian */ +#else out_uint8(pixel_format, 0); /* big endian */ +#endif out_uint8(pixel_format, 1); /* true color flag */ out_uint16_be(pixel_format, 31); /* red max */ out_uint16_be(pixel_format, 63); /* green max */ diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c index f798bea6..52f8ac5a 100644 --- a/xrdp/xrdp.c +++ b/xrdp/xrdp.c @@ -108,9 +108,37 @@ pipe_sig(int sig_num) int main(int argc, char** argv) { + int test; + int host_be; #if defined(_WIN32) WSADATA w; - +#endif + + /* check compiled endian with actual edian */ + test = 1; + host_be = !((int)(*(unsigned char*)(&test))); +#if defined(B_ENDIAN) + if (!host_be) +#endif +#if defined(L_ENDIAN) + if (host_be) +#endif + { + g_printf("endian wrong, edit arch.h\n\r"); + return 0; + } + /* check long, int and void* sizes */ + if (sizeof(int) != 4) + { + g_printf("unusable int size, must be 4\n\r"); + return 0; + } + if (sizeof(long) != sizeof(void*) || (sizeof(long) != 4 && sizeof(long) != 8)) + { + g_printf("unusable long size, must be 4 or 8\n\r"); + return 0; + } +#if defined(_WIN32) WSAStartup(2, &w); InitializeCriticalSection(&g_term_mutex); #endif