Linux-Development-Sys Digest #558, Volume #8     Mon, 12 Mar 01 00:13:14 EST

Contents:
  Re: why is mmap() unhappy?? ([EMAIL PROTECTED])
  LD problem (Stefan Okrongli)
  Re: How to access hardware in Linux (Grant Edwards)
  Re: LD problem ([EMAIL PROTECTED])
  Re: Can linux be trusted? (Peter da Silva)
  Re: Can linux be trusted? (Erik Max Francis)
  Re: Can linux be trusted? (Erik Max Francis)
  Re: How to access hardware in Linux (Uwe Bonnes)
  I2C port (Aminudin Khalid)
  Re: I2C port
  Re: why is mmap() unhappy?? (Dragan Cvetkovic)
  Re: I2C port ("Gene Heskett")
  Re: why is mmap() unhappy?? ([EMAIL PROTECTED])
  Re: why is mmap() unhappy?? (Alexander Viro)
  Re: I2C port (Grant Edwards)

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

From: [EMAIL PROTECTED]
Subject: Re: why is mmap() unhappy??
Date: Sun, 11 Mar 2001 15:16:15 -0000

On Sun, 11 Mar 2001 11:28:01 +0000 Kasper Dupont <[EMAIL PROTECTED]> wrote:

| The solution I suggested works fine on Linux, I've
| never tried it on other systems. But since this is
| the only way to ensure segments get freed, I will
| continue to use it and suggest it, and I will
| consider systems not allowing it to bre broken.
|
| The man page has this to say about IPC_RMID:
|
|        IPC_RMID    is  used  to mark the segment as destroyed. It
|                    will actually  be  destroyed  after  the  last
|                    detach.   (I.e., when the shm_nattch member of
|                    the associated structure  shmid_ds  is  zero.)
|                    The  user  must  be the owner, creator, or the
|                    super-user.

And I will agree with you.  This is the way I handled it in:

    http://phil.ipal.org/freeware/vrb/vrb-0.2.0.tar.gz

It is analogous to getting temporary file space and making sure it
is removed by unlinking its name right after being opened, and then
proceeding to use it while only the in-kernel inode references it.
In my virtual ring buffer implementation above, the caller can choose
between shared memory and a file as the sharing object, but it will
remove either object once it makes its 2 virtual adjacent mappings.

-- 
=================================================================
| Phil Howard - KA9WGN |   Dallas   | http://linuxhomepage.com/ |
| [EMAIL PROTECTED] | Texas, USA | http://phil.ipal.org/     |
=================================================================

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

From: Stefan Okrongli <[EMAIL PROTECTED]>
Subject: LD problem
Crossposted-To: comp.os.linux.development,comp.os.linux.development.apps
Reply-To: [EMAIL PROTECTED]
Date: Sun, 11 Mar 2001 11:29:17 -0500

Hi,

