Mark Radbourne / Mbed 2 deprecated iothub_client_sample_amqp

Dependencies:   EthernetInterface NTPClient iothub_amqp_transport iothub_client mbed-rtos mbed

Fork of iothub_client_sample_amqp by Azure IoT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers crt_abstractions.h Source File

crt_abstractions.h

00001 // Copyright (c) Microsoft. All rights reserved.
00002 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
00003 
00004 #ifndef CRT_ABSTRACTIONS_H
00005 #define CRT_ABSTRACTIONS_H
00006 
00007 #include "azure_c_shared_utility/umock_c_prod.h"
00008 
00009 #ifdef __cplusplus
00010 #include <cstdio>
00011 #include <cstring>
00012 #include <cerrno>
00013 #include <cmath>
00014 extern "C" {
00015 #else
00016 #include <stdio.h>
00017 #include <string.h>
00018 #include <errno.h>
00019 #endif
00020 
00021 #ifdef _MSC_VER
00022 
00023 #ifdef QUARKGALILEO
00024 #define HAS_STDBOOL
00025 #ifdef __cplusplus
00026 typedef bool _Bool;
00027 #else
00028 /*galileo apparently has _Bool and bool as built in types*/
00029 #endif
00030 #endif
00031 
00032 #ifndef _WIN32_WCE
00033 #define HAS_STDBOOL
00034 #ifdef __cplusplus
00035 #include <cstdbool>
00036 /*because C++ doesn't do anything about _Bool... */
00037 #define _Bool bool
00038 #else
00039 #include <stdbool.h>
00040 #endif
00041 #else 
00042 /* WINCE does not support bool as C datatype */
00043 #define __bool_true_false_are_defined   1
00044 
00045 #define HAS_STDBOOL
00046 
00047 #define _Bool bool
00048 
00049 #ifdef __cplusplus
00050 #define _CSTDBOOL_
00051 #else
00052 typedef unsigned char bool;
00053 
00054 #define false   0
00055 #define true    1
00056 #endif
00057 #endif
00058 #else
00059 #if defined __STDC_VERSION__
00060 #if ((__STDC_VERSION__  == 199901L) || (__STDC_VERSION__ == 201000L) || (__STDC_VERSION__ == 201112L))
00061 /*C99 compiler or C11*/
00062 #define HAS_STDBOOL
00063 #include <stdbool.h>
00064 #endif
00065 #endif
00066 #endif
00067 
00068 #ifndef HAS_STDBOOL
00069 #ifdef __cplusplus
00070 #define _Bool bool
00071 #else
00072 typedef unsigned char _Bool;
00073 typedef unsigned char bool;
00074 #define false 0
00075 #define true 1
00076 #endif
00077 #endif
00078 
00079 
00080 /* Codes_SRS_CRT_ABSTRACTIONS_99_001:[The module shall not redefine the secure functions implemented by Microsoft CRT.] */
00081 /* Codes_SRS_CRT_ABSTRACTIONS_99_040 : [The module shall still compile when building on a Microsoft platform.] */
00082 /* Codes_SRS_CRT_ABSTRACTIONS_99_002: [CRTAbstractions module shall expose the following API]*/
00083 #ifdef _MSC_VER
00084 #else
00085 #include "inttypes.h"
00086 
00087 /* Adding definitions from errno.h & crtdefs.h */
00088 #if !defined (_TRUNCATE)
00089 #define _TRUNCATE ((size_t)-1)
00090 #endif  /* !defined (_TRUNCATE) */
00091 
00092 #if !defined STRUNCATE
00093 #define STRUNCATE       80
00094 #endif  /* !defined (STRUNCATE) */
00095 
00096 typedef int errno_t;
00097 
00098 extern int strcpy_s(char* dst, size_t dstSizeInBytes, const char* src);
00099 extern int strcat_s(char* dst, size_t dstSizeInBytes, const char* src);
00100 extern int strncpy_s(char* dst, size_t dstSizeInBytes, const char* src, size_t maxCount);
00101 extern int sprintf_s(char* dst, size_t dstSizeInBytes, const char* format, ...);
00102 #endif
00103 extern unsigned long long strtoull_s(const char* nptr, char** endPtr, int base);
00104 extern float strtof_s(const char* nptr, char** endPtr);
00105 extern long double strtold_s(const char* nptr, char** endPtr);
00106 
00107 MOCKABLE_FUNCTION(, int, mallocAndStrcpy_s, char**, destination, const char*, source);
00108 MOCKABLE_FUNCTION(, int, unsignedIntToString, char*, destination, size_t, destinationSize, unsigned int, value);
00109 MOCKABLE_FUNCTION(, int, size_tToString, char*, destination, size_t, destinationSize, size_t, value);
00110 /*following logic shall define the ISNAN macro*/
00111 /*if runing on Microsoft Visual C compiler, than ISNAN shall be _isnan*/
00112 /*else if running on C99 or C11, ISNAN shall be isnan*/
00113 /*else if running on C89 ... #error and inform user*/
00114 
00115 #ifdef _MSC_VER
00116 #define ISNAN _isnan
00117 #else
00118 #if defined __STDC_VERSION__
00119 #if ((__STDC_VERSION__  == 199901L) || (__STDC_VERSION__ == 201000L) || (__STDC_VERSION__ == 201112L))
00120 /*C99 compiler or C11*/
00121 #define ISNAN isnan
00122 #else
00123 #error update this file to contain the latest C standard.
00124 #endif
00125 #else
00126 #ifdef __cplusplus
00127 /*C++ defines isnan... in C11*/
00128 extern "C++" {
00129 #define ISNAN std::isnan
00130 }
00131 #else
00132 #error unknown (or C89) compiler, provide ISNAN with the same meaning as isnan in C99 standard  
00133 #endif
00134 
00135 #endif
00136 #endif
00137 
00138 #ifdef _MSC_VER
00139 #define INT64_PRINTF "%I64d"
00140 #else
00141 #if defined __STDC_VERSION__
00142 #if ((__STDC_VERSION__  == 199901L) || (__STDC_VERSION__ == 201000L) || (__STDC_VERSION__ == 201112L))
00143 /*C99 compiler or C11*/
00144 #define INT64_PRINTF "%" PRId64 ""
00145 #else
00146 #error update this file to contain the latest C standard.
00147 #endif
00148 #else
00149 #ifdef __cplusplus 
00150 #define INT64_PRINTF "%" PRId64 ""
00151 #else
00152 #error unknown (or C89) compiler, provide INT64_PRINTF with the same meaning as PRIdN in C99 standard
00153 #endif
00154 #endif
00155 #endif
00156 
00157 #ifdef __cplusplus
00158 }
00159 #endif
00160 
00161 #endif /* CRT_ABSTRACTIONS_H */