Comment 1 for bug 541258

Revision history for this message
Jeff Hill (johill-lanl) wrote :

Only in base: funcPtrWarningPatch
diff -u -r base.orig/src/dbStatic/dbLexRoutines.c base/src/dbStatic/dbLexRoutines.c
--- base.orig/src/dbStatic/dbLexRoutines.c 2005-08-29 21:14:14.000000000 +0200
+++ base/src/dbStatic/dbLexRoutines.c 2005-10-14 17:53:14.000000000 +0200
@@ -453,7 +453,7 @@
     if(!pgphentry) {
  yyerrorAbort("gphAdd failed");
     } else {
- pgphentry->userPvt = pnewMenu;
+ pgphentry->user.data = pnewMenu;
     }
 }

@@ -682,7 +682,7 @@
     if(!pgphentry) {
  yyerrorAbort("gphAdd failed");
     } else {
- pgphentry->userPvt = pdbRecordType;
+ pgphentry->user.data = pdbRecordType;
     }
     ellAdd(&pdbbase->recordTypeList,&pdbRecordType->node);
 }
@@ -710,7 +710,7 @@
  yyerror("Illegal link type");
  return;
     }
- pdbRecordType = (dbRecordType *)pgphentry->userPvt;
+ pdbRecordType = (dbRecordType *)pgphentry->user.data;
     pgphentry = gphFind(pdbbase->pgpHash,choicestring,&pdbRecordType->devList);
     if(pgphentry) {
  return;
@@ -723,7 +723,7 @@
     if(!pgphentry) {
  yyerror("gphAdd failed");
     } else {
- pgphentry->userPvt = pdevSup;
+ pgphentry->user.data = pdevSup;
     }
     ellAdd(&pdbRecordType->devList,&pdevSup->node);
 }
@@ -743,7 +743,7 @@
     if(!pgphentry) {
  yyerrorAbort("gphAdd failed");
     }
- pgphentry->userPvt = pdrvSup;
+ pgphentry->user.data = pdrvSup;
     ellAdd(&pdbbase->drvList,&pdrvSup->node);
 }

@@ -762,7 +762,7 @@
     if(!pgphentry) {
  yyerrorAbort("gphAdd failed");
     }
- pgphentry->userPvt = ptext;
+ pgphentry->user.data = ptext;
     ellAdd(&pdbbase->registrarList,&ptext->node);
 }

@@ -781,7 +781,7 @@
     if(!pgphentry) {
        yyerrorAbort("gphAdd failed");
     }
- pgphentry->userPvt = ptext;
+ pgphentry->user.data = ptext;
     ellAdd(&pdbbase->functionList,&ptext->node);
 }

@@ -801,7 +801,7 @@
     if(!pgphentry) {
  yyerrorAbort("gphAdd failed");
     }
- pgphentry->userPvt = pvar;
+ pgphentry->user.data = pvar;
     ellAdd(&pdbbase->variableList,&pvar->node);
 }

@@ -891,7 +891,7 @@
     if(!pgphentry) {
  yyerrorAbort("gphAdd failed");
     } else {
- pgphentry->userPvt = pnewbrkTable;
+ pgphentry->user.data = pnewbrkTable;
     }
     if(!pbrkTable) ellAdd(&pdbbase->bptList,&pnewbrkTable->node);
 }
diff -u -r base.orig/src/dbStatic/dbStaticLib.c base/src/dbStatic/dbStaticLib.c
--- base.orig/src/dbStatic/dbStaticLib.c 2004-10-11 20:17:22.000000000 +0200
+++ base/src/dbStatic/dbStaticLib.c 2005-10-14 17:52:24.000000000 +0200
@@ -1251,7 +1251,7 @@
     zeroDbentry(pdbentry);
     phash = gphFind(pdbbase->pgpHash,recordType,&pdbbase->recordTypeList);
     if(!phash) return(S_dbLib_recordTypeNotFound);
- pdbentry->precordType = phash->userPvt;
+ pdbentry->precordType = phash->user.data;
     return(0);
 }

@@ -2690,7 +2690,7 @@

     pgph = gphFind(pdbbase->pgpHash,name,(void *)&pdbbase->bptList);
     if(!pgph) return(NULL);
- return((brkTable *)pgph->userPvt);
+ return((brkTable *)pgph->user.data);
 }

 dbMenu * epicsShareAPI dbFindMenu(dbBase *pdbbase,const char *name)
