Linux-Development-Apps Digest #455, Volume #7     Wed, 6 Jun 01 07:13:18 EDT

Contents:
  Re: Porting solaris software to Linux ("Norman Black")
  Re: ping works once and hangs
  Re: getopt + optional parameter (Micah Cowan)
  Re: GCC: "unused variable" warning not reported (Micah Cowan)
  displaying images in Gtk ("Rajarshi Guha")
  Re: Porting solaris software to Linux (Kjetil Torgrim Homme)
  Re: inexplicable error (David Tanzer)
  Re: Critical Sections (Kaz Kylheku)
  Re: Cyclic file (Kaz Kylheku)
  Re: global variable in shared library? (Kaz Kylheku)
  Re: global variable in shared library? (Kaz Kylheku)
  Re: tabstops (Kaz Kylheku)
  Re: ping works once and hangs (Nate Eldredge)
  Re: global variable in shared library? (James Cownie)
  Re: displaying images in Gtk ("Glitch")
  Re: displaying images in Gtk (Sergei Organov)
  Re: global variable in shared library? (Jan Atle Ramsli)

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

From: "Norman Black" <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.system,comp.unix.programmer,comp.unix.solaris
Subject: Re: Porting solaris software to Linux
Date: Tue, 5 Jun 2001 15:12:43 -0700
Reply-To: "Norman Black" <[EMAIL PROTECTED]>

I use pthreads on both systems and I use PTHREAD_SCOPE_SYSTEM to get a
consistent scheduling behavior between the two systems. Seems to work for me
just fine.

--
Norman Black
Stony Brook Software
the reply, fubar => ix.netcom

"jamal" <[EMAIL PROTECTED]> wrote in message
news:9fhrtj$cho$[EMAIL PROTECTED]...
> Hi ,
>
> I am new in linux or unix programming in general.
> My company has an application written for Windows and Solaris.
> We plan to port it to Linux. So the easiest should be porting
> Solaris version into Linux version. I wonder what the main issues that I
> should take care of for doing the porting.
> Is it just compatibility between solaris system library and linux system
> library or is there any specific
> problem?
> As I know that all unix system should have the similar API right? So in
what
> part they differ?
> For your imformation the solaris software is compiled using sun cc
compiler,
> but there are some error when I tried to compile
> using gcc, so obviously the compiler difference is one of the
consideration.
>
>
> regards
>
> Jamal
>
>
>
>


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

From: <[EMAIL PROTECTED]>
Subject: Re: ping works once and hangs
Date: 5 Jun 2001 22:49:34 GMT

Nate Eldredge <[EMAIL PROTECTED]> wrote:
> I don't know.  I find it very odd that ping *acknowledges* that it has
> only sent one packet.  If it had tried to send more and failed (due to
> hardware, software, or other problem), it should have reported the
> error.  Or, if it sent the packet, but something kept the packet or
> the reply from arriving, ping should have reported that packet in its
> count of sent packets.  But it doesn't; it says "packets sent: 1".
> That's why I suspect the problem is in ping itself.

If ping is itself broken then why does it work correctly on two of the 
machines with the same disk image?  I've tried copying ping across from 
one machine that worked and it still did the same thing on the other 
machine.  The firewall rules allow all incoming and outgoing icmp packets 
and I can ping the machines remotely.  I unfortunately can't test the 
hardware because all the servers are located in different cities and my
only access is via telnet.  Everything else on these machines work exactly
the way its supposed to.

Mandie

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

Subject: Re: getopt + optional parameter
From: Micah Cowan <[EMAIL PROTECTED]>
Date: 05 Jun 2001 16:35:32 -0700

Felix Natter <[EMAIL PROTECTED]> writes:

> hi,
> 
> I usually use optarg to get a required parameter for an option,
> but if I declare an option with an optional argument (i.e. "c::"),
> optarg is NULL even if an argument is specified.
> 
> Is there another way to get an argument for an option
> (optarg is a GNU extension anyway) ?

