Linux-Development-Sys Digest #843, Volume #7     Wed, 10 May 00 18:13:18 EDT

Contents:
  Re: Determining amount of physical RAM from a driver? (Timur Tabi)
  <!-- To use a different cobrand, make sure you have a template for it in 
/parts/cobrand/ --> (ytnplHOo)
  Re: Two really easy (I'm sure) questions (Joe Pfeiffer)
  CD-R Packet writing (Chris J/#6)
  Re: Determining amount of physical RAM from a driver? (Timur Tabi)
  Re: Two really easy (I'm sure) questions (Erik Max Francis)
  Re: Two really easy (I'm sure) questions (Kaz Kylheku)

----------------------------------------------------------------------------

From: Timur Tabi <[EMAIL PROTECTED]>
Subject: Re: Determining amount of physical RAM from a driver?
Date: Wed, 10 May 2000 21:01:26 GMT

In article <TNiS4.1554$[EMAIL PROTECTED]>,
  "Norm Dresner" <[EMAIL PROTECTED]> wrote:
> If you can install the driver with a script file, you can get exactly
that
> information (and lots more, too) by "reading" /proc/meminfo and
having your
> script pass the value(s) you need as a parameter.

What happens if the user installs or removes memory after the driver is
installed?

--
Timur Tabi
Interactive Silicon - http://www.interactivesi.com
Remove "nospam_" from my email address when replying


Sent via Deja.com http://www.deja.com/
Before you buy.

------------------------------

From: ytnplHOo <[EMAIL PROTECTED]>
Subject: <!-- To use a different cobrand, make sure you have a template for it in 
/parts/cobrand/ -->
Date: 10 May 2000 08:25:41 GMT







<!-- Get Specific Variables for cobrand -->
<!-- YESs and NOs are CaSe SeNsItIvE... Always use ALL CAPS for them! -->

    

   


<!-- EXTRA_CODE_AFTER_TOP/BOTTOM are typically used for consistent
         identification or used for "floating" nav bars. If you say YES
         make sure you hare corresponding code in /parts/cobrand/ -->



<!-- What Modules to use --->







    










<HTML>
<HEAD>

<TITLE>XOOM.it Servizi Iscritti: </TITLE>
<META name="resource-type" content=document>
<META name="description" content="XOOM.COM Get your web space free! Get Chat! See 
Movies! Cool Stuff all for Free!">
<META name="keywords" content="XOOM FREE CHAT WEB SPACE MOVIES EMAIL WEB CLIP ART HTML 
CLIPART CARDS DOWNLOADS">
<META name=distribution content=global>
</HEAD>

<BODY BGCOLOR="#FFFFFF" BACKGROUND="http://media.xoom.it/new/Background.gif" 
TEXT="#000000" LINK="#0000FF" VLINK="#0000FF" ALINK="#FF0000">

<!-- Top Part Table -->


<TABLE border=0 cellPadding=0 cellSpacing=0 width=600>
  <TBODY>
  <TR>
    <TD background="http://media.xoom.it/new/Left_Background.gif" vAlign=top wid
th=111>
        <A href="http://www.xoom.it">
        <IMG border=0 height=113 hspace=0 
src="http://media.xoom.it/new/logo_corner.gif" width=111>
        </A>
      <TABLE background="http://media.xoom.it/new/spacer.gif" border=0 cellPaddi
ng=0 cellSpacing=0 width=111>
        <TBODY>
        <TR>
          <TD align=middle vAlign=top>

<!--- inizio HOTSPOT --->

<IMG height=1 hspace=0 src="http://media.xoom.it/new/clear.gif" width=90><BR><IMG 
height=25 hspace=0 src="http://media.xoom.it/new/hot_spots_top.gif" width=90><BR>

<!-- Hotspot 1 -->
<A href="http://www.xoom.it/cgi-bin/redir.cgi?url=http://www.xoom.it/downloads" 
target=_top>
<IMG alt="Software Download" border=0 height=27 
src="http://media.xoom.it/hotspots/hs_shareit.gif" width=90></A><BR>

<!-- Hotspot 2 -->
<A href="http://www.xoom.it/cgi-bin/redir.cgi?url=http://www.risateonline.it&title=hs" 
target=_top>
<IMG alt="Barzellette via email" border=0 height=27 
src="http://media.xoom.it/hotspots/hs_barzelletta.gif" width=90></A><BR>

<!-- Hotspot 3 -->
<A href="http://www.xoom.it/chat" target=_top>
<IMG alt="Preleva la tua Chat" border=0 height=27 
src="http://media.xoom.it/hotspots/hs_chat.gif" width=90></A><BR>

<!-- Hotspot 4 -->
<A 
href="http://www.xoom.it/cgi-bin/redir.cgi?url=http://www.namesecure.com/partners/xoom/it/&title=hs"
 target=_top>
<IMG alt="Registra il tuo dominio" border=0 height=27 
src="http://media.xoom.it/hotspots/hs_namesecure2.gif" width=90></A><BR>


<IMG height=1 hspace=0 src="http://media.xoom.it/new/hot_spots_bottom.gif" 
width=90><BR><IMG height=10 src="http://media.xoom.it/new/spacer.gif" width=90><BR>

<!--- fine HOTSPOT --->


<!-- *** HOTSPOT *** -->
<!--< include ("/usr/WWW/parts/hotspot.html");>-->


<!---- inizio RISORSE ---->
<br>
<IMG alt="" border=0 height=161 hspace=0 src="http://media.xoom.it/new/resources5.gif" 
useMap=#RESOURCES width=90>
<MAP name=RESOURCES>
<AREA alt="" coords=1,17,88,32 
href="http://www.xoom.it/cgi-bin/redir.cgi?url=http://www.xoom.it/dizionario&title=ris"
 shape=RECT>
<AREA alt="" coords=1,34,88,48 href="http://www.xoom.it/chatroom/xoom" shape=RECT>
<AREA alt="" coords=2,50,88,65 href="/products/boutique.php" shape=RECT>
<AREA alt="" coords=2,66,88,80 
href="http://www.xoom.it/cgi-bin/redir.cgi?url=http://www.tariffe.it/xoom" shape=RECT>
<AREA alt="" coords=2,82,88,95 
href="http://www.xoom.it/cgi-bin/redir.cgi?url=http://cartoline.xoom.it/xigo" 
shape=RECT>
<AREA alt="" coords=2,97,88,111 
href="http://www.xoom.it/cgi-bin/redir.cgi?url=http://www.webcast.it&title=ris" 
shape=RECT>
<AREA alt="" coords=2,113,88,126 
href="http://www.xoom.it/cgi-bin/redir.cgi?url=http://www.tuttogratis.com/cgi/entra.cgi&title=ris"
 shape=RECT>
<AREA alt="" coords=2,129,88,141 
href="http://www.xoom.it/cgi-bin/redir.cgi?url=http://sharehouse.xoom.it&title=ris" 
shape=RECT>
<AREA alt="" coords=2,145,88,157 
href="http://www.xoom.it/cgi-bin/redir.cgi?url=http://www.qxl.com/cgi-bin/qxlhome.cgi/IT/xoom&title=ris1"
 shape=RECT>
</MAP>


<!--- fine RISORSE --->

<!---- inizio RISORSE ---->
<br><br>
                        <IMG alt="" border=0
            hspace=0 src="http://media.xoom.it/services/altriservizi.gif"
            useMap=#altrimap width=90> <MAP name=altrimap><AREA alt=""
              coords=1,17,88,32
              href="http://www.xoom.it/clipart"
              shape=RECT><AREA alt="" coords=1,34,88,48
              href="http://www.xoom.it/downloads"
              shape=RECT>
            </MAP>
<!--- fine RISORSE --->



</TD></TR></TBODY></TABLE></TD>

        <TD vAlign=top width=489>
        <!--- inizio LATO DESTRO --->      <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 
WIDTH=489><TR>
<TD HEIGHT=2 BGCOLOR=#000000 COLSPAN=2 WIDTH=489><SPACER TYPE="BLOCK" WIDTH=1 HE
IGHT=2></TD></TR>
</TABLE>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=489 bgcolor=#ffcc99><TR>
<!-- Inizio banner -->
<STYLE TYPE=text/css>
<!--
xoom8 {font-family:Verdana,Tresbuchet MS,Helvetica,Arial; font-size:7pt;}
xoom9 {font-family:Verdana,Tresbuchet MS,Helvetica,Arial; font-size:8pt;}
xoom10 {font-family:Verdana,Tresbuchet MS,Helvetica,Arial; font-size:8pt;}
xoom12 {font-family:Verdana,Tresbuchet MS,Helvetica,Arial; font-size:10pt; }
xoom14 {font-family:Verdana,Tresbuchet MS,Helvetica,Arial; font-size:12pt; }
xoom16 {font-family:Verdana,Tresbuchet MS,Helvetica,Arial; font-size:14pt; }
xoomhead {font-family:Verdana,Tresbuchet MS,Helvetica,Arial; font-size:14pt; 
font-weight:bold; }
xoomcomhead {font-family:Verdana,Tresbuchet MS,Helvetica,Arial; font-size:10pt; 
font-weight:bold;}
xoomcomsubhead {font-family:Verdana,Tresbuchet MS,Helvetica,Arial; font-size:9pt; 
margin-left:4pt; }
-->
</STYLE>


<TD bgcolor=#FFCC66 align=center WIDTH=487>

<table border=0><tr><td height=4 nowrap>
</td></tr></table>

<IFRAME 
SRC="http://ad.it.doubleclick.net/adi/xoom.it/membersarea;area=membersarea;sz=468x60;ord=2534?"
 WIDTH=468 HEIGHT=60 MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 
SCROLLING=no BORDERCOLOR="#FFCC66">
<SCRIPT language="JavaScript1.1" 
SRC="http://ad.it.doubleclick.net/adj/xoom.it/membersarea;area=membersarea;abr=!ie;sz=468x60;ord=2534?">
</SCRIPT>
<NOSCRIPT>
<A 
HREF="http://ad.it.doubleclick.net/jump/xoom.it/membersarea;area=membersarea;abr=!ie4;abr=!ie5;sz=468x60;ord=2534?">
<IMG 
SRC="http://ad.it.doubleclick.net/ad/xoom.it/membersarea;area=membersarea;abr=!ie4;abr=!ie5;sz=468x60;ord=2534?"
 BORDER=0 WIDTH=468 HEIGHT=60>
</A>
</NOSCRIPT>
</IFRAME>


<CENTER><IMG SRC="http://media.xoom.it/NovLook/spacer.gif" HEIGHT=3 WIDTH=468><BR>
<IMG SRC="http://media.xoom.it/blackline.gif" HEIGHT=1 WIDTH=468><BR>
    
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
                <TR>
                        <TD COLSPAN=4><IMG SRC="http://media.xoom.it/new/clear.gif" 
WIDTH="487" HEIGHT="4" HSPACE="0" VSPACE="0"><BR></TD>
                </TR>

                <TR>

<!-- Tastino 1 -->
<TD VALIGN=TOP ALIGN=MIDDLE WIDTH=25%><A 
HREF="http://www.xoom.it/cgi-bin/redir.cgi?url=http://www.italianetwork.it" 
TARGET=_top><IMG SRC="http://media.xoom.it/bottoni/rin_nero.gif" BORDER=1 WIDTH=88 
HEIGHT=31></A><BR>
<FONT FACE="Verdana,Arial,HELVETICA" SIZE=1><SPAN CLASS=X9><B>NET 
RADIO</B></SPAN></FONT></TD>

<!-- Tastino 3 -->
<TD VALIGN=TOP ALIGN=MIDDLE WIDTH=25%><A HREF="http://www.webcast.it/newsmp3.php3" 
TARGET=_top><IMG SRC="http://media.xoom.it/bottoni/wc_mp3news_88x31.gif" BORDER=1 
WIDTH=88 HEIGHT=31></A><BR>
<FONT FACE="Verdana,Arial,HELVETICA" SIZE=1><SPAN CLASS=X9><B>NOVITA' via 
E-MAIL</B></SPAN></FONT></TD>

<!-- Tastino 2 -->
<TD VALIGN=TOP ALIGN=MIDDLE WIDTH=25%><A 
HREF="http://www.xoom.it/cgi-bin/redir.cgi?url=http://www.xoom.it/premiowww.php" 
TARGET=_top><IMG SRC="http://media.xoom.it/bottoni/www_88x31a.gif" BORDER=1 WIDTH=88 
HEIGHT=31></A><BR>
<FONT FACE="Verdana,Arial,HELVETICA" SIZE=1><SPAN CLASS=X9><B>PREMIO 
WWW</B></SPAN></FONT></TD>

<!-- Tastino 4 -->
<TD VALIGN=TOP ALIGN=MIDDLE WIDTH=25%><A 
HREF="http://www.xoom.it/cgi-bin/redir.cgi?url=http://fgs.vittoria.net&title=but" 
TARGET=_top><IMG SRC="http://media.xoom.it/bottoni/fgs_88x31.gif" BORDER=1 WIDTH=88 
HEIGHT=31></A><BR>
<FONT FACE="Verdana,Arial,HELVETICA" SIZE=1><SPAN CLASS=X9><B>SICURI al 
VOLANTE</B></SPAN></FONT></TD>

                </TR>
                </TABLE>




<!-- fine banner -->
</TD>

        <TD BGCOLOR=#000000><SPACER TYPE="BLOCK" WIDTH=2 HEIGHT=2></TD>
</TR>

<TR>
        <TD HEIGHT=2 BGCOLOR=#000000 COLSPAN=2><SPACER TYPE="BLOCK" WIDTH=1 
HEIGHT=2></TD>
</TR>
</TABLE>



<TABLE CELLPADDING=10 BORDER=0> <!-- Inside Table START   Only here for padding -->
<TR><TD>
<IMG SRC="http://media.xoom.it/images/headers/Ooops.gif" ALT="( Ooops! )" WIDTH="450" 
HEIGHT="48"><P>

<FONT SIZE=+2>
La pagina a cui stai cercando di accedere non pu� essere trovata!<P></FONT>

Cause possibili:<P>

<UL>
<LI TYPE="circ">La pagina � momentaneamente offline per allestimento. Controlla 
l'homepage di XOOM.it per il sistema status/alerts e riprova pi� tardi.
<LI TYPE="circ"> Indirizzo non corretto. (Ricorda, gli indirizzi URL sono 
case-sensitive!) </LI>
<LI TYPE="circ">La suddetta pagina non esiste pi�</LI>
<LI TYPE="circ">Il membro � stato rimosso per violazione delle  <A 
HREF=http://xoom.it/TOS>Condizioni di Utilizzo</A>di XOOM.it.</FONT><P>
</UL>

XOOM.it non permette riferimenti a:<P>

<UL>
<LI TYPE="circ">materiale pornografico e a sfondo sessuale di natura oscena; 
<LI TYPE="circ">materiale che viola i diritti d'autore, in particolare software pirata
                        ("WAREZ, CRACK") file musicali, immagini, video, testi 
protetti da
                        copyright; 
<LI TYPE="circ">materiale offensivo incluse espressioni diffamatorie, di fanatismo,
                        razzismo, odio, irriverenza o minaccia; 
<LI TYPE="circ">materiale che promuove o fornisce informazioni che istruiscano su
                        attivit� illegali o che possano causare pregiudizio a terzi; 
<LI TYPE="circ">software, informazioni o altro materiale contenente virus o componenti
                        dannosi; 
<LI TYPE="circ">iniziative legate al gioco d'azzardo, concorsi, giochi che richiedono 
una
                        partecipazione a titolo oneroso. 
<LI TYPE="circ">Inserire sulla tua pagina pubblicit� o banner di sponsor. 
<LI TYPE="circ">Rimuovere dalla tua pagina il banner di XOOM.it e relativi 
collegamenti a
                        XOOM.it o sue directory. 
<LI TYPE="circ">Concedere l'accesso alla tua pagina(e) XOOM.it solo a utenti con
                        password. 
<LI TYPE="circ">Inviare email utilizzando un indirizzo di XOOM.it o contenenti 
riferimenti
                        alla tua home page su XOOM.it. 
<LI TYPE="circ">Utilizzare nella fase di registrazione come membro un account di email
                        che non � il tuo o che non funziona. 
<P>
</UL>

<FONT SIZE=+2>Per conoscere al completo le Condizioni di Utilizzo
                   clicca <A HREF=http://xoom.it/TOS>qui</A>.<P>

Se pensi che la tua pagina membro sia stata rimossa
                   per errore, spedisci una e-mail a  <A 
HREF=mailto:[EMAIL PROTECTED]>Webmaster</A>.<P>

<A HREF="http://xoom.it/signup/JoinNow.xihtml?R=0&P=7">Iscriviti ora a XOOM.it! E' 
gratis!</A></FONT><P>

</FONT>
</TD></TR></TABLE>

</TD></TR>

  <TR>
    <TD background="http://media.xoom.it/new/Left_Background.gif" height=70
    vAlign=bottom width=111><IMG align=baseline height=70 hspace=0
      src="http://media.xoom.it/new/left_bottom4.gif" width=111></TD>
    <TD height=70 vAlign=top width=489 bgcolor=#ffcc66>

        <!---- punto di inserimento snap ----->


      <TABLE border=0 cellPadding=0 cellSpacing=0 height=2 width=489>
        <TBODY>
        <TR>
          <TD bgColor=#000000 colSpan=2 height=2 width=489><SPACER HEIGHT="2"
            WIDTH="1" TYPE="BLOCK"></TD></TR></TBODY></TABLE>
      <TABLE border=0 cellPadding=0 cellSpacing=0 height=66 width=489>
        <TBODY>
        <TR>
          <TD bgColor=#ffcc66 width=487><IMG height=5 hspace=0 
src="http://media.xoom.it/new/spacer.gif" width=314><BR><B><FONT class=X11 
face="Verdana, Arial, Helvetica">&nbsp;&nbsp;&nbsp;Iscriviti a XOOM.it adesso per 
questi servizi gratuiti!<BR></FONT>

<FONT class=X11 face="Verdana, Arial, Helvetica">&nbsp;&nbsp;&nbsp;</FONT><FONT 
class=xh9 face="Arial, Helvetica" size=1><A href="http://xoom.it/webspace/">Spazio 
Web</A> | <A href="http://xoom.it/email/">Email</A> | <A 
href="http://xoom.it/chat/">Chat Room</A> | <A 
href="http://xoom.it/cgi-bin/redir.cgi?url=http://counter.xoom.it/">Xoomcounter</A> | 
<A href="http://xoom.it/clipart/">Clip
            Art</A> | <A href="http://xoom.it/downloads/">Area Download</A>
            </FONT></B><IMG height=2 hspace=0
            src="http://media.xoom.it/new/spacer.gif" width=314><BR><FONT class=
X11
            face="Verdana, Arial, Helvetica">&nbsp;&nbsp;</FONT><FONT class=X9
            face="Arial, Helvetica" size=1><A href="http://xoom.it/about">Chi e' 
Xoom.it</A> |
 <A href="http://xoom.it/about/advertising">Pubblicita'</A> | <A
            href="http://xoom.it/PPS">Legge sulla privacy</A> | <A
            href="http://xoom.it/TOS">Condizioni di utilizzo</A><BR><A
            href="http://xoom.it/copyright">Copyright</A> xa9 1999 Licenze XOOM.it. 
Tutti i d
iritti riservati. Powered by <a href=http://www.it.net><b><font color="#800000">
IT</font><font color="#008000"><i>net</i></b></a></FONT>.
                        <br>
                        <BR clear=all><IMG height=5 hspace=0
            src="http://media.xoom.it/new/spacer.gif" width=314><BR></TD>
          <TD bgColor=#000000 width=2><SPACER HEIGHT="2" WIDTH="2"
            TYPE="BLOCK"></TD></TR></TBODY></TABLE>
      <TABLE border=0 cellPadding=0 cellSpacing=0 height=2 width=489>
        <TBODY>
        <TR>
          <TD bgColor=#000000 colSpan=2 height=2 width=489><SPACER HEIGHT="2"
            WIDTH="1" TYPE="BLOCK"></TD></TR></TBODY></TABLE></TD></TR>
  <TR>
    <TD align=left colSpan=2 vAlign=top><IMG height=20 
src="http://media.xoom.it/new/fade_bottom.gif" width=250>
</TD></TR></TBODY></TABLE>
</FORM>
</BODY>
</HTML>



------------------------------

From: Joe Pfeiffer <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development,comp.os.linux.development.apps
Subject: Re: Two really easy (I'm sure) questions
Date: 10 May 2000 15:12:43 -0600

Nate Eldredge <[EMAIL PROTECTED]> writes:

> [EMAIL PROTECTED] (Mario Klebsch) writes:
> 
> > Nate Eldredge <[EMAIL PROTECTED]> writes:
> > 
> > 
> > Do you say, that calling exit() will result in undefined behavior? I
> > know, it works on the systems, I use, and I can accept, that it works
> > only by accident, but pleaye explain, why the behavoir is undefined?
> 
> It's not the calling exit() that's the problem, it's the void main.
> Having void main immediately results in undefined behavior; thus
> sayeth the ANSI C standard.  Calling exit just tends to make the
> behavior what you want, but of course is not guaranteed to do so.
> 
> In an otherwise correct program, calling exit() is well-defined.

In theory (which means I don't know of any compilers/systems in which
this actually happens), things could go screwy when you call main()
if it's declared void, and you might never get to the call to exit()
as a result.  So it isn't the return value (or some such) that's
undefined, it's the complete behavior of the program.

I *think* (which means I haven't read enough of the standards, and
haven't been careful enough in reading what I have) that if your
program's behavior happens to make it to the call of exit(0), and the
call happens successfully, then you are guaranteed to terminate with a
correct exit status.  But I wouldn't be at all surprised to find
out that the fact the program's behavior is undefined ``trumps'' the
definition of exit(), so even that wouldn't be sure.

Here's an example of fortuitous and non-fortuitous undefined behavior
(not in the context of a void main(), but maybe it'll help get the
idea across).  A while back, I wrote a function that returned an int,
and forgot to call return to end the function.  Through sheer blind
luck, the last computation in the function happened to calculate the
return value, which meant that on an Intel processor the right value
happened to be in the EAX register upon return, and the program
worked.  When I compiled and ran it on a a Sparc... it didn't.
-- 
Joseph J. Pfeiffer, Jr., Ph.D.       Phone -- (505) 646-1605
Department of Computer Science       FAX   -- (505) 646-1002
New Mexico State University          http://www.cs.nmsu.edu/~pfeiffer
VL 2000 Homepage:  http://www.cs.orst.edu/~burnett/vl2000/

------------------------------

From: [EMAIL PROTECTED] (Chris J/#6)
Subject: CD-R Packet writing
Reply-To: [EMAIL PROTECTED]
Date: 10 May 2000 21:58:20 +0100

Hiya,

Does/will Linux support packet writing for CD-R/CD-RW? I've been looking for
info, but as yet found nowt. Any pointers to info would be appreciated.

Thanks,

Chris...

-- 
@}-,'--------------------------------------------------  Chris Johnson --'-{@
    / "(it is) crucial that we learn the difference / [EMAIL PROTECTED]  \
   / between Sex and Gender. Therein lies the key  /                       \ 
  / to our freedom" -- LB                         / www.nccnet.co.uk/~sixie \ 

------------------------------

From: Timur Tabi <[EMAIL PROTECTED]>
Subject: Re: Determining amount of physical RAM from a driver?
Date: Wed, 10 May 2000 21:38:30 GMT

In article <[EMAIL PROTECTED]>,
  nilesh patel <[EMAIL PROTECTED]> wrote:
> Timur Tabi wrote:
>
> high_mem - 0xC0000000
> Try this.

Thanks.  For the record, the code I'm using is:

#include <linux/mm.h>
#include <asm/page.h>

unsigned int ram = (unsigned int) high_memory - PAGE_OFFSET;

Two questions:

1. Can the user override this by using a kernel command-line parameter?
2. I see a bunch of code/comments about memory holes created by ACPI.
Can someone explain to me what that is, and whether it will affect my
code?

--
Timur Tabi
Interactive Silicon - http://www.interactivesi.com
Remove "nospam_" from my email address when replying


Sent via Deja.com http://www.deja.com/
Before you buy.

------------------------------

From: Erik Max Francis <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development,comp.os.linux.development.apps
Subject: Re: Two really easy (I'm sure) questions
Date: Wed, 10 May 2000 14:42:30 -0700

Mike McDonald wrote:

>   We understand what "undefined behavior" means. We don't understand
> why
> "exit(0)" is undefined behavior. Is it because ANSI C doesn't defined
> exit()?
> That it's left to POSIX instead to define?

In the code fragment in question, namely:

| void main() {
| ...
| exit(N);
| }

What results in undefined behavior here is the fact that main is
declared as returning void; it has nothing to do with the call to exit. 
In particular, if control never reaches the end of a main that returns
void (i.e., exit is guaranteed to be called before then), that _still_
doesn't avoid undefined behavior.  The problem is that main returns
void, not whether main conceptually returns or not.  The comp.lang.c FAQ
goes over this issue in detail.

-- 
 Erik Max Francis / [EMAIL PROTECTED] / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ You win the victory when you yield to friends.
\__/ Sophocles
    Kepler's laws / http://www.alcyone.com/max/physics/kepler/
 A proof of Kepler's laws.

------------------------------

From: [EMAIL PROTECTED] (Kaz Kylheku)
Crossposted-To: comp.os.linux.development,comp.os.linux.development.apps
Subject: Re: Two really easy (I'm sure) questions
Reply-To: [EMAIL PROTECTED]
Date: Wed, 10 May 2000 21:58:18 GMT

On 10 May 2000 15:12:43 -0600, Joe Pfeiffer <[EMAIL PROTECTED]> wrote:
>correct exit status.  But I wouldn't be at all surprised to find
>out that the fact the program's behavior is undefined ``trumps'' the
>definition of exit(), so even that wouldn't be sure.

Once the program invokes undefined behavior, it's meaningless to ponder
whether it can subsequently do anything that is well-defined. Any behavior
the program has after that point is not required.

>Here's an example of fortuitous and non-fortuitous undefined behavior
>(not in the context of a void main(), but maybe it'll help get the
>idea across).  A while back, I wrote a function that returned an int,
>and forgot to call return to end the function.  Through sheer blind
>luck, the last computation in the function happened to calculate the
>return value, which meant that on an Intel processor the right value
>happened to be in the EAX register upon return, and the program
>worked.  When I compiled and ran it on a a Sparc... it didn't.

Yep; you should find out if your compiler have a diagnostic for this.
GCC can most certainly warn about this. Though such warnings can be
a nuisance if they are not intelligently implemented. The compiler should
do at least some minimal analysis to try to prove that control does not
fall off the end of that function before complaining. ;)

In C (at least 1989, don't know about 1999) it's actually well defined
to fail to return a value, provided that the caller does not try to
extract it. Functions returning int were used in classic C to simulate
procedures. Such functions were often declared with implicit int,
to complete the illusion.

The practice extended to main, which in many programs came to be defined like
this:

    main()
    {
        /* no return, undefined termination status */
    }

When compilers started introducing the void keyword, some boneheads picked up
on that and started adding it to main instead of sticking to the above
semi-correct form.

-- 
#exclude <windows.h>

------------------------------


** FOR YOUR REFERENCE **

The service address, to which questions about the list itself and requests
to be added to or deleted from it should be directed, is:

    Internet: [EMAIL PROTECTED]

You can send mail to the entire list (and comp.os.linux.development.system) via:

    Internet: [EMAIL PROTECTED]

Linux may be obtained via one of these FTP sites:
    ftp.funet.fi                                pub/Linux
    tsx-11.mit.edu                              pub/linux
    sunsite.unc.edu                             pub/Linux

End of Linux-Development-System Digest
******************************

Reply via email to