CppUTest
PlatformSpecificFunctions_c.h
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 int PlatformSpecificSetJmp(void (*function) (void*), void* data);
46 void PlatformSpecificLongJmp(void);
47 void PlatformSpecificRestoreJumpBuffer(void);
48 
49 /* Time operations */
50 long GetPlatformSpecificTimeInMillis(void);
51 void SetPlatformSpecificTimeInMillisMethod(long(*platformSpecific)(void));
52 
53 const char* GetPlatformSpecificTimeString(void);
54 void SetPlatformSpecificTimeStringMethod(const char* (*platformMethod)(void));
55 
56 /* String operations */
57 int PlatformSpecificAtoI(const char*str);
58 size_t PlatformSpecificStrLen(const char* str);
59 char* PlatformSpecificStrCat(char* s1, const char* s2);
60 char* PlatformSpecificStrCpy(char* s1, const char* s2);
61 char* PlatformSpecificStrNCpy(char* s1, const char* s2, size_t size);
62 int PlatformSpecificStrCmp(const char* s1, const char* s2);
63 int PlatformSpecificStrNCmp(const char* s1, const char* s2, size_t size);
64 char* PlatformSpecificStrStr(const char* s1, const char* s2);
65 
66 int PlatformSpecificVSNprintf(char *str, size_t size, const char* format,
67  va_list va_args_list);
68 
69 char PlatformSpecificToLower(char c);
70 
71 /* Misc */
72 double PlatformSpecificFabs(double d);
73 int PlatformSpecificIsNan(double d);
74 int PlatformSpecificAtExit(void(*func)(void));
75 
76 /* IO operations */
77 typedef void* PlatformSpecificFile;
78 
79 PlatformSpecificFile PlatformSpecificFOpen(const char* filename,
80  const char* flag);
81 void PlatformSpecificFPuts(const char* str, PlatformSpecificFile file);
82 void PlatformSpecificFClose(PlatformSpecificFile file);
83 
84 int PlatformSpecificPutchar(int c);
85 void PlatformSpecificFlush(void);
86 
87 /* Dynamic Memory operations */
88 void* PlatformSpecificMalloc(size_t size);
89 void* PlatformSpecificRealloc(void* memory, size_t size);
90 void PlatformSpecificFree(void* memory);
91 void* PlatformSpecificMemCpy(void* s1, const void* s2, size_t size);
92 void* PlatformSpecificMemset(void* mem, int c, size_t size);
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif /* PLATFORMSPECIFICFUNCTIONS_C_H_ */