From e94e08475dabaec0cfd160da66cccdebebe35467 Mon Sep 17 00:00:00 2001
From: yuyi <yuyi98@163.com>
Date: Mon, 4 Oct 2021 23:27:38 +0800
Subject: [PATCH] cgen: format shared structs (#12062)

---
 vlib/v/gen/c/cgen.v     |  5 ++++-
 vlib/v/gen/c/cheaders.v | 10 ++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v
index a3f7345d26..218200bab4 100644
--- a/vlib/v/gen/c/cgen.v
+++ b/vlib/v/gen/c/cgen.v
@@ -877,7 +877,10 @@ fn (mut g Gen) write_shareds() {
 		done_types << typ
 		sh_typ := '__shared__$base'
 		mtx_typ := 'sync__RwMutex'
-		g.shared_types.writeln('struct $sh_typ { $mtx_typ mtx; $base val; };')
+		g.shared_types.writeln('struct $sh_typ {')
+		g.shared_types.writeln('\t$mtx_typ mtx;')
+		g.shared_types.writeln('\t$base val;')
+		g.shared_types.writeln('};')
 		g.shared_functions.writeln('static inline voidptr __dup${sh_typ}(voidptr src, int sz) {')
 		g.shared_functions.writeln('\t$sh_typ* dest = memdup(src, sz);')
 		g.shared_functions.writeln('\tsync__RwMutex_init(&dest->mtx);')
diff --git a/vlib/v/gen/c/cheaders.v b/vlib/v/gen/c/cheaders.v
index 9cb75a34d3..c7f941c125 100644
--- a/vlib/v/gen/c/cheaders.v
+++ b/vlib/v/gen/c/cheaders.v
@@ -23,14 +23,20 @@ const c_current_commit_hash_default = '
 
 const c_concurrency_helpers = '
 typedef struct __shared_map __shared_map;
-struct __shared_map { sync__RwMutex mtx; map val; };
+struct __shared_map {
+	sync__RwMutex mtx;
+	map val;
+};
 static inline voidptr __dup_shared_map(voidptr src, int sz) {
 	__shared_map* dest = memdup(src, sz);
 	sync__RwMutex_init(&dest->mtx);
 	return dest;
 }
 typedef struct __shared_array __shared_array;
-struct __shared_array { sync__RwMutex mtx; array val; };
+struct __shared_array {
+	sync__RwMutex mtx;
+	array val;
+};
 static inline voidptr __dup_shared_array(voidptr src, int sz) {
 	__shared_array* dest = memdup(src, sz);
 	sync__RwMutex_init(&dest->mtx);