AIUI, not optarg but the optional argument "c::" syntax is a GNU
extension.  And optarg works fine for me - can you post the relevant
argument-parsing portion of the offending code and the command line
you're using?

Micah

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

Subject: Re: GCC: "unused variable" warning not reported
From: Micah Cowan <[EMAIL PROTECTED]>
Date: 05 Jun 2001 16:41:06 -0700

[EMAIL PROTECTED] (Mathieu Deziel) writes:

> > > Even when I am using the option -Wall OR -Wunused, I am not warned
> > > about unused variables (I deliberately introduce unused variables to
> > > test the compiler ability to warn).
> 
> Ok, here was my problem: a tab at the end of a line in my makefile caused 
> the Makefile to be read incorrectly.  Thank you all for your help.
> 
> > > Its ability to do so depend on the chosen optimization level.
> > > The information about unused variables is a side product of 
> > > optimizing the code.
> 
> Villy, I don't see how optimization would prevent some
> warnings on the source code to be reported.  The "Unused variable" warning
> relates to the source code itself, not to the compiled code (which, 
> with optimization turned on, might not reflect exactly the source code).
> I haven't done any extensive tests, but changing the optimization level had
> no impact on the warnings reported in my case.
> Do you have some more details about it?  Am I missing something ?

I think that Villy is thinking of the "uninitialized variable"
warning, for which this is true.  man gcc(1).

Micah

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

From: "Rajarshi Guha" <[EMAIL PROTECTED]>
Subject: displaying images in Gtk
Date: Tue, 5 Jun 2001 13:35:34 +0530

Hi,
  I'm a little confused with displaying images in Gtk. I read in a PNG file
and have the pixel data in a 2D array. How can I go about displaying it in a
Gtk window.
Actually, am I right in saying ' a GtkWindow'? Or shoudl I be referring to
GtkPixmap/GdkBitmap....or what??

I'd appreciate it if somebody could explain the process of displaying images
using Gtk.

TIA,

--
=============================================================
Rajarshi Guha

email: [EMAIL PROTECTED]
web: http:/www.psynet.net/jijog



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

From: Kjetil Torgrim Homme <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.system,comp.unix.programmer,comp.unix.solaris
Subject: Re: Porting solaris software to Linux
Date: 06 Jun 2001 05:26:15 +0200

[jamal]

>   I am new in linux or unix programming in general.  My company has
>   an application written for Windows and Solaris.  We plan to port
>   it to Linux. So the easiest should be porting Solaris version into
>   Linux version. I wonder what the main issues that I should take
>   care of for doing the porting.  Is it just compatibility between
>   solaris system library and linux system library or is there any
>   specific problem?

Run, don't walk, to your closest book shop and buy W. Richard Stevens'
books.  They're all very good, you decide which ones you need (sooner
or later you will probably find use for them all).


Kjetil T.

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

Date: Wed, 06 Jun 2001 08:31:39 +0200
From: David Tanzer <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Subject: Re: inexplicable error

jeff wrote:
> 
> Well, I am not sure what DIR is or how the dirent structure works,
> but going entirely from the DIR *the_dir = NULL statement, I would say
> the problem is you have not allocated memory for the pointer.
> In C, this would be malloc(), and in C++ this would be new.

opendir allocates the memory for the DIR, or returns NULL. Maybe the
problem really is BEFORE the opendir. I had some strange segfaults
some time ago, which occured in a completely different function as
where the problem was. The problem was allocating not enough memory
in an init-routine...
 
> Check the man pages for exactly how malloc() works, but I think
> it is
> the_dir = malloc(SIZE_TO_ALLOCATE);
> [...]

cu,
  David.

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

From: [EMAIL PROTECTED] (Kaz Kylheku)
Subject: Re: Critical Sections
Reply-To: [EMAIL PROTECTED]
Date: Wed, 06 Jun 2001 07:14:20 GMT

