8#define _USE_MATH_DEFINES  
   16#if defined(_WIN32) && defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) 
   22#include <android/log.h> 
   24#elif defined(__APPLE__) && defined(__MACH__) 
   25#include <TargetConditionals.h> 
   26#include <AvailabilityMacros.h> 
   38#define SPB_VERSION_STRING  "0.8.24" 
   41#define SPB_UPDATE_LEVEL    24 
   42#define SPB_VERSION_ID      (SPB_VERSION * 1000 + SPB_REVISION) 
   49#define SPB_CHECK_VERSION(version, revision, update) \ 
   50    (SPB_VERSION > (version) || \ 
   51     (SPB_VERSION == (version) && SPB_REVISION > (revision)) || \ 
   52     (SPB_VERSION == (version) && SPB_REVISION == (revision) && SPB_UPDATE_LEVEL >= (update))) 
 
   54typedef int (*spMainFunc)(
int argc, 
char *argv[]);
 
   56#if defined(__CYGWIN__) 
   57#if !defined(_WIN32_IE) 
   58#define _WIN32_IE 0x0400 
   63#if !defined(__CYGWIN32__) 
   68#if (TARGET_RT_MAC_MACHO || defined(__APPLE__)) && !defined(MACOSX) 
   74#if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || (defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR) 
   79#if !defined(IPHONE) && !defined(__LP64__) && !defined(COCOA) 
   80#ifndef TARGET_API_MAC_CARBON 
   81#define TARGET_API_MAC_CARBON 1 
   90#if defined(__LP64__) && !defined(MACOSX64) 
   99#if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || defined(__MRC__) ||\ 
  100    defined(THINK_C) || defined(__SC__) || (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1) 
  102#if !defined(powerc) && defined(__MRC__) 
  108#if defined(MACOS) && !defined(MACOSX) 
  110#ifndef TARGET_API_MAC_CARBON 
  111#define TARGET_API_MAC_CARBON 0 
  115#if TARGET_API_MAC_CARBON 
  116#ifndef HIGH_LEVEL_EVENT 
  117#define HIGH_LEVEL_EVENT 
  121#if defined(__CYGWIN32__) || defined(__MINGW32__) || (!defined(_WIN32) && !defined(MACOS9)) || defined(ANDROID) 
  122#define SP_SUPPORT_UTF8_STRING 
  127#define __P(args) args 
  135#if defined(__MINGW64__) || defined(__CYGWIN64__) 
  136#define spLong long long 
  137#define spULong unsigned long long 
  139#define spLong __int64 
  140#define spULong unsigned __int64 
  144#define spULong unsigned long 
  147#if defined(_WIN32) && !(defined(__CYGWIN32__) || defined(__MINGW32__)) 
  148#define SP_SUPPORT_64BIT_INT 
  149#define spLong64 __int64 
  150#define spULong64 unsigned __int64 
  153#define SP_SUPPORT_64BIT_INT 
  154#define spLong64 SInt64 
  155#define spULong64 UInt64 
  158#define SP_SUPPORT_64BIT_INT 
  159#define spLong64 long long 
  160#define spULong64 unsigned long long 
  163#if defined(__alpha__) || defined(__alpha) || defined(__LP64__) || defined(__ia64__) || \ 
  164    defined(__s390x__) || defined(__ppc64__) || defined(__x86_64__) 
  166#define spULong32 unsigned int 
  167#define SP_LONG32_IS_INT 
  170#define spULong32 unsigned long 
  171#define SP_LONG32_IS_LONG 
  190#define spLONG spLong32 
  191#define spULONG spULong32 
  195#define spULONG unsigned long 
  197#define spDWORD spULONG 
  198#define spINT8 signed char 
  200#define spBYTE unsigned char 
  201#define spWORD unsigned short 
  203#if defined(_WIN32) && !defined(__CYGWIN32__) 
  204#define spFileOffset __int64 
  205#elif defined(HAVE_FSEEKO) 
  206#define spFileOffset off_t 
  208#define spFileOffset long 
  211#if defined(_WIN32) && !defined(__CYGWIN32__) 
  212#if defined(_MSC_VER) && (_MSC_VER >= 1400) 
  213#define HAVE_VSPRINTF_S 1 
  214#define HAVE_SPRINTF_S 1 
  215#define HAVE_FOPEN_S 1 
  216#define HAVE_STRCPY_S 1 
  217#define HAVE_STRCAT_S 1 
  218#define HAVE_STRNCPY_S 1 
  219#define HAVE_STRNCAT_S 1 
  220#define HAVE_SPLITPATH_S 1 
  221#define HAVE_DUPENV_S 1 
  222#define HAVE_SSCANF_S 1 
  224#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) 
  225#define HAVE_VSNPRINTF 1 
  226#define HAVE_SNPRINTF 1 
  229#if defined(sun) && !defined(HAVE_MEMCPY) 
  230#define memmove(dst,src,len) bcopy((char *)(src),(char *)(dst),(int)(len)) 
  231#define memcpy(dst,src,len) bcopy((char *)(src),(char *)(dst),(int)(len)) 
  232#define memcmp(b1,b2,len) bcmp((char *)(b1),(char *)(b2),(int)(len)) 
  235#define SP_MAX_NAME 128 
  236#define SP_MAX_LINE 192 
  237#define SP_MAX_PATHNAME 256 
  238#define SP_MAX_MESSAGE  1024 
  239#define SP_MAX_IE_URL   2084 
  240#define SP_MAX_SUFFIX_SIZE 8 
  241#define SP_MAX_LANGUAGE 32   
  242#define SP_EPSILON  2.2204460492503131e-016 
  243#define SP_TINY_NUMBER 1.0e-10 
  244#define SP_EPSILONF 1.192092896e-07f 
  245#define SP_TINY_NUMBERF 1.0e-10f 
  252#define SP_TRUE_STRING  "1"      
  253#define SP_FALSE_STRING "0"      
  256#define SP_OFF      SP_FALSE 
  259#define SP_EXIT_SUCCESS 0 
  260#define SP_EXIT_FAILURE 1 
  262#define SP_UNIX_DEFAULT_PATH_LIST "/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:~/bin" 
  263#define SP_UNIX_DEFAULT_LIBRARY_PATH_LIST "/usr/lib:/usr/local/lib:~/lib" 
  264#define SP_UNIX_DEFAULT_SHARE_PATH_LIST "/usr/share:/usr/local/share:~/share" 
  265#define SP_BROWSER_COMMAND_ENV "SP_BROWSER" 
  267#define SP_WIN_DIR_SEPARATOR '\\' 
  268#define SP_WIN_DIR_SEPARATOR_STRING "\\" 
  269#define SP_UNIX_DIR_SEPARATOR '/' 
  270#define SP_UNIX_DIR_SEPARATOR_STRING "/" 
  271#define SP_MAC_DIR_SEPARATOR ':' 
  272#define SP_MAC_DIR_SEPARATOR_STRING ":" 
  274#define SP_WIN_PARENT_DIR_STRING ".." 
  275#define SP_WIN_CURRENT_DIR_STRING "." 
  276#define SP_UNIX_PARENT_DIR_STRING ".." 
  277#define SP_UNIX_CURRENT_DIR_STRING "." 
  278#define SP_MAC_PARENT_DIR_STRING "::" 
  279#define SP_MAC_CURRENT_DIR_STRING ":" 
  281#define SP_WIN_SEPARATED_PARENT_DIR_STRING "..\\" 
  282#define SP_WIN_SEPARATED_CURRENT_DIR_STRING ".\\" 
  283#define SP_UNIX_SEPARATED_PARENT_DIR_STRING "../" 
  284#define SP_UNIX_SEPARATED_CURRENT_DIR_STRING "./" 
  285#define SP_MAC_SEPARATED_PARENT_DIR_STRING "::" 
  286#define SP_MAC_SEPARATED_CURRENT_DIR_STRING ":" 
  293#if !defined(__CYGWIN32__) 
  294#define SP_DIR_SEPARATOR SP_WIN_DIR_SEPARATOR 
  295#define SP_DIR_SEPARATOR_STRING SP_WIN_DIR_SEPARATOR_STRING 
  296#define SP_PARENT_DIR_STRING SP_WIN_PARENT_DIR_STRING 
  297#define SP_CURRENT_DIR_STRING SP_WIN_CURRENT_DIR_STRING 
  298#define SP_SEPARATED_PARENT_DIR_STRING SP_WIN_SEPARATED_PARENT_DIR_STRING 
  299#define SP_SEPARATED_CURRENT_DIR_STRING SP_WIN_SEPARATED_CURRENT_DIR_STRING 
  300#define SP_ANOTHER_DIR_SEPARATOR SP_UNIX_DIR_SEPARATOR 
  301#define SP_ANOTHER_DIR_SEPARATOR_STRING SP_UNIX_DIR_SEPARATOR_STRING 
  303#define SP_DIR_SEPARATOR SP_UNIX_DIR_SEPARATOR 
  304#define SP_DIR_SEPARATOR_STRING SP_UNIX_DIR_SEPARATOR_STRING 
  305#define SP_PARENT_DIR_STRING SP_UNIX_PARENT_DIR_STRING 
  306#define SP_CURRENT_DIR_STRING SP_UNIX_CURRENT_DIR_STRING 
  307#define SP_SEPARATED_PARENT_DIR_STRING SP_UNIX_SEPARATED_PARENT_DIR_STRING 
  308#define SP_SEPARATED_CURRENT_DIR_STRING SP_UNIX_SEPARATED_CURRENT_DIR_STRING 
  309#define SP_ANOTHER_DIR_SEPARATOR SP_WIN_DIR_SEPARATOR 
  310#define SP_ANOTHER_DIR_SEPARATOR_STRING SP_WIN_DIR_SEPARATOR_STRING 
  313#define SP_DEFAULT_DIRECTORY "c:" 
  314#define SP_PATHLIST_SEPARATOR ';' 
  316#define SP_DEFAULT_LF_STRING "\r\n" 
  320#define SP_DIR_SEPARATOR SP_MAC_DIR_SEPARATOR 
  321#define SP_DIR_SEPARATOR_STRING SP_MAC_DIR_SEPARATOR_STRING 
  322#define SP_PARENT_DIR_STRING SP_MAC_PARENT_DIR_STRING 
  323#define SP_CURRENT_DIR_STRING SP_MAC_CURRENT_DIR_STRING 
  324#define SP_SEPARATED_PARENT_DIR_STRING SP_MAC_SEPARATED_PARENT_DIR_STRING 
  325#define SP_SEPARATED_CURRENT_DIR_STRING SP_MAC_SEPARATED_CURRENT_DIR_STRING 
  327#define SP_ANOTHER_DIR_SEPARATOR SP_UNIX_DIR_SEPARATOR 
  328#define SP_ANOTHER_DIR_SEPARATOR_STRING SP_UNIX_DIR_SEPARATOR_STRING 
  329#define SP_DEFAULT_DIRECTORY ":" 
  330#define SP_PATHLIST_SEPARATOR ';' 
  333#define SP_DEFAULT_LF_STRING "\n" 
  335#define SP_DEFAULT_LF_STRING "\r" 
  340#define SP_DIR_SEPARATOR SP_UNIX_DIR_SEPARATOR 
  341#define SP_DIR_SEPARATOR_STRING SP_UNIX_DIR_SEPARATOR_STRING 
  342#define SP_PARENT_DIR_STRING SP_UNIX_PARENT_DIR_STRING 
  343#define SP_CURRENT_DIR_STRING SP_UNIX_CURRENT_DIR_STRING 
  344#define SP_SEPARATED_PARENT_DIR_STRING SP_UNIX_SEPARATED_PARENT_DIR_STRING 
  345#define SP_SEPARATED_CURRENT_DIR_STRING SP_UNIX_SEPARATED_CURRENT_DIR_STRING 
  348#define SP_ANOTHER_DIR_SEPARATOR SP_MAC_DIR_SEPARATOR 
  349#define SP_ANOTHER_DIR_SEPARATOR_STRING SP_MAC_DIR_SEPARATOR_STRING 
  350#define SP_DEFAULT_DIRECTORY "/" 
  351#define SP_PATHLIST_SEPARATOR ';' 
  353#define SP_ANOTHER_DIR_SEPARATOR SP_UNIX_DIR_SEPARATOR 
  354#define SP_ANOTHER_DIR_SEPARATOR_STRING SP_UNIX_DIR_SEPARATOR_STRING 
  355#define SP_DEFAULT_DIRECTORY "/" 
  356#define SP_PATHLIST_SEPARATOR ':' 
  359#define SP_DEFAULT_LF_STRING "\n" 
  362#define spMax(a, b) ((a) > (b) ? (a) : (b))  
  363#define spMin(a, b) ((a) < (b) ? (a) : (b))  
  364#define spAbs(x) ((x) >= 0 ? (x) : -(x))     
  365#define spCAbs(xr, xi) sqrt((double)(xr)*(double)(xr)+(double)(xi)*(double)(xi))  
  366#define spCAbsf(xr, xi) sqrtf((float)((xr)*(xr)+(xi)*(xi)))  
  367#define spSquare(x) ((x) * (x))                              
  368#define spCSquare(xr, xi) ((xr)*(xr)+(xi)*(xi))              
  369#define spPow2(p) (1 << (long)(p))                           
  371#define spArraySize(array) ((unsigned int)(sizeof(array) / sizeof(array[0])))  
  372#define spStrEq(s1, s2) ((s1 != NULL) && (s2 != NULL) && (strcmp((s1), (s2)) == 0) ? 1 : 0)  
  373#define spStrNEq(s1, s2, n) ((s1 != NULL) && (s2 != NULL) && (strncmp((s1), (s2), n) == 0) ? 1 : 0)  
  374#define spStrVEq(s1, s2) ((s1 != NULL) && (s2 != NULL) && (strncmp((s1), (s2), strlen(s2)) == 0) ? 1 : 0)  
  375#define spStrNone(string) (((string) == NULL || *(string) == NUL) ? 1 : 0)  
  376#define spIsTrue(flag) ((flag) != SP_FALSE ? SP_TRUE : SP_FALSE)  
  377#define spIsFalse(flag) ((flag) == SP_FALSE ? SP_TRUE : SP_FALSE)  
  379#define spdBf(x) (20.0f * log10f((float)((x) <= 0.0f ? SP_TINY_NUMBER : (x))))  
  380#define spdB(x) (20.0 * log10((double)((x) <= 0.0 ? SP_TINY_NUMBER : (x))))  
  381#define spdBpowf(x) (10.0f * log10f((float)((x) <= 0.0f ? SP_TINY_NUMBER : (x))))  
  382#define spdBpow(x) (10.0 * log10((double)((x) <= 0.0 ? SP_TINY_NUMBER : (x))))  
  385#define spOffset XtOffset 
  387#define spOffset(typep, field) \ 
  388    ((int) (((char *) (&(((typep)0)->field))) - ((char *)0)))  
 
  392#define spOffsetOf XtOffsetOf 
  395#define spOffsetOf offsetof 
  397#define spOffsetOf(type, field) spOffset(type*, field)  
  403#if !defined(SP_DISABLE_ABBREVIATION) 
  417#define PI      3.1415926535897932385 
  423#define RAND_MAX INT_MAX 
  425#define RAND_MAX 2147483647 
  448#define SQUARE spSquare 
  451#define CSQUARE spCSquare 
  458#define arrsize spArraySize 
  464#define strneq spStrNEq 
  467#define strveq spStrVEq 
  470#define strnone spStrNone 
  475#define dBpowf spdBpowf 
  480#define  printf(...)  __android_log_print(ANDROID_LOG_INFO,"printf",__VA_ARGS__) 
  481#define  fprintf(fp, ...)   \ 
  482    if (fp == stdout) {     \ 
  483    __android_log_print(ANDROID_LOG_INFO,"printf",__VA_ARGS__); \ 
  484    } else if (fp == stderr) {                      \ 
  485    __android_log_print(ANDROID_LOG_WARN,"printf",__VA_ARGS__); \ 
  487    fprintf(fp, __VA_ARGS__);                   \ 
  491#if defined(__CUDACC__) 
  492#if !defined(_WIN32) || (defined(_WIN32) && defined(_DEBUG)) 
  493#define spCudaSafeCall(err) __spCudaSafeCall(err, __FILE__, __LINE__) 
  494#define spCudaCheckMsg(msg) __spCudaCheckMsg(msg, __FILE__, __LINE__) 
  496#define spCudaSafeCall(err) err 
  497#define spCudaCheckMsg(msg)  
  499inline void __spCudaSafeCall(cudaError err, 
const char *file, 
const int line)
 
  501    if (cudaSuccess != err) {
 
  502    fprintf(stderr, 
"%s(%i) : CUDA Runtime API error : %s.\n", file, line, cudaGetErrorString(err));
 
  507inline void __spCudaCheckMsg(
const char *errorMessage, 
const char *file, 
const int line)
 
  509    cudaError_t err = cudaGetLastError();
 
  511    if (cudaSuccess != err) {
 
  512        fprintf(stderr, 
"%s(%i) : CUDA error : %s : %s.\n",
 
  513                file, line, errorMessage, cudaGetErrorString(err));
 
int spBool
Definition spDefs.h:248