CUBRID Engine  latest
cache_time.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 /*
20  * cache_time.h - CACHE TIME RELATED DEFINITIONS
21  */
22 
23 #ifndef _CACHE_TIME_H_
24 #define _CACHE_TIME_H_
25 
26 #ident "$Id$"
27 
28 typedef struct cache_time CACHE_TIME;
29 struct cache_time
30 {
31  int sec;
32  int usec;
33 };
34 
35 #define CACHE_TIME_AS_ARGS(ct) (ct)->sec, (ct)->usec
36 
37 #define CACHE_TIME_EQ(T1, T2) \
38  (((T1)->sec != 0) && ((T1)->sec == (T2)->sec) && ((T1)->usec == (T2)->usec))
39 
40 #define CACHE_TIME_RESET(T) \
41  do \
42  { \
43  (T)->sec = 0; \
44  (T)->usec = 0; \
45  } \
46  while (0)
47 
48 #define CACHE_TIME_MAKE(CT, TV) \
49  do \
50  { \
51  (CT)->sec = (TV)->tv_sec; \
52  (CT)->usec = (TV)->tv_usec; \
53  } \
54  while (0)
55 
56 #define OR_CACHE_TIME_SIZE (OR_INT_SIZE * 2)
57 
58 #define OR_PACK_CACHE_TIME(PTR, T) \
59  do \
60  { \
61  if ((CACHE_TIME *) (T) != NULL) \
62  { \
63  PTR = or_pack_int (PTR, (T)->sec); \
64  PTR = or_pack_int (PTR, (T)->usec); \
65  } \
66  else \
67  { \
68  PTR = or_pack_int (PTR, 0); \
69  PTR = or_pack_int (PTR, 0); \
70  } \
71  } \
72  while (0)
73 
74 #define OR_UNPACK_CACHE_TIME(PTR, T) \
75  do \
76  { \
77  if ((CACHE_TIME *) (T) != NULL) \
78  { \
79  PTR = or_unpack_int (PTR, &((T)->sec)); \
80  PTR = or_unpack_int (PTR, &((T)->usec)); \
81  } \
82  } \
83  while (0)
84 
85 #endif /* _CACHE_TIME_T_ */