<address> Last modified 16 July 1998</address>
<address> <<< Under construction >>></address>
Unix platforms are probably the easiest platforms to port NSPR to. However, if you are not familiar with the structure of the NSPR source tree and its build system, it may take you extra time. Therefore I write this article to document the more mechanical part of the Unix porting task. For certain more "standard" Unix platforms, this may be all you have to do. On other platforms, you may need to do extra work to deal with their idiosyncrasies.
You can use different threading packages to implement NSPR threads. NSPR has a user-level threading library where thread context switches are done by <tt>setjmp/longjmp</tt> or <tt>sigsetjmp/siglongjmp</tt>. This is called the local threads only version of classic NSPR. You should attempt to do a local threads only port first. The classic NSPR source files are in <tt>mozilla/nsprpub/pr/src/threads</tt> and <tt>mozilla/nsprpub/pr/src/io</tt>.
If the platform has pthreads, you can also use pthreads as an implementation strategy. This is referred to as pthreads NSPR. Pthreads NSPR has relatively orthogonal source code in the thread management, thread synchronization, and I/O area. The pthreads source files are in <tt>mozilla/nsprpub/pr/src/pthreads</tt>.
I use the NetBSD port I recently received as an example to illustrate the mechanical part of the porting process.
There are a few new files you need to add:
<tt> cd mozilla/nsprpub/pr/include</tt>
<tt> gmake gencfg</tt>
<tt> gencfg > foo.bar</tt>
Then you use the macro values in <tt>foo.bar</tt> as a basis for the <tt>_xxxos.cfg</tt> file.
Testing Your Port
We have some unit tests in <tt>mozilla/nsprpub/pr/tests</tt>. First a warning: some of the tests are broken. Further, we don't have documentation of our unit tests, so you often need to resort to read the source code to understand what they do. Some of them respond to the <tt>-h</tt> command line option and print a usage message. Henry Sobotka of the OS/2 Mozilla porting project has a web page at <tt><a href="http://www.axess.com/users/sobotka/nsprtest/warpztjs.html">http://www.axess.com/users/sobotka/nsprtest/warpztjs.html</a></tt> with good documentation of the nspr unit tests.
Here are my favorite tests.
For thread management and synchronization:
<tt>cvar -d</tt></li> <tt>cvar2</tt></li> <tt>./join -d</tt></li> <tt>perf</tt></li> <tt>./switch -d</tt></li> <tt>intrupt -d</tt></li>
<tt>cltsrv -d</tt>, <tt>cltsrv -Gd</tt></li> <tt>socket</tt></li> <tt>testfile -d</tt></li> <tt>tmocon -d</tt></li> '<tt>tmoacc -d</tt>' in conjunction with '<tt>writev -d</tt>'</li>
<tt>dlltest -d</tt></li> <tt>forktest</tt></li>