Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 103 lines 3.3 kB view raw
1From fa120ba1a02437c762fc6a37a60728cac380aa41 Mon Sep 17 00:00:00 2001 2From: =?UTF-8?q?Zsolt=20Vad=C3=A1sz?= <zsolt_vadasz@protonmail.com> 3Date: Sun, 11 May 2025 12:34:28 +0000 4Subject: [PATCH] v4l2-tracer: Allow building on systems using musl 5 6Signed-off-by: Zsolt Vadasz <zsolt_vadasz@protonmail.com> 7Message-ID: <4dgJekVdP7lLqOQ6JNW05sRHSkRmLLMMQnEn8NGUHPoHDn4SBkaGlHUW89vkJJu3IeFDAh3p6mlplTJJlWJx8V4rr62-hd83quCJ2sIuqoA=@protonmail.com> 8--- 9 utils/v4l2-tracer/retrace.cpp | 24 ++++++++++++++++++++++++ 10 1 file changed, 24 insertions(+) 11 12diff --git a/utils/v4l2-tracer/retrace.cpp b/utils/v4l2-tracer/retrace.cpp 13index 010936c0..0acce10c 100644 14--- a/utils/v4l2-tracer/retrace.cpp 15+++ b/utils/v4l2-tracer/retrace.cpp 16@@ -10,10 +10,14 @@ extern struct retrace_context ctx_retrace; 17 void retrace_mmap(json_object *mmap_obj, bool is_mmap64) 18 { 19 json_object *mmap_args_obj; 20+#if defined(linux) && defined(__GLIBC__) 21 if (is_mmap64) 22 json_object_object_get_ex(mmap_obj, "mmap64", &mmap_args_obj); 23 else 24 json_object_object_get_ex(mmap_obj, "mmap", &mmap_args_obj); 25+#else 26+ json_object_object_get_ex(mmap_obj, "mmap", &mmap_args_obj); 27+#endif 28 29 json_object *len_obj; 30 json_object_object_get_ex(mmap_args_obj, "len", &len_obj); 31@@ -46,16 +50,24 @@ void retrace_mmap(json_object *mmap_obj, bool is_mmap64) 32 return; 33 34 void *buf_address_retrace_pointer = nullptr; 35+#if defined(linux) && defined(__GLIBC__) 36 if (is_mmap64) 37 buf_address_retrace_pointer = mmap64(0, len, prot, flags, fd_retrace, off); 38 else 39 buf_address_retrace_pointer = mmap(0, len, prot, flags, fd_retrace, off); 40+#else 41+ buf_address_retrace_pointer = mmap(0, len, prot, flags, fd_retrace, off); 42+#endif 43 44 if (buf_address_retrace_pointer == MAP_FAILED) { 45+#if defined(linux) && defined(__GLIBC__) 46 if (is_mmap64) 47 perror("mmap64"); 48 else 49 perror("mmap"); 50+#else 51+ perror("mmap"); 52+#endif 53 debug_line_info(); 54 print_context(); 55 exit(EXIT_FAILURE); 56@@ -116,10 +128,14 @@ void retrace_open(json_object *jobj, bool is_open64) 57 int fd_trace = json_object_get_int(fd_trace_obj); 58 59 json_object *open_args_obj; 60+#if defined(linux) && defined(__GLIBC__) 61 if (is_open64) 62 json_object_object_get_ex(jobj, "open64", &open_args_obj); 63 else 64 json_object_object_get_ex(jobj, "open", &open_args_obj); 65+#else 66+ json_object_object_get_ex(jobj, "open", &open_args_obj); 67+#endif 68 69 json_object *path_obj; 70 std::string path_trace; 71@@ -148,10 +164,14 @@ void retrace_open(json_object *jobj, bool is_open64) 72 mode = s2number(json_object_get_string(mode_obj)); 73 74 int fd_retrace = 0; 75+#if defined(linux) && defined(__GLIBC__) 76 if (is_open64) 77 fd_retrace = open64(path_retrace.c_str(), oflag, mode); 78 else 79 fd_retrace = open(path_retrace.c_str(), oflag, mode); 80+#else 81+ fd_retrace = open(path_retrace.c_str(), oflag, mode); 82+#endif 83 84 if (fd_retrace <= 0) { 85 line_info("\n\tCan't open: %s", path_retrace.c_str()); 86@@ -162,10 +182,14 @@ void retrace_open(json_object *jobj, bool is_open64) 87 88 if (is_verbose() || errno != 0) { 89 fprintf(stderr, "path: %s ", path_retrace.c_str()); 90+#if defined(linux) && defined(__GLIBC__) 91 if (is_open64) 92 perror("open64"); 93 else 94 perror("open"); 95+#else 96+ perror("open"); 97+#endif 98 debug_line_info(); 99 print_context(); 100 } 101-- 1022.49.0 103