Go to the documentation of this file. 1 #ifndef _COMPILER_HINTS_H_
2 #define _COMPILER_HINTS_H_ "$Id: compiler_hints.h 472 2020-07-25 21:03:30Z geoff $"
288 # ifndef _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
289 # define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1
291 # ifndef _CRT_SECURE_NO_WARNINGS
292 # define _CRT_SECURE_NO_WARNINGS 1
294 # ifndef _CRT_NONSTDC_NO_WARNINGS
295 # define _CRT_NONSTDC_NO_WARNINGS 1
298 # define OME_FAST_CALL __fastcall
300 # pragma warning(disable : 4996)
307 # define OME_DEPRECATED __attribute__((deprecated))
308 # define OME_DEPRECATED_BECAUSE(msg) __attribute__((deprecated(msg)))
309 # define OME_USAGE_WARNING(msg) __attribute__((warning(msg)))
310 # define OME_USAGE_ERROR(msg) __attribute__((error(msg)))
311 # define CONSTEXPR constexpr
312 # define AN_ENUM(x) x
314 # define NONNULL_PARAMETERS(...) __attribute__((nonnull(__VA_ARGS__)))
316 # define NONNULL_CLASS_PARAMETERS(...) __attribute__((nonnull(__VA_ARGS__)))
318 # define NONNULL_RETURN __attribute__((returns_nonnull))
320 # define OME_USED __attribute__((used))
321 # define OME_ALWAYS_INLINE __attribute__((always_inline))
322 # define OME_INIT_PRIORITY(n) __attribute__((init_priority(n)))
323 # define OME_PURE_FUNCTION __attribute__((pure))
324 # define OME_CONST_FUNCTION __attribute__((const))
325 # define OME_EXPECT(expr, expected) __builtin_expect((expr), expected)
327 # define OME_PREFETCH(addr, rw, locality) __builtin_prefetch(addr, rw, locality)
331 # define OME_UNUSED __attribute__((unused))
335 # define NONNULL_PARAMETERS(...) __attribute__((nonnull(__VA_ARGS__)))
337 # define NONNULL_CLASS_PARAMETERS(...) __attribute__((nonnull(__VA_ARGS__)))
339 # define NONNULL_RETURN __attribute__((returns_nonnull))
341 # ifdef HAVE_GCCVISIBILITYPATCH
342 # define OME_DLL_EXPORT __attribute__((visibility("default")))
343 # define OME_DLL_LOCAL __attribute__((visibility("hidden")))
349 # define OME_DLL_EXPORT __declspec(dllexport)
351 # define OME_DLL_EXPORT __declspec(dllimport)
353 # define OME_DLL_LOCAL
360 # define OME_EXPECT(expr, expected) __builtin_expect((expr), expected)
362 # define OME_PREFETCH(addr, rw, locality) __builtin_prefetch(addr, rw, locality)
364 # define OME_ALWAYS_INLINE __attribute__((always_inline))
366 # define OME_NEVER_INLINE __attribute__((noinline))
368 # define OME_ALWAYS_FLATTEN __attribute__((flatten))
370 # define OME_COLD_ROUTINE __attribute__((cold))
372 # define OME_INIT_PRIORITY(n) __attribute__((init_priority(n)))
374 # define OME_DEPRECATED __attribute__((deprecated))
376 # define OME_USAGE_WARNING(msg) __attribute__((warning(msg)))
378 # define OME_USAGE_ERROR(msg) __attribute__((error(msg)))
380 # define OME_USED __attribute__((used))
382 # define OME_UNUSED __attribute__((unused))
386 #define OME_WEAK __attribute__((weak))
388 # define OME_PURE_FUNCTION __attribute__((pure))
390 # define OME_CONST_FUNCTION __attribute__((const))
392 # define AN_ENUM(x) x
399 # define OME_FAST_CALL __attribute__((__cdecl__)) __attribute__((__regparm__(3)))
403 # if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
404 # define OME_DEPRECATED_BECAUSE(msg) __attribute__((deprecated(msg)))
406 # define OME_ALWAYS_OPTIMIZE(level) __attribute__((optimize(level)))
409 # define OME_DEPRECATED_BECAUSE(msg) __attribute__((deprecated))
416 # if _MSC_VER >= 1400
417 # define VIRTUAL_OVERRIDE override
420 # if _MSV_VER >= 1900
421 # define CONSTEXPR constexpr
424 # define AN_ENUM(x) ((uint32_t)(x))
427 #if __cplusplus >= 201100
428 # ifndef EXPLICIT_CONVERSION
429 # define EXPLICIT_CONVERSION explicit
432 # define CONSTEXPR constexpr
434 # ifndef VIRTUAL_OVERRIDE
435 # define VIRTUAL_OVERRIDE override
437 # ifndef NOEXCEPT_SPECIFIER
438 # define NOEXCEPT_SPECIFIER noexcept
443 #ifndef NOEXCEPT_SPECIFIER
444 # define NOEXCEPT_SPECIFIER
447 #ifndef VIRTUAL_OVERRIDE
448 # define VIRTUAL_OVERRIDE
451 #ifndef EXPLICIT_CONVERSION
452 # define EXPLICIT_CONVERSION
456 # ifdef _GLIBCXX_USE_CONSTEXPR
457 # define CONSTEXPR _GLIBCXX_USE_CONSTEXPR
459 # define CONSTEXPR const
463 #ifndef OME_DLL_EXPORT
464 # define OME_DLL_EXPORT
467 #ifndef OME_FAST_CALL
468 # define OME_FAST_CALL
471 #ifndef OME_CORE_CALL
472 # define OME_CORE_CALL
476 # define OME_EXPECT(expr, expected) (expr)
479 # define OME_PREFETCH(addr, rw, locality)
482 #ifndef OME_FAST_CALL
483 # define OME_FAST_CALL
485 #ifndef OME_ALWAYS_INLINE
486 # define OME_ALWAYS_INLINE
488 #ifndef OME_NEVER_INLINE
489 # define OME_NEVER_INLINE
491 #ifndef OME_ALWAYS_FLATTEN
492 # define OME_ALWAYS_FLATTEN
494 #ifndef OME_COLD_ROUTINE
495 # define OME_COLD_ROUTINE
497 #ifndef OME_ALWAYS_OPTIMIZE
498 # define OME_ALWAYS_OPTIMIZE(level)
500 #ifndef OME_INIT_PRIORITY
501 # define OME_INIT_PRIORITY(n)
503 #ifndef OME_DEPRECATED
504 # define OME_DEPRECATED
506 #ifndef OME_DEPRECATED_BECAUSE
507 # define OME_DEPRECATED_BECAUSE(msg)
509 #ifndef OME_USAGE_WARNING
510 # define OME_USAGE_WARNING(msg)
512 #ifndef OME_USAGE_ERROR
513 # define OME_USAGE_ERROR(msg)
524 #ifndef OME_PURE_FUNCTION
525 # define OME_PURE_FUNCTION
527 #ifndef OME_CONST_FUNCTION
528 # define OME_CONST_FUNCTION
530 #ifndef NONNULL_PARAMETERS
531 # define NONNULL_PARAMETERS(...)
533 #ifndef NONNULL_CLASS_PARAMETERS
534 # define NONNULL_CLASS_PARAMETERS(...)
536 #ifndef NONNULL_RETURN
537 # define NONNULL_RETURN
540 #define OME_EXPECT_FALSE(expr) OME_EXPECT(expr, false)
541 #define OME_EXPECT_TRUE(expr) OME_EXPECT(expr, true)
544 # define OME_YIELD_THREAD() SwitchToThread()
546 # ifdef _POSIX_PRIORITY_SCHEDULING
547 # define OME_YIELD_THREAD() sched_yield()
551 #ifndef OME_YIELD_THREAD
554 # define OME_YIELD_THREAD() \
556 struct timespec nano_delay = {0, 0}; \
557 nanosleep(&nano_delay, 0); \
563 # define USE_GCC_PREFETCH 1
567 # define MemoryBarrier() __sync_synchronize()
569 # define USE_GCC_PREFETCH 0
576 #define CACHE_LINE_LENGTH 64
580 #define MAX_PREFETCH_REQUESTS 8
583 # if USE_GCC_PREFETCH == 1
585 # define DO_PREFETCH(a) OME_PREFETCH(a, 0, 1)
588 # define DO_PREFETCH(a) p_fetch += *a
592 # define OME_PREFETCH_OBJECT_VTABLE(obj, relativeFunction) \
594 unsigned char ***vTablePtr = (unsigned char ***) (obj); \
595 unsigned char **vTableBase = *vTablePtr; \
596 unsigned char **funcPtrAddr = vTableBase + relativeFunction; \
597 OME_PREFETCH(funcPtrAddr, 0, 3); \
600 # define OME_PREFETCH_OBJECT_VTABLE(obj, relativeFunction) \
626 const unsigned int len)
631 int cache_bytes = len -
sizeof(int_fast32_t);
632 if (cache_bytes <= 0) {
640 # if USE_GCC_PREFETCH == 0
644 const int_fast32_t *a = (
const int_fast32_t *)(addr);
651 switch (cache_lines) {
677 # if USE_GCC_PREFETCH == 1
696 #define safe_strcpy(d, s, l) ((memccpy(d, s, 0, (l)) == 0) ? (*(d + (l) -1) = 0) : 1)
743 #pragma GCC diagnostic push
744 #pragma GCC diagnostic ignored "-Wmissing-attributes"
755 template <u
int_fast8_t N>
inline char *
do_copyShortStringUntil(
char *bfr,
const char *src,
const char stopAt,
const char altStopAt)
766 enum { AVE_LEN_LEFT = 2 };
767 if (
OME_EXPECT(((c == stopAt) || (c == altStopAt)), (N <= AVE_LEN_LEFT))) {
771 return (do_copyShortStringUntil < N - 1 > (bfr + 1, src + 1, stopAt));
774 #pragma GCC diagnostic pop
804 template <uint_fast8_t N> inline
char *
copyShortStringUntil(
char *bfr, const
char *src, const
char stopAt, const
char altStopAt, const
bool truncateIfNeeded)
807 char *end = do_copyShortStringUntil<N>(bfr, src, stopAt, altStopAt);
809 if ((truncateIfNeeded ==
true) && (end == (bfr + N))) {
845 char *end = do_copyShortStringUntil<N>(bfr, src, stopAt, altStopAt);
847 if ((truncateIfNeeded ==
true) && (end == (bfr + N))) {
852 return (
static_cast<uint_fast32_t
>(end - bfr));
870 char *readableName = abi::__cxa_demangle(name, 0, 0, &result);
875 UnDecorateSymbolName(name, bfr, bfrLen, 0);
902 template <
typename TYPENAME>
928 #define demangledTypeIdName(typeid_var, bfr) demangleEncodedTypeName((typeid_var).name(), bfr, sizeof(bfr))
OME_DLL_EXPORT void INIT_DECLARE_clPI()
Definition: clPI.cpp:1790
OMEtype threadContext
Definition: OMEthread.h:77
#define safe_strcpy(d, s, l)
Safe strcpy() routine that will not copy more than l bytes and always ensures that a null is present ...
Definition: compiler_hints.h:696
void * threadStack
Definition: OMEthread.h:41
OMEtype thisMethod
Definition: OMEthread.h:36
int base64ToASCII(OMEthread *thread, OMEtype &result, const OMEtype &source)
Definition: OILmimeDecode.cpp:338
@ OME_NLM
Definition: OMEmanifests.h:90
void initializeAsType(const enum OMEtypes_t t)
The fundamental tagged data type used through the FARGOS/VISTA infrastructure.
Definition: OMEtype.cpp:95
#define DO_PREFETCH(a)
Prefetch an address line for read.
Definition: compiler_hints.h:585
OMEclass * OMEdefineNewClass(const OMEstring &nmSpaceArg, const OMEstring &classNameArg, const uint32_t verID, const uint32_t iSize, const bool unique, int *errCode, const CreateInstanceFP csRoutine, const DeleteInstanceFP dsRoutine)
Create new class entry.
Definition: OMEnamespace.cpp:198
#define OME_ALWAYS_FLATTEN
Annotation macro to request compiler to always inline body and any called routines.
Definition: compiler_hints.h:368
bool OMEokToAssignTypes(uint32_t srcType, uint32_t targetType, OMEthread *t)
Definition: OMEthread.cpp:1260
int prefetch_memory_block(const void *addr, const unsigned int len) OME_ALWAYS_INLINE
Prefetch a memory block into the CPU's cache.
Definition: compiler_hints.h:625
int compressString(OMEthread *thread, OMEtype &result, const OMEtype &data)
Definition: OILencode.cpp:100
OME_FAST_CALL int returnReply(const OMEtype &result)
Definition: OMEthread.cpp:730
void yieldSlice()
Definition: OMEthread.cpp:1112
const OMEtype & getThisObject() const OME_ALWAYS_INLINE
Definition: OMEthread.h:152
OME_FAST_CALL int callMethodWithSetArgument(const OMEtype &methodName, const uint32_t hashIndx, const OMEtype &argSet)
Definition: OMEthread.cpp:678
int asciiToBase64(OMEthread *thread, OMEtype &result, const OMEtype &source, const OMEtype &breakIntoLines)
Definition: OILmimeDecode.cpp:318
int uncompressString(OMEthread *thread, OMEtype &result, const OMEtype &data)
Definition: OILencode.cpp:118
int encodeData(OMEthread *thread, OMEtype &result, const OMEtype &data, const OMEtype &version)
Definition: OILencode.cpp:26
int setStorageDescription(const struct OMEinstanceVarDescr *desc)
Definition: OMEclass.cpp:224
Fundamental ANY type for FARGOS/VISTA Object Management Environment.
Definition: OMEbaseType.h:250
void noteLineNumber(int line, const char *fileName=nullptr) OME_ALWAYS_INLINE
Definition: OMEthread.h:193
int decodeData(OMEthread *thread, OMEtype &result, const OMEtype &data)
Definition: OILencode.cpp:61
@ OME_DOUBLE
Definition: OMEmanifests.h:83
#define OME_ALWAYS_OPTIMIZE(level)
Mark a function to be compiled with a specific level of optimization.
Definition: compiler_hints.h:406
const OMEstring & OMEshareConstant(const OMEstring &stringConstant)
Definition: OMEnamespace.cpp:338
const typedef void * OMEstringInROM
Points to immovable, read-only string data.
Definition: OMEstring.h:68
char * copyShortStringUntil(char *bfr, const char *src, const char stopAt='\0', const char altStopAt='\0', const bool truncateIfNeeded=false) OME_ALWAYS_INLINE OME_ALWAYS_FLATTEN OME_ALWAYS_OPTIMIZE("-O3") NONNULL_PARAMETERS(1
Templated C++-only variant of safe_strcpy() suitable for handling small-sized strings that are being ...
Definition: compiler_hints.h:804
OME_CORE_CALL int registerService(class OMEthread *thread, OMEtype &result, const OMEtype &name, const OMEtype &obj, const OMEtype &flag)
Definition: OMEthread.cpp:118
int priorIndex(OMEthread *thread, OMEtype &result, const OMEtype &array, const OMEtype &subscript)
Definition: OILtypeFuncs.cpp:416
OMEtype argv
Definition: OMEthread.h:38
#define NONNULL_PARAMETERS(...)
Mark parameters to a function as not permitting null pointers.
Definition: compiler_hints.h:335
int32_t i
Definition: OMEbaseType.h:285
Meta data record to describe an instance variable of a class.
Definition: OMEnamespace.h:76
void exitRoutine()
Definition: OMEthread.cpp:1004
FARGOS/VISTA Object Management Environment class description.
Definition: OMEclass.h:24
int getSystemInfo(OMEthread *thread, OMEtype &result)
Definition: OILtime.cpp:31
void suspendThread()
Definition: OMEthread.cpp:1086
#define CACHE_LINE_LENGTH_IN_WORDS
Definition: tmp.o.cpp:30
Define method implementation.
Definition: OMEnamespace.h:86
int resolveLinkages(OMEstring *missingClassName=nullptr, uint32_t *missingClassVersionID=nullptr)
Attempt to resolve inheritance tree.
Definition: OMEclass.cpp:428
bool replyStillPending() const OME_ALWAYS_INLINE
Definition: OMEthread.h:113
OMEtype argc
Definition: OMEthread.h:37
int arrayToSet(OMEthread *thread, OMEtype &result, const OMEtype &arg)
Definition: OILtypeFuncs.cpp:571
int relativePathToAbsolute(OMEthread *thread, OMEtype &result, const OMEtype ¤tDir, const OMEtype &path)
Definition: OILhttpFuncs.cpp:186
@ OME_STRING
Definition: OMEmanifests.h:85
int nextIndex(OMEthread *thread, OMEtype &result, const OMEtype &array, const OMEtype &subscript)
Definition: OILtypeFuncs.cpp:396
char * do_copyShortStringUntil(char *bfr, const char *src, const char stopAt='\0', const char altStopAt='\0') OME_ALWAYS_INLINE OME_ALWAYS_FLATTEN OME_ALWAYS_OPTIMIZE("-O3") NONNULL_PARAMETERS(1
Templated C++-only routine similar to memccpy() that is suitable for handling short strings that are ...
Definition: compiler_hints.h:755
OME_FAST_CALL int sendMessageWithSetArgument(const OMEtype &methodName, const uint32_t hashIndx, const OMEtype &argSet, const OMEtype &destObj, const OMEtype &fromObj, const int32_t timeout)
Definition: OMEthread.cpp:593
int getTicksSinceBoot(OMEthread *thread, OMEtype &result)
Definition: OILtime.cpp:94
#define CACHE_LINE_LENGTH
Definition for target system's cache line length.
Definition: compiler_hints.h:576
OME_DLL_EXPORT void INIT_DECLARE()
Definition: clTest.cpp:11826
@ OME_NIL
Definition: OMEmanifests.h:78
const OMEtype & getReplyOID()
Definition: OMEthread.h:125
@ OME_OID
Definition: OMEmanifests.h:84
int getLocalRelativeTime(OMEthread *thread, OMEtype &result)
Definition: OILtime.cpp:76
int getRelativeMilliseconds(OMEthread *thread, OMEtype &result)
Definition: OILtime.cpp:85
int OMEdefineNewMethod(const OMEmethodDefinition &definitionRecord)
Definition: OMEnamespace.cpp:248
int pathComponentsToString(OMEthread *thread, OMEtype &result, const OMEtype &elements, const OMEtype &startIndex, const OMEtype &stopIndex)
Definition: OILhttpFuncs.cpp:237
OMEcallStack * callStack
Definition: OMEthread.h:74
OME_CORE_CALL int unregisterService(class OMEthread *thread, OMEtype &result, const OMEtype &name, const OMEtype &obj)
Definition: OMEthread.cpp:162
const OMEtype & getReplyResult() const OME_ALWAYS_INLINE
Definition: OMEthread.h:177
int display(OMEthread *thread, OMEtype &result, const OMEtype &argSet)
Definition: OILdebug.cpp:112
int typeOf(OMEthread *thread, OMEtype &result, const OMEtype &arg)
Definition: OILtypeFuncs.cpp:127
#define OME_EXPECT(expr, expected)
Annotation macro for conditional expression to indicate expected Boolean outcome.
Definition: compiler_hints.h:360
OME_CORE_CALL int createNewOIDthatOnlyAllowsOthers(class OMEthread *thread, OMEtype &result, const OMEtype &args)
Definition: OMEobjACL.cpp:338
OMEtype fromObject
Definition: OMEthread.h:78
const char * demangledTypeName(char *bfr, uint32_t bfrLen)
Templated convenience function that obtains the demangled type name of a C++ type.
Definition: compiler_hints.h:903
int alwaysAllow(OMEthread *thread, OMEtype &result, const OMEtype &methodName)
Definition: OILallow.cpp:20
const char * demangleEncodedTypeName(const char *name, char *bfr, uint32_t bfrLen) NONNULL_PARAMETERS(1
Demangles a C++ encoded type name into its human-readable name.
Definition: compiler_hints.h:866
int allow(OMEthread *thread, OMEtype &result, const OMEtype &methodName)
Definition: OILallow.cpp:5
@ OME_SET
Definition: OMEmanifests.h:89
uint_fast32_t copyShortStringUntilAndReturnLength(char *bfr, const char *src, const char stopAt='\0', const char altStopAt='\0', const bool truncateIfNeeded=false) OME_ALWAYS_INLINE OME_ALWAYS_FLATTEN OME_ALWAYS_OPTIMIZE("-O3") NONNULL_PARAMETERS(1
Similar to copyShortStringUntil<>(), but returns the number of bytes before the trailing null....
#define OME_ALWAYS_INLINE
Tell the compiler to alway inline a function, regardless of optimization level.
Definition: compiler_hints.h:364
Record to describe the implementation of the method of an OME class.
Definition: OMEmethod.h:35
int parsePathComponents(OMEthread *thread, OMEtype &result, const OMEtype &path)
Definition: OILhttpFuncs.cpp:133
int elementCount(OMEthread *thread, OMEtype &result, const OMEtype &arg)
Definition: OILtypeFuncs.cpp:168
void setResultPending() OME_ALWAYS_INLINE
Definition: OMEthread.h:111
#define OME_DLL_EXPORT
Definition: compiler_hints.h:464
OME_CORE_CALL int lookupLocalService(class OMEthread *thread, OMEtype &result, const OMEtype &name)
Definition: OMEthread.cpp:190
#define MAX_PREFETCH_REQUESTS
Maximum number of prefetch requests supported by the hardware.
Definition: compiler_hints.h:580
Public interface to an OME thread.
Definition: OMEthread.h:60
uint32_t programCounter
Definition: OMEthread.h:39
OME_FAST_CALL void * getInstanceData() const
Definition: OMEthread.cpp:1036
const class OMEtype & READ_ONLY_OMEtype
A convenience typedef for performing read-only access to sparse and associative arrays....
Definition: OMEtype.h:58
int inheritFromClass(const OMEstring &nameSpace, const OMEstring &name, const uint32_t verID=0, const bool unique=false)
Definition: OMEclass.cpp:349
OME_CORE_CALL int makeDefaultACL(class OMEthread *thread, OMEtype &result)
Definition: OMEobjACL.cpp:267
int SHA1hash(OMEthread *thread, OMEtype &result, const OMEtype &message)
Definition: OILcrypto.cpp:9
int createNLM(OMEthread *thread, OMEtype &result, const OMEtype &catName, const OMEtype &messID, const OMEtype &defaultMess, const OMEtype &args, const OMEtype &extras)
Definition: OILtypeFuncs.cpp:810
OMEtype & OMEgetObjectCreatorOID(const OMEtype &userInfo)
Definition: OMEcreate.cpp:117
int displayAsHex(OMEthread *thread, OMEtype &result, const OMEtype &args)
Definition: OILdebug.cpp:260
OME_DLL_EXPORT void INIT_DECLARE()
Definition: clPlayWinSound.cpp:697
void free(char *block)
Definition: test_malloc.c:553
int length(OMEthread *thread, OMEtype &result, const OMEtype &arg)
Definition: OILtypeFuncs.cpp:19
#define OME_CORE_CALL
Definition: compiler_hints.h:472
@ OME_ARRAY
Definition: OMEmanifests.h:86
OME_FAST_CALL void setPC(uint32_t pc) OME_ALWAYS_INLINE
Definition: OMEthread.h:165
Internal data type to generate fixed-point constant from floating-point value.
Definition: OMEfixed.h:26
const OMEtype & getUserID() const OME_ALWAYS_INLINE
Definition: OMEthread.h:146
#define NONNULL_RETURN
Mark a function as never returning a null pointer.
Definition: compiler_hints.h:339
#define OME_INVOKE_OIL2_NATIVE
Definition: OMEmethod.h:12
@ OME_ASSOC
Definition: OMEmanifests.h:87
void noteObjectModified() OME_ALWAYS_INLINE
Definition: OMEthread.h:191
@ OME_INT32
Definition: OMEmanifests.h:79
@ OME_INT64
Definition: OMEmanifests.h:81