This is the mail archive of the 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: cygipc (and PostgreSQL) XP problem resolved!

Corinna Vinschen wrote:

Is there actually a need to convert key_t to 64 bit?


with old 32bit key_t, cygipc uses this to create a key for a given filepath and id#:

  key = ((st.st_ino & 0xffff) | ((st.st_dev & 0xff) << 16)
         | ((id & 0xff) << 24));

Given the sizes of the various fields of st, there are obvious problems with aliasing here.

cygdaemon (and cygipc) with 64bit key_t uses:

  /* dev_t is short for cygwin
   * ino_t is long for cygwin
   * and we need 8 bits for the id.
   * thus key_t is long long.
  return ((long long) statbuf.st_dev << (5*8)) |
          (statbuf.st_ino << (8) ) |
          (id & 0x00ff);

Currently, the above code is in winsup/cygwin/ -- but if key_t is 32 bits, the (long long) cast gets recast down to 32bits by the 'return' statement. Which means that the ftok() function currently exported by cygwin is more or less broken -- fortunately nothing uses that except cygdaemon.


Unsubscribe info:
Problem reports:

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