Linux-Development-Sys Digest #556, Volume #8     Sun, 11 Mar 01 01:13:14 EST

Contents:
  Re: ld configuration (Nix)
  Re: getting user input non-blocking (Fraser Stewart)
  Re: Where are inw and outw? (Michael Mueller)
  Re: Can linux be trusted? (Kirk Strauser)
  Re: Can linux be trusted? (Gergo Barany)
  coding a demo, svgalib ? ("BenKenobi")
  Re: Why is this process swapping? ("Joseph A. Knapka")
  Re: Where are inw and outw? (Matt)
  #include order in modules (Matt)
  Re: Can linux be trusted? (Mark McIntyre)
  Re: Private functions in shared library? (Nix)
  Re: Can linux be trusted? (Hartmann Schaffer)
  Re: Can linux be trusted? (Mark McIntyre)
  Re: Can linux be trusted? (Peter da Silva)
  Re: Can linux be trusted? (John Hampton)
  Re: Is bootsect.s the code of MBR?? ("hushui")
  Re: why is mmap() unhappy?? (Dragan Cvetkovic)
  Re: Can linux be trusted? (Erik Max Francis)
  pci devices ("Moe")
  forked ("Shaun Troedson")
  Re: Can linux be trusted? (Robert Redelmeier)

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

From: Nix <$}xinix{$@esperi.demon.co.uk>
Subject: Re: ld configuration
Date: 10 Mar 2001 20:09:43 +0000

On Wed, 07 Mar 2001, Byron Young stipulated:
> How do I configure ld to produce the same executible as gcc? So all I
> have to do is issue the command:
> ld test.o -o test.bin

In many cases, especially where C++ is concerned, you cannot.

Precisely whether you can or not in a given case is system-dependent;
but it is best not to try at all.

(In any case, you'd have to add at least -lgcc, and perhaps -lstdc++
-lgcc -lc to that line, and you'd need a bunch of -Ls too, to point ld
at the GCC backend directory. Not worth it.)

> If I run ld using exactly the same command line options as collect2,

collect2 does do things other than run ld, you know; just because it
calls ld doesn't mean that's all it does.

> then a executable binary is created. Otherwise, errors happen.

Er, what you're saying is `if I link a program using a link line other
than the correct one, errors happen.' Yes. They would.


Use gcc as the linker. It works.

If what you're trying to do is pass in special linker options, look up
the -Wl switch to gcc.

-- 
`I put "Update To-Do List" on my to-do list. I'm never sure whether or
 not to tick it off.' --- Simon Cozens

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

From: Fraser Stewart <[EMAIL PROTECTED]>
Subject: Re: getting user input non-blocking
Date: Sat, 10 Mar 2001 20:14:06 +0000

Eric Malkowski wrote:
> 
> Kaz's solution will work well.
> 
> If you don't want to worry about clearing the error condition on the
> stdin stream and setting the stdin file number (0) to nonblocking, you
> can select() on STDIN_FILENO for data ready to read and then use your
> favorite function like getchar() or getc() to read the data and not have
> to worry about blocking.
> 
> Good luck,
> 

Thank you all, much appreciated.

Fraser.

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

From: Michael Mueller <[EMAIL PROTECTED]>
Subject: Re: Where are inw and outw?
Date: Sat, 10 Mar 2001 21:31:25 +0100

Hi Matt,

you wrote:
> I'm slowly writing a device driver for a DSP controller, and I have just
> gotten around to the I/O port furtling. I'm trying to use the inw and
> outw and my module compiles fine, but when I try and load it into my
> kernel, I get:

Enable the optimization ("-O") when compiling the module. The functions
will be inlined then. You should have to include <asm/io.h> thought.


Malware

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

Crossposted-To: 
comp.lang.c,comp.os.linux.development.apps,comp.sys.be.programmer,comp.sys.mac.programmer.misc,comp.unix.bsd.freebsd.misc,comp.unix.bsd.misc,gnu.gcc
Subject: Re: Can linux be trusted?
From: Kirk Strauser <[EMAIL PROTECTED]>
Date: 10 Mar 2001 14:51:11 -0600


At 2001-03-10T19:31:33Z, pete <[EMAIL PROTECTED]> writes:

>        for(mask = 1 << CHAR_BIT - 1; mask; mask >>= 1)
>           *b++ = ((char*)p)[bytes] & mask? '1': '0';

In one of my compsci classes, we did the same analysis.  However, we used
the `union' structure to overlay a float onto an unsigned int.  The math was
somewhat more elegant.  :)
-- 
Kirk Strauser

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