On Tue, 5 Jun 2001 13:51:53 -0400, Timur Aydin <[EMAIL PROTECTED]> wrote:
>
>"Konstantin Seiler" <[EMAIL PROTECTED]> wrote in message
>news:[EMAIL PROTECTED]...
>> I'm looking for something similar to the Critical Sections used by
>Windows.
>
>The closest that you can come to a critical section is the pthread_mutex_t.
>However, note that pthread_mutex_t can be set up to support or not to
>support recursive locking, while win32 critical sections are always
>recursive. Also, recent versions of C runtime library support timed waits on
>mutexes using pthread_mutex_timedwait, while a critical section doesn't have
>a timeout.

Also, mutexes can be initialized statically, whereas critical sections
require an explicit call. Also, each critical section object can consume
an auto-reset event handle. These are allocated in a lazy way, which
means that the EnterCriticalSection() function potentially acquires a
dynamic resource and can throw a low memory exception.

>I don't know how the two compare performance wise, but if the
>amount of time that the shared resource is kept locked is very short (which
>it should be), their overhead should be negligible.

On x86 NT, at least, the critical section operations appear to be hand written
assembly language. There are some slick tricks, like pulling the thread ID
directly out of FS:[0x18]. 

>However, when examining the CRITICAL_SECTION data structure, there are some
>fields that suggest that the critical section can sometimes "degrade" to a
>kernel object (maybe if the wait time is too long?). Does anybody else know
>more about this? Is there a similar mechanism for pthread mutexes?

No, LinuxThreads mutexes are strictly non-kernel objects. Suspending a thread
is done in a reasonable way, without allocating a kernel semaphore to each
object. A thread suspends by atomically waiting for a signal using
sigsuspend(). Resuming a suspended thread is done using kill() to generate the
restart signal.  The actual interface used by the various LinuxThreads modules
are three inline functions in "restart.h", namely suspend(), restart() and
timedsuspend(). 

The POSIX interface does allow for mutexes which allocate dynamic resources,
whether it be memory or system objects. That is why pthread_mutex_init()
has a return value.

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

From: [EMAIL PROTECTED] (Kaz Kylheku)
Subject: Re: Cyclic file
Reply-To: [EMAIL PROTECTED]
Date: Wed, 06 Jun 2001 07:18:05 GMT

On Tue, 5 Jun 2001 15:01:44 +0200, Moshe Shimoni <[EMAIL PROTECTED]> wrote:
>Hello all,
>I need to write data from a process into a file. I don't want the file size
>to grow too much.
>I can't just truncate the file because I need the latest data. Let's say I
>need always the last 1MB of the file.
>I can rewind the FILE cursor after 1MB but it will not be clear to the user
>to read the file.
>I can also fork and run a system tail command and try to play with it but it
>doesn't seem so simple.
>Isn't there a simple way which manages this thing?

Yes. What you do is you write to two or more files, and rotate among
them. Three log example: when log 1 is considered full, you switch to log 2.
Then when log 2 fills up, you switch to log 3. When that fills up, you
start overwriting log 1.

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

From: [EMAIL PROTECTED] (Kaz Kylheku)
Subject: Re: global variable in shared library?
Reply-To: [EMAIL PROTECTED]
Date: Wed, 06 Jun 2001 07:19:42 GMT

On Tue, 5 Jun 2001 17:23:34 +0800, Wong Ka Chun <[EMAIL PROTECTED]> wrote:
>Hi Bob,
>
>  So, it means that global variables in shared library are indeed visible
>to application. But it is not possible for one to assign a name which may
>not clash with someone else application. In Win32, global variable in DLL
>is not visible to application unless you explicity put it to a shared
>memory region. Why this is not done similar under Linux?

Dude, you have no clue. Shared libraries have capabilities that can run circles
around DLL's.

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

