OpenClovis Logo

clCommon.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright (C) 2002-2012 OpenClovis Solutions Inc. All Rights Reserved.
4  *
5  * This file is available under a commercial license from the
6  * copyright holder or the GNU General Public License Version 2.0.
7  *
8  * The source code for this program is not published or otherwise
9  * divested of its trade secrets, irrespective of what has been
10  * deposited with the U.S. Copyright office.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * For more information, see the file COPYING provided with this
18  * material.
19  */
20 /*******************************************************************************
21  * ModuleName : include
22  * File : clCommon.h
23  *******************************************************************************/
24 
25 /*******************************************************************************
26  * Description :
27  *
28  * This header file contains all the common data types used across ASP
29  *
30  *
31  *****************************************************************************/
32 
45 #ifndef _CL_COMMON_H_
46 #define _CL_COMMON_H_
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 #include <clArchHeaders.h>
53 
54 /******************************************************************************
55  * Clovis Data Types
56  *****************************************************************************/
57 
59 #define CL_TRUE 1
61 #define CL_FALSE 0
62 
64 #define CL_YES 1
66 #define CL_NO 0
67 
69 #define CL_ENABLE 1
71 #define CL_DISABLE 0
72 
76 typedef enum {
81 
86 } ClStatusT;
87 
88 #if defined(__STDC__) && __STDC_VERSION__ >= 199901L
89 #define __FUNCTION__ __func__
90 #endif
91 
93 #define CL_MIN(a,b) ( (a) < (b) ? (a) : (b) )
95 #define CL_MAX(a,b) ( (a) > (b) ? (a) : (b) )
96 
98 #define CL_ROUNDUP(VAL,BASE) (((VAL) + (BASE) - 1)/(BASE) * (BASE))
100 #define CL_ROUNDDOWN(VAL,BASE) ((VAL)/(BASE) * (BASE))
101 
103 #define CL_SIZEOF_ARRAY(__ArrayName__) sizeof((__ArrayName__)) / sizeof((__ArrayName__)[0])
104 
106 #define CL_IN
108 #define CL_INOUT
110 #define CL_OUT
111 
112 /* Note: for the 64 bit types, align yourself using "__attribute__((__aligned__(8)))".
113  We cannot align automatically as part of this typedef, since SAF does not align its
114  corresponding type. See bug 7155 */
115 typedef unsigned long long ClUint64T;
116 typedef signed long long ClInt64T;
117 
118 typedef unsigned int ClUint32T;
119 typedef signed int ClInt32T;
120 typedef unsigned short ClUint16T;
121 typedef signed short ClInt16T;
122 typedef unsigned char ClUint8T;
123 typedef signed char ClInt8T;
124 typedef char ClCharT; /* Use this for strings */
125 typedef signed int ClFdT; /* Use this for file descriptors */
126 /*
127  * Special type with word size for portability b/n 32 & 64 bit
128  * Recommended type would be intptr_t but not working for some
129  * reason. Need to fix this - Mynk
130  */
131 typedef unsigned long ClWordT;
132 
133 
134 typedef ClUint16T ClBoolT;
135 
136 typedef ClWordT ClPidT;
137 
139 #define CL_MICRO_TO_NANO 1000ULL
141 #define CL_MILLI_TO_MICRO 1000ULL
143 #define CL_SEC_TO_MILLI 1000ULL
145 #define CL_MILLI_TO_NANO (CL_MICRO_TO_NANO * CL_MILLI_TO_MICRO)
147 #define CL_SEC_TO_NANO (CL_MILLI_TO_NANO * CL_SEC_TO_MILLI)
149 #define CL_TIME_END 0x7fffffffffffffffULL
151 #define CL_TIME_FOREVER 0x7fffffffffffffffULL
152 
154 typedef ClInt64T ClTimeT;
155 typedef ClUint64T ClHandleT;
157 typedef ClUint64T ClSizeT;
159 typedef ClInt64T ClOffsetT;
160 typedef ClUint64T ClInvocationT;
161 typedef ClUint64T ClSelectionObjectT;
162 typedef ClUint64T ClNtfIdentifierT;
163 typedef ClInt8T *ClAddrT;
164 typedef void* ClPtrT;
165 
168 typedef ClUint32T ClRcT;
169 
179 typedef ClRcT (*ClCallbackT) (CL_IN ClPtrT invocation);
180 
181 typedef union cl_u64_u /* FIXME: This is not endian-safe; shouldn't be used */
182  {
183  struct {
184  ClUint32T high;
185  ClUint32T low;
186  } DWord;
187  ClUint32T dWords[2];
188  ClUint16T words[4];
189  ClInt8T bytes[8];
190  } ClUnion64T;
191 
192 
194 #define CL_MAX_NAME_LENGTH 256
195 
197 typedef struct {
199  ClUint16T length;
201  ClCharT value[CL_MAX_NAME_LENGTH];
202 } ClNameT;
203 
210 void clNameSet(ClNameT* name, const char* str);
211 
218 void clNameCopy(ClNameT* nameOut, const ClNameT *nameIn);
219 
228 void clNameConcat(ClNameT* nameOut, const ClNameT *prefix, const char* separator, const ClNameT *suffix);
229 
239 ClCharT *clStrdup(const ClCharT *str);
240 
241 ClBoolT clParseEnvBoolean(ClCharT* envvar);
242 
243 ClCharT *clParseEnvStr(const ClCharT* envvar);
244 
245 ClInt32T clCreatePipe(ClInt32T fds[2], ClUint32T numMsgs, ClUint32T msgSize);
246 
247 ClUint32T clBinaryPower(ClUint32T size);
248 
250 typedef struct {
252  ClUint8T releaseCode;
254  ClUint8T majorVersion;
256  ClUint8T minorVersion;
257 } ClVersionT;
258 
260 typedef enum {
261  CL_DISPATCH_ONE = 1,
262  CL_DISPATCH_ALL = 2,
263  CL_DISPATCH_BLOCKING = 3,
265 
266 /*****************************************************************************
267  * Bit related Types
268  *****************************************************************************/
269 #define CL_FORCED_TO_8BITS 0xff
270 #define CL_FORCED_TO_16BITS 0xffff
271 #define CL_FORCED_TO_32BITS 0xffffffff
272 #define CL_BITS_PER_BYTE 8
273 #define CL_BIT(X) (0x1 << (X))
274 
275 #if 0
276 typedef enum ClMetricId
277 {
278  CL_METRIC_ALL,
279  CL_METRIC_CPU,
280  CL_METRIC_MEM,
281  CL_METRIC_MAX,
282 }ClMetricIdT;
283 
284 typedef struct ClMetric
285 {
286  const ClCharT *pType;
287  ClMetricIdT id;
288  ClUint32T maxThreshold;
289  ClUint32T currentThreshold;
290  ClUint32T maxOccurences;
291  ClUint32T numOccurences;
292 }ClMetricT;
293 
294 #define CL_METRIC_STR(id) \
295  ((id) == CL_METRIC_ALL) ? "all" : \
296  ((id) == CL_METRIC_CPU) ? "cpu" : \
297  ((id) == CL_METRIC_MEM) ? "mem" : \
298  "unknown"
299 #endif
300 
304 typedef enum {
307 
309  CL_CID_OSAL = 0x01,
310 
312  CL_CID_HAL = 0x02,
313 
315  CL_CID_DBAL = 0x03,
316 
318  CL_CID_EO = 0x04,
319 
321  CL_CID_IOC = 0x05,
322 
324  CL_CID_RMD = 0x06,
325 
327  CL_CID_NAMES = 0x07,
328 
330  CL_CID_TIMER = 0x08,
331 
333  CL_CID_SHM = 0x09,
334 
336  CL_CID_DSHM = 0x0a,
337 
339  CL_CID_LOG = 0x0b,
340 
342  CL_CID_MSG = 0x0c,
343 
345  CL_CID_DIAG = 0x0d,
346 
348  CL_CID_DEBUG = 0x0e,
349 
351  CL_CID_CPM = 0x0f,
352 
354  CL_CID_CAP = 0x10,
355 
357  CL_CID_RES = 0x11,
358 
360  CL_CID_GMS = 0x12,
361 
364 
366  CL_CID_DLOCK = 0x14,
367 
369  CL_CID_TXN = 0x15,
370 
372  CL_CID_CKPT = 0x16,
373 
375  CL_CID_COR = 0x17,
376 
378  CL_CID_CNT = 0x18,
379 
381  CL_CID_DCNT = 0x19,
382 
384  CL_CID_RCNT = 0x1a,
385 
388 
391 
393  CL_CID_RULE = 0x1d,
394 
397 
399  CL_CID_CM = 0x1f,
400 
402  CL_CID_HPI = 0x20,
403 
406 
408  CL_CID_AMS = 0x22,
409 
411  CL_CID_MED = 0x23,
412 
415 
417  CL_CID_QUEUE = 0x25,
418 
420  CL_CID_CLIST = 0x26,
421 
423  CL_CID_SNMP = 0x27,
424 
426  CL_CID_NS = 0x28,
427 
429  CL_CID_OM = 0x29,
430 
432  CL_CID_POOL = 0x2a,
433 
435  CL_CID_CD = 0x2b,
436 
438  CL_CID_DM = 0x2c,
439 
442 
444  CL_CID_PROV = 0x2e,
445 
447  CL_CID_UM = 0x2f,
448 
451 
454 
456  CL_CID_XDR = 0x32,
457 
459  CL_CID_IDL = 0x33,
460 
462  CL_CID_HEAP = 0x34,
463 
465  CL_CID_MEM = 0x35,
466 
469 
470  CL_CID_BACKING_STORAGE = 0x37,
471 
472  CL_CID_JOB = 0x38,
473  CL_CID_JOBQUEUE = 0x38,
474 
475  CL_CID_THREADPOOL = 0x39,
476  CL_CID_TASKPOOL = 0x39,
477 
480 
481 
482  /* Add more CID here if required */
483  CL_CID_LEAKY_BUCKET = 0x3b,
484 
486  CL_CID_MSO = 0x3c,
487 
489  CL_CID_PM = 0x3d,
490 
492  CL_CID_NF = 0x3e,
493 
495  CL_CID_MAX
496 
498 
499 typedef struct ClWaterMark
500 {
501  ClUint64T lowLimit;
502  ClUint64T highLimit;
503 } ClWaterMarkT;
504 
505 typedef enum
506 {
507  CL_WM_LOW_LIMIT = 0,
508  CL_WM_HIGH_LIMIT = 1,
509 }
510 ClEoWaterMarkFlagT;
511 
512 typedef enum{
513  CL_WM_LOW,
514  CL_WM_HIGH,
515  CL_WM_MED,
516  CL_WM_SENDQ,
517  CL_WM_RECVQ,
518  CL_WM_MAX
519 }ClWaterMarkIdT;
520 
521 #define CL_WEAK __attribute__((weak))
522 
523 #define CL_EO_ACTION_CUSTOM (1<<0)
524 #define CL_EO_ACTION_EVENT (1<<1)
525 #define CL_EO_ACTION_LOG (1<<2)
526 #define CL_EO_ACTION_NOT (1<<3)
527 #define CL_EO_ACTION_MAX (1<<31) // ClUnt8T type bieng used for bitMap
528 
529 typedef struct ClEoActionInfo {
530  ClUint32T bitMap;
531 } ClEoActionInfoT;
532 
537 typedef ClPtrT* ClEoActionArgListT;
538 
539 typedef struct
540 {
541  ClUint32T length;
542  ClCharT *pValue;
543 }ClStringT;
544 
545 extern ClStringT *clStringDup(const ClStringT *);
546 
547 /* Macro to print into the name */
552 #define clNamePrintf(name, ...) \
553 do \
554 { \
555  name.length = snprintf(name.value, CL_MAX_NAME_LENGTH - 1, __VA_ARGS__);\
556  name.value[CL_MIN(name.length, CL_MAX_NAME_LENGTH - 1)] = '\0'; \
557 }while(0)
558 
559 #ifdef __GNUC__
560 #define CL_DEPRECATED __attribute__((__deprecated__))
561 #define CL_PRINTF_FORMAT(fmtPos, argPos) __attribute__((format(printf, fmtPos, argPos)))
562 #else
563 #define CL_DEPRECATED
564 #define CL_PRINTF_FORMAT(fmtPos, argPos)
565 #endif
566 
567 #ifdef __cplusplus
568 }
569 #endif
570 
575 #endif /* _CL_COMMON_H_ */
ClUint32T ClRcT
Clovis return code type.
Definition: clCommon.h:168
ClPtrT * ClEoActionArgListT
The argument list that can be provided to the custom action taken on water mark hit.
Definition: clCommon.h:537
ClInt64T ClTimeT
Time duration specified in nanoseconds.
Definition: clCommon.h:154
ClCompIdT
Clovis Component Ids.
Definition: clCommon.h:304
#define CL_MAX_NAME_LENGTH
The Maximum length of most string names in the OpenClovis ASP framework.
Definition: clCommon.h:194
ClRcT(* ClCallbackT)(CL_IN ClPtrT invocation)
Definition of a generic single argument callback function.
Definition: clCommon.h:179
ClInt64T ClOffsetT
Offset of a buffer or object within another
Definition: clCommon.h:159
ClCharT * clStrdup(const ClCharT *str)
Duplicate a string.
void clNameSet(ClNameT *name, const char *str)
Load the ClNameT structure.
void clNameCopy(ClNameT *nameOut, const ClNameT *nameIn)
Load the ClNameT structure.
ClDispatchFlagsT
Dispatch flags.
Definition: clCommon.h:260
ClUint64T ClSizeT
Definition: clCommon.h:157
ClStatusT
These define all the possible states that a component/node can be in.
Definition: clCommon.h:76
void clNameConcat(ClNameT *nameOut, const ClNameT *prefix, const char *separator, const ClNameT *suffix)
Join ClNameT structures.
#define CL_IN
CL_IN macro assists in clearly defining arguments of an API, but has no actual meaning.
Definition: clCommon.h:106
@ CL_CID_DEBUG
Debug.
Definition: clCommon.h:348
@ CL_CID_IOC
Intelligent Object Communication.
Definition: clCommon.h:321
@ CL_CID_MEM
Memory Management.
Definition: clCommon.h:465
@ CL_CID_SNMP
SNMP Agent.
Definition: clCommon.h:423
@ CL_CID_OAMP_RT
OAMP RT parser.
Definition: clCommon.h:441
@ CL_CID_RES
Resource Management (for future use)
Definition: clCommon.h:357
@ CL_CID_EO
Execution Object.
Definition: clCommon.h:318
@ CL_CID_UM
Upgrade Manager (for future use)
Definition: clCommon.h:447
@ CL_CID_CKPT
Checkpointing Service.
Definition: clCommon.h:372
@ CL_CID_TIMER
Timer.
Definition: clCommon.h:330
@ CL_CID_ALARMS
Alarm Manager.
Definition: clCommon.h:387
@ CL_CID_MAX
This will help validate if needs to be.
Definition: clCommon.h:495
@ CL_CID_TXN
Transactions.
Definition: clCommon.h:369
@ CL_CID_FAULTS
Fault Management.
Definition: clCommon.h:405
@ CL_CID_DCNT
Distributed Containers (for future use)
Definition: clCommon.h:381
@ CL_CID_SCRIPTING
Scripting Engine (for future use)
Definition: clCommon.h:396
@ CL_CID_HAL
Hardware Abstraction Layer.
Definition: clCommon.h:312
@ CL_CID_DLOCK
Distributed Locking (for future use)
Definition: clCommon.h:366
@ CL_CID_HPI
Hardware Platform Interface.
Definition: clCommon.h:402
@ CL_CID_CD
Common Diagnostics (for future use)
Definition: clCommon.h:435
@ CL_CID_OSAL
OS Abstraction Layer.
Definition: clCommon.h:309
@ CL_CID_NAMES
Name Service.
Definition: clCommon.h:327
@ CL_CID_UNSPECIFIED
Unspecified.
Definition: clCommon.h:306
@ CL_CID_SHM
Shared Memory Support.
Definition: clCommon.h:333
@ CL_CID_PARSER
Parser.
Definition: clCommon.h:468
@ CL_CID_CM
Chassis Manager.
Definition: clCommon.h:399
@ CL_CID_HEAP
Heap Management.
Definition: clCommon.h:462
@ CL_CID_PM
Performance Management.
Definition: clCommon.h:489
@ CL_CID_CAP
Capability Management (for future use)
Definition: clCommon.h:354
@ CL_CID_MED
Mediation Library.
Definition: clCommon.h:411
@ CL_CID_DSHM
Distributed Shared Memory.
Definition: clCommon.h:336
@ CL_CID_BITMAP
Bitmap Management.
Definition: clCommon.h:479
@ CL_CID_QUEUE
Queue Management.
Definition: clCommon.h:417
@ CL_CID_AMS
Availability Management Service.
Definition: clCommon.h:408
@ CL_CID_PROV
Provisioning Manager.
Definition: clCommon.h:444
@ CL_CID_CNT
Containers.
Definition: clCommon.h:378
@ CL_CID_NS
Name Service.
Definition: clCommon.h:426
@ CL_CID_RULE
Rule Base Engine.
Definition: clCommon.h:393
@ CL_CID_EVENTS
Event Service.
Definition: clCommon.h:363
@ CL_CID_COR
Clovis Object Registry.
Definition: clCommon.h:375
@ CL_CID_RCNT
Resilient Containers (for future use)
Definition: clCommon.h:384
@ CL_CID_NF
SAF Notification service.
Definition: clCommon.h:492
@ CL_CID_MSO
Mso Services Management.
Definition: clCommon.h:486
@ CL_CID_CLIST
Circular List Management.
Definition: clCommon.h:420
@ CL_CID_MSG
Message Service.
Definition: clCommon.h:342
@ CL_CID_RMD
Remote Method Dispatch.
Definition: clCommon.h:324
@ CL_CID_LOG
Logging.
Definition: clCommon.h:339
@ CL_CID_DM
Diagnostics Manager (for future use)
Definition: clCommon.h:438
@ CL_CID_OM
Object Manager.
Definition: clCommon.h:429
@ CL_CID_POOL
Pool Management.
Definition: clCommon.h:432
@ CL_CID_DBAL
Database Abstraction Layer.
Definition: clCommon.h:315
@ CL_CID_POLICY
Policy Engine.
Definition: clCommon.h:390
@ CL_CID_DIAG
Diagnostics.
Definition: clCommon.h:345
@ CL_CID_XDR
XDR Library.
Definition: clCommon.h:456
@ CL_CID_IDL
IDL.
Definition: clCommon.h:459
@ CL_CID_HANDLE
Handle Database.
Definition: clCommon.h:450
@ CL_CID_CPM
Component Management.
Definition: clCommon.h:351
@ CL_CID_VERSION
Version Checker Library.
Definition: clCommon.h:453
@ CL_CID_GMS
Group Membership Service.
Definition: clCommon.h:360
@ CL_CID_BUFFER
Buffer Management.
Definition: clCommon.h:414
@ CL_STATUS_UP
This determines that the node/component is up.
Definition: clCommon.h:85
@ CL_STATUS_DOWN
This determines that the node/component is down.
Definition: clCommon.h:80
A name.
Definition: clCommon.h:197
ClUint16T length
Length of the name in bytes excluding '\0'.
Definition: clCommon.h:199
Version Information for various services.
Definition: clCommon.h:250
ClUint8T minorVersion
Minor Number in range of [01-255].
Definition: clCommon.h:256
ClUint8T releaseCode
single ASCII capitol letter "A-Z"
Definition: clCommon.h:252
ClUint8T majorVersion
Major Number in range of [01-255].
Definition: clCommon.h:254

Generated on Tue Jan 10 10:29:15 PST 2012 for OpenClovis SDK using Doxygen