All of lore.kernel.org
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Introduce a global bool type
Date: Mon, 7 Jan 2013 16:50:52 -0600	[thread overview]
Message-ID: <1357599052.1113.14@snotra> (raw)
In-Reply-To: <20130107223942.94BED20DA7E@gemini.denx.de> (from wd@denx.de on Mon Jan  7 16:39:42 2013)

On 01/07/2013 04:39:42 PM, Wolfgang Denk wrote:
> Dear York Sun,
> 
> In message <1357596628-27501-1-git-send-email-yorksun@freescale.com>  
> you wrote:
> > 'bool' is defined in random places. This patch consolidates them  
> into a
> > single typedef.
> 
> Has this been actually compile tested?
> 
> ...
> > --- a/include/linux/types.h
> > +++ b/include/linux/types.h
> > @@ -113,6 +113,8 @@ typedef		__u64		u_int64_t;
> >  typedef		__s64		int64_t;
> >  #endif
> >
> > +typedef _Bool bool;
> 
> And what exactly would "_Bool" be?

It's a standard C99 type (as is bool, but _Bool comes directly from the  
compiler rather than from headers).

> ...
> > --- a/include/xyzModem.h
> > +++ b/include/xyzModem.h
> > @@ -97,11 +97,6 @@ typedef struct {
> >  #endif
> >  } connection_info_t;
> >
> > -#ifndef	BOOL_WAS_DEFINED
> > -#define BOOL_WAS_DEFINED
> > -typedef unsigned int bool;
> > -#endif
> > -
> >  #define false 0
> >  #define true 1
> 
> And don't these remaining definitions of "false" and "true" cause
> nasty build errors somewhere?

Yes, the definition of true/false needs to move along with the  
definition of bool.

> This seems broken to me.  Can we rather try8 and get rid of all this
> "bool" stuff instead?  It's just obfuscating the code...

That's obviously a matter of opinion (I think "bool" is clearer than  
"int"), but I'd like to point out that Linux's use of bool has been  
growing, and U-Boot often borrows code from Linux...

Also, FWIW the compiler will generally allocate only one byte for a  
built-in boolean, so there is a minor run-time benefit in some  
situations.

-Scott

  reply	other threads:[~2013-01-07 22:50 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-07 22:10 [U-Boot] [PATCH] Introduce a global bool type York Sun
2013-01-07 22:29 ` Scott Wood
2013-01-07 22:32 ` [U-Boot] [u-boot-release] " Timur Tabi
2013-01-07 22:39 ` [U-Boot] " Wolfgang Denk
2013-01-07 22:50   ` Scott Wood [this message]
2013-01-07 22:54   ` Måns Rullgård
2013-01-08  6:25     ` Wolfgang Denk
2013-01-08 16:51   ` Tabi Timur-B04825
2013-01-08 17:49     ` Wolfgang Denk
2013-01-08 17:53       ` Timur Tabi
2013-01-08 19:07         ` Wolfgang Denk
2013-01-08 19:09           ` Timur Tabi
2013-01-08 19:56           ` York Sun
2013-01-08 21:39             ` Wolfgang Denk
2013-01-08 21:43               ` York Sun
2013-01-08 21:46                 ` Scott Wood
2013-01-19  9:30           ` Albert ARIBAUD
2013-01-21 18:05             ` Scott Wood
2013-01-21 22:36               ` Måns Rullgård
2013-01-21 22:51                 ` Scott Wood
2013-01-21 23:08                   ` Måns Rullgård
2013-01-22  7:41                     ` Albert ARIBAUD
2013-01-22 12:59                       ` Måns Rullgård
2013-01-08 18:34       ` Bernhard Walle
2013-01-08 19:08         ` Wolfgang Denk

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=1357599052.1113.14@snotra \
    --to=scottwood@freescale.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.