source: azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/inc/azure_c_shared_utility/gb_time.h@ 457

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

ファイルを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 1.8 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 GB_TIME_H
5#define GB_TIME_H
6
7/*this file, if included instead of <stdio.h> has the following functionality:
81) if GB_TIME_INTERCEPT is defined then
9 a) some of the time.h symbols shall be redefined, for example: time => gb_time
10 b) all "code" using the time will actually (because of the preprocessor) call to gb_time
11 c) gb_time shall blindly call into time, thus realizing a passthrough
12
13 reason is: unittesting. time comes with the C Run Time and cannot be mocked (that is, in the global namespace cannot exist a function called time
14
152) if GB_TIME_INTERCEPT is not defined then
16 a) it shall include <time.h> => no passthrough, just direct linking.
17*/
18
19#ifndef GB_TIME_INTERCEPT
20#ifdef __cplusplus
21#include <ctime>
22#else
23#include <time.h>
24#endif
25#else
26
27/*source level intercepting of function calls*/
28#define time time_never_called_never_implemented_always_forgotten
29#define localtime localtime_never_called_never_implemented_always_forgotten
30#define strftime strftime_never_called_never_implemented_always_forgotten
31
32#ifdef __cplusplus
33#include <ctime>
34#else
35#include <time.h>
36#endif
37
38#include "umock_c/umock_c_prod.h"
39
40#ifdef __cplusplus
41extern "C"
42{
43#endif
44
45#undef time
46#define time gb_time
47MOCKABLE_FUNCTION(, time_t, time, time_t *, timer);
48
49#undef localtime
50#define localtime gb_localtime
51MOCKABLE_FUNCTION(, struct tm *, localtime, const time_t *, timer);
52
53#undef strftime
54#define strftime gb_strftime
55MOCKABLE_FUNCTION(, size_t, strftime, char *, s, size_t, maxsize, const char *, format, const struct tm *, timeptr);
56
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif /*GB_TIME_INTERCEPT*/
63
64#endif /* GB_TIME_H */
Note: See TracBrowser for help on using the repository browser.