[M3devel] eliminating platform-specifity of pthread_t?

Jay jay.krell at cornell.edu
Mon Mar 16 02:39:51 CET 2009


pthread_t
 

1) do nothing; leave it as platform-dependent
 

2) Widen it to INTEGER or ADDRESS and declare that is portable and correct.
  Put in an assert that pthread_t fits in size_t/void*.
  This is often correct, and where it isn't, it is probably ok.
  correct: OpenBSD, FreeBSD, NetBSD, all or probably all 32bit platforms, Cygwin, Darwin, Linux
  wasteful: 64bit HP-UX, 64bit Solaris; which apparently both always use a 32bit integer for pthread_t
  not yet determined: Tru64, AIX, Irix (including 32bit AIX, Irix; I have these systems.)
 

Given that its neighbors on both sides are pointers, this isn't likely
to consume any extra space on most platforms (but maybe on AMD64_SOLARIS?)
 

Odds are high that passing a pointer instead of 32bit integer is
ok on all platforms, but wrappers can be introduced to make that safer,
like how I did for mode_t.
 

3) Some sort of C wrapping, that I haven't thought of yet.
 Well, there are some candidates, more and less satisfactory.
  3a) heap allocate it; not satisfactory
  3b) Put it at the end of Activation and use it with C wrappers
    fairly satisfactory, just that the system-dependent FloatMode.ThreadState
    and RTHeapRep.ThreadState have to be accounted for, somehow.
    Either by having the C know their definition on all platforms, ok.
    Or by having the Modula-3 code pass that data to the C code.
 
  These are both signficantly less satisfactory imho than any other C
   wrapping I have put in.
 

I think #2 with wrappers is my favorite.
 

 - Jay


More information about the M3devel mailing list