@@ -2699,7 +2699,7 @@

     pgph = gphFind(pdbbase->pgpHash,name,(void *)&pdbbase->menuList);
     if(!pgph) return(NULL);
- return((dbMenu *)pgph->userPvt);
+ return((dbMenu *)pgph->user.data);
 }

 char ** epicsShareAPI dbGetMenuChoices(DBENTRY *pdbentry)
diff -u -r base.orig/src/iocsh/registryRegister.c base/src/iocsh/registryRegister.c
--- base.orig/src/iocsh/registryRegister.c 2002-12-17 21:01:14.000000000 +0100
+++ base/src/iocsh/registryRegister.c 2005-10-14 20:35:22.000000000 +0200
@@ -55,7 +55,7 @@
 static const iocshFuncDef registryFunctionFindFuncDef = {
     "registryFunctionFind",1,registryXxxFindArgs};
 static void registryFunctionFindCallFunc(const iocshArgBuf *args) {
- printf("%p\n", (void*) registryFunctionFind(args[0].sval));
+ printf("%p\n", registryFunctionFind(args[0].sval));
 }

 void epicsShareAPI registryRegister(void)
diff -u -r base.orig/src/libCom/gpHash/gpHash.h base/src/libCom/gpHash/gpHash.h
--- base.orig/src/libCom/gpHash/gpHash.h 2004-03-29 21:35:58.000000000 +0200
+++ base/src/libCom/gpHash/gpHash.h 2005-10-14 18:18:36.000000000 +0200
@@ -23,7 +23,10 @@
     ELLNODE node;
     const char *name; /*address of name placed in directory*/
     void *pvtid; /*private name for subsystem user*/
- void *userPvt; /*private for user*/
+ union {
+ void *data; /*private for user data*/
+ void (*func) (); /*private for user function*/
+ } user;
 } GPHENTRY;

 #ifdef __cplusplus
diff -u -r base.orig/src/libCom/misc/epicsExport.h base/src/libCom/misc/epicsExport.h
--- base.orig/src/libCom/misc/epicsExport.h 2005-02-18 23:03:24.000000000 +0100
+++ base/src/libCom/misc/epicsExport.h 2005-10-14 18:23:32.000000000 +0200
@@ -29,7 +29,7 @@
 epicsShareDef typ *EPICS_EXPORT_POBJ(typ,obj) = (typ *)(char *)&obj

 #define epicsExportRegistrar(func) \
-epicsShareFunc REGISTRAR EPICS_EXPORT_PFUNC(func) = (REGISTRAR)(void*)&func
+epicsShareFunc REGISTRAR EPICS_EXPORT_PFUNC(func) = (REGISTRAR)&func

 #define epicsRegisterFunction(func) \
 static void register_func_ ## func(void) { \
diff -u -r base.orig/src/rec/subRecord.c base/src/rec/subRecord.c
--- base.orig/src/rec/subRecord.c 2004-10-12 00:32:06.000000000 +0200
+++ base/src/rec/subRecord.c 2005-10-14 21:00:04.000000000 +0200
@@ -127,7 +127,7 @@
  psub->pact = TRUE;
  return(0);
     }
- psub->sadr = (void *)registryFunctionFind(psub->snam);
+ psub->sadr = (SUBFUNCPTR)registryFunctionFind(psub->snam);
     if(psub->sadr==0) {
  recGblRecordError(S_db_BadSub,(void *)psub,"recSub(init_record)");
  return(S_db_BadSub);
diff -u -r base.orig/src/rec/subRecord.dbd base/src/rec/subRecord.dbd
--- base.orig/src/rec/subRecord.dbd 2002-07-12 23:35:28.000000000 +0200
+++ base/src/rec/subRecord.dbd 2005-10-14 20:54:46.000000000 +0200
@@ -32,7 +32,7 @@
   prompt("Subroutine Address")
   special(SPC_NOMOD)
   interest(4)
- extra("void * sadr")
+ extra("long (*sadr) ()")
  }
  field(INPA,DBF_INLINK) {
   prompt("Input A")
diff -u -r base.orig/src/registry/registry.c base/src/registry/registry.c
--- base.orig/src/registry/registry.c 2003-07-15 20:52:30.000000000 +0200
+++ base/src/registry/registry.c 2005-10-14 22:17:50.000000000 +0200
@@ -50,7 +50,7 @@
     if(!gphPvt) registryInit(0);
     pentry = gphAdd(gphPvt,name,registryID);
     if(!pentry) return(FALSE);
- pentry->userPvt = data;
+ pentry->user.data = data;
     return(TRUE);
 }

