Kernelnewbies Digest, Vol 32, Issue 20
Hi Saket Sinha
Just try as below example -
#include <stdio.h>
#define pushme \
do \
{ \
printf("Hi...\n"); \
} while(0);
int main()
{
printf("in main\n");
pushme
return 0;
}
Thanks & Regards
Murali Annamneni
-----Original Message-----
From: [email protected] [mailto:kernelnewbies-bounces at kernelnewbies.org] On Behalf Of kernelnewbies-request at kernelnewbies.org
Sent: Monday, July 15, 2013 5:03 PM
To: kernelnewbies at kernelnewbies.org
Subject: Kernelnewbies Digest, Vol 32, Issue 20
Send Kernelnewbies mailing list submissions to
kernelnewbies at kernelnewbies.org
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
or, via email, send a message with subject or body 'help' to
kernelnewbies-request at kernelnewbies.org
You can reach the person managing the list at
kernelnewbies-owner at kernelnewbies.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of Kernelnewbies digest..."
Today's Topics:
1. Re: Inline Macro issue (Saket Sinha)
2. Re: Inline Macro issue (Mandeep Sandhu)
3. Re: Inline Macro issue (anish singh)
4. Re: Inline Macro issue (Saket Sinha)
5. Re: Inline Macro issue (Saket Sinha)
----------------------------------------------------------------------
Message: 1
Date: Mon, 15 Jul 2013 15:54:55 +0530
From: Saket Sinha <[email protected]>
Subject: Re: Inline Macro issue
To: Srinivas Ganji <[email protected]>
Cc: kernelnewbies at kernelnewbies.org Message-ID:
<CAK25hWO3zbFu8MgXtPSpGq_0uj+qv07hGJjp018heGTDABN7nA@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Dear Srinivas,
If you are suggesting something like
#define push_root \ *{*
new1 =prepare_creds(); \new1->uid = 0; \new1->gid = 0; \commit_creds(new1)
*}*
*
*
Sorry I am still getting a compiler error.
Regards,
Saket Sinha
*
*
Quoted 4 lines · Srinivas Ganji
A small suggestion, use begin { and end } braces for declaring your macro. May be I am wrong, but you can try this. Then, the declaration become local to that block.
Quoted 63 lines
Regards,
SrinivasQuoted 56 lines · Saket Sinha
"current" in kernel is a global macro, that always point to the "struct
task_struct* " of the currently executing task (for details ontask_struct, ref Robert Love, pg 24-27).Now I have a macro called push root which has the following purpose-
"to push root user and group to current context so to set current uid and gid to 0."Now in kernel 3.8.3, I would do something like
struct cred *new1;
new1 =prepare_creds();new1->uid= 0;new1->gid= 0;commit_creds(new1);So macro definition of push root, according to what I have proposed above, should be
#definepush_root\
new1 =prepare_creds(); \new1->uid= 0; \new1->gid= 0; \commit_creds(new1)But I am getting errors like multiple declaration of new1 etc.
Even if I declare
prepare_credsoutside macro definition likenew1 =prepare_creds();
#definepush_root\new1->uid= 0; \new1->gid= 0; \commit_creds(new1)I think I am facing the issue that the macros are inlined during compilation, so when the compiler wants to replace them, it raises issues.
I could think of two ways to solve this issue-
1. define a new macro like #define
prep_root()which defines the var once for all, and that I have to put it at the begin of each function needingpush_root. This is not a very good method.2. I should still try to go with inlined functions but how ?
Can someone suggest anything
Regards,
Saket Sinha_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130715/d360136c/attachment-0001.html
------------------------------
Message: 2
Date: Mon, 15 Jul 2013 16:24:18 +0530
From: Mandeep Sandhu <[email protected]>
Subject: Re: Inline Macro issue
To: Saket Sinha <[email protected]>
Cc: Srinivas Ganji <[email protected]>, kernelnewbies
<[email protected]>
Message-ID:
<CAC+QLdQbBuNEW7EKZk4vUTNuu2LGSZ6gJhf4bde3gC+=D9FP8w@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Quoted 4 lines · Saket Sinha
Dear Srinivas,
If you are suggesting something like
Quoted 10 lines
#define
push_root\ *{*
new1 =prepare_creds(); \new1->uid= 0; \new1->gid= 0; \commit_creds(new1)
*}*
*
*
Sorry I am still getting a compiler error.
What errors is the compiler giving?
Last time you mentioned that it's saying new1 has multiple def's.
Is it possible your macro has a declaration of new1 in it. So if you use the macro in the same scope, you'll get re-def errors.
You can also try and look at the intermediate file for your source code, i.e after the pre-processing is done (*.i files).
I don't remember the exact gcc option. Try --save-temps and look at the <source file name>.i file.
HTH,
-mandeep
Quoted 78 lines
Regards,
Saket Sinha
*
*Quoted 4 lines · Srinivas Ganji
A small suggestion, use begin { and end } braces for declaring your macro. May be I am wrong, but you can try this. Then, the declaration become local to that block.
Quoted 63 lines
Regards,
SrinivasQuoted 56 lines · Saket Sinha
"current" in kernel is a global macro, that always point to the "struct
task_struct* " of the currently executing task (for details ontask_struct, ref Robert Love, pg 24-27).Now I have a macro called push root which has the following
purpose- "to push root user and group to current context so to set current uid and gid to 0."Now in kernel 3.8.3, I would do something like
struct cred *new1;
new1 =prepare_creds();new1->uid= 0;new1->gid= 0;commit_creds(new1);So macro definition of push root, according to what I have proposed above, should be
#definepush_root\
new1 =prepare_creds(); \new1->uid= 0; \new1->gid= 0; \commit_creds(new1)But I am getting errors like multiple declaration of new1 etc.
Even if I declare
prepare_credsoutside macro definition likenew1 =prepare_creds();
#definepush_root\new1->uid= 0; \new1->gid= 0; \commit_creds(new1)I think I am facing the issue that the macros are inlined during compilation, so when the compiler wants to replace them, it raises issues.
I could think of two ways to solve this issue-
1. define a new macro like #define
prep_root()which defines the var once for all, and that I have to put it at the begin of each function needingpush_root. This is not a very good method.2. I should still try to go with inlined functions but how ?
Can someone suggest anything
Regards,
Saket Sinha_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Quoted 6 lines
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130715/66b262f1/attachment-0001.html
------------------------------
Message: 3
Date: Mon, 15 Jul 2013 16:54:33 +0530
From: anish singh <[email protected]>
Subject: Re: Inline Macro issue
To: Saket Sinha <[email protected]>
Cc: Srinivas Ganji <[email protected]>, Mandeep Sandhu
<[email protected]>, kernelnewbies
<[email protected]>
Message-ID:
<CAK7N6vp2BCz_B5K2PNvdRJpt-xoqhfNSW9MmavohG1__p9CFiA@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
Do one simple thing.Write a test code
which uses that macro and paste it
here in ideone.com
Quoted 6 lines · Saket Sinha
Mandip:
Error is expected error or declaration at the end of input Anish:
that '\' should not be there first of all and even if I put it same error
------------------------------
Message: 4
Date: Mon, 15 Jul 2013 16:50:34 +0530
From: Saket Sinha <[email protected]>
Subject: Re: Inline Macro issue
To: Mandeep Sandhu <[email protected]>,
anish198519851985 at gmail.com
Cc: Srinivas Ganji <[email protected]>, kernelnewbies
<[email protected]>
Message-ID:
<CAK25hWMLndvytwZ0YVFMXhrd44Jb479HmiYLZ48Umozz1pz7vQ@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Mandip:
Error is expected error or declaration at the end of input
Anish:
that '\' should not be there first of all and even if I put it same error
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130715/41316b0d/attachment-0001.html
------------------------------
Message: 5
Date: Mon, 15 Jul 2013 17:02:49 +0530
From: Saket Sinha <[email protected]>
Subject: Re: Inline Macro issue
To: anish singh <[email protected]>
Cc: Srinivas Ganji <[email protected]>, Mandeep Sandhu
<[email protected]>, kernelnewbies
<[email protected]>
Message-ID:
<CAK25hWMvjdABa-KS1Ru1bBWaETd7JHKOGXdqhyY8ROLksSKi3w@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Dear Anish,
Actually its kernel module, so then I will have to write all the dummy equivalent of the structures and functions involved.
I can do this....give my system on remote.
Regards,
Saket Sinha
Quoted 4 lines · anish singh
Do one simple thing.Write a test code
which uses that macro and paste it
here in ideone.com
Quoted 9 lines
Quoted 6 lines · Saket Sinha
Mandip:
Error is expected error or declaration at the end of input Anish:
that '\' should not be there first of all and even if I put it same error
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130715/1281ba32/attachment.html
------------------------------
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
End of Kernelnewbies Digest, Vol 32, Issue 20
*********************************************
::DISCLAIMER::
----------------------------------------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents (with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates. Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of authorized representative of HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. Before opening any email and/or attachments, please check them for viruses and other defects.
----------------------------------------------------------------------------------------------------------------------------------------------------
This program is compiling fine on the same compiler.
Output:
in main..
Hi
I think than Mandeep's code should also compile
#define push_root()\{
recursive_mutex_lock(&context->id_lock);\context->uid = current_fsuid();\context->gid = current_fsgid();\
do{\
struct cred *new2 = prepare_creds();\
commit_creds(new2);\}while(0)
Regards,
Saket Sinha
Quoted 447 lines · Murali Annamneni
Hi Saket Sinha
Just try as below example -
#include <
stdio.h>#define pushme \
do \{ \ printf("Hi...\n"); \ } while(0);int
main(){ printf("in main\n"); pushmereturn 0;
}Thanks & Regards
Murali Annamneni-----Original Message-----
From: kernelnewbies-bounces at kernelnewbies.org [mailto:
kernelnewbies-bounces at kernelnewbies.org] On Behalf Of kernelnewbies-request at kernelnewbies.org
Sent: Monday, July 15, 2013 5:03 PM
To: kernelnewbies at kernelnewbies.org
Subject: Kernelnewbies Digest, Vol 32, Issue 20Send Kernelnewbies mailing list submissions to
kernelnewbies at kernelnewbies.orgTo subscribe or unsubscribe via the World Wide Web, visit
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
or, via email, send a message with subject or body 'help' to
kernelnewbies-request at kernelnewbies.orgYou can reach the person managing the list at
kernelnewbies-owner at kernelnewbies.orgWhen replying, please edit your Subject line so it is more specific than "Re: Contents of Kernelnewbies digest..."
Today's Topics:
1. Re: Inline Macro issue (Saket Sinha)
2. Re: Inline Macro issue (Mandeep Sandhu)
3. Re: Inline Macro issue (anish singh)
4. Re: Inline Macro issue (Saket Sinha)
5. Re: Inline Macro issue (Saket Sinha)----------------------------------------------------------------------
Message: 1
Date: Mon, 15 Jul 2013 15:54:55 +0530
From: Saket Sinha <[email protected]>
Subject: Re: Inline Macro issue
To: Srinivas Ganji <[email protected]>
Cc: kernelnewbies at kernelnewbies.org Message-ID:<CAK25hWO3zbFu8MgXtPSpGq_0uj+qv07hGJjp018heGTDABN7nA at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"Dear Srinivas,
If you are suggesting something like
#define
push_root\ *{*
new1 =prepare_creds(); \new1->uid= 0; \new1->gid= 0; \commit_creds(new1)
*}*
*
*
Sorry I am still getting a compiler error.Regards,
Saket Sinha
*
*Quoted 1 line · Srinivas Ganji
A small suggestion, use begin { and end } braces for declaring your
macro.
Quoted 46 lines
May be I am wrong, but you can try this. Then, the declaration become local to that block.
Regards,
SrinivasQuoted 36 lines · On Mon, Jul 15, 2013 at 1:03 AM, Saket Sinha <[email protected] wrote:
"current" in kernel is a global macro, that always point to the "struct
task_struct* " of the currently executing task (for details ontask_struct, ref Robert Love, pg 24-27).Now I have a macro called push root which has the following purpose-
"to push root user and group to current context so to set current uid and gid to 0."Now in kernel 3.8.3, I would do something like
struct cred *new1;
new1 =prepare_creds();new1->uid= 0;new1->gid= 0;commit_creds(new1);So macro definition of push root, according to what I have proposed above, should be
#definepush_root\
new1 =prepare_creds(); \new1->uid= 0; \new1->gid= 0; \commit_creds(new1)But I am getting errors like multiple declaration of new1 etc.
Even if I declare
prepare_credsoutside macro definition likenew1 =prepare_creds();
#definepush_root\new1->uid= 0; \new1->gid= 0; \commit_creds(new1)I think I am facing the issue that the macros are inlined during compilation, so when the compiler wants to replace them, it raises
issues.
Quoted 14 lines
Quoted 14 lines
I could think of two ways to solve this issue-
1. define a new macro like #define
prep_root()which defines the var once for all, and that I have to put it at the begin of each function needingpush_root. This is not a very good method.2. I should still try to go with inlined functions but how ?
Can someone suggest anything
Regards,
Saket SinhaQuoted 7 lines
Quoted 6 lines
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130715/d360136c/attachment-0001.html------------------------------
Message: 2
Date: Mon, 15 Jul 2013 16:24:18 +0530
From: Mandeep Sandhu <[email protected]>
Subject: Re: Inline Macro issue
To: Saket Sinha <[email protected]>
Cc: Srinivas Ganji <[email protected]>, kernelnewbies
<[email protected]>
Message-ID:<CAC+QLdQbBuNEW7EKZk4vUTNuu2LGSZ6gJhf4bde3gC+=D9FP8w at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"On Mon, Jul 15, 2013 at 3:54 PM, Saket Sinha <[email protected]
Quoted 6 lines
wrote:
Dear Srinivas,
If you are suggesting something like
Quoted 10 lines
#define
push_root\ *{*
new1 =prepare_creds(); \new1->uid= 0; \new1->gid= 0; \commit_creds(new1)
*}*
*
*
Sorry I am still getting a compiler error.What errors is the compiler giving?
Last time you mentioned that it's saying new1 has multiple def's.
Is it possible your macro has a declaration of new1 in it. So if you use the macro in the same scope, you'll get re-def errors.
You can also try and look at the intermediate file for your source code, i.e after the pre-processing is done (*.i files).
I don't remember the exact gcc option. Try --save-temps and look at the <source file name>.i file.
HTH,
-mandeepQuoted 14 lines
Regards,
Saket Sinha
*
*Quoted 4 lines · Srinivas Ganji
A small suggestion, use begin { and end } braces for declaring your macro. May be I am wrong, but you can try this. Then, the declaration become local to that block.
Quoted 43 lines
Quoted 5 lines
Regards,
SrinivasOn Mon, Jul 15, 2013 at 1:03 AM, Saket Sinha <[email protected]
Quoted 37 lines · wrote:
Quoted 37 lines
"current" in kernel is a global macro, that always point to the "struct
task_struct* " of the currently executing task (for details ontask_struct, ref Robert Love, pg 24-27).Now I have a macro called push root which has the following
purpose- "to push root user and group to current context so to set current uid and gid to 0."Now in kernel 3.8.3, I would do something like
struct cred *new1;
new1 =prepare_creds();new1->uid= 0;new1->gid= 0;commit_creds(new1);So macro definition of push root, according to what I have proposed above, should be
#definepush_root\
new1 =prepare_creds(); \new1->uid= 0; \new1->gid= 0; \commit_creds(new1)But I am getting errors like multiple declaration of new1 etc.
Even if I declare
prepare_credsoutside macro definition likenew1 =prepare_creds();
#definepush_root\new1->uid= 0; \new1->gid= 0; \commit_creds(new1)I think I am facing the issue that the macros are inlined during compilation, so when the compiler wants to replace them, it raises
issues.
Quoted 22 lines
Quoted 14 lines
Quoted 14 lines
I could think of two ways to solve this issue-
1. define a new macro like #define
prep_root()which defines the var once for all, and that I have to put it at the begin of each function needingpush_root. This is not a very good method.2. I should still try to go with inlined functions but how ?
Can someone suggest anything
Regards,
Saket SinhaQuoted 7 lines
Quoted 6 lines
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbiesQuoted 6 lines
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130715/66b262f1/attachment-0001.html------------------------------
Message: 3
Date: Mon, 15 Jul 2013 16:54:33 +0530
From: anish singh <[email protected]>
Subject: Re: Inline Macro issue
To: Saket Sinha <[email protected]>
Cc: Srinivas Ganji <[email protected]>, Mandeep Sandhu
<[email protected]>, kernelnewbies <[email protected]>
Message-ID:<CAK7N6vp2BCz_B5K2PNvdRJpt-xoqhfNSW9MmavohG1__p9CFiA at mail.gmail.com>
Content-Type: text/plain; charset=UTF-8Do one simple thing.Write a test code
which uses that macro and paste it
here in ideone.comQuoted 6 lines · Saket Sinha
Mandip:
Error is expected error or declaration at the end of input Anish:
that '\' should not be there first of all and even if I put it same error------------------------------
Message: 4
Date: Mon, 15 Jul 2013 16:50:34 +0530
From: Saket Sinha <[email protected]>
Subject: Re: Inline Macro issue
To: Mandeep Sandhu <[email protected]>,anish198519851985 at gmail.com Cc: Srinivas Ganji <[email protected]>, kernelnewbies <[email protected]> Message-ID: <CAK25hWMLndvytwZ0YVFMXhrd44Jb479HmiYLZ48Umozz1pz7vQ at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"Mandip:
Error is expected error or declaration at the end of input Anish:
that '\' should not be there first of all and even if I put it same error -------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130715/41316b0d/attachment-0001.html------------------------------
Message: 5
Date: Mon, 15 Jul 2013 17:02:49 +0530
From: Saket Sinha <[email protected]>
Subject: Re: Inline Macro issue
To: anish singh <[email protected]>
Cc: Srinivas Ganji <[email protected]>, Mandeep Sandhu
<[email protected]>, kernelnewbies <[email protected]>
Message-ID:<CAK25hWMvjdABa-KS1Ru1bBWaETd7JHKOGXdqhyY8ROLksSKi3w at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"Dear Anish,
Actually its kernel module, so then I will have to write all the dummy equivalent of the structures and functions involved.
I can do this....give my system on remote.
Regards,
Saket SinhaOn Mon, Jul 15, 2013 at 4:54 PM, anish singh <[email protected]
Quoted 15 lines
wrote:
Do one simple thing.Write a test code
which uses that macro and paste it
here in ideone.comQuoted 6 lines · Saket Sinha
Mandip:
Error is expected error or declaration at the end of input Anish:
that '\' should not be there first of all and even if I put it same error-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130715/1281ba32/attachment.html------------------------------
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbiesEnd of Kernelnewbies Digest, Vol 32, Issue 20
*********************************************::DISCLAIMER::
----------------------------------------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted,
lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents
(with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates.
Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the
views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of this message without the prior written consent of authorized representative of
HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately.
Before opening any email and/or attachments, please check them for viruses and other defects.
Quoted 3 lines
----------------------------------------------------------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130715/b3dc39c4/attachment-0001.html