From: Yordan Karadzhov <y.karadz@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v2 3/9] kernel-shark: Fix KS_DEFINE_PLUGIN_CONTEXT macro
Date: Mon, 10 May 2021 23:18:38 +0300 [thread overview]
Message-ID: <0dc10813-0fe9-2506-4c32-028892e17082@gmail.com> (raw)
In-Reply-To: <20210510152349.3de97b82@gandalf.local.home>
On 10.05.21 г. 22:23, Steven Rostedt wrote:
> On Mon, 10 May 2021 21:50:57 +0300
> Yordan Karadzhov <y.karadz@gmail.com> wrote:
>
>> On 10.05.21 г. 21:25, Steven Rostedt wrote:
>>> On Mon, 10 May 2021 14:53:08 +0300
>>> Yordan Karadzhov <y.karadz@gmail.com> wrote:
>>>
>>>>> Can you show me how you see this error, because this solution does not make
>>>>> any sense.
>>>>
>>>> The problem is that some plugins can build from multiple source files.
>>>> For example in the case when part of the plugin is written in C and
>>>> another part in C++. In those cases we cannot have the functions being
>>>> static.
>>>
>>> So it's because its a mixture of C and C++ code? And you can't make them
>>> static?
>>
>> No, this has no direct connection with C++. The static functions are the
>> same in C++.
>> It became an issue if you have multiple source files. If this is the
>> case you have to put the macro in a header file, so that you can use the
>> functions defined in the macro in all your source files. But this does
>> not work, because the macro defines some global variables as well. To
>> solve this I defined second macro to be used only in the header, but
>> then the functions can't be static.
>>
>
> Still does not make sense. Obviously, I'm missing something to connect the
> dots.
>
> Can you show me the error message that you are fixing.
It is not an error message. It is a malfunctioning. Say you have a macro
that looks like this:
#define KS_DEFINE_PLUGIN_CONTEXT(type) \
static type **__context_handler; \
static ssize_t __n_streams = -1; \
static inline type *__get_context(int sd) \
{ \
if (sd < 0 || sd >= __n_streams) \
return NULL; \
return __context_handler[sd]; \
}
\
and you want to use __get_context(int sd) in different source files.
If you just place the macro in a header, each source file will have its
own "static __context_handler" variable which is not what I would like.
So this is a malfunctioning.
I can solve this problem by having a second macro that only declares
"type *__get_context(int sd)" and place this macro in the header, while
keeping the original macro in one of the source files, but then
__get_context() cannot be static. If I go this way and I have multiple
plugins using the same macro I will have multiple versions of the same
function and this time the dynamic linking will start to misbehave.
Does that make sense?
Thanks!
Yordan
>
> Thanks,
>
> -- Steve
>
next prev parent reply other threads:[~2021-05-10 20:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-28 13:47 [PATCH v2 0/9] (Not so) Minor fixes toward KS 2.0 Yordan Karadzhov (VMware)
2021-04-28 13:47 ` [PATCH v2 1/9] kernel-shark: Fix the build for 32b systems Yordan Karadzhov (VMware)
2021-04-28 13:47 ` [PATCH v2 2/9] kernel-shark: Add "cron" job to workflows Yordan Karadzhov (VMware)
2021-04-28 13:47 ` [PATCH v2 3/9] kernel-shark: Fix KS_DEFINE_PLUGIN_CONTEXT macro Yordan Karadzhov (VMware)
2021-05-06 18:11 ` Steven Rostedt
2021-05-10 11:53 ` Yordan Karadzhov
2021-05-10 18:25 ` Steven Rostedt
2021-05-10 18:50 ` Yordan Karadzhov
2021-05-10 19:23 ` Steven Rostedt
2021-05-10 20:18 ` Yordan Karadzhov [this message]
2021-05-10 20:34 ` Yordan Karadzhov
2021-05-10 21:02 ` Steven Rostedt
2021-05-11 13:30 ` Yordan Karadzhov
2021-04-28 13:47 ` [PATCH v2 4/9] kernel-shark: Add cleanup of all plugin contexts Yordan Karadzhov (VMware)
2021-04-28 13:47 ` [PATCH v2 5/9] kernel-shark: Fix memory leak in "sched events" plugin Yordan Karadzhov (VMware)
2021-04-28 13:47 ` [PATCH v2 6/9] kernel-shark: Disable the pop-up offset dialog Yordan Karadzhov (VMware)
2021-04-28 13:47 ` [PATCH v2 7/9] kernel-shark: Remove kvm_combo from the list of default plugins Yordan Karadzhov (VMware)
2021-05-06 18:25 ` Steven Rostedt
2021-05-10 12:15 ` Yordan Karadzhov
2021-04-28 13:47 ` [PATCH v2 8/9] kernel-shark: Remove debugging print out from plugins Yordan Karadzhov (VMware)
2021-04-28 13:47 ` [PATCH v2 9/9] kernel-shark: Hide all plugin internals Yordan Karadzhov (VMware)
2021-05-06 18:26 ` [PATCH v2 0/9] (Not so) Minor fixes toward KS 2.0 Steven Rostedt
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=0dc10813-0fe9-2506-4c32-028892e17082@gmail.com \
--to=y.karadz@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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).