1 /*---------------------------------------------------------------------------* 2 * portable.h * 3 * * 4 * Copyright 2007, 2008 Nuance Communciations, Inc. * 5 * * 6 * Licensed under the Apache License, Version 2.0 (the 'License'); * 7 * you may not use this file except in compliance with the License. * 8 * * 9 * You may obtain a copy of the License at * 10 * http://www.apache.org/licenses/LICENSE-2.0 * 11 * * 12 * Unless required by applicable law or agreed to in writing, software * 13 * distributed under the License is distributed on an 'AS IS' BASIS, * 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 15 * See the License for the specific language governing permissions and * 16 * limitations under the License. * 17 * * 18 *---------------------------------------------------------------------------*/ 19 20 21 #ifndef _h_portable_ 22 #define _h_portable_ 23 24 #ifdef SET_RCSID 25 static const char portable_h[] = "$Id: portable.h,v 1.4.10.4 2007/10/15 18:06:25 dahan Exp $"; 26 #endif 27 28 29 #include <math.h> 30 31 #include "passert.h" 32 #include "pmemory.h" 33 #include "PFileSystem.h" 34 #include "plog.h" 35 #include "pstdio.h" 36 #include "ptypes.h" 37 #include "setting.h" 38 39 #define ASSERT passert 40 41 /* QNX defines log in math.h */ 42 #ifndef log 43 #define log(X) ((X) <= 1e-32 ? -MAX_LOG : log(X)) 44 /* #define exp(X) ((X) < FLT_MIN_EXP ? 0.0 : exp(X)) */ 45 #endif 46 /* Allocation macros 47 */ 48 49 #if defined(__sgi) 50 #define inline 51 #elif defined(unix) 52 #define inline __inline__ 53 #endif 54 55 static PINLINE PFile* file_must_open(PFile* afile, const LCHAR *name, const LCHAR *mode, ESR_BOOL littleEndian) 56 { 57 PFile* fp; 58 ESR_ReturnCode rc; 59 60 fp = pfopen ( name, mode ); 61 62 if (fp == NULL) 63 { 64 LCHAR path[P_PATH_MAX]; 65 LCHAR *tmp = path; 66 size_t len; 67 68 len = P_PATH_MAX; 69 CHKLOG(rc, pf_get_cwd (path, &len)); 70 PLogError(L("Could not open file %s, mode=%s, cwd=%s\n"), name, mode, tmp); 71 /* passert(0); */ 72 fp = NULL; 73 } 74 return fp; 75 CLEANUP: 76 return NULL; 77 } 78 79 #define report_malloc_usage() do { } while(0); /* do nothing */ 80 #define log_report PLogMessage 81 82 #define SERVICE_ERROR(X) do \ 83 { \ 84 log_report("service error (%d)\n", X); \ 85 assert(0); \ 86 exit(1); \ 87 } while(0) 88 89 90 #endif 91