* problem with <asm/semaphore.h>
@ 2002-06-04 11:19 Hossein Mobahi
2002-06-04 11:44 ` Shanks
0 siblings, 1 reply; 7+ messages in thread
From: Hossein Mobahi @ 2002-06-04 11:19 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-c-programming
Hi
I compiled the following code with gcc under Redhat
7.2 :
#include <asm/semaphore.h>
main()
{
struct semaphore sum;
}
It doesn't compile, saying "storage size of `sem'
isn't known".
Please guide me how to fix it.
Sincerely
--Hossein Mobahi
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem with <asm/semaphore.h>
@ 2002-06-04 11:41 bonganilinux
2002-06-04 11:44 ` Thomas 'Dent' Mirlacher
0 siblings, 1 reply; 7+ messages in thread
From: bonganilinux @ 2002-06-04 11:41 UTC (permalink / raw)
To: Hossein Mobahi, linux-kernel, linux-c-programming
I think you a trying to include a file from the linux source
which will not work for use-space apps. Try using
#include <semaphore.h> instead
> Hi
>
> I compiled the following code with gcc under Redhat
> 7.2 :
>
> #include <asm/semaphore.h>
> main()
> {
> struct semaphore sum;
> }
>
> It doesn't compile, saying "storage size of `sem'
> isn't known".
> Please guide me how to fix it.
>
> Sincerely
>
> --Hossein Mobahi
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
---------------------------------------------
This message was sent using M-Web Airmail.
JUST LIKE THAT
Are you ready for 10-digit dialling on the 8th of May?
To find out how this will affect your Internet connection go to www.mweb.co.za/ten
http://airmail.mweb.co.za/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem with <asm/semaphore.h>
2002-06-04 11:19 Hossein Mobahi
@ 2002-06-04 11:44 ` Shanks
0 siblings, 0 replies; 7+ messages in thread
From: Shanks @ 2002-06-04 11:44 UTC (permalink / raw)
To: Hossein Mobahi, linux-kernel; +Cc: linux-c-programming
Hi Hossein,
If you look inside <asm/semaphore.h> you will see that
the definition of struct semaphore is within a
conditional #ifdef __KERNEL__
Hence __KERNEL__ needs to be defined for this code to
compile.
Try compiling like this
$> gcc -D__KERNEL__ file.c
Regards,
Shanks
--- Hossein Mobahi <hmobahi@yahoo.com> wrote:
> Hi
> I compiled the following code with gcc under Redhat
> 7.2 :
> #include <asm/semaphore.h>
> main()
> {
> struct semaphore sum;
> }
>
> It doesn't compile, saying "storage size of `sem'
> isn't known".
>
> Sincerely
> --Hossein Mobahi
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem with <asm/semaphore.h>
2002-06-04 11:41 bonganilinux
@ 2002-06-04 11:44 ` Thomas 'Dent' Mirlacher
0 siblings, 0 replies; 7+ messages in thread
From: Thomas 'Dent' Mirlacher @ 2002-06-04 11:44 UTC (permalink / raw)
To: bonganilinux; +Cc: Hossein Mobahi, linux-kernel, linux-c-programming
On Tue, 4 Jun 2002 bonganilinux@mweb.co.za wrote:
> I think you a trying to include a file from the linux source
> which will not work for use-space apps. Try using
> #include <semaphore.h> instead
yes, sounds right, since struct semaphore in asm/semaphore will be
defined only if __KERNEL__ is defined.
tm
--
in some way i do, and in some way i don't.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem with <asm/semaphore.h>
[not found] <1176885218.597268.304370@l77g2000hsb.googlegroups.com>
@ 2007-04-19 0:50 ` Robert Hancock
[not found] ` <fa.fBTtgscoj66JCf4bIm8v290vCRo@ifi.uio.no>
1 sibling, 0 replies; 7+ messages in thread
From: Robert Hancock @ 2007-04-19 0:50 UTC (permalink / raw)
To: liangbowen, linux-kernel
liangbowen wrote:
> Hi
>
> I compiled the following code with gcc under FC2 :
>
> #include <asm/semaphore.h>
> main()
> {
> struct semaphore sum;
>
> }
>
> It doesn't compile, saying "storage size of `sem'
> isn't known".
>
> and I looked inside asm/semaphore.h, I saw:
> #ifndef I386_SEMAPHORE_H
> #define I386_SEMAPHORE_H
>
> #include <linux/linkage.h>
>
> #endif
>
> Did I missed something? Please guide me how to fix it.
>
> Sincerely
You're trying to use a kernel data structure in a user-space program.
Don't. The definitions in that header are inside #ifdef __KERNEL__ and
so the provided userspace headers remove that part.
--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@nospamshaw.ca
Home Page: http://www.roberthancock.com/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem with <asm/semaphore.h>
[not found] ` <1176961482.904618.250700@e65g2000hsc.googlegroups.com>
@ 2007-04-19 14:26 ` Robert Hancock
0 siblings, 0 replies; 7+ messages in thread
From: Robert Hancock @ 2007-04-19 14:26 UTC (permalink / raw)
To: liangbowen, linux-kernel
liangbowen wrote:
>> You're trying to use a kernel data structure in a user-space program.
>> Don't. The definitions in that header are inside #ifdef __KERNEL__ and
>> so the provided userspace headers remove that part.
>
> someone've said the exact same thing, and he said that I can add the -
> D__KERNEL__ to the compilation options,
> but I can't see any #ifdef __KERNEL__ macro in that header(<asm/
> semaphore.h>).
> Is my header differ from yours?
>
It's because the userspace headers have been processed with unifdef to
remove any sections which are inside #ifdef __KERNEL__, since userspace
apps are not supposed to see those sections.
I'm not sure why you want to use a semaphore in a userspace program.
Even if you can get it to compile, they definitely won't function
properly. Aside from the legal issues (using internal kernel code like
that would make your program a derived work of the kernel and thus
covered under the GPL).
--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@nospamshaw.ca
Home Page: http://www.roberthancock.com/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem with <asm/semaphore.h>
[not found] ` <1177003071.879067.80590@n76g2000hsh.googlegroups.com>
@ 2007-04-21 22:57 ` Robert Hancock
0 siblings, 0 replies; 7+ messages in thread
From: Robert Hancock @ 2007-04-21 22:57 UTC (permalink / raw)
To: liangbowen, linux-kernel
liangbowen wrote:
> maybe you've misunderstood my meaning. I mean the whole <asm/
> semaphore.h> header file has only 4 lines of code in total:
> #ifndef I386_SEMAPHORE_H
> #define I386_SEMAPHORE_H
> #include <linux/linkage.h>
> #endif
>
> it's supposed to have more codes than that. like
> struct semaphore {
> int count;
> int waking;
> int lock ; /* to make waking testing atomic */
> struct wait_queue * wait;
> };
> and the down(), up() functions.
>
> but I can't see any of those codes, not even the #ifdef __KERNEL__
> macro.
>
It does in the kernel version of that header. The userspace version of
that header has everything inside #ifdef __KERNEL__ stripped out.
--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@nospamshaw.ca
Home Page: http://www.roberthancock.com/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-04-21 22:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1176885218.597268.304370@l77g2000hsb.googlegroups.com>
2007-04-19 0:50 ` problem with <asm/semaphore.h> Robert Hancock
[not found] ` <fa.fBTtgscoj66JCf4bIm8v290vCRo@ifi.uio.no>
[not found] ` <fa.w5cKcLCYzl2eiKiQW21MMlLALWM@ifi.uio.no>
[not found] ` <1176961482.904618.250700@e65g2000hsc.googlegroups.com>
2007-04-19 14:26 ` Robert Hancock
[not found] ` <fa.AvTW9UjANJ733AbQtnQmG3hvo7U@ifi.uio.no>
[not found] ` <fa.BgzkXXMJTw3V0hCHG6tJNpgDbkw@ifi.uio.no>
[not found] ` <fa.aUMayTTuQ16UFy6Q+LWR4hiTB1Q@ifi.uio.no>
[not found] ` <fa.633EuMGTHsDpCL9UutDSzsItJUQ@ifi.uio.no>
[not found] ` <1177003071.879067.80590@n76g2000hsh.googlegroups.com>
2007-04-21 22:57 ` Robert Hancock
2002-06-04 11:41 bonganilinux
2002-06-04 11:44 ` Thomas 'Dent' Mirlacher
-- strict thread matches above, loose matches on Subject: below --
2002-06-04 11:19 Hossein Mobahi
2002-06-04 11:44 ` Shanks
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox