diff --git a/app/src/adb.h b/app/src/adb.h index 453e3019..e27f34fa 100644 --- a/app/src/adb.h +++ b/app/src/adb.h @@ -1,11 +1,11 @@ #ifndef SC_ADB_H #define SC_ADB_H +#include "common.h" + #include #include -#include "common.h" - #include "util/process.h" process_t diff --git a/app/src/cli.h b/app/src/cli.h index 22bded79..419f156f 100644 --- a/app/src/cli.h +++ b/app/src/cli.h @@ -1,9 +1,10 @@ #ifndef SCRCPY_CLI_H #define SCRCPY_CLI_H +#include "common.h" + #include -#include "common.h" #include "scrcpy.h" struct scrcpy_cli_args { diff --git a/app/src/compat.h b/app/src/compat.h index 21f19214..5464589a 100644 --- a/app/src/compat.h +++ b/app/src/compat.h @@ -1,6 +1,13 @@ #ifndef COMPAT_H #define COMPAT_H +#define _POSIX_C_SOURCE 200809L +#define _XOPEN_SOURCE 700 +#define _GNU_SOURCE +#ifdef __APPLE__ +# define _DARWIN_C_SOURCE +#endif + #include #include #include diff --git a/app/src/control_msg.h b/app/src/control_msg.h index e23cc89c..20b2ef45 100644 --- a/app/src/control_msg.h +++ b/app/src/control_msg.h @@ -1,11 +1,12 @@ #ifndef CONTROLMSG_H #define CONTROLMSG_H +#include "common.h" + #include #include #include -#include "common.h" #include "android/input.h" #include "android/keycodes.h" #include "coords.h" diff --git a/app/src/controller.h b/app/src/controller.h index 5ef8755a..d6fe35e2 100644 --- a/app/src/controller.h +++ b/app/src/controller.h @@ -1,11 +1,12 @@ #ifndef CONTROLLER_H #define CONTROLLER_H +#include "common.h" + #include #include #include -#include "common.h" #include "control_msg.h" #include "receiver.h" #include "util/cbuf.h" diff --git a/app/src/decoder.h b/app/src/decoder.h index 8a3bc297..27afcd8e 100644 --- a/app/src/decoder.h +++ b/app/src/decoder.h @@ -1,11 +1,11 @@ #ifndef DECODER_H #define DECODER_H +#include "common.h" + #include #include -#include "common.h" - struct video_buffer; struct decoder { diff --git a/app/src/device.h b/app/src/device.h index c21b1ace..376e3d4b 100644 --- a/app/src/device.h +++ b/app/src/device.h @@ -1,9 +1,10 @@ #ifndef DEVICE_H #define DEVICE_H +#include "common.h" + #include -#include "common.h" #include "coords.h" #include "util/net.h" diff --git a/app/src/device_msg.h b/app/src/device_msg.h index b1860726..bc13cebb 100644 --- a/app/src/device_msg.h +++ b/app/src/device_msg.h @@ -1,12 +1,12 @@ #ifndef DEVICEMSG_H #define DEVICEMSG_H +#include "common.h" + #include #include #include -#include "common.h" - #define DEVICE_MSG_MAX_SIZE (1 << 18) // 256k // type: 1 byte; length: 4 bytes #define DEVICE_MSG_TEXT_MAX_LENGTH (DEVICE_MSG_MAX_SIZE - 5) diff --git a/app/src/event_converter.h b/app/src/event_converter.h index cbd578a0..d28e9fdc 100644 --- a/app/src/event_converter.h +++ b/app/src/event_converter.h @@ -1,10 +1,11 @@ #ifndef CONVERT_H #define CONVERT_H +#include "common.h" + #include #include -#include "common.h" #include "control_msg.h" bool diff --git a/app/src/file_handler.h b/app/src/file_handler.h index 6649b9ea..a8f469e2 100644 --- a/app/src/file_handler.h +++ b/app/src/file_handler.h @@ -1,11 +1,12 @@ #ifndef FILE_HANDLER_H #define FILE_HANDLER_H +#include "common.h" + #include #include #include -#include "common.h" #include "adb.h" #include "util/cbuf.h" diff --git a/app/src/fps_counter.h b/app/src/fps_counter.h index 2c13b3e2..68255bb6 100644 --- a/app/src/fps_counter.h +++ b/app/src/fps_counter.h @@ -1,14 +1,14 @@ #ifndef FPSCOUNTER_H #define FPSCOUNTER_H +#include "common.h" + #include #include #include #include #include -#include "common.h" - struct fps_counter { SDL_Thread *thread; SDL_mutex *mutex; diff --git a/app/src/input_manager.h b/app/src/input_manager.h index 66daa9dd..a23a731d 100644 --- a/app/src/input_manager.h +++ b/app/src/input_manager.h @@ -1,11 +1,12 @@ #ifndef INPUTMANAGER_H #define INPUTMANAGER_H +#include "common.h" + #include #include -#include "common.h" #include "controller.h" #include "fps_counter.h" #include "scrcpy.h" diff --git a/app/src/main.c b/app/src/main.c index 18b9c710..e1e44f68 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -1,5 +1,7 @@ #include "scrcpy.h" +#include "common.h" + #include #include #include @@ -7,7 +9,6 @@ #define SDL_MAIN_HANDLED // avoid link error on Linux Windows Subsystem #include -#include "common.h" #include "cli.h" #include "util/log.h" diff --git a/app/src/opengl.h b/app/src/opengl.h index 1c1e4658..81163704 100644 --- a/app/src/opengl.h +++ b/app/src/opengl.h @@ -1,11 +1,11 @@ #ifndef SC_OPENGL_H #define SC_OPENGL_H +#include "common.h" + #include #include -#include "common.h" - struct sc_opengl { const char *version; bool is_opengles; diff --git a/app/src/receiver.h b/app/src/receiver.h index 8f628238..3b1cc03a 100644 --- a/app/src/receiver.h +++ b/app/src/receiver.h @@ -1,11 +1,12 @@ #ifndef RECEIVER_H #define RECEIVER_H +#include "common.h" + #include #include #include -#include "common.h" #include "util/net.h" // receive events from the device diff --git a/app/src/recorder.h b/app/src/recorder.h index fc05d06c..1e942110 100644 --- a/app/src/recorder.h +++ b/app/src/recorder.h @@ -1,12 +1,13 @@ #ifndef RECORDER_H #define RECORDER_H +#include "common.h" + #include #include #include #include -#include "common.h" #include "coords.h" #include "scrcpy.h" #include "util/queue.h" diff --git a/app/src/scrcpy.h b/app/src/scrcpy.h index 08bce7e3..2253cc28 100644 --- a/app/src/scrcpy.h +++ b/app/src/scrcpy.h @@ -1,12 +1,12 @@ #ifndef SCRCPY_H #define SCRCPY_H +#include "common.h" + #include #include #include -#include "common.h" - enum sc_log_level { SC_LOG_LEVEL_DEBUG, SC_LOG_LEVEL_INFO, diff --git a/app/src/screen.h b/app/src/screen.h index 820c7382..ea94d538 100644 --- a/app/src/screen.h +++ b/app/src/screen.h @@ -1,11 +1,12 @@ #ifndef SCREEN_H #define SCREEN_H +#include "common.h" + #include #include #include -#include "common.h" #include "coords.h" #include "opengl.h" diff --git a/app/src/server.h b/app/src/server.h index b48bcd61..7a66670f 100644 --- a/app/src/server.h +++ b/app/src/server.h @@ -1,12 +1,13 @@ #ifndef SERVER_H #define SERVER_H +#include "common.h" + #include #include #include #include -#include "common.h" #include "adb.h" #include "scrcpy.h" #include "util/log.h" diff --git a/app/src/stream.h b/app/src/stream.h index 7b0a5d42..d308df88 100644 --- a/app/src/stream.h +++ b/app/src/stream.h @@ -1,13 +1,14 @@ #ifndef STREAM_H #define STREAM_H +#include "common.h" + #include #include #include #include #include -#include "common.h" #include "util/net.h" struct video_buffer; diff --git a/app/src/sys/unix/process.c b/app/src/sys/unix/process.c index dc4f5649..3bb55010 100644 --- a/app/src/sys/unix/process.c +++ b/app/src/sys/unix/process.c @@ -1,14 +1,3 @@ -// for portability (kill, readlink, strdup, strtok_r) -#define _POSIX_C_SOURCE 200809L -#define _BSD_SOURCE - -// modern glibc will complain without this -#define _DEFAULT_SOURCE - -#ifdef __APPLE__ -# define _DARWIN_C_SOURCE // for strdup(), strtok_r(), memset_pattern4() -#endif - #include "util/process.h" #include diff --git a/app/src/tiny_xpm.h b/app/src/tiny_xpm.h index 2dcbeb07..29b42d14 100644 --- a/app/src/tiny_xpm.h +++ b/app/src/tiny_xpm.h @@ -1,10 +1,10 @@ #ifndef TINYXPM_H #define TINYXPM_H -#include - #include "common.h" +#include + SDL_Surface * read_xpm(char *xpm[]); diff --git a/app/src/util/buffer_util.h b/app/src/util/buffer_util.h index 265704bc..ab22ab24 100644 --- a/app/src/util/buffer_util.h +++ b/app/src/util/buffer_util.h @@ -1,11 +1,11 @@ #ifndef BUFFER_UTIL_H #define BUFFER_UTIL_H +#include "common.h" + #include #include -#include "common.h" - static inline void buffer_write16be(uint8_t *buf, uint16_t value) { buf[0] = value >> 8; diff --git a/app/src/util/cbuf.h b/app/src/util/cbuf.h index 6abc984b..01e41044 100644 --- a/app/src/util/cbuf.h +++ b/app/src/util/cbuf.h @@ -2,11 +2,11 @@ #ifndef CBUF_H #define CBUF_H +#include "common.h" + #include #include -#include "common.h" - // To define a circular buffer type of 20 ints: // struct cbuf_int CBUF(int, 20); // diff --git a/app/src/util/lock.h b/app/src/util/lock.h index a0a044b1..f031bd69 100644 --- a/app/src/util/lock.h +++ b/app/src/util/lock.h @@ -1,10 +1,11 @@ #ifndef LOCK_H #define LOCK_H +#include "common.h" + #include #include -#include "common.h" #include "log.h" static inline void diff --git a/app/src/util/net.h b/app/src/util/net.h index f86c048d..d3b1f941 100644 --- a/app/src/util/net.h +++ b/app/src/util/net.h @@ -1,6 +1,8 @@ #ifndef NET_H #define NET_H +#include "common.h" + #include #include #include @@ -17,8 +19,6 @@ typedef int socket_t; #endif -#include "common.h" - bool net_init(void); diff --git a/app/src/util/process.h b/app/src/util/process.h index f91553d4..46e481bb 100644 --- a/app/src/util/process.h +++ b/app/src/util/process.h @@ -1,10 +1,10 @@ #ifndef SC_PROCESS_H #define SC_PROCESS_H -#include - #include "common.h" +#include + #ifdef _WIN32 // not needed here, but winsock2.h must never be included AFTER windows.h diff --git a/app/src/util/queue.h b/app/src/util/queue.h index 6092c712..0681070c 100644 --- a/app/src/util/queue.h +++ b/app/src/util/queue.h @@ -2,12 +2,12 @@ #ifndef QUEUE_H #define QUEUE_H +#include "common.h" + #include #include #include -#include "common.h" - // To define a queue type of "struct foo": // struct queue_foo QUEUE(struct foo); #define QUEUE(TYPE) { \ diff --git a/app/src/util/str_util.h b/app/src/util/str_util.h index dd523400..25bec444 100644 --- a/app/src/util/str_util.h +++ b/app/src/util/str_util.h @@ -1,11 +1,11 @@ #ifndef STRUTIL_H #define STRUTIL_H +#include "common.h" + #include #include -#include "common.h" - // like strncpy, except: // - it copies at most n-1 chars // - the dest string is nul-terminated diff --git a/app/src/video_buffer.h b/app/src/video_buffer.h index ddd639ad..68ef8e04 100644 --- a/app/src/video_buffer.h +++ b/app/src/video_buffer.h @@ -1,10 +1,11 @@ #ifndef VIDEO_BUFFER_H #define VIDEO_BUFFER_H +#include "common.h" + #include #include -#include "common.h" #include "fps_counter.h" // forward declarations diff --git a/app/tests/test_buffer_util.c b/app/tests/test_buffer_util.c index d61e6918..c7c13bdd 100644 --- a/app/tests/test_buffer_util.c +++ b/app/tests/test_buffer_util.c @@ -1,3 +1,5 @@ +#include "common.h" + #include #include "util/buffer_util.h" diff --git a/app/tests/test_cbuf.c b/app/tests/test_cbuf.c index f8beb880..16674e92 100644 --- a/app/tests/test_cbuf.c +++ b/app/tests/test_cbuf.c @@ -1,3 +1,5 @@ +#include "common.h" + #include #include diff --git a/app/tests/test_cli.c b/app/tests/test_cli.c index 9699b024..cd222d63 100644 --- a/app/tests/test_cli.c +++ b/app/tests/test_cli.c @@ -1,7 +1,8 @@ +#include "common.h" + #include #include -#include "common.h" #include "cli.h" #include "scrcpy.h" diff --git a/app/tests/test_control_msg_serialize.c b/app/tests/test_control_msg_serialize.c index b58c8e20..ffd5f300 100644 --- a/app/tests/test_control_msg_serialize.c +++ b/app/tests/test_control_msg_serialize.c @@ -1,3 +1,5 @@ +#include "common.h" + #include #include diff --git a/app/tests/test_device_msg_deserialize.c b/app/tests/test_device_msg_deserialize.c index 3dfd0b0f..3427d640 100644 --- a/app/tests/test_device_msg_deserialize.c +++ b/app/tests/test_device_msg_deserialize.c @@ -1,3 +1,5 @@ +#include "common.h" + #include #include diff --git a/app/tests/test_queue.c b/app/tests/test_queue.c index e10821cd..fcbafc62 100644 --- a/app/tests/test_queue.c +++ b/app/tests/test_queue.c @@ -1,3 +1,5 @@ +#include "common.h" + #include #include "util/queue.h" diff --git a/app/tests/test_strutil.c b/app/tests/test_strutil.c index 7b9c61da..9d35f983 100644 --- a/app/tests/test_strutil.c +++ b/app/tests/test_strutil.c @@ -1,3 +1,5 @@ +#include "common.h" + #include #include #include