/* * (c) Copyright, Real-Time Innovations, 2010-2024. * All rights reserved. * * No duplications, whole or partial, manual or electronic, may be made * without express written permission. Any such copies, or * revisions thereof, must display this notice unaltered. * This code contains trade secrets of Real-Time Innovations, Inc. */ #ifndef osapi_cpu_h #define osapi_cpu_h #include "osapi/osapi_dll.h" #include "osapi/osapi_type.h" #ifdef __cplusplus extern "C" { #endif /** @internal \file * \brief Processor related utility */ /** @internal \defgroup RTIOsapiCpuBitmapClass RTIOsapiCpuBitmap * \ingroup RTIOsapiModule * \brief Bitmask of available processors. */ #if defined(RTI_QNX) #define RTI_OSAPI_CPU_BITMAP_MAX_BITS (32) #else #define RTI_OSAPI_CPU_BITMAP_MAX_BITS (1024) #endif #define RTI_OSAPI_CPU_BITMAP_LENGTH (RTI_OSAPI_CPU_BITMAP_MAX_BITS / 32) #define RTI_OSAPI_CPU_NO_ROTATION (0) #define RTI_OSAPI_CPU_RR_ROTATION (1) struct RTIOsapiCpuBitmap { RTI_UINT32 mask[RTI_OSAPI_CPU_BITMAP_LENGTH]; int rotation; int _numCpus; int _numUses; }; #if defined(RTI_QNX) #define RTI_OSAPI_CPU_BITMAP_DEFAULT \ { \ { 0 }, RTI_OSAPI_CPU_NO_ROTATION, 0, 0 \ } #else #define RTI_OSAPI_CPU_BITMAP_DEFAULT \ { \ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, \ RTI_OSAPI_CPU_NO_ROTATION, 0, 0 \ } #endif #define RTIOsapiCpuBitmap_test(me, i) \ ((me)->mask[i >> 5] & (RTI_UINT32) (1U << (i & 0x1F))) #define RTIOsapiCpuBitmap_set(me, i) \ do { \ if (((me)->mask[i >> 5] & (RTI_UINT32) (1U << (i & 0x1F))) == 0) \ (me)->_numCpus++; \ (me)->mask[i >> 5] |= (RTI_UINT32) (1U << (i & 0x1F)); \ } while (0) #define RTIOsapiCpuBitmap_zero(me) RTIOsapiMemory_zero((me), sizeof(*(me))) #define RTIOsapiCpuBitmap_incrementUseCounter(me) ((me)->_numUses++) #define RTIOsapiCpuBitmap_copy(to, src) \ RTIOsapiMemory_copy((to), (src), sizeof(*(src))) extern RTIOsapiDllExport RTIBool RTIOsapiCpuBitmap_equals( const struct RTIOsapiCpuBitmap *me, const struct RTIOsapiCpuBitmap *other); extern RTIOsapiDllExport void RTIOsapiCpuBitmap_toStringI( struct RTIOsapiCpuBitmap *me, char *dst, int max); #ifdef __cplusplus } /* extern "C" */ #endif #endif /* osapi_cpu_h */