From: [EMAIL PROTECTED] (Gergo Barany)
Crossposted-To: 
comp.lang.c,comp.os.linux.development.apps,comp.sys.be.programmer,comp.sys.mac.programmer.misc,comp.unix.bsd.freebsd.misc,comp.unix.bsd.misc,gnu.gcc
Subject: Re: Can linux be trusted?
Date: 10 Mar 2001 21:41:07 GMT

Kirk Strauser <[EMAIL PROTECTED]> wrote:
> At 2001-03-10T19:31:33Z, pete <[EMAIL PROTECTED]> writes:
> 
> >      for(mask = 1 << CHAR_BIT - 1; mask; mask >>= 1)
> >         *b++ = ((char*)p)[bytes] & mask? '1': '0';
> 
> In one of my compsci classes, we did the same analysis.  However, we used
> the `union' structure to overlay a float onto an unsigned int.  The math was
> somewhat more elegant.  :)

Type punning via unions is implementation defined (except for the
"structs with common initial sequences" exception that doesn't apply
here).
Two of the things that might bite you are unequal sizes of two
types and padding bits in one of the types.

Gergo

-- 
> /* clear Ginger */
> spice_girls &= ~SPICE_GINGER;
        -- Gregory Pietsch

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

From: "BenKenobi" <[EMAIL PROTECTED]>
Subject: coding a demo, svgalib ?
Date: Sat, 10 Mar 2001 22:54:58 +0100
Reply-To: [EMAIL PROTECTED]

helo,

what is the best method to code gfx demo without xfree ?

should i use svgalib ?

how can i access to the video memory ?
thx


-- 
benkenobi
rembr the futur,imagine the past,listen 2 trance

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

From: "Joseph A. Knapka" <[EMAIL PROTECTED]>
Subject: Re: Why is this process swapping?
Date: Sat, 10 Mar 2001 21:53:54 GMT

Kaelin Colclasure wrote:
> 
> But every-other bit in the sieve vector is touched during the programs
> first pass... Hmmm, I suppose the machine might be swapping the whole
> time, but the effect doesn't become noticable until the algorithm's
> stride through the sieve starts to approach the 4K page size. Still, I
> am somewhat surprised at how slowly things are running. I am wondering
> if this isn't some sort of worst-case for Linux's swap algorithm?

Could be. If you are going to hit every page (give or take) in
the process's virtual space in address order, then chances are
really good that the next page you are about to hit is the
least-recently-used one, since the last time you touched it was
on your last cycle through all the pages. So it has a high likelihood
of being chosen as a swapout victim if the *current* page access
requires a page to be freed. Which is bad, since you're
about to reference it again.

When you're hitting every other bit, you only swap after every
2048*8 memory ops + whatever processing you do on those bits
in between. But when the seive stride hits about 4096*8 bits,
you're hitting a new, probably missing, page on every single
bit!

Of course the Linux swap policy isn't strictly LRU, but may be
close enough to leat to this kind of behavior.


-- Joe Knapka
"It was just a maddened crocodile hidden in a flower bed. It could
 have happened to anyone." -- Pratchett

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

From: Matt <[EMAIL PROTECTED]>
Subject: Re: Where are inw and outw?
Date: Sat, 10 Mar 2001 22:46:19 GMT

On Sat, 10 Mar 2001, Michael Mueller wrote:

| you wrote:
| > I'm slowly writing a device driver for a DSP controller, and I have just
| > gotten around to the I/O port furtling. I'm trying to use the inw and
| > outw and my module compiles fine, but when I try and load it into my
| > kernel, I get:
| 
| Enable the optimization ("-O") when compiling the module. The functions
| will be inlined then. You should have to include <asm/io.h> thought.

/me smacks forehead

DOH! It inserts fine now. Now all I've got to do is make sure I inw and
outw the right places! :)

Thanks

Matt


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

From: Matt <[EMAIL PROTECTED]>
Subject: #include order in modules
Date: Sat, 10 Mar 2001 22:57:24 GMT

Can anyone give me a rough order of the #includes that I should have at
the top of my kernel driver. I've looked at some of the drivers in the
kernel source and they all differ :)

I've got:

#include <linux/config.h>
#include <linux/version.h>

#ifdef MODVERSIONS
#include <linux/modversions.h>
#endif

#ifdef MODULE
#include <linux/module.h>
#endif

#include <linux/kernel.h>
...

Anything wrong with that?

Cheers

Matt


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

From: Mark McIntyre <[EMAIL PROTECTED]>
Crossposted-To: 
comp.lang.c,comp.os.linux.development.apps,comp.sys.be.programmer,comp.sys.mac.programmer.misc,comp.unix.bsd.freebsd.misc,comp.unix.bsd.misc,gnu.gcc
Subject: Re: Can linux be trusted?
Date: Sat, 10 Mar 2001 23:25:11 +0000

On Sat, 10 Mar 2001 07:36:32 -0600, Robert Redelmeier <[EMAIL PROTECTED]>
wrote:

>Mark McIntyre wrote:
>> 
>> On Fri, 09 Mar 2001 23:37:29 -0500, Willam Hughes <[EMAIL PROTECTED]>
>> >While it is true that the floating point constant 3.
>> >will probably be represented exactly,
>> 
>> How ? Is it an exact binary number ?
>
>YES!  3d = 1.1b * 2^1b .
>
>In general, all non-mantissa over[under?]flowing integers 
>can be exactly representing by floats.

Interesting. 

<snip>

>Worse, even when you try to decimally represent an exact 
>binary fraction [like 0.25d], it may wind up inexact.
>The compiler may do 25/100 rather than 1/4 .

so if the compiler was annoying it could represent 3 as 30/100 ? :->


-- 
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>

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

From: Nix <$}xinix{$@esperi.demon.co.uk>
Subject: Re: Private functions in shared library?
Date: 10 Mar 2001 20:14:54 +0000

On Wed, 7 Mar 2001, Roger Leigh spake:
> I had a look at this: another arcane scripting language to master!
> However, is this specific to GNU ld, or will linker commmand files
> work with any ld?

The symbol versioning script language is like that for Solaris's linker,
but not the same.

> There is a libtool option to select which symbols to export:
> '-export-symbols-regex stp_', seems to work, but when the information
> is passed to the linker with
> '-Wl,-retain-symbols-file -Wl,.libs/libgimpprint.exp' nothing actually
> changes. Only the stp_* functions are listed in the symbol file, nothing
> else (which is what should happen).

What version of binutils do you have? Some versions (around early 2.10
IIRC) had trouble getting ELF visibility limitations right (and made
everything visible always, just as you're experiencing); versions before
2.10 didn't know about it at all.

-- 
`I put "Update To-Do List" on my to-do list. I'm never sure whether or
 not to tick it off.' --- Simon Cozens

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