@@ -61,7 +61,7 @@
     if(!gphPvt) registryInit(0);
     pentry = gphFind(gphPvt,(char *)name,registryID);
     if(!pentry) return(FALSE);
- pentry->userPvt = data;
+ pentry->user.data = data;
     return(TRUE);
 }

@@ -74,7 +74,45 @@
     if(!gphPvt) registryInit(0);
     pentry = gphFind(gphPvt,(char *)name,registryID);
     if(!pentry) return(0);
- return(pentry->userPvt);
+ return(pentry->user.data);
+}
+
+epicsShareFunc int epicsShareAPI registryAddFunc(
+ void *registryID,const char *name,FUNCTION func)
+{
+ GPHENTRY *pentry;
+ if(!gphPvt) registryInit(0);
+ pentry = gphAdd(gphPvt,name,registryID);
+ if(!pentry) return(FALSE);
+ pentry->user.func = func;
+ return(TRUE);
+}
+
+epicsShareFunc int epicsShareAPI registryChangeFunc(
+ void *registryID,const char *name,FUNCTION func)
+{
+ GPHENTRY *pentry;
+ if(!gphPvt) registryInit(0);
+ pentry = gphFind(gphPvt,(char *)name,registryID);
+ if(!pentry) return(FALSE);
+ pentry->user.func = func;
+ return(TRUE);
+}
+
+epicsShareFunc FUNCTION epicsShareAPI registryFindFunc(
+ void *registryID,const char *name)
+{
+ GPHENTRY *pentry;
+ if(name==0) return(0);
+ if(registryID==0) {
+ /* Not a really nice cast but it suppresses warning on cygwin gcc 3.4.4.
+ Anyway, only on vxWorks epicsFindSymbol can return not-NULL. */
+ return((long)epicsFindSymbol(name));
+ }
+ if(!gphPvt) registryInit(0);
+ pentry = gphFind(gphPvt,(char *)name,registryID);
+ if(!pentry) return(0);
+ return(pentry->user.func);
 }

 epicsShareFunc void epicsShareAPI registryFree()
diff -u -r base.orig/src/registry/registry.h base/src/registry/registry.h
--- base.orig/src/registry/registry.h 2003-07-15 20:52:30.000000000 +0200
+++ base/src/registry/registry.h 2005-10-14 18:17:00.000000000 +0200
@@ -16,6 +16,7 @@
 #endif

 #define DEFAULT_TABLE_SIZE 1024
+typedef void (*FUNCTION)();

 epicsShareFunc int epicsShareAPI registryAdd(
     void *registryID,const char *name,void *data);
@@ -24,6 +25,13 @@
 epicsShareFunc int epicsShareAPI registryChange(
     void *registryID,const char *name,void *data);

+epicsShareFunc int epicsShareAPI registryAddFunc(
+ void *registryID,const char *name,FUNCTION func);
+epicsShareFunc FUNCTION epicsShareAPI registryFindFunc(
+ void *registryID,const char *name);
+epicsShareFunc int epicsShareAPI registryChangeFunc(
+ void *registryID,const char *name,FUNCTION func);
+
 epicsShareFunc int epicsShareAPI registrySetTableSize(int size);
 epicsShareFunc void epicsShareAPI registryFree();
 epicsShareFunc int epicsShareAPI registryDump(void);
diff -u -r base.orig/src/registry/registryFunction.c base/src/registry/registryFunction.c
--- base.orig/src/registry/registryFunction.c 2003-03-27 22:59:36.000000000 +0100
+++ base/src/registry/registryFunction.c 2005-10-14 20:36:26.000000000 +0200
@@ -27,16 +27,16 @@
 epicsShareFunc int epicsShareAPI registryFunctionAdd(
     const char *name,REGISTRYFUNCTION func)
 {
- return(registryAdd(registryID,name,(void *)func));
+ return(registryAddFunc(registryID,name,func));
 }

 epicsShareFunc REGISTRYFUNCTION epicsShareAPI registryFunctionFind(
     const char *name)
 {
     REGISTRYFUNCTION func;
- func = (REGISTRYFUNCTION)registryFind(registryID,name);
+ func = registryFindFunc(registryID,name);
     if(!func) {
- func = (REGISTRYFUNCTION)registryFind(0,name);
+ func = registryFindFunc(0,name);
         if(func)registryFunctionAdd(name,func);
     }
     return(func);