diff --git a/app/src/adb.h b/app/src/adb.h index 453e301..e27f34f 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 22bded7..419f156 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 21f1921..5464589 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 e23cc89..20b2ef4 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 5ef8755..d6fe35e 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 8a3bc29..27afcd8 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 c21b1ac..376e3d4 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 b186072..bc13ceb 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 cbd578a..d28e9fd 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 6649b9e..a8f469e 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 2c13b3e..68255bb 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 66daa9d..a23a731 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 18b9c71..e1e44f6 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 1c1e465..8116370 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 8f62823..3b1cc03 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 fc05d06..1e94211 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 08bce7e..2253cc2 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 820c738..ea94d53 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 b48bcd6..7a66670 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 7b0a5d4..d308df8 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 dc4f564..3bb5501 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 2dcbeb0..29b42d1 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 265704b..ab22ab2 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 6abc984..01e4104 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 a0a044b..f031bd6 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 f86c048..d3b1f94 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 f91553d..46e481b 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 6092c71..0681070 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 dd52340..25bec44 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 ddd639a..68ef8e0 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 d61e691..c7c13bd 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 f8beb88..16674e9 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 9699b02..cd222d6 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 b58c8e2..ffd5f30 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 3dfd0b0..3427d64 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 e10821c..fcbafc6 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 7b9c61d..9d35f98 100644 --- a/app/tests/test_strutil.c +++ b/app/tests/test_strutil.c @@ -1,3 +1,5 @@ +#include "common.h" + #include #include #include