This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 1.7.0 sem_open


On Jun 12 01:50, Pedro Izecksohn wrote:
>   Does the function sem_open work for anyone using Cygwin 1.7.0 ?

Yes.

>   How to use semtool ?

What is semtool?

>   I wrote an example that works on Jaunty on x86-64 but not on Cygwin:
> http://www.izecksohn.com/pedro/c/semaphores/semaphores.tar.gz

Works for me.

  $ gcc -g test.c -o test
  $ ./test /my-sem
  Press ENTER to delete the semaphore or press Control c to its persistence.

I guess I see what you mean:

  $ ./test my-sem
  sem_open: Invalid argument

Maybe I was trying to be over-exact?  sem_open creates a file in
/dev/shm.  The semaphore name is expected to be an absolute pathname.

SUSv4 states:

  The name argument conforms to the construction rules for a pathname,
  except that the interpretation of <slash> characters other than the
  leading <slash> character in name is implementation-defined, [...]

  If name begins with the <slash> character, then processes calling
  sem_open() with the same value of name shall refer to the same semaphore
  object, as long as that name has not been removed. If name does not
  begin with the <slash> character, the effect is implementation-defined.

In my implementation "implementation-defined" means, that the leading
slash is necessary.

Hmm.  I guess I have to lift this restriction.  However, this will very
likly result in "/sem-name" refering the same semaphore as "sem-name".

>   Also: gcc4 does not understand the option "-lrt" so it must be removed.

Even if linking against librt.a would be necessary on Cygwin, which it
isn't, the gcc call is wrong.  The libs must always follow the object
files which request symbols from the lib:

  gcc -lfoo need-foo.c  <-- wrong
  gcc need-foo.c -lfoo  <-- right

That's a restriction of ... I'm not quite sure, either some Windows
rules or in the ld implementation when building PE/COFF files.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]