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 /* Allocation macros 42 */ 43 44 #if defined(__sgi) 45 #define inline 46 #elif defined(unix) 47 #define inline __inline__ 48 #endif 49 file_must_open(PFile * afile,const LCHAR * name,const LCHAR * mode,ESR_BOOL littleEndian)50 static PINLINE PFile* file_must_open(PFile* afile, const LCHAR *name, const LCHAR *mode, ESR_BOOL littleEndian) 51 { 52 PFile* fp; 53 ESR_ReturnCode rc; 54 55 fp = pfopen ( name, mode ); 56 57 if (fp == NULL) 58 { 59 LCHAR path[P_PATH_MAX]; 60 LCHAR *tmp = path; 61 size_t len; 62 63 len = P_PATH_MAX; 64 CHKLOG(rc, pf_get_cwd (path, &len)); 65 PLogError(L("Could not open file %s, mode=%s, cwd=%s\n"), name, mode, tmp); 66 /* passert(0); */ 67 fp = NULL; 68 } 69 return fp; 70 CLEANUP: 71 return NULL; 72 } 73 74 #define report_malloc_usage() do { } while(0); /* do nothing */ 75 #define log_report PLogMessage 76 77 #define SERVICE_ERROR(X) do \ 78 { \ 79 log_report("service error (%d)\n", X); \ 80 assert(0); \ 81 exit(1); \ 82 } while(0) 83 84 85 #endif 86