Robert P. J. Day | 7 Oct 2006 15:12
Picon

pointer indirection on the LHS of an assignment


  sort of a combination of a C and gcc question but what's the rules
these days on the following (ripped from the linux kernel source, from
asm/semaphore.h)?

===
static inline void sema_init (struct semaphore *sem, int val)
{
/*
 *      *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
 *
 * i'd rather use the more flexible initialization above, but sadly
 * GCC 2.7.2.3 emits a bogus warning. EGCS doesn't. Oh well.
 */
        atomic_set(&sem->count, val);
        sem->sleepers = 0;
        init_waitqueue_head(&sem->wait);
}
===

  i recall that earlier compilers complained about that first example
of pointer indirection as the target of an assignment.  is that legal
these days?

rday
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

(Continue reading)

Glynn Clements | 8 Oct 2006 00:53

Re: pointer indirection on the LHS of an assignment


Robert P. J. Day wrote:

>   sort of a combination of a C and gcc question but what's the rules
> these days on the following (ripped from the linux kernel source, from
> asm/semaphore.h)?
> 
> ===
> static inline void sema_init (struct semaphore *sem, int val)
> {
> /*
>  *      *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
>  *
>  * i'd rather use the more flexible initialization above, but sadly
>  * GCC 2.7.2.3 emits a bogus warning. EGCS doesn't. Oh well.
>  */
>         atomic_set(&sem->count, val);
>         sem->sleepers = 0;
>         init_waitqueue_head(&sem->wait);
> }
> ===
> 
>   i recall that earlier compilers complained about that first example
> of pointer indirection as the target of an assignment.  is that legal
> these days?

The problem with the first example is that the __SEMAPHORE_INITIALIZER
macro uses C99 features, which probably aren't supported in gcc 2.7.x.

The LHS has nothing to do with it.
(Continue reading)

Robert P. J. Day | 8 Oct 2006 08:53
Picon

Re: pointer indirection on the LHS of an assignment

On Sat, 7 Oct 2006, Glynn Clements wrote:

>
> Robert P. J. Day wrote:
>
> >   sort of a combination of a C and gcc question but what's the rules
> > these days on the following (ripped from the linux kernel source, from
> > asm/semaphore.h)?
> >
> > ===
> > static inline void sema_init (struct semaphore *sem, int val)
> > {
> > /*
> >  *      *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
> >  *
> >  * i'd rather use the more flexible initialization above, but sadly
> >  * GCC 2.7.2.3 emits a bogus warning. EGCS doesn't. Oh well.
> >  */
> >         atomic_set(&sem->count, val);
> >         sem->sleepers = 0;
> >         init_waitqueue_head(&sem->wait);
> > }
> > ===
> >
> >   i recall that earlier compilers complained about that first example
> > of pointer indirection as the target of an assignment.  is that legal
> > these days?
>
> The problem with the first example is that the
> __SEMAPHORE_INITIALIZER macro uses C99 features, which probably
(Continue reading)

Glynn Clements | 8 Oct 2006 14:17

Re: pointer indirection on the LHS of an assignment


Robert P. J. Day wrote:

> > The problem with the first example is that the
> > __SEMAPHORE_INITIALIZER macro uses C99 features, which probably
> > aren't supported in gcc 2.7.x.
> >
> > The LHS has nothing to do with it.
> 
> ah, sorry, i didn't look closely enough.  so if one could count on a
> C99-compilant compiler being available, then the first form would be
> perfectly acceptable?  thanks.

Yes.

--

-- 
Glynn Clements <glynn <at> gclements.plus.com>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Raseel Bhagat | 11 Oct 2006 08:04
Picon

Turning PC monitor on/off

Hi,
 I want to write a C code for toggling my PC monitor on/off in Linux.
Can some one point to any reading material or a hint or line of thought ?

--

-- 
Raseel.
http://www.opensourcedeal.com
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

ZeeGeek | 11 Oct 2006 09:05
Picon
Gravatar

Re: Turning PC monitor on/off

On 10/11/06, Raseel Bhagat <raseelbhagat <at> gmail.com> wrote:
> Hi,
>  I want to write a C code for toggling my PC monitor on/off in Linux.
> Can some one point to any reading material or a hint or line of thought ?

You need to look into the X library or whatever screensaver library
you are using.

>
> --
> Raseel.
> http://www.opensourcedeal.com
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo <at> vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

--

-- 
My blog: http://ihome.ust.hk/~cs_snx/blog/

Ning Shi
URH 0706 Oglesby Hall
1005 College Ct.
Urbana, IL 61801
(217) 332-5238
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
(Continue reading)

Henry Margies | 11 Oct 2006 10:11
Picon
Picon

Re: Turning PC monitor on/off

On Wed, 2006-10-11 at 11:34 +0530, Raseel Bhagat wrote:
> Hi,
>  I want to write a C code for toggling my PC monitor on/off in Linux.
> Can some one point to any reading material or a hint or line of thought ?
> 

Maybe it also helps to look at the sources of xset program  of X11.

xset dpms force off

Turns off the monitor (until you press a key or so).

Henry

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Raseel Bhagat | 11 Oct 2006 11:26
Picon

Re: Turning PC monitor on/off

Hi

On 10/11/06, Henry Margies <henry.margies <at> gmx.de> wrote:
> Maybe it also helps to look at the sources of xset program  of X11.
>
> xset dpms force off
>
> Turns off the monitor (until you press a key or so).

But what if I'm not on the X-window ?
As in, I'm running this program from console, or one of the virtual terminals ?

--

-- 
Raseel.
http://raseel.livejournal.com
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Per Jessen | 11 Oct 2006 12:02
Picon
Favicon

Re: Turning PC monitor on/off

Raseel Bhagat wrote:
> Hi
> 
> On 10/11/06, Henry Margies <henry.margies <at> gmx.de> wrote:
>> Maybe it also helps to look at the sources of xset program  of X11.
>>
>> xset dpms force off
>>
>> Turns off the monitor (until you press a key or so).
> 
> But what if I'm not on the X-window ?
> As in, I'm running this program from console, or one of the virtual 
> terminals ?

You said you wanted to look at the code and xset is probably a good 
example.  Whether it'll also work from the commandline with no active X 
system, that's for you to find out :-)

/Per Jessen, Zurich
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Markus Rechberger | 11 Oct 2006 12:20
Picon

Re: Turning PC monitor on/off

Hi,

first of all it might be useful how DPMS works,
http://webpages.charter.net/dperr/dpms.htm

Instead of using X you could try to use some kind of Vesa feature.
Maybe your bios has a revealed interface in Linux for that feature too

Markus

On 10/11/06, Per Jessen <per <at> computer.org> wrote:
> Raseel Bhagat wrote:
> > Hi
> >
> > On 10/11/06, Henry Margies <henry.margies <at> gmx.de> wrote:
> >> Maybe it also helps to look at the sources of xset program  of X11.
> >>
> >> xset dpms force off
> >>
> >> Turns off the monitor (until you press a key or so).
> >
> > But what if I'm not on the X-window ?
> > As in, I'm running this program from console, or one of the virtual
> > terminals ?
>
> You said you wanted to look at the code and xset is probably a good
> example.  Whether it'll also work from the commandline with no active X
> system, that's for you to find out :-)
>
>
(Continue reading)


Gmane