I'm a decent win32 GUI developer (VC5), and want to explore the depths of 
linux GUI development.
I decided to give it a try with QT, and bought (don't laugh) 'QT 
Programming in 24 hours', just to get an idea. 
The problem I have is with compiling even the simplest app. I have set my 
bash environment variables (QTDIR, amended PATH, LD_LIBRARY_PATH, 
LIBRARY_PATH, MANPATH) in my .bash_profile, exported all of them, and use a 
XTerminal. I use bash with the --login option, and I do see all the 
env-vars using echo.
When it comes to compiling/linling, however, I get a bag full of complaints 
from ld regarding 'undefined references' in all QT calls. Looks like ld 
does not find the proper libraries, although I triple checked that the 
env-vars point to the QT version currently in use (qt-2.2.4). I also tried 
earlier versions (1.45), with the same result.
Can anybody give me the (most likely simple) answer to this problem?

Thanks

-- 
Stefan Okrongli
- Happy Win32 programmer trying to convert

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

From: [EMAIL PROTECTED] (Grant Edwards)
Subject: Re: How to access hardware in Linux
Date: Sun, 11 Mar 2001 16:50:08 GMT

In article <[EMAIL PROTECTED]>, Kasper Dupont wrote:
>Grant Edwards wrote:

>> >He can access ioports in user space if as root he issues an iopl
>> >or ioperm call.  One doesn't always need to create a driver.
>> 
>> You can also do open(), seek(), read(), write() on /dev/port.
>
>You can do that, but ioperm() gives much better performance. And you can
>create a suid binary that first calls ioperm() then drops priveleges, that
>cannot be done in a safe way with /dev/port.

Last time I was doing I/O port stuff the ioperm() call only worked for I/O
addresses below 1K.  If you wanted to access the other 98.4% of the I/O
space you had to use /dev/port.  Has ioperm() been changed to allow access
to I/O above 1K?

>> Being able to mmap() /dev/port would be cool -- but I don't
>> think that is implimented.
>
>I don't think it would be possible.
>
>(Unless you want to emulate *ALL* CPU instructions that can do memory
>access, and you are willing to accept a huge overhead.)

Is that the only way to find out the address and operation (read/write
word/byte/etc.) that caused a page fault?  That would be nasty.

-- 
Grant Edwards                   grante             Yow!  Is this an out-take
                                  at               from the "BRADY BUNCH"?
                               visi.com            

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

From: [EMAIL PROTECTED]
Crossposted-To: comp.os.linux.development,comp.os.linux.development.apps
Subject: Re: LD problem
Date: Sun, 11 Mar 2001 16:56:47 -0000

In comp.os.linux.development.system Stefan Okrongli <[EMAIL PROTECTED]> wrote:

| I'm a decent win32 GUI developer (VC5), and want to explore the depths of 
| linux GUI development.
| I decided to give it a try with QT, and bought (don't laugh) 'QT 
| Programming in 24 hours', just to get an idea. 
| The problem I have is with compiling even the simplest app. I have set my 
| bash environment variables (QTDIR, amended PATH, LD_LIBRARY_PATH, 
| LIBRARY_PATH, MANPATH) in my .bash_profile, exported all of them, and use a 
| XTerminal. I use bash with the --login option, and I do see all the 
| env-vars using echo.
| When it comes to compiling/linling, however, I get a bag full of complaints 
| from ld regarding 'undefined references' in all QT calls. Looks like ld 
| does not find the proper libraries, although I triple checked that the 
| env-vars point to the QT version currently in use (qt-2.2.4). I also tried 
| earlier versions (1.45), with the same result.
| Can anybody give me the (most likely simple) answer to this problem?

Please include in your next post the Makefile and log of commands
being executed so we can see if everything is actually set up right.

-- 
=================================================================
| Phil Howard - KA9WGN |   Dallas   | http://linuxhomepage.com/ |
| [EMAIL PROTECTED] | Texas, USA | http://phil.ipal.org/     |
=================================================================

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

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 17:03:10 GMT

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

By making this an auto, you're initialising it to 0 every pass through
the program, and thus your realloc is equivalent to a malloc. Your original
code was correct, just a little obscure. This code works but will leak memory
every time through since the allocated memory is discarded.

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

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

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: Sun, 11 Mar 2001 11:05:32 -0800

pete wrote:

> However, when I do that, the return value just gets discarded.
>   Bits(&b,0);
> I don't what what difference it makes,
> whether or not a discarded pointer is invalid.
> I don't see any possibility for unexpected behavior.

It's discarded in the way that _you_ use it.  But it is a serious
problem, as anyone who mistakenly even _loads_ the invalid pointer is
potentially in trouble.

> I'll find another way, but then I'm going to have to post it again.

If you really wanted to have the semantics remain the same, you simply
should have made the function return the null pointer when it was called
with a zero byte count.  The problem is not the semantics, it's that it
returns an invalid pointer in one of its modes.

A better approach overall would not be to store a static buffer locally
_anyway_, but instead have the user pass the buffer in (you already have
an implicit size given by the byte count).

-- 
 Erik Max Francis / [EMAIL PROTECTED] / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ Weakness of attitude becomes weakness of character.
\__/ Albert Einstein
    Interstelen / http://www.interstelen.com/
 A multiplayer, strategic, turn-based Web game on an interstellar scale.

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

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: Sun, 11 Mar 2001 11:06:58 -0800

pete wrote:

> I felt funny about that too.
> What do you think about it this way?

If the called function allocate its own storage buffer that it manages,
it should free it, not the caller.

Either have it return the null pointer in the freeing case, or simply
don't store the buffer locally and have the caller pass it in.  The
latter solution also would make your code reentrant.

-- 
 Erik Max Francis / [EMAIL PROTECTED] / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ Weakness of attitude becomes weakness of character.
\__/ Albert Einstein
    Interstelen / http://www.interstelen.com/
 A multiplayer, strategic, turn-based Web game on an interstellar scale.

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

From: Uwe Bonnes <[EMAIL PROTECTED]>
Subject: Re: How to access hardware in Linux
Date: 11 Mar 2001 19:11:29 GMT

Grant Edwards <[EMAIL PROTECTED]> wrote:

: Last time I was doing I/O port stuff the ioperm() call only worked for I/O
: addresses below 1K.  If you wanted to access the other 98.4% of the I/O
: space you had to use /dev/port.  Has ioperm() been changed to allow access
: to I/O above 1K?

man iopl
-- 
Uwe Bonnes                [EMAIL PROTECTED]

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
========= Tel. 06151 162516 ======== Fax. 06151 164321 ==========

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

From: Aminudin Khalid <[EMAIL PROTECTED]>
Subject: I2C port
Date: Mon, 12 Mar 2001 09:29:53 +0800
Reply-To: [EMAIL PROTECTED]

Hi,

What is I2C port ? Is it serial port ?

Thanx.


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

From: <[EMAIL PROTECTED]>
Subject: Re: I2C port
Date: Sun, 11 Mar 2001 17:50:20 -0800

Dear Aminudin:
    I2C stands for Inter Integrated Circuit. It is a two wire connection
usually between chips on a circuit board. It was created by Philips some
years back to support slow speed (it runs about 100kbits/sec) configuration
and control of chips on a circuit board. It sort of is like a serial port,
but unless you are trying to do hardware development, you won't be
connecting it to either a serial or parallel port. You will frequently find
references to it in relation to digital video as it is the default control
mechanism for such chips as the SAA7114 and all of its cousins.

"Aminudin Khalid" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> Hi,
>
> What is I2C port ? Is it serial port ?
>
> Thanx.
>
>



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

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

Kasper Dupont <[EMAIL PROTECTED]> writes:

> The solution I suggested works fine on Linux, I've
> never tried it on other systems. But since this is
> the only way to ensure segments get freed, I will
> continue to use it and suggest it, and I will
> consider systems not allowing it to bre broken.
        
OK, try your solution on other major UNIX platforms (Solaris, AIX, HP-UX
etc.) and let's talk again afterwards. 
 
> 
> The man page has this to say about IPC_RMID:
> 
>        IPC_RMID    is  used  to mark the segment as destroyed. It
>                    will actually  be  destroyed  after  the  last
>                    detach.   (I.e., when the shm_nattch member of
>                    the associated structure  shmid_ds  is  zero.)
>                    The  user  must  be the owner, creator, or the
>                    super-user.

I know. I have read the man page on Linux. The problem is that man pages on
other Unices don't say it. For example, this is what AIX 4.3.3 shmctl(2)
man page says:

"IPC_RMID Removes the shared memory identifier specified by the SharedMemoryID
parameter from the system and erases the shared memory segment and data
structure associated with it."
The same with Solaris. I haven't checked the others. 

And the problem with your approach is that since shmctl with IPC_RMID works
differently, your program won't work. And don't hold your breath that the
will fix the behaviour that is blessed by POSIX just because Linux
behaviour maybe makes more sense.

Bye, Dragan

-- 
Dragan Cvetkovic, 

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

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

Date: 11 Mar 2001 22:10:44 -0500
From: "Gene Heskett" <[EMAIL PROTECTED]>
Subject: Re: I2C port

Gene Heskett sends Greetings to cfk ;

> Dear Aminudin:
>    I2C stands for Inter Integrated Circuit. It is a two wire
>    connection
> usually between chips on a circuit board. It was created by Philips
> some years back to support slow speed (it runs about 100kbits/sec)
> configuration and control of chips on a circuit board. It sort of is
> like a serial port, but unless you are trying to do hardware
> development, you won't be connecting it to either a serial or
> parallel port. You will frequently find references to it in relation
> to digital video as it is the default control mechanism for such
> chips as the SAA7114 and all of its cousins.

It is also used as the bus thru which the hardware sensors on the board,
if there are any, can report back to scanning utils such things as the
cpu core voltages, cpu temperatures, installed memory by brand name and
size and probably half a dozen other board monitoring functions I've
left out.

See the utility program 'lm-sensors' as one such monitoring util.

Cheers, Gene
-- 
  Gene Heskett, CET, UHK       |Amiga A2k Zeus040, Linux @ 500mhz 
        email gene underscore heskett at iolinc dot net
#Amiga based X10 home automation program EZHome, see at:#
 <http://www.thirdwave.net/~jimlucia/amigahomeauto>
This messages reply content, but not any previously quoted material,
is � 2001 by Gene Heskett, all rights reserved.
-- 


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

From: [EMAIL PROTECTED]
Subject: Re: why is mmap() unhappy??
Date: Mon, 12 Mar 2001 04:21:48 -0000

On 11 Mar 2001 22:02:13 -0500 Dragan Cvetkovic <[EMAIL PROTECTED]> wrote:

| Kasper Dupont <[EMAIL PROTECTED]> writes:
|
|> The solution I suggested works fine on Linux, I've
|> never tried it on other systems. But since this is
|> the only way to ensure segments get freed, I will
|> continue to use it and suggest it, and I will
|> consider systems not allowing it to bre broken.
|         
| OK, try your solution on other major UNIX platforms (Solaris, AIX, HP-UX
| etc.) and let's talk again afterwards. 
|  
|> 
|> The man page has this to say about IPC_RMID:
|> 
|>        IPC_RMID    is  used  to mark the segment as destroyed. It
|>                    will actually  be  destroyed  after  the  last
|>                    detach.   (I.e., when the shm_nattch member of
|>                    the associated structure  shmid_ds  is  zero.)
|>                    The  user  must  be the owner, creator, or the
|>                    super-user.
|
| I know. I have read the man page on Linux. The problem is that man pages on
| other Unices don't say it. For example, this is what AIX 4.3.3 shmctl(2)
| man page says:
|
| "IPC_RMID Removes the shared memory identifier specified by the SharedMemoryID
| parameter from the system and erases the shared memory segment and data
| structure associated with it."
| The same with Solaris. I haven't checked the others. 
|
| And the problem with your approach is that since shmctl with IPC_RMID works
| differently, your program won't work. And don't hold your breath that the
| will fix the behaviour that is blessed by POSIX just because Linux
| behaviour maybe makes more sense.

Before there was POSIX, some systems were just not as well designed.
Now that there is POSIX, perhaps this has not improved?

So suggest something that works.

I need to be able to set up a shared object AND not have resources
left lingering around if a process dies prematurely, or is killed.
I'm not sure about others, but I know that I need to be able to do
this in such a way that backing store space allocation is in swap
space.

If there is no available way that works universally, then we have
no choice but to try something that works less than universally.
At that point we have to make the choice, and I tend to choose to
work with designs that make more sense.

-- 
=================================================================
| Phil Howard - KA9WGN |   Dallas   | http://linuxhomepage.com/ |
| [EMAIL PROTECTED] | Texas, USA | http://phil.ipal.org/     |
=================================================================

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

From: [EMAIL PROTECTED] (Alexander Viro)
Subject: Re: why is mmap() unhappy??
Date: 11 Mar 2001 23:39:03 -0500

In article <[EMAIL PROTECTED]>,
 <[EMAIL PROTECTED]> wrote:

>Before there was POSIX, some systems were just not as well designed.
>Now that there is POSIX, perhaps this has not improved?
>
>So suggest something that works.

Suggestion: stop bothering with Missed'em'V shared memory and use the
right thing. Namely, create a file on tmpfs, mmap it and unlink when
you want it to become invisible.  Will work on Solaris, *BSD and Linux (2.4)
(s/tmpfs/ramfs). Normal semantics of unlink() applies - when the last
user of file with i_nlink==0 releases it the file is destroyed.

That's how shared memory should've been implemented in the first place,
instead of wanking with additional syscalls. 


-- 
"You're one of those condescending Unix computer users!"
"Here's a nickel, kid.  Get yourself a better computer" - Dilbert.

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

From: [EMAIL PROTECTED] (Grant Edwards)
Subject: Re: I2C port
Date: Mon, 12 Mar 2001 04:59:35 GMT

In article <eRVq6.10511$[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote:
>Dear Aminudin:
>    I2C stands for Inter Integrated Circuit. It is a two wire connection
>usually between chips on a circuit board. It was created by Philips some
>years back to support slow speed (it runs about 100kbits/sec) configuration
>and control of chips on a circuit board. It sort of is like a serial port,
>but unless you are trying to do hardware development, you won't be
>connecting it to either a serial or parallel port. You will frequently find
>references to it in relation to digital video as it is the default control
>mechanism for such chips as the SAA7114 and all of its cousins.

It's also very common for connecting small memory devices to things.  For a
few pennies, you can get a 1Kbit I2C eeprom which is handy for storing
things like MAC addresses on NICs (or any other serialization type info),
boot-up configuration info for diskless widgets, and other miscellaneous
stuff that doesn't need to be changed very often or accessed frequently or
quickly.

-- 
Grant Edwards                   grante             Yow!  With YOU, I can be
                                  at               MYSELF... We don't NEED
                               visi.com            Dan Rather...

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


** 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