From: [EMAIL PROTECTED] (Kaz Kylheku)
Subject: Re: global variable in shared library?
Reply-To: [EMAIL PROTECTED]
Date: Wed, 06 Jun 2001 07:33:49 GMT

On 5 Jun 2001 21:06:59 +0200, Ulrich Weigand
<[EMAIL PROTECTED]> wrote:
>If you want to do this sort of name space encapsulation on Unix, you have 
>to use some other mechanism -- shared libraries won't do it for you. 

Sure they will. Create a symbolic shared library with -Bsymbolic.
This causes the linker to resolve the library's references to its own
internal symbols, so that its own references won't be overriden at dynamic
link time. So suppose you have an executable with the external
function foo(), and two symbolic libraries each with their own foo().
The three foo's will not interfere with each other in any way;
every object will call its foo().

As a nice side effect, when you link a symbolic library, unresolved references
are errors, just like when you build a Windows DLL.

To restrict the visibility of the identifiers within your library,
use a version script, exactly as you mention later in your article.

I ported a COM object to Linux this way. The symbolic library exported only
DllMain, DllCanUnloadNow, and DllGetClassObject.  I wrote a COM loader which
supports the functions CoGetClassObject, CoInitializeEx and CoUninitialize.
Also a registry layer based over text files, so that the location of the COM
``DLL'' could be fetched by class ID and all that crap.

This COM object used a lot of the same C++ libraries as the executable
loading it, without interference.

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

From: [EMAIL PROTECTED] (Kaz Kylheku)
Subject: Re: tabstops
Reply-To: [EMAIL PROTECTED]
Date: Wed, 06 Jun 2001 07:39:11 GMT

On Tue, 05 Jun 2001 07:13:32 GMT, Charles Wilkins <[EMAIL PROTECTED]> wrote:
>I should be more specific with what I am trying to do. I am in fact
>running vim on Mandrake 8.  I have made some progress for setting the
>behaviour that I prefer, but there is still a minor catch.
>
>With vim, while editing .c and .cpp files specifically, I would like
>the following behavior to be the default:
>Tabstops to be 5 spaces instead of 8.
>No autoindenting at all OR autoindenting to 5 spaces only while in
>functions or subroutines.
>
>Here is what I have done so far, and what it has accomplished.
>In the .vimrc file, I have added the following lines:
>
>" my settings
>set tabstop=5
>set noautoindent

You can have a .vimrc file in the project directory. Having the
editor read a .vimrc from the current directory is a potential
security hole, so this feature won't work unless you 
have :set exrc in your home directory .vimrc.

Another somewhat more intrusive solution is to embed VIM directives into
coments within your source files themselves, e.g

    /* :vim:set ts=5: */

When VIM loads the file, it will find this and obey it.

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

From: Nate Eldredge <[EMAIL PROTECTED]>
Subject: Re: ping works once and hangs
Date: 06 Jun 2001 00:49:37 -0700

<[EMAIL PROTECTED]> writes:

> Nate Eldredge <[EMAIL PROTECTED]> wrote:
> > I don't know.  I find it very odd that ping *acknowledges* that it has
> > only sent one packet.  If it had tried to send more and failed (due to
> > hardware, software, or other problem), it should have reported the
> > error.  Or, if it sent the packet, but something kept the packet or
> > the reply from arriving, ping should have reported that packet in its
> > count of sent packets.  But it doesn't; it says "packets sent: 1".
> > That's why I suspect the problem is in ping itself.
> 
> If ping is itself broken then why does it work correctly on two of the 
> machines with the same disk image?

I don't know; I can't explain it.  You might md5sum ping and your
system libraries (and possibly kernel) to see if they really are still
identical.

Did you try stracing ping, though, as I suggested?

  I've tried copying ping across from 
