Cross-Platform Portability
You want to read the design guidelines before writing any new code. The following documents issues I had trying to compile on FreeBSD.
Contents
Target OS
The following target OS are mentioned explicitly in the source code:
- Linux
- Darwin / MacOS X
- Windows
- FreeBSD
- OpenBSD
Portability Issues
pthreads
autoclean.cpp uses pthread_kill which is only available since MacOS X 10.2 signalmonitor.cpp uses (although commented out) pthread_kill, too.
sendfile
Sendfile an optimization for copying files to the network, often associated with the zero-copy concept where unneeded transfer of buffers between kernel and userland is avoided. (as are unneeded copies in the kernel) libmythupnp uses it to send files via HTTP. It is availible on the following OS:
- FreeBSD since shortly before release 3.1
- Darwin 9 / MacOS 10.5
- Linux since xxx
- Solaris since xxx
- HPUX since xxx
- AIX since xxx
Linux and Solaris share one variant. While all other unices share another. With the latter allowing for adding additional data to be sent before and after the file within one function call. The Apache Portable Runtime library has platform independent support for sendfile. This optimization is of interest especially for lightweight backends with many or resource hungry frontends. (Think of a small SOHO NAS device running mythbackend with some USB DVB receivers and some HD UPNP frontends)
64bit off_t
Didn't we leave 32bit off_t land behind like 7 years ago? Only references on current OS having 32bit is Linux. This applies to lseek64 and alike, too.
configure and shells
Our (based on FFmpeg's) configure script provides utility function to hide differences between shells. These are useful when /bin/sh is not bash.
Avoid whitespace around variable manipulation, as the following will break on FreeBSD at least.
VAR = "$VAR addsomething"
Use the function append
instead. (removing the whitespace around then equal sign might work, but we have append
)
Sources
Apple Developer Connection - Technical Note TN2071 - Porting Command Line Unix Tools to Mac OS X http://developer.apple.com/technotes/tn2002/tn2071.html