From: [EMAIL PROTECTED] (Hartmann Schaffer)
Crossposted-To: 
comp.lang.c,comp.os.linux.development.apps,comp.sys.be.programmer,comp.sys.mac.programmer.misc,comp.unix.bsd.freebsd.misc,comp.unix.bsd.misc,gnu.gcc
Subject: Re: Can linux be trusted?
Date: 10 Mar 2001 18:47:11 -0500

In article <[EMAIL PROTECTED]>, Mark McIntyre wrote:
> ...
>so if the compiler was annoying it could represent 3 as 30/100 ? :->

only if it had a serious bug

hs

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

From: Mark McIntyre <[EMAIL PROTECTED]>
Crossposted-To: 
comp.lang.c,comp.os.linux.development.apps,comp.sys.be.programmer,comp.sys.mac.programmer.misc,comp.unix.bsd.freebsd.misc,comp.unix.bsd.misc,gnu.gcc
Subject: Re: Can linux be trusted?
Date: Sun, 11 Mar 2001 00:03:30 +0000

On 10 Mar 2001 18:47:11 -0500, [EMAIL PROTECTED] (Hartmann
Schaffer) wrote:

>In article <[EMAIL PROTECTED]>, Mark McIntyre wrote:
>> ...
>>so if the compiler was annoying it could represent 3 as 30/100 ? :->
>
>only if it had a serious bug