> one machine that worked and it still did the same thing on the other 
> machine.  The firewall rules allow all incoming and outgoing icmp packets 
> and I can ping the machines remotely.  I unfortunately can't test the 
> hardware because all the servers are located in different cities and my
> only access is via telnet.  Everything else on these machines work exactly
> the way its supposed to.

-- 

Nate Eldredge
[EMAIL PROTECTED]

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

From: James Cownie <[EMAIL PROTECTED]>
Subject: Re: global variable in shared library?
Date: Wed, 06 Jun 2001 08:18:26 GMT

Ulrich Weigand wrote:
  A very nice summary of naming issues with shared libraries and ...

> B.t.w. nowadays Unix toolchains (including the GNU toolchain used on Linux)
> have introduced various additions to the simple model described above.
> With the GNU linker, it is in fact now possible to decide on a symbol-
> by-symbol basis which global symbols should be visible outside a shared
> library and which ones not.
> 
> To do so, you'll need to create a 'version script' which looks like:
> 
> VERSION_TAG {
>   global:
>      foo;
>   local:
>      bar;
> };
> 
> where you list under 'global' those names that should be visible outside
> and under 'local' those that shouldn't; you can use wildcards.  You then
> specify the version script as argument to the link process. Check out the
> ld info pages ('VERSION command') for more details.
> 
> Note that this is not portable; other linkers on other Unix platforms
> may offer similar features, but the syntax will be completely different ...

It just seems worth pointing out that while this is not portable, neither are
the M$ language extensions used when dealing with their shared libraries.

-- Jim 

James Cownie    <[EMAIL PROTECTED]>
Etnus, LLC.     +44 117 9071438
http://www.etnus.com

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

From: "Glitch" <[EMAIL PROTECTED]>
Subject: Re: displaying images in Gtk
Date: Wed, 06 Jun 2001 03:54:33 -0400

In article <9fk780$4ga6l$[EMAIL PROTECTED]>, "Rajarshi Guha"
<[EMAIL PROTECTED]> wrote:

> Hi,
>   I'm a little confused with displaying images in Gtk. I read in a PNG
>   file
> and have the pixel data in a 2D array. How can I go about displaying it
> in a Gtk window.
> Actually, am I right in saying ' a GtkWindow'? Or shoudl I be referring
> to GtkPixmap/GdkBitmap....or what??
> 
> I'd appreciate it if somebody could explain the process of displaying
> images using Gtk.
> 
> TIA,
> 

why not subscribe to the gtk mailing lists? They exist solely for people
programming in Gtk/Glade/Gdk with whatever language bindings.

goto gtk.org or gnome.org for more info

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

From: Sergei Organov <[EMAIL PROTECTED]>
Subject: Re: displaying images in Gtk
Date: 06 Jun 2001 14:11:58 +0400

"Rajarshi Guha" <[EMAIL PROTECTED]> writes:
> Hi,
>   I'm a little confused with displaying images in Gtk. I read in a PNG file
> and have the pixel data in a 2D array. How can I go about displaying it in a
> Gtk window.

<http://www.gtk.org/faq/#AEN654>


[...]


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

Date: Wed, 06 Jun 2001 14:50:00 +0200
From: Jan Atle Ramsli <[EMAIL PROTECTED]>
Subject: Re: global variable in shared library?

Wong Ka Chun wrote:
> 
> Hi Bob,
> 
>   So, it means that global variables in shared library are indeed visible
> to application. But it is not possible for one to assign a name which may
> not clash with someone else application. In Win32, global variable in DLL
> is not visible to application unless you explicity put it to a shared
> memory region. Why this is not done similar under Linux?

This may be easier if you state excactly what it is you want to achieve.
If you want to exploit side-effects from the dynamic loading of
functions from a DLL, there may be a better way to obtain the same
result.
Please give a small example of the Win32 code with a short description
of what part is relevant.

This will make it easier to understand what you try to do, and probably
'filter' away the kind of responses you are not interested in.

Atle

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


** 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.apps 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-Apps Digest
******************************

Reply via email to