1 /* 2 * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * * Neither the name of the <organization> nor the 13 * names of its contributors may be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 /****************************************************************************** 29 * 30 * PlatformSpecificFunctions_c.H 31 * 32 * Provides an interface for when working with pure C 33 * 34 *******************************************************************************/ 35 36 37 #ifndef PLATFORMSPECIFICFUNCTIONS_C_H_ 38 #define PLATFORMSPECIFICFUNCTIONS_C_H_ 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /* Jumping operations. They manage their own jump buffers */ 45 extern int (*PlatformSpecificSetJmp)(void (*function) (void*), void* data); 46 extern void (*PlatformSpecificLongJmp)(void); 47 extern void (*PlatformSpecificRestoreJumpBuffer)(void); 48 49 /* Time operations */ 50 extern long (*GetPlatformSpecificTimeInMillis)(void); 51 extern const char* (*GetPlatformSpecificTimeString)(void); 52 53 /* String operations */ 54 extern int (*PlatformSpecificVSNprintf)(char *str, size_t size, const char* format, va_list va_args_list); 55 56 /* Misc */ 57 extern double (*PlatformSpecificFabs)(double d); 58 extern int (*PlatformSpecificIsNan)(double d); 59 extern int (*PlatformSpecificIsInf)(double d); 60 extern int (*PlatformSpecificAtExit)(void(*func)(void)); 61 62 /* IO operations */ 63 typedef void* PlatformSpecificFile; 64 65 extern PlatformSpecificFile (*PlatformSpecificFOpen)(const char* filename, const char* flag); 66 extern void (*PlatformSpecificFPuts)(const char* str, PlatformSpecificFile file); 67 extern void (*PlatformSpecificFClose)(PlatformSpecificFile file); 68 69 extern int (*PlatformSpecificPutchar)(int c); 70 extern void (*PlatformSpecificFlush)(void); 71 72 /* Random operations */ 73 extern void (*PlatformSpecificSrand)(unsigned int); 74 extern int (*PlatformSpecificRand)(void); 75 76 /* Dynamic Memory operations */ 77 extern void* (*PlatformSpecificMalloc)(size_t size); 78 extern void* (*PlatformSpecificRealloc)(void* memory, size_t size); 79 extern void (*PlatformSpecificFree)(void* memory); 80 extern void* (*PlatformSpecificMemCpy)(void* s1, const void* s2, size_t size); 81 extern void* (*PlatformSpecificMemset)(void* mem, int c, size_t size); 82 83 typedef void* PlatformSpecificMutex; 84 extern PlatformSpecificMutex (*PlatformSpecificMutexCreate)(void); 85 extern void (*PlatformSpecificMutexLock)(PlatformSpecificMutex mtx); 86 extern void (*PlatformSpecificMutexUnlock)(PlatformSpecificMutex mtx); 87 extern void (*PlatformSpecificMutexDestroy)(PlatformSpecificMutex mtx); 88 89 #ifdef __cplusplus 90 } 91 #endif 92 93 #endif /* PLATFORMSPECIFICFUNCTIONS_C_H_ */ 94