From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v26 11/15] trace-cmd: Define a macro for packed structures Date: Thu, 21 Jan 2021 09:44:52 +0200 Message-ID: <20210121074456.157658-12-tz.stoyanov@gmail.com> (raw) In-Reply-To: <20210121074456.157658-1-tz.stoyanov@gmail.com> Defined a new macro #define __packed __attribute__((packed)) used for packing the structures, to make the code look cleaner. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- lib/trace-cmd/include/trace-cmd-local.h | 2 ++ lib/trace-cmd/trace-msg.c | 14 +++++++------- lib/trace-cmd/trace-timesync.c | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/trace-cmd/include/trace-cmd-local.h b/lib/trace-cmd/include/trace-cmd-local.h index 0cd27441..d265e4c8 100644 --- a/lib/trace-cmd/include/trace-cmd-local.h +++ b/lib/trace-cmd/include/trace-cmd-local.h @@ -12,6 +12,8 @@ /* Can be overridden */ void warning(const char *fmt, ...); +#define __packed __attribute__((packed)) + /* trace.dat file format version */ #define FILE_VERSION 6 diff --git a/lib/trace-cmd/trace-msg.c b/lib/trace-cmd/trace-msg.c index e0cdf677..8d2ed38d 100644 --- a/lib/trace-cmd/trace-msg.c +++ b/lib/trace-cmd/trace-msg.c @@ -57,11 +57,11 @@ struct tracecmd_msg_tinit { be32 cpus; be32 page_size; be32 opt_num; -} __attribute__((packed)); +} __packed; struct tracecmd_msg_rinit { be32 cpus; -} __attribute__((packed)); +} __packed; #define TRACE_REQ_PARAM_SIZE (2 * sizeof(int)) enum trace_req_params { @@ -79,7 +79,7 @@ struct tracecmd_msg_trace_req { be32 flags; be32 argc; u64 trace_id; -} __attribute__((packed)); +} __packed; struct tracecmd_msg_trace_resp { be32 flags; @@ -88,18 +88,18 @@ struct tracecmd_msg_trace_resp { u64 trace_id; char tsync_proto_name[TRACECMD_TSYNC_PNAME_LENGTH]; be32 tsync_port; -} __attribute__((packed)); +} __packed; struct tracecmd_msg_tsync { char sync_protocol_name[TRACECMD_TSYNC_PNAME_LENGTH]; be32 sync_msg_id; -} __attribute__((packed)); +} __packed; struct tracecmd_msg_header { be32 size; be32 cmd; be32 cmd_size; -} __attribute__((packed)); +} __packed; #define MSG_MAP \ C(CLOSE, 0, 0), \ @@ -148,7 +148,7 @@ struct tracecmd_msg { struct tracecmd_msg_tsync tsync; }; char *buf; -} __attribute__((packed)); +} __packed; static inline int msg_buf_len(struct tracecmd_msg *msg) { diff --git a/lib/trace-cmd/trace-timesync.c b/lib/trace-cmd/trace-timesync.c index 994a935a..8371a141 100644 --- a/lib/trace-cmd/trace-timesync.c +++ b/lib/trace-cmd/trace-timesync.c @@ -41,7 +41,7 @@ struct tsync_proto { struct tsync_probe_request_msg { be16 cpu; -} __attribute__((packed)); +} __packed; static struct tsync_proto *tsync_proto_list; -- 2.29.2
next prev parent reply index Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-01-21 7:44 [PATCH v26 00/15] Timestamp synchronization of host - guest tracing session Tzvetomir Stoyanov (VMware) 2021-01-21 7:44 ` [PATCH v26 01/15] trace-cmd: Replace time sync protocol ID with string Tzvetomir Stoyanov (VMware) 2021-01-21 7:44 ` [PATCH v26 02/15] trace-cmd: Add trace-cmd library APIs for ftrace clock name Tzvetomir Stoyanov (VMware) 2021-01-21 7:44 ` [PATCH v26 03/15] trace-cmd: Move VM related logic in a separate file Tzvetomir Stoyanov (VMware) 2021-01-21 7:44 ` [PATCH v26 04/15] trace-cmd: Add clock parameter to timestamp synchronization plugins Tzvetomir Stoyanov (VMware) 2021-01-21 7:44 ` [PATCH v26 05/15] trace-cmd: Add role " Tzvetomir Stoyanov (VMware) 2021-01-21 7:44 ` [PATCH v26 06/15] trace-cmd: Add host / guest role in timestamp synchronization context Tzvetomir Stoyanov (VMware) 2021-01-21 7:44 ` [PATCH v26 07/15] trace-cmd: Add guest CPU count PID in tracecmd_time_sync struct Tzvetomir Stoyanov (VMware) 2021-01-21 7:44 ` [PATCH v26 08/15] trace-cmd: Add scaling ratio for timestamp correction Tzvetomir Stoyanov (VMware) 2021-01-21 7:44 ` [PATCH v26 09/15] trace-cmd: Add time sync protocol flags Tzvetomir Stoyanov (VMware) 2021-01-21 7:44 ` [PATCH v26 10/15] trace-cmd: Add timestamp synchronization per vCPU Tzvetomir Stoyanov (VMware) 2021-01-28 2:09 ` Steven Rostedt 2021-01-21 7:44 ` Tzvetomir Stoyanov (VMware) [this message] 2021-01-28 22:44 ` [PATCH v26 11/15] trace-cmd: Define a macro for packed structures Steven Rostedt 2021-01-21 7:44 ` [PATCH v26 12/15] trace-cmd: Add dummy function to initialize timestamp sync logic Tzvetomir Stoyanov (VMware) 2021-01-21 7:44 ` [PATCH v26 13/15] trace-cmd: [POC] PTP-like algorithm for host - guest timestamp synchronization Tzvetomir Stoyanov (VMware) 2021-01-21 7:44 ` [PATCH v26 14/15] trace-cmd: Debug scripts for " Tzvetomir Stoyanov (VMware) 2021-01-21 7:44 ` [PATCH v26 15/15] trace-cmd [POC]: Add KVM timestamp synchronization plugin Tzvetomir Stoyanov (VMware)
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210121074456.157658-12-tz.stoyanov@gmail.com \ --to=tz.stoyanov@gmail.com \ --cc=linux-trace-devel@vger.kernel.org \ --cc=rostedt@goodmis.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Linux-Trace-Devel Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-trace-devel/0 linux-trace-devel/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-trace-devel linux-trace-devel/ https://lore.kernel.org/linux-trace-devel \ linux-trace-devel@vger.kernel.org public-inbox-index linux-trace-devel Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-trace-devel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git