oops... maybe I meant 300/100... :->

-- 
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>

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

From: [EMAIL PROTECTED] (Peter da Silva)
Crossposted-To: 
comp.lang.c,comp.os.linux.development.apps,comp.sys.be.programmer,comp.sys.mac.programmer.misc,comp.unix.bsd.freebsd.misc,comp.unix.bsd.misc,gnu.gcc
Subject: Re: Can linux be trusted?
Date: 11 Mar 2001 01:29:36 GMT

In article <[EMAIL PROTECTED]>, pete  <[EMAIL PROTECTED]> wrote:
>    static unsigned char *a;
>    unsigned char *b, mask;
> 
>    if(!(a = realloc(a, CHAR_BIT * bytes + 1)))
>       printf("realloc() failure in Bits()\n"), exit(EXIT_FAILURE);

While it is true that "static unsigned char *a" is initialised to zero,
it is good programming practice to explicitly point that out with:

        static unsigned char *a = 0;

lest some later programmer make it "auto" and produce undefined behaviour. I
realise that would be a foolish thing to do (and would at least cause a
memory leak) but fools are ingenious in their foolishness.

-- 
 `-_-'   In hoc signo hack, Peter da Silva.
  'U`    "A well-rounded geek should be able to geek about anything."
                                                       -- [EMAIL PROTECTED]
         Disclaimer: WWFD?

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

From: John Hampton <[EMAIL PROTECTED]>
Crossposted-To: 
comp.lang.c,comp.os.linux.development.apps,comp.sys.be.programmer,comp.sys.mac.programmer.misc,comp.unix.bsd.freebsd.misc,comp.unix.bsd.misc,gnu.gcc
Subject: Re: Can linux be trusted?
Date: Sun, 11 Mar 2001 02:12:41 GMT

Erik Max Francis wrote:
> 
> pete wrote:
> 
> > I'm showing off my new function, Bits()
> > This is the second time I've posted it and I know it gets old fast,
> > so I won't post it again.
> 
> It has a serious bug.  What happens when it's called with bytes == 0?
> 
> --
>  Erik Max Francis / [EMAIL PROTECTED] / http://www.alcyone.com/max/
>  __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
> /  \ They have rights who dare defend them.
> \__/ Roger Baldwin
>     Official Omega page / http://www.alcyone.com/max/projects/omega/
>  The official distribution page for the popular Roguelike, Omega.

Correct me if I am wrong, but I think that calling Bits() with bytes ==
0 is the flag to free the memory used by static char *a in the
function.  In fact, the OP uses his function this way, by passing 0 into
the parameter bytes.

-John

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

From: "hushui" <[EMAIL PROTECTED]>
Subject: Re: Is bootsect.s the code of MBR??
Date: Sun, 11 Mar 2001 11:09:06 +0800

thank you.
> The kernel image has a boot  sector in the front so that
 the front is following the 512 bytes boot sector (mbr) ??? Is it called the
second boot sector?

 > LILO has its own boot sector. This is contained in the binary file
> /boot/boot.b.  When you run lilo to install it, it copies from this
> file to the boot sector of the target boot device.
you means the first 512 bytes of the harddisk,that is mbr  ??
I want to know the code in mbr (except the partion table) is including
what??? lilo's code that is boot.b???

 thank you .
I am a start learner.



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

From: Dragan Cvetkovic <[EMAIL PROTECTED]>
Subject: Re: why is mmap() unhappy??
Date: 10 Mar 2001 22:45:15 -0500
Reply-To: [EMAIL PROTECTED]

[EMAIL PROTECTED] writes:
> | to the implementation. On the other hand Stevens' APUE p. 465 says the same
> | as you said, but UNPv2, p. 345 just says:
> | " IPC_RMID Remove the shared memory segment identified by shmid from the
> | system and destroy the shared memory segment."
> |
> | I guess the situation has changed since APUE publication (1992, I think).
> 
> This could be a problem on Solaris.  Back when Solaris was part of my job
> responsibility, it was very typical to see lots of leftover shared memory
> segments.  Reboot was the easy way to clean it up.  Perhaps they were
> there because of bad programming practice in the application due to this
> kind of problem.  Perhaps it is no longer a problem with Solaris 8.  There
> certainly needs to be a way to make sure that shared memory segments go
> away when not needed anymore (including cases of processes being killed
> ot the machine power cycling) and it be done in a standard way so it can
> be coded one way and work everywhere.

        Actually it is not a problem with Solaris since Solaris and POSIX
