source: azure_iot_hub/trunk/azure_iohub/c-utility/inc/azure_c_shared_utility/crt_abstractions.h@ 388

Last change on this file since 388 was 388, checked in by coas-nagasima, 5 years ago

Azure IoT Hub Device C SDK を使ったサンプルの追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-chdr
File size: 4.3 KB
Line 
1// Copyright (c) Microsoft. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4#ifndef CRT_ABSTRACTIONS_H
5#define CRT_ABSTRACTIONS_H
6
7#include "azure_c_shared_utility/umock_c_prod.h"
8
9#ifdef __cplusplus
10#include <cstdio>
11#include <cstring>
12#include <cerrno>
13#include <cmath>
14extern "C" {
15#else // __cplusplus
16#include <stdio.h>
17#include <string.h>
18#include <errno.h>
19#endif // __cplusplus
20
21#ifdef _MSC_VER
22
23#ifdef QUARKGALILEO
24#define HAS_STDBOOL
25#ifdef __cplusplus
26typedef bool _Bool;
27#else
28/*galileo apparently has _Bool and bool as built in types*/
29#endif
30#endif // QUARKGALILEO
31
32#define HAS_STDBOOL
33#ifdef __cplusplus
34/*because C++ doesn't do anything about _Bool... */
35#define _Bool bool
36#else // __cplusplus
37#include <stdbool.h>
38#endif // __cplusplus
39
40#else // _MSC_VER
41
42#if defined __STDC_VERSION__
43#if ((__STDC_VERSION__ == 199901L) || (__STDC_VERSION__ == 201000L) || (__STDC_VERSION__ == 201112L))
44/*C99 compiler or C11*/
45#define HAS_STDBOOL
46#include <stdbool.h>
47#endif // ((__STDC_VERSION__ == 199901L) || (__STDC_VERSION__ == 201000L) || (__STDC_VERSION__ == 201112L))
48#endif // __STDC_VERSION__
49#endif // _MSC_VER
50
51#ifndef HAS_STDBOOL
52#ifdef __cplusplus
53#define _Bool bool
54#else // __cplusplus
55typedef unsigned char _Bool;
56typedef unsigned char bool;
57#define false 0
58#define true 1
59#endif // __cplusplus
60#endif // HAS_STDBOOL
61
62
63/* Codes_SRS_CRT_ABSTRACTIONS_99_001:[The module shall not redefine the secure functions implemented by Microsoft CRT.] */
64/* Codes_SRS_CRT_ABSTRACTIONS_99_040 : [The module shall still compile when building on a Microsoft platform.] */
65/* Codes_SRS_CRT_ABSTRACTIONS_99_002: [CRTAbstractions module shall expose the following API]*/
66#if defined (_MSC_VER) || defined (MINGW_HAS_SECURE_API)
67#else // _MSC_VER || MINGW_HAS_SECURE_API
68
69/* Adding definitions from errno.h & crtdefs.h */
70#if !defined (_TRUNCATE)
71#define _TRUNCATE ((size_t)-1)
72#endif /* !defined (_TRUNCATE) */
73
74#if !defined STRUNCATE
75#define STRUNCATE 80
76#endif /* !defined (STRUNCATE) */
77
78extern int strcpy_s(char* dst, size_t dstSizeInBytes, const char* src);
79extern int strcat_s(char* dst, size_t dstSizeInBytes, const char* src);
80extern int strncpy_s(char* dst, size_t dstSizeInBytes, const char* src, size_t maxCount);
81extern int sprintf_s(char* dst, size_t dstSizeInBytes, const char* format, ...);
82#endif // _MSC_VER || MINGW_HAS_SECURE_API
83
84extern unsigned long long strtoull_s(const char* nptr, char** endPtr, int base);
85extern float strtof_s(const char* nptr, char** endPtr);
86extern long double strtold_s(const char* nptr, char** endPtr);
87
88#ifdef _MSC_VER
89#define stricmp _stricmp
90#endif // _MSC_VER
91
92MOCKABLE_FUNCTION(, int, mallocAndStrcpy_s, char**, destination, const char*, source);
93MOCKABLE_FUNCTION(, int, unsignedIntToString, char*, destination, size_t, destinationSize, unsigned int, value);
94MOCKABLE_FUNCTION(, int, size_tToString, char*, destination, size_t, destinationSize, size_t, value);
95
96/*following logic shall define the TOUPPER and ISDIGIT, we do that because the SDK is not happy with some Arduino implementation of it.*/
97#define TOUPPER(c) ((((c)>='a') && ((c)<='z'))?(c)-'a'+'A':c)
98#define ISDIGIT(c) ((((c)>='0') && ((c)<='9'))?1:0)
99
100/*following logic shall define the ISNAN macro*/
101/*if runing on Microsoft Visual C compiler, than ISNAN shall be _isnan*/
102/*else if running on C99 or C11, ISNAN shall be isnan*/
103/*else if running on C89 ... #error and inform user*/
104
105#ifdef _MSC_VER
106#define ISNAN _isnan
107#else // _MSC_VER
108#if defined __STDC_VERSION__
109#if ((__STDC_VERSION__ == 199901L) || (__STDC_VERSION__ == 201000L) || (__STDC_VERSION__ == 201112L))
110/*C99 compiler or C11*/
111#define ISNAN isnan
112#else // ((__STDC_VERSION__ == 199901L) || (__STDC_VERSION__ == 201000L) || (__STDC_VERSION__ == 201112L))
113#error update this file to contain the latest C standard.
114#endif // ((__STDC_VERSION__ == 199901L) || (__STDC_VERSION__ == 201000L) || (__STDC_VERSION__ == 201112L))
115#else // __STDC_VERSION__
116#ifdef __cplusplus
117/*C++ defines isnan... in C11*/
118extern "C++" {
119#define ISNAN std::isnan
120}
121#else // __cplusplus
122#error unknown (or C89) compiler, provide ISNAN with the same meaning as isnan in C99 standard
123#endif // __cplusplus
124
125#endif // __STDC_VERSION__
126#endif // _MSC_VER
127
128#ifdef __cplusplus
129}
130#endif // __cplusplus
131
132#endif /* CRT_ABSTRACTIONS_H */
Note: See TracBrowser for help on using the repository browser.