Merge branch '7.0' (after codeathon 2023) into PSI-7.0

This commit is contained in:
2023-03-29 13:36:52 +02:00
36 changed files with 662 additions and 181 deletions
+1 -1
View File
@@ -663,7 +663,7 @@ int otoi(Char *str)
char *readable_form(int c)
{
static char rform[10];
static char rform[16];
if ( (c >= 0 && c < 32) || c >= 127 )
{
+2
View File
@@ -29,6 +29,8 @@
extern "C" {
#endif
LIBCOM_API extern int freeListBypass;
LIBCOM_API void epicsStdCall freeListInitPvt(void **ppvt, int size, int malloc);
LIBCOM_API void * epicsStdCall freeListCalloc(void *pvt);
LIBCOM_API void * epicsStdCall freeListMalloc(void *pvt);
+42 -16
View File
@@ -26,6 +26,20 @@
#include "epicsMutex.h"
#include "freeList.h"
#include "adjustment.h"
#include "errlog.h"
#include "epicsString.h"
#include "epicsAtomic.h"
#include "epicsExport.h"
/* Bypass free list and directly call malloc() every time? */
int freeListBypass
#ifdef EPICS_FREELIST_DEBUG
= 1;
#else
= 2; /* checks environment $EPICS_FREELIST_BYPASS */
#endif
epicsExportAddress(int, freeListBypass);
typedef struct allocMem {
struct allocMem *next;
@@ -44,10 +58,25 @@ LIBCOM_API void epicsStdCall
freeListInitPvt(void **ppvt,int size,int nmalloc)
{
FREELISTPVT *pfl;
int bypass = epicsAtomicGetIntT(&freeListBypass);
if(bypass==2) {
const char *str = getenv("EPICS_FREELIST_BYPASS");
if(str && epicsStrCaseCmp(str, "YES")==0) {
bypass = 1;
} else if(!str || str[0]=='\0' || epicsStrCaseCmp(str, "NO")==0) {
bypass = 0;
} else {
errlogPrintf(ERL_WARNING " EPICS_FREELIST_BYPASS expected to be YES, NO, or empty. Not \"%s\"\n", str);
}
epicsAtomicSetIntT(&freeListBypass, bypass);
}
pfl = callocMustSucceed(1,sizeof(FREELISTPVT), "freeListInitPvt");
pfl->size = adjustToWorstCaseAlignment(size);
pfl->nmalloc = nmalloc;
if(!bypass)
pfl->nmalloc = nmalloc; /* nmalloc==0 to bypass */
pfl->head = NULL;
pfl->mallochead = NULL;
pfl->nBlocksAvailable = 0u;
@@ -60,28 +89,26 @@ LIBCOM_API void epicsStdCall
LIBCOM_API void * epicsStdCall freeListCalloc(void *pvt)
{
FREELISTPVT *pfl = pvt;
# ifdef EPICS_FREELIST_DEBUG
return callocMustSucceed(1,pfl->size,"freeList Debug Calloc");
# else
void *ptemp;
ptemp = freeListMalloc(pvt);
if(ptemp) memset((char *)ptemp,0,pfl->size);
if(!pfl->nmalloc)
ptemp = calloc(1u, pfl->size);
else if(!!(ptemp = freeListMalloc(pvt)))
memset((char *)ptemp,0,pfl->size);
return(ptemp);
# endif
}
LIBCOM_API void * epicsStdCall freeListMalloc(void *pvt)
{
FREELISTPVT *pfl = pvt;
# ifdef EPICS_FREELIST_DEBUG
return callocMustSucceed(1,pfl->size,"freeList Debug Malloc");
# else
void *ptemp;
void **ppnext;
allocMem *pallocmem;
int i;
if(!pfl->nmalloc)
return malloc(pfl->size);
epicsMutexMustLock(pfl->lock);
ptemp = pfl->head;
if(ptemp==0) {
@@ -125,18 +152,18 @@ LIBCOM_API void * epicsStdCall freeListMalloc(void *pvt)
VALGRIND_MEMPOOL_FREE(pfl, ptemp);
VALGRIND_MEMPOOL_ALLOC(pfl, ptemp, pfl->size);
return(ptemp);
# endif
}
LIBCOM_API void epicsStdCall freeListFree(void *pvt,void*pmem)
{
FREELISTPVT *pfl = pvt;
# ifdef EPICS_FREELIST_DEBUG
memset ( pmem, 0xdd, pfl->size );
free(pmem);
# else
void **ppnext;
if(!pfl->nmalloc) {
free(pmem);
return;
}
VALGRIND_MEMPOOL_FREE(pvt, pmem);
VALGRIND_MEMPOOL_ALLOC(pvt, pmem, sizeof(void*));
@@ -146,7 +173,6 @@ LIBCOM_API void epicsStdCall freeListFree(void *pvt,void*pmem)
pfl->head = pmem;
pfl->nBlocksAvailable++;
epicsMutexUnlock(pfl->lock);
# endif
}
LIBCOM_API void epicsStdCall freeListCleanup(void *pvt)
+2 -2
View File
@@ -95,9 +95,9 @@ typedef enum {
initHookAtShutdown, /**< Start of iocShutdown() (unit tests only) */
initHookAfterCloseLinks, /**< Links disabled/deleted */
initHookAfterStopScan, /**< Scan tasks stopped */
initHookAfterStopScan, /**< Scan tasks stopped. Prior to UNRELEASED, triggered only by unittest code. */
initHookAfterStopCallback, /**< Callback tasks stopped */
initHookAfterStopLinks, /**< CA links stopped */
initHookAfterStopLinks, /**< CA links stopped. Prior to UNRELEASED, triggered only by unittest code. */
initHookBeforeFree, /**< Resource cleanup about to happen */
initHookAfterShutdown, /**< End of iocShutdown() */
+10 -4
View File
@@ -25,6 +25,7 @@
#include "taskwd.h"
#include "registry.h"
#include "epicsGeneralTime.h"
#include "freeList.h"
#include "libComRegister.h"
/* Register the PWD environment variable when the cd IOC shell function is
@@ -447,7 +448,7 @@ static void epicsThreadResumeCallFunc(const iocshArgBuf *args)
}
/* generalTimeReport */
static const iocshArg generalTimeReportArg0 = { "interest_level", iocshArgArgv};
static const iocshArg generalTimeReportArg0 = { "interest_level", iocshArgInt};
static const iocshArg * const generalTimeReportArgs[1] = { &generalTimeReportArg0 };
static const iocshFuncDef generalTimeReportFuncDef = {"generalTimeReport",1,generalTimeReportArgs,
"Display time providers and their priority levels"
@@ -467,7 +468,11 @@ static void installLastResortEventProviderCallFunc(const iocshArgBuf *args)
installLastResortEventProvider();
}
static iocshVarDef asCheckClientIPDef[] = { { "asCheckClientIP", iocshArgInt, 0 }, { NULL, iocshArgInt, NULL } };
static iocshVarDef comDefs[] = {
{ "asCheckClientIP", iocshArgInt, 0 },
{ "freeListBypass", iocshArgInt, 0 },
{ NULL, iocshArgInt, NULL }
};
void epicsStdCall libComRegister(void)
{
@@ -504,6 +509,7 @@ void epicsStdCall libComRegister(void)
iocshRegister(&generalTimeReportFuncDef,generalTimeReportCallFunc);
iocshRegister(&installLastResortEventProviderFuncDef, installLastResortEventProviderCallFunc);
asCheckClientIPDef[0].pval = &asCheckClientIP;
iocshRegisterVariable(asCheckClientIPDef);
comDefs[0].pval = &asCheckClientIP;
comDefs[1].pval = &freeListBypass;
iocshRegisterVariable(comDefs);
}
@@ -371,6 +371,9 @@ void epicsThreadMustJoin(epicsThreadId id)
rtems_id target_tid = (rtems_id)id, self_tid;
struct taskVar *v = 0;
if(!id)
return;
rtems_task_ident (RTEMS_SELF, 0, &self_tid);
{
+2 -2
View File
@@ -85,7 +85,7 @@ set_first_derives(void)
k = 0;
}
if (cword & (1 << k))
if (cword & (1u << k))
{
rp = derives[j];
while ((rule = *rp++) >= 0)
@@ -152,7 +152,7 @@ closure(short int *nucleus, int n)
{
for (i = 0; i < BITS_PER_WORD; ++i)
{
if (word & (1 << i))
if (word & (1u << i))
{
itemno = rrhs[ruleno+i];
while (csp < csend && *csp < itemno)
+2 -2
View File
@@ -26,7 +26,7 @@ transitive_closure(unsigned int *R, int n)
while (rowj < relend)
{
if (*ccol & (1 << i))
if (*ccol & (1u << i))
{
rp = rowi;
rend = rowj + rowsize;
@@ -68,7 +68,7 @@ reflexive_transitive_closure(unsigned int *R, int n)
rp = R;
while (rp < relend)
{
*rp |= (1 << i);
*rp |= (1u << i);
if (++i >= BITS_PER_WORD)
{
i = 0;