X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=o-du%2Fphy.git;a=blobdiff_plain;f=wls_lib%2Ftestapp%2Fpool.h;fp=wls_lib%2Ftestapp%2Fpool.h;h=bb1863eaae611a2967bc146ded3c58c6d0fdfa62;hp=0000000000000000000000000000000000000000;hb=9d66fca5c45c8b3e0d6eab6d51a90c8e9d2614dc;hpb=2fbf70096f64af622da983e88c5a64e90ad9bdbd diff --git a/wls_lib/testapp/pool.h b/wls_lib/testapp/pool.h new file mode 100644 index 0000000..bb1863e --- /dev/null +++ b/wls_lib/testapp/pool.h @@ -0,0 +1,56 @@ +/****************************************************************************** +* +* Copyright (c) 2019 Intel. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*******************************************************************************/ + +#ifndef _POOL_API_H_ +#define _POOL_API_H_ + +#ifdef __KERNEL__ +#include +#endif +#include +#include "ttypes.h" + + +typedef struct _POOL_ +{ + unsigned char* StoragePtr; // The pointer to the storage where blocks are located + unsigned int BlockNum; // The number of blocks in storage + unsigned int BlockSize; // The size of block in bytes + + unsigned long long* FreePtr; // The pointer to the storage with free object indexes + volatile unsigned long long FreePut; // PUT index used to put the new item to 'free' storage + volatile unsigned long long FreeGet; // GET index used to get the new free item from 'free' storage + + unsigned long long* UsedPtr; // The pointer to the storage with 'Used' object indexes + volatile unsigned long long UsedPut; // PUT index used to put the new item to 'already used' storage + volatile unsigned long long UsedGet; // GET index used to get the item from 'already used' storage +#ifdef __KERNEL__ + struct mutex lock; +#else + pthread_mutex_t lock; +#endif +}POOL, *PPOOL; + + +unsigned int PoolInit (PPOOL pPool, void * pStorage, unsigned int nBlockNum, unsigned int nBlockSize, unsigned long long* pFreePtr, unsigned long long* pUsedPtr); +void* PoolAlloc(PPOOL pPool); +unsigned int PoolFree(PPOOL pPool, void * pBlock); +unsigned int PoolGetFreeNum(PPOOL pPool); +unsigned int PoolGetAllocNum(PPOOL pPool); + +#endif //_POOL_API_H_