NCBI C++ ToolKit
ncbi_types.h
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef CONNECT___NCBI_TYPES__H
2 #define CONNECT___NCBI_TYPES__H
3 
4 /* $Id: ncbi_types.h 85796 2019-03-13 19:52:25Z lavr $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Author: Anton Lavrentiev
30  *
31  * File Description:
32  * @file ncbi_types.h
33  * Special types for connect core library.
34  *
35  * Timeout:
36  * struct STimeout
37  *
38  * Switch:
39  * ESwitch (on/off/default)
40  *
41  * Fixed-size size_t and time_t equivalents:
42  * TNCBI_Size
43  * TNCBI_Time
44  * these two we need to use when mixing 32/64 bit programs
45  * which make simultaneous access to inter-process communication
46  * data areas, like shared memory segments
47  *
48  */
49 
50 #include <connect/connect_export.h>
51 #ifndef _WIN32
52 # ifndef __STDC_FORMAT_MACROS
53 # define __STDC_FORMAT_MACROS
54 # endif /*!__STDC_FORMAT_MACROS*/
55 # include <inttypes.h>
56 # include <stdint.h>
57 #endif /*_WIN32*/
58 #include <stddef.h>
59 
60 
61 /** @addtogroup UtilityFunc
62  *
63  * @{
64  */
65 
66 
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70 
71 
72 /** Timeout structure
73  *
74  * @sa CTimeout, g_CTimeoutToSTimeout, g_STimeoutToCTimeout
75  */
76 typedef struct STimeoutTag {
77  unsigned int sec; /**< seconds */
78  unsigned int usec; /**< microseconds (modulo 1,000,000) */
80 
81 #define kDefaultTimeout ((const STimeout*)(-1))
82 #define kInfiniteTimeout ((const STimeout*)( 0))
83 
84 
85 extern NCBI_XCONNECT_EXPORT unsigned long NcbiTimeoutToMs
86 (const STimeout* timeout
87 );
88 
89 
91 (STimeout* timeout,
92  unsigned long ms
93  );
94 
95 
96 #ifndef NCBI_ESWITCH_DEFINED
97 #define NCBI_ESWITCH_DEFINED
98 
99 /*
100  * ATTENTION! Do not change this enumeration!
101  *
102  * It must always be kept in sync with its C++ counterpart defined in
103  * "corelib/ncbimisc.hpp". If you absolutely(sic!) need to alter this
104  * type, please apply equivalent changes to both definitions.
105  */
106 
107 /** Aux. enum to set/unset/default various features.
108  */
109 typedef enum ENcbiSwitch {
110  eOff = 0,
112  eDefault
114 
115 #endif /*!NCBI_ESWITCH_DEFINED*/
116 
117 
118 #ifndef NCBI_EOWNERSHIP_DEFINED
119 #define NCBI_EOWNERSHIP_DEFINED
120 
121 /*
122  * ATTENTION! Do not change this enumeration!
123  *
124  * It must always be kept in sync with its C++ counterpart defined in
125  * "corelib/ncbimisc.hpp". If you absolutely(sic!) need to alter this
126  * type, please apply equivalent changes to both definitions.
127  */
128 
129 /** Ownership relations between objects.
130  *
131  * Can be used to define or transfer ownership of objects.
132  * For example, specify if a CSocket object owns its underlying SOCK object.
133  */
134 typedef enum ENcbiOwnership {
135  eNoOwnership, /**< No ownership is assumed */
136  eTakeOwnership /**< An object can take ownership of another */
138 
139 #endif /*!NCBI_EOWNERSHIP_DEFINED*/
140 
141 
142 /** Fixed-size analogs of size_t and time_t (mainly for IPC)
143  */
144 typedef unsigned int TNCBI_Size;
145 typedef unsigned int TNCBI_Time;
146 
147 #define NCBI_TIME_INFINITE ((TNCBI_Time)(-1))
148 
149 
150 /** Big unsigned integer for file size and position
151  */
152 
153 #if defined(__MINGW32__) || defined(__MINGW64__)
154 typedef unsigned long long TNCBI_BigCount;
155 # define NCBI_BIGCOUNT_FORMAT_SPEC "I64u"
156 # define NCBI_BIGCOUNT_FORMAT_SPEC_HEX "I64x"
157 # define NCBI_BIGCOUNT_FORMAT_SPEC_HEX_X "I64X"
158 #elif defined(_WIN32)
159 typedef unsigned __int64 TNCBI_BigCount;
160 # define NCBI_BIGCOUNT_FORMAT_SPEC "I64u"
161 # define NCBI_BIGCOUNT_FORMAT_SPEC_HEX "I64x"
162 # define NCBI_BIGCOUNT_FORMAT_SPEC_HEX_X "I64X"
163 #else
165 # define NCBI_BIGCOUNT_FORMAT_SPEC PRIu64
166 # define NCBI_BIGCOUNT_FORMAT_SPEC_HEX PRIx64
167 # define NCBI_BIGCOUNT_FORMAT_SPEC_HEX_X PRIX64
168 #endif
169 
170 
171 #ifdef __cplusplus
172 } /* extern "C" */
173 #endif
174 
175 
176 /* @} */
177 
178 #endif /* CONNECT___NCBI_TYPES__H */
Uint8 uint64_t
@ eOff
Definition: ncbi_types.h:110
@ eDefault
Definition: ncbi_types.h:112
@ eOn
Definition: ncbi_types.h:111
@ eTakeOwnership
An object can take ownership of another.
Definition: ncbi_types.h:136
@ eNoOwnership
No ownership is assumed.
Definition: ncbi_types.h:135
enum ENcbiSwitch ESwitch
Aux.
unsigned int TNCBI_Time
Definition: ncbi_types.h:145
unsigned int TNCBI_Size
Fixed-size analogs of size_t and time_t (mainly for IPC)
Definition: ncbi_types.h:144
unsigned long NcbiTimeoutToMs(const STimeout *timeout)
Definition: ncbi_types.c:40
unsigned int usec
microseconds (modulo 1,000,000)
Definition: ncbi_types.h:78
enum ENcbiOwnership EOwnership
Ownership relations between objects.
ENcbiSwitch
Aux.
Definition: ncbi_types.h:109
STimeout * NcbiMsToTimeout(STimeout *timeout, unsigned long ms)
Definition: ncbi_types.c:48
unsigned int sec
seconds
Definition: ncbi_types.h:77
struct STimeoutTag STimeout
Timeout structure.
ENcbiOwnership
Ownership relations between objects.
Definition: ncbi_types.h:134
uint64_t TNCBI_BigCount
Big unsigned integer for file size and position.
Definition: ncbi_types.h:164
#define NCBI_XCONNECT_EXPORT
#define __int64
Definition: sse2neon.h:208
Timeout structure.
Definition: ncbi_types.h:76
Modified on Sat Apr 13 11:50:07 2024 by modify_doxy.py rev. 669887