wording are the same. I guess the situation is the same as with all IPC
resources i.e.  they will stay in memory until explicitelly removed or until
machine reboots. Since semaphores and message queues are handled that way
(they can be removed regardless of processes waiting on semaphore or on a
message), so why consider shared memory an exception? 

Bye, Dragan

-- 
Dragan Cvetkovic, 

To be or not to be is true. G. Boole

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

From: Erik Max Francis <[EMAIL PROTECTED]>
Crossposted-To: 
comp.lang.c,comp.os.linux.development.apps,comp.sys.be.programmer,comp.sys.mac.programmer.misc,comp.unix.bsd.freebsd.misc,comp.unix.bsd.misc,gnu.gcc
Subject: Re: Can linux be trusted?
Date: Sat, 10 Mar 2001 19:46:26 -0800

John Hampton wrote:

> Correct me if I am wrong, but I think that calling Bits() with bytes
> ==
> 0 is the flag to free the memory used by static char *a in the
> function.  In fact, the OP uses his function this way, by passing 0
> into
> the parameter bytes.

It returns an invalid pointer when called with bytes == 0.

-- 
 Erik Max Francis / [EMAIL PROTECTED] / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ Sometimes life gets in the way / You'll survive, be strongest
\__/ Des'ree
    Physics reference / http://www.alcyone.com/max/reference/physics/
 A physics reference.

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

From: "Moe" <[EMAIL PROTECTED]>
Subject: pci devices
Date: Sun, 11 Mar 2001 04:28:15 GMT

I am looking for information containing PCI device class/subclass codes.
How do I detect weather device is MEM, NETWORK, MULTIMEDIA, DISPLAY, BRIDGE?
I found code for concrete venors and devices i.e. 3com and 3c509c, but not
classes.
Thanks.
Moe.







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

From: "Shaun Troedson" <[EMAIL PROTECTED]>
Subject: forked
Date: Sun, 11 Mar 2001 15:53:51 +1030

I don't know if this is standard behaviour with the fork call, but it seems
surprising.

If I have the following code:
main()
{
  printf("Test");
  fork();
}

I get the following:
TestTest

(If I put a "\n" after the "Test" I get just "Test" printed out as the \n is
causing a flush)

So it seems that the standard out is being flushed at exit time by both the
parent and child. But surely standard output is a single entity, ie the
controlling terminal, and once it is flushed then flushing it again
shouldn't output the same string.



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

Date: Sat, 10 Mar 2001 23:45:35 -0600
From: Robert Redelmeier <[EMAIL PROTECTED]>
Crossposted-To: 
comp.lang.c,comp.os.linux.development.apps,comp.sys.be.programmer,comp.sys.mac.programmer.misc,comp.unix.bsd.freebsd.misc,comp.unix.bsd.misc,gnu.gcc
Subject: Re: Can linux be trusted?

Mark McIntyre wrote:
> 
> [EMAIL PROTECTED] (Hartmann Schaffer) wrote:
> 
> >In  Mark McIntyre wrote:
> >>so if the compiler was annoying it could represent 3 as 30/100 ? :->
> >
> >only if it had a serious bug
> 
> oops... maybe I meant 300/100... :->

Weell, I hope not :)   Compilers ought to be able to figure
out that numbers without decimal points are integers.  
And be able to convert integer to float exactly, so long
as the mantissa has enough bits of precision.

But 3.00 is a whole _different_ matter.  The quick and
general way to convert fixed decimals into binary floats
at least on x86 is to load 300 (FBLD) and multiply by 
(1/100) from a table.  3. will get loaded correctly,
3.00 might not unless the compiler has special code
to recognize and drop trailing zeros.

3. might not equal 3.00.  Check your compiler.

-- Robert  "You have to play the hand you are dealt in Silicon."

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


** 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 by posting to the
comp.os.linux.development.system newsgroup.

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