PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.c > Re: C both slow and memory-hungry for embedded systems?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Re: C both slow and memory-hungry for embedded systems?

Réponse
 
LinkBack Outils de la discussion
Vieux 18/10/2007, 10h21   #1
Martin Wells
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: C both slow and memory-hungry for embedded systems?

Spiros:

> > Standarising C in such a way that int is at least 16-Bit, has this
> > made C both slow and memory-hungry for embedded systems programming?

>
> What's stopping you from using (unsigned) char on such systems ?



I write fully-portably in C89, paying no attention to the particulars
of the platform. If I was to start using char instead of int, I'd
introduce inefficiency on systems whose optimal int type is >= 16
bits.

I think a fair few embedded programmers are starting to use things
like int_fastest_at_least_8 which are defined in C99.

To be a fully-portable programmer both for PC's and for embedded
systems, should we start using these <stdint.h> types?

Martin

  Réponse avec citation
Vieux 18/10/2007, 10h40   #2
Richard Heathfield
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: C both slow and memory-hungry for embedded systems?

Martin Wells said:

<snip>

> I think a fair few embedded programmers are starting to use things
> like int_fastest_at_least_8 which are defined in C99.
>
> To be a fully-portable programmer both for PC's and for embedded
> systems, should we start using these <stdint.h> types?


Given the limited availability of conforming C99 implementations, a *fully*
portable program cannot assume the existence of <stdint.h> or the C99
types defined therein. So, at the very least, you should be prepared to
supply your own definitions of those types if you can (portably) determine
that they are not provided by the implementation.

Personally, I don't bother - I find the types in C90 to be perfectly
adequate to my needs - but it's something to consider if your view isn't
quite as... um... radical as mine.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
  Réponse avec citation
Vieux 18/10/2007, 12h23   #3
Spiros Bousbouras
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: C both slow and memory-hungry for embedded systems?

On Oct 18, 10:21 am, Martin Wells <war...@eircom.net> wrote:
> Spiros:
>
> > > Standarising C in such a way that int is at least 16-Bit, has this
> > > made C both slow and memory-hungry for embedded systems programming?

>
> > What's stopping you from using (unsigned) char on such systems ?

>
> I write fully-portably in C89, paying no attention to the particulars
> of the platform. If I was to start using char instead of int, I'd
> introduce inefficiency on systems whose optimal int type is >= 16
> bits.


Not necessarily. It is entirely possible that a compiler will
represent internally a char using whichever integer type is the
fastest in the platform.

> I think a fair few embedded programmers are starting to use things
> like int_fastest_at_least_8 which are defined in C99.
>
> To be a fully-portable programmer both for PC's and for embedded
> systems, should we start using these <stdint.h> types?


If you want to be fully portable *and* the fastest possible *and* pay
no attention to the particulars of the platform then I guess you
would have to use int_fast8_t. If on the other hand you are willing
to pay just a bit of attention to the particulars of the platform
then you could do something like
typedef char my_int_fast_8_t
and replace char in the line above by whatever type is the fastest
in each platform.


  Réponse avec citation
Vieux 18/10/2007, 12h45   #4
James Kuyper Jr.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: C both slow and memory-hungry for embedded systems?

Martin Wells wrote:
> Spiros:
>
>>> Standarising C in such a way that int is at least 16-Bit, has this
>>> made C both slow and memory-hungry for embedded systems programming?

>> What's stopping you from using (unsigned) char on such systems ?

>
>
> I write fully-portably in C89, paying no attention to the particulars
> of the platform. If I was to start using char instead of int, I'd
> introduce inefficiency on systems whose optimal int type is >= 16
> bits.
>
> I think a fair few embedded programmers are starting to use things
> like int_fastest_at_least_8 which are defined in C99.


Using int_fast8_t isn't sufficient; you also have to put the compiler
into a mode which is nonconforming either because it disables automatic
conversion to 'int' in the many contexts where that conversion is
required, or because 'int' is an 8 bit type.

The other problem, of course, is the number of C standard library
routines which take 'int' arguments and return 'int' values. However,
there's an easy workaround for that: create alternative functions that
take 8-bit arguments, where appropriate.
  Réponse avec citation
Vieux 18/10/2007, 14h18   #5
CBFalconer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: C both slow and memory-hungry for embedded systems?

Martin Wells wrote:
>

.... snip ...
>
> I think a fair few embedded programmers are starting to use things
> like int_fastest_at_least_8 which are defined in C99.
>
> To be a fully-portable programmer both for PC's and for embedded
> systems, should we start using these <stdint.h> types?


No. They (and we) should avoid them. They are not portable,
because they are not universally available (as are byte, int, long)
and are also a C99 construct. Note that even a C99 system will not
necessarily make those types available, because they are hardware
dependant.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>



--
Posted via a free Usenet account from http://www.teranews.com

  Réponse avec citation
Vieux 19/10/2007, 05h58   #6
Ben Pfaff
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: C both slow and memory-hungry for embedded systems?

CBFalconer <cbfalconer@yahoo.com> writes:

> Martin Wells wrote:
>>

> ... snip ...
>>
>> I think a fair few embedded programmers are starting to use things
>> like int_fastest_at_least_8 which are defined in C99.
>>
>> To be a fully-portable programmer both for PC's and for embedded
>> systems, should we start using these <stdint.h> types?

>
> No. They (and we) should avoid them. They are not portable,
> because they are not universally available (as are byte, int, long)
> and are also a C99 construct. Note that even a C99 system will not
> necessarily make those types available, because they are hardware
> dependant.


You must be reading a different C99 from me, because my copy says
this in 7.18.1:

3 The following types are required:
int_least8_t uint_least8_t
int_least16_t uint_least16_t
int_least32_t uint_least32_t
int_least64_t uint_least64_t
All other types of this form are optional.

...

3 The following types are required:
int_fast8_t uint_fast8_t
int_fast16_t uint_fast16_t
int_fast32_t uint_fast32_t
int_fast64_t uint_fast64_t

(It's the exact-width types that are optional.)
--
Go not to Usenet for counsel, for they will say both no and yes.
  Réponse avec citation
Vieux 19/10/2007, 07h11   #7
Keith Thompson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: C both slow and memory-hungry for embedded systems?

CBFalconer <cbfalconer@yahoo.com> writes:
> Martin Wells wrote:
> ... snip ...
>>
>> I think a fair few embedded programmers are starting to use things
>> like int_fastest_at_least_8 which are defined in C99.
>>
>> To be a fully-portable programmer both for PC's and for embedded
>> systems, should we start using these <stdint.h> types?

>
> No. They (and we) should avoid them. They are not portable,
> because they are not universally available (as are byte, int, long)
> and are also a C99 construct. Note that even a C99 system will not
> necessarily make those types available, because they are hardware
> dependant.


As Ben Pfaff points out, the 8-, 16-, 32-, and 64-bit "least" and
"fast" types are mandatory; only the exact-width types are optional.
And even though they weren't standardized until C99, they're not hard
to define in C90 (except perhaps for the 64-bit types). See for
example Doug Gywn's "q8" package (though I suppose the "fast" types
can't reliably be defined automatically).

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
  Réponse avec citation
Vieux 21/10/2007, 08h57   #8
Wade Ward
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: C both slow and memory-hungry for embedded systems?



"CBFalconer" <cbfalconer@yahoo.com> wrote in message
news:47175D25.B0E10F8C@yahoo.com...
> Martin Wells wrote:
>>

> ... snip ...
>>
>> I think a fair few embedded programmers are starting to use things
>> like int_fastest_at_least_8 which are defined in C99.
>>
>> To be a fully-portable programmer both for PC's and for embedded
>> systems, should we start using these <stdint.h> types?

>
> No. They (and we) should avoid them. They are not portable,
> because they are not universally available (as are byte, int, long)
> and are also a C99 construct. Note that even a C99 system will not
> necessarily make those types available, because they are hardware
> dependant.

Interpersonal normative statement => philosophically unintelligible.

> because they are hardware
> dependant.

As, usual, you err.
--
wade ward
wade@zaxfuuq.net
"Der Katze tritt die Treppe hoch; Der Kater tritt sie krumm.%
% De Teufel geit um; er bringt de menschen allet dumm."
schau, schau


  Réponse avec citation
Vieux 21/10/2007, 16h51   #9
Thad Smith
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: C both slow and memory-hungry for embedded systems?

James Kuyper Jr. wrote:
> Martin Wells wrote:


>> I think a fair few embedded programmers are starting to use things
>> like int_fastest_at_least_8 which are defined in C99.

>
> Using int_fast8_t isn't sufficient; you also have to put the compiler
> into a mode which is nonconforming either because it disables automatic
> conversion to 'int' in the many contexts where that conversion is
> required, or because 'int' is an 8 bit type.


A good compiler for 8-bit targets can optimize many expressions with
8-bit operands and still be conforming. Addition, multiplication, and,
or, exclusive or, and left shift operations can be combined with 8-bit
operands, ignoring upper bytes. A single subtraction, division, or
right shift on 8-bit operands can also be done. The upper byte DOES
need to be calculated when these operation are combined, such as a*b/c.

> The other problem, of course, is the number of C standard library
> routines which take 'int' arguments and return 'int' values.


True. Optimized library routines can test for values which fit within a
byte and use simper code. This is often done for the arithmetic er
routines.

--
Thad
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 14h31.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,21144 seconds with 17 queries