//******************************************************************************
///
/// @file /macintosh/config/syspovconfig.h
///
/// configuration file for macintosh platform
///
/// @copyright
/// @parblock
///
/// Unofficial Macintosh GUI port of POV-Ray 3.x.x
/// Copyright 2002-2017 Yvo Smellenbergh
///
/// This port of POV-Ray is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License, or (at your option) any later version.
///
/// This port of POV-Ray is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
/// GNU Affero General Public License for more details.
///
/// You should have received a copy of the GNU Affero General Public License
/// along with this program.  If not, see <http://www.gnu.org/licenses/>.
///
/// ----------------------------------------------------------------------------
///
/// This unofficial port of POV-Ray is based on the Persistence of Vision Ray
/// Tracer ('POV-Ray') version 3.x.x, Copyright 1991-2017 Persistence of Vision
/// Raytracer Pty. Ltd.
/// ----------------------------------------------------------------------------
///
/// POV-Ray is based on the popular DKB raytracer version 2.12.
/// DKBTrace was originally written by David K. Buck.
/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
///
/// @endparblock
///
//******************************************************************************


#ifndef POVRAY_MACINTOSH_SYSPOVCONFIG_H
	#define POVRAY_MACINTOSH_SYSPOVCONFIG_H

//	#define fseek64(stream,offset,whence) fseeko(stream,offset,whence)
//	#define lseek64(handle,offset,whence) lseek(handle,offset,whence)
#define POV_LSEEK(handle,offset,whence) lseek(handle,offset,whence)
#define POV_OFF_T off_t

// C++ variants of C standard headers
#include <cmath>
#include <cstdarg>

// C++ standard headers
#include <algorithm>
#include <exception>
#include <limits>
#include <list>
#include <memory>
#include <stdexcept>
#include <string>
#include <vector>

// boost headers
#include <boost/intrusive_ptr.hpp>

#if defined(__i386__)
#define POVRAY_PLATFORM_NAME "Macintosh 32Bit"
#elif defined(__x86_64__)
#define POVRAY_PLATFORM_NAME "Macintosh 64Bit"
#endif
	//#include <fcntl.h>

    using std::max;
	using std::min;


	// the following types are used extensively throughout the POV source and hence are
	// included and named here for reasons of clarity and convenience.

	// when we say 'string' we mean std::string
	using std::string;

	// and vector is a std::vector
	using std::vector;

	// yup, list too
	using std::list;

	// runtime_error is the base of our Exception class, plus is referred
	// to in a few other places.
	using std::runtime_error;

// we use the C++11 standard shared pointers
using std::shared_ptr;
using std::weak_ptr;
using std::dynamic_pointer_cast;
using std::static_pointer_cast;
using std::const_pointer_cast;

using boost::intrusive_ptr;


	#define METADATA_PLATFORM_STRING POVRAY_PLATFORM_NAME
	#define METADATA_COMPILER_STRING __VERSION__

	#define POV_RAY_IS_OFFICIAL 0

//#if defined(__GNUC__)
//#define POV_COMPILER_INFO "\nCompiler: gcc " __VERSION__
//#else
#define POV_COMPILER_INFO "\nCompiler: " __VERSION__
//#endif

	#define NEW_LINE_STRING "\n"  // default
	#define SYS_DEF_EXT     ""
	#define POV_FILE_SEPARATOR_2  '/'
	#define POV_FILE_SEPARATOR '/'
	#define DEFAULT_OUTPUT_FORMAT    kPOVList_FileType_PNG

#define HAVE_NAN
	#define IFF_SWITCH_CAST (long)

	#define NON_UNIX_OPENEXR_HEADERS
	

	#define MEM_STATS 1 

	// After Stroustrop in _The C++ Programming Language, 3rd Ed_ p. 88
	#ifndef NULL
		const int NULL=0;
	#endif
 

	#define POV_LONG long long

	#define POV_DELETE_FILE(name)  unlink(name)

	# define FILE_NAME_LENGTH   PATH_MAX
	#ifndef MAX_PATH
		#define MAX_PATH PATH_MAX
	#endif

	// use a larger buffer for more efficient parsing
	#define DEFAULT_ITEXTSTREAM_BUFFER_SIZE 65536

	#define DEFAULT_DISPLAY_GAMMA 1.8
	
	#define DEFAULT_DISPLAY_GAMMA_TYPE          kPOVList_GammaType_SRGB

	#define POV_ISNAN(x) std::isnan(x)

	#define POV_ISINF(x) std::isinf(x)

	#define POV_ISFINITE(x) (!POV_ISNAN(x) && !POV_ISINF(x))
	#define POV_MULTITHREADED 1


	/// Specifies the person or organization responsible for this build.
	/// @attention Please set this to your real name, and/or include a working email or website address to contact you.
	#define BUILT_BY "Yvo Smellenbergh - yvo.s@gmx.net"
	//#error Please fill in BUILT_BY, then remove this line

	/*options for optimized noise*/
 	#define MACHINE_INTRINSICS_H <x86intrin.h>
	#define ALIGN32 __attribute__ ((aligned(32)))

	#define POV_CPUINFO         CPUInfo::GetFeatures()
	#define POV_CPUINFO_DETAILS CPUInfo::GetDetails()
	#define POV_CPUINFO_H       "cpuid.h"

	/// XCode compiler does support all of these
	#define HAVE_ASM_AVX
	#define HAVE_ASM_AVX2
	#define HAVE_ASM_FMA3
	#define HAVE_ASM_FMA4
	// Decide which optimized code to enable.
	#if defined(HAVE_ASM_AVX)
		#define TRY_OPTIMIZED_NOISE                 // optimized noise master switch.
		#define TRY_OPTIMIZED_NOISE_AVX_PORTABLE    // AVX-only compiler-optimized noise.
		#define TRY_OPTIMIZED_NOISE_AVX             // AVX-only hand-optimized noise (Intel).
	#endif

	#if defined(DISABLE_AVX)
		#define DISABLE_OPTIMIZED_NOISE_AVX
		#define DISABLE_OPTIMIZED_NOISE_AVX_PORTABLE
	#endif

	#if defined(HAVE_ASM_AVX) && defined(HAVE_ASM_FMA4)
		#define TRY_OPTIMIZED_NOISE                 // optimized noise master switch.
		#define TRY_OPTIMIZED_NOISE_AVXFMA4         // AVX/FMA4 hand-optimized noise (AMD).
	#endif

	#if defined(DISABLE_AVX) || defined(DISABLE_FMA4)
		#define DISABLE_OPTIMIZED_NOISE_AVXFMA4
	#endif

	#if defined(HAVE_ASM_AVX2) && defined(HAVE_ASM_FMA3)
		#define TRY_OPTIMIZED_NOISE                 // optimized noise master switch.
		#define TRY_OPTIMIZED_NOISE_AVX2FMA3        // AVX2/FMA3 hand-optimized noise (Intel).
	#endif

	#if defined(DISABLE_AVX2) || defined(DISABLE_FMA3)
		#define DISABLE_OPTIMIZED_NOISE_AVX2FMA3
	#endif

#endif // POVRAY_MACINTOSH_SYSPOVCONFIG_H
