Merge pull request #842 from whorfin/master

Port to OmniOS/Solaris
This commit is contained in:
Andrew Bauer 2015-05-19 08:35:22 -05:00
commit 8d0bdc4cf1
15 changed files with 83 additions and 2 deletions

17
README-OmniOS.txt Normal file
View File

@ -0,0 +1,17 @@
The following has worked [with newest patches] with buildtools and gcc48 from pkg,
and ffmpeg2, LAMP and libjpeg-turbo from pkgin for OmniOS r151012 and r151014
./bootstrap.sh
# omnios default is 32bit, -m64 is unneeded if perl/libs versions match
export CXXFLAGS=-m64
export CFLAGS=-m64
export PERL=/usr/perl5/5.16.1/bin/amd64/perl
export CPPFLAGS="-I/opt/local/include/ffmpeg2 -I/opt/local/include/mysql
-I/opt/local/include"
# need the -R for runtime load library
export LDFLAGS="-L/opt/local/lib/ffmpeg2 -L/opt/local/lib -R/opt/local/lib
-R/opt/local/lib/ffmpeg2"
export ZM_SSL_LIB=openssl
# need -lsocket -lnsl for recv/send to work, and latest version needs -lsendfile
./configure --with-webdir=/opt/local/share/httpd/htdocs/zm --with-extralibs="-lsocket -lnsl -lsendfile" --with-cgidir=/opt/local/libexec/cgi-bin --with-webuser=www --with-webgroup=www --with-webhost=MACHINENAME.local

View File

@ -34,6 +34,11 @@ case $host_os in
HOST_OS='BSD'
AC_DEFINE(BSD,1,"This is a BSD system")
;;
*solaris*)
# Do something specific for Solaris
HOST_OS='solaris'
AC_DEFINE(SOLARIS,1,"We are running a Solaroid OS [tested on OmniOS]")
;;
*)
#Default Case
AC_MSG_ERROR([Your platform is not currently supported])

View File

@ -834,6 +834,8 @@ sub killAll
if ( '@HOST_OS@' eq 'BSD' )
{
$killall = 'killall -';
} elsif ( '@HOST_OS@' eq 'solaris' ) {
$killall = 'pkill -';
} else {
$killall = 'killall -q -s ';
}

View File

@ -294,7 +294,7 @@ sub systemdRunning
{
my $result = 0;
my $output = qx(ps -o comm="" 1);
my $output = qx(ps -o comm="" -p 1);
chomp( $output );
if ($output =~ /systemd/) {
@ -309,7 +309,7 @@ sub calledBysystem
my $result = 0;
my $ppid = getppid();
my $output = qx(ps -o comm="" $ppid);
my $output = qx(ps -o comm="" -p $ppid);
chomp( $output );
if ($output =~ /^(?:systemd|init)$/) {

View File

@ -25,6 +25,10 @@
#define ZM_H
#include "zm_config.h"
#ifdef SOLARIS
#undef DEFAULT_TYPE // pthread defines this which breaks StreamType DEFAULT_TYPE
#include <string.h> // define strerror() and friends
#endif
#include "zm_logger.h"
#include <stdint.h>

View File

@ -23,7 +23,11 @@
#include "zm.h"
#include "zm_coord.h"
#ifndef SOLARIS
#include <math.h>
#else
#include <cmath>
#endif
//
// Class used for storing a box, which is defined as a region

View File

@ -36,6 +36,10 @@
#include <sys/param.h>
#include <netinet/tcp.h>
#ifdef SOLARIS
#include <sys/filio.h> // define FIONREAD
#endif
int CommsBase::readV( int iovcnt, /* const void *, int, */ ... )
{
va_list arg_ptr;

View File

@ -27,6 +27,12 @@
#define AV_ERROR_MAX_STRING_SIZE 64
#endif
#ifdef SOLARIS
#include <sys/errno.h> // for ESRCH
#include <signal.h>
#include <pthread.h>
#endif
FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::string &p_method, const std::string &p_options, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) :
Camera( p_id, FFMPEG_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture ),
mPath( p_path ),

View File

@ -1580,7 +1580,11 @@ Image *Image::Highlight( unsigned int n_images, Image *images[], const Rgb thres
{
uint8_t *psrc = images[j]->buffer+c;
#ifndef SOLARIS
if ( (unsigned)abs((*psrc)-RGB_VAL(ref_colour,c)) >= RGB_VAL(threshold,c) )
#else
if ( (unsigned)std::abs((*psrc)-RGB_VAL(ref_colour,c)) >= RGB_VAL(threshold,c) )
#endif
{
count++;
}

View File

@ -542,7 +542,10 @@ void Logger::logPrint( bool hex, const char * const file, const int line, const
if ( (syscall(SYS_thr_self, &tid)) < 0 ) // Thread/Process id
# else
// SOLARIS doesn't have SYS_gettid; don't assume
#ifdef SYS_gettid
if ( (tid = syscall(SYS_gettid)) < 0 ) // Thread/Process id
#endif // SYS_gettid
#endif
#endif // HAVE_SYSCALL
#endif

View File

@ -55,6 +55,11 @@
#include <sys/shm.h>
#endif // ZM_MEM_MAPPED
// SOLARIS - we don't have MAP_LOCKED on openSolaris/illumos
#ifndef MAP_LOCKED
#define MAP_LOCKED 0
#endif
//=============================================================================
std::vector<std::string> split(const std::string &s, char delim) {
std::vector<std::string> elems;

View File

@ -20,7 +20,11 @@
#include "zm.h"
#include "zm_poly.h"
#ifndef SOLARIS
#include <math.h>
#else
#include <cmath>
#endif
void Polygon::calcArea()
{

View File

@ -26,6 +26,10 @@
#include <errno.h>
#include <netdb.h>
#ifdef SOLARIS
#include <sys/filio.h> // FIONREAD and friends
#endif
RemoteCameraHttp::RemoteCameraHttp( int p_id, const std::string &p_method, const std::string &p_host, const std::string &p_port, const std::string &p_path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) :
RemoteCamera( p_id, "http", p_host, p_port, p_path, p_width, p_height, p_colours, p_brightness, p_contrast, p_hue, p_colour, p_capture )
{

View File

@ -35,6 +35,7 @@
class ThreadException : public Exception
{
private:
#ifndef SOLARIS
pid_t pid() {
pid_t tid;
#ifdef __FreeBSD__
@ -50,6 +51,9 @@ pid_t pid() {
#endif
return tid;
}
#else
pthread_t pid() { return( pthread_self() ); }
#endif
public:
ThreadException( const std::string &message ) : Exception( stringtf( "(%d) "+message, (long int)pid() ) ) {
}
@ -213,7 +217,11 @@ protected:
Mutex mThreadMutex;
Condition mThreadCondition;
#ifndef SOLARIS
pid_t mPid;
#else
pthread_t mPid;
#endif
bool mStarted;
bool mRunning;
@ -221,6 +229,7 @@ protected:
Thread();
virtual ~Thread();
#ifndef SOLARIS
pid_t id() const
{
pid_t tid;
@ -238,6 +247,12 @@ protected:
#endif
return tid;
}
#else
pthread_t id() const
{
return( pthread_self() );
}
#endif
void exit( int status = 0 )
{
//INFO( "Exiting" );

View File

@ -33,6 +33,7 @@ private:
class TimerException : public Exception
{
private:
#ifndef SOLARIS
pid_t pid() {
pid_t tid;
#ifdef __FreeBSD__
@ -48,6 +49,9 @@ private:
#endif
return tid;
}
#else
pthread_t pid() { return( pthread_self() ); }
#endif
public:
TimerException( const std::string &message ) : Exception( stringtf( "(%d) "+message, (long int)pid() ) )
{