g+
g+ Communities
Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014 
<== Date ==> <== Thread ==>

Subject: [Merge] lp:~epics-core/epics-base/array-opt into lp:epics-base
From: mdavidsaver <mdavidsaver@bnl.gov>
To: mp+149396@code.launchpad.net
Date: Tue, 19 Feb 2013 20:36:21 -0000
mdavidsaver has proposed merging lp:~epics-core/epics-base/array-opt into lp:epics-base.

Requested reviews:
  EPICS Core Developers (epics-core)

For more details, see:
https://code.launchpad.net/~epics-core/epics-base/array-opt/+merge/149396

Allow device support code to safely replace BPTR for waveform, aai, and aao recordtypes.  This avoids a copy when moving array data into and out of a record.
-- 
https://code.launchpad.net/~epics-core/epics-base/array-opt/+merge/149396
Your team EPICS Core Developers is requested to review the proposed merge of lp:~epics-core/epics-base/array-opt into lp:epics-base.
=== modified file 'src/ioc/db/dbAccess.c'
--- src/ioc/db/dbAccess.c	2012-10-29 06:20:56 +0000
+++ src/ioc/db/dbAccess.c	2013-02-19 20:35:24 +0000
@@ -780,6 +780,7 @@
     void *pbuffer, long *options, long *nRequest, void *pflin)
 {
     char *pbuf = pbuffer;
+    void *pfieldsave;
     db_field_log *pfl = (db_field_log *)pflin;
     short field_type;
     long no_elements;
@@ -815,6 +816,13 @@
         return S_db_badDbrtype;
     }
 
+    /* For array field, the rset function
+     * get_array_info() is allowed to modify
+     * paddr->pfield.  So we store the original
+     * value and restore it later.
+     */
+    pfieldsave = paddr->pfield;
+
     /* check for array */
     if ((!pfl || pfl->type == dbfl_type_rec) &&
         paddr->special == SPC_DBADDR &&
@@ -860,7 +868,8 @@
             sprintf(message, "dbGet: Missing conversion for [%d][%d]\n",
                     field_type, dbrType);
             recGblDbaddrError(S_db_badDbrtype, paddr, message);
-            return S_db_badDbrtype;
+            status = S_db_badDbrtype;
+            goto done;
         }
         /* convert database field  and place it in the buffer */
         if (n <= 0) {
@@ -880,6 +889,8 @@
             status = convert(&localAddr, pbuf, n, no_elements, offset);
         }
     }
+done:
+    paddr->pfield = pfieldsave;
     return status;
 }
 

=== modified file 'src/std/filters/arr.c'
--- src/std/filters/arr.c	2012-07-17 19:33:31 +0000
+++ src/std/filters/arr.c	2013-02-19 20:35:24 +0000
@@ -104,7 +104,9 @@
         if (chan->addr.special == SPC_DBADDR &&
             nSource > 1 &&
             (prset = dbGetRset(&chan->addr)) &&
-            prset->get_array_info) {
+            prset->get_array_info)
+        {
+            void *pfieldsave = chan->addr.pfield;
             prec = dbChannelRecord(chan);
             dbScanLock(prec);
             prset->get_array_info(&chan->addr, &nSource, &offset);
@@ -126,6 +128,7 @@
                 pfl->u.r.field = pdst;
             }
             dbScanUnlock(prec);
+            chan->addr.pfield = pfieldsave;
         }
 
     /* Extract from buffer */

=== modified file 'src/std/rec/aaiRecord.c'
--- src/std/rec/aaiRecord.c	2012-01-21 21:20:11 +0000
+++ src/std/rec/aaiRecord.c	2013-02-19 20:35:24 +0000
@@ -183,7 +183,6 @@
 {
     aaiRecord *prec = (aaiRecord *)paddr->precord;
 
-    paddr->pfield         = prec->bptr;
     paddr->no_elements    = prec->nelm;
     paddr->field_type     = prec->ftvl;
     paddr->field_size     = dbValueSize(prec->ftvl);
@@ -195,6 +194,7 @@
 {
     aaiRecord *prec = (aaiRecord *)paddr->precord;
 
+    paddr->pfield = prec->bptr;
     *no_elements =  prec->nord;
     *offset = 0;
     return 0;
@@ -308,7 +308,7 @@
     }
 
     if (monitor_mask)
-        db_post_events(prec, prec->bptr, monitor_mask);
+        db_post_events(prec, (void*)&prec->val, monitor_mask);
 }
 
 static long readValue(aaiRecord *prec)

=== modified file 'src/std/rec/aaoRecord.c'
--- src/std/rec/aaoRecord.c	2012-01-21 21:20:11 +0000
+++ src/std/rec/aaoRecord.c	2013-02-19 20:35:24 +0000
@@ -183,7 +183,6 @@
 {
     aaoRecord *prec = (aaoRecord *)paddr->precord;
 
-    paddr->pfield         = prec->bptr;
     paddr->no_elements    = prec->nelm;
     paddr->field_type     = prec->ftvl;
     paddr->field_size     = dbValueSize(prec->ftvl);
@@ -195,6 +194,7 @@
 {
     aaoRecord *prec = (aaoRecord *)paddr->precord;
 
+    paddr->pfield = prec->bptr;
     *no_elements =  prec->nord;
     *offset = 0;
     return 0;
@@ -308,7 +308,7 @@
     }
 
     if (monitor_mask)
-        db_post_events(prec, prec->bptr, monitor_mask);
+        db_post_events(prec, (void*)&prec->val, monitor_mask);
 }
 
 static long writeValue(aaoRecord *prec)

=== modified file 'src/std/rec/waveformRecord.c'
--- src/std/rec/waveformRecord.c	2012-07-07 20:54:31 +0000
+++ src/std/rec/waveformRecord.c	2013-02-19 20:35:24 +0000
@@ -163,7 +163,6 @@
 {
     waveformRecord *prec = (waveformRecord *) paddr->precord;
 
-    paddr->pfield = prec->bptr;
     paddr->no_elements = prec->nelm;
     paddr->field_type = prec->ftvl;
     paddr->field_size = dbValueSize(prec->ftvl);
@@ -176,6 +175,7 @@
 {
     waveformRecord *prec = (waveformRecord *) paddr->precord;
 
+    paddr->pfield = prec->bptr;
     *no_elements = prec->nord;
     *offset = 0;
 
@@ -300,7 +300,7 @@
     }
 
     if (monitor_mask) {
-        db_post_events(prec, prec->bptr, monitor_mask);
+        db_post_events(prec, (void*)&prec->val, monitor_mask);
     }
 }
 


Replies:
Re: [Merge] lp:~epics-core/epics-base/array-opt into lp:epics-base Andrew Johnson
[Merge] lp:~epics-core/epics-base/array-opt into lp:epics-base noreply

Navigate by Date:
Prev: Re: mbboDirect changes Andrew Johnson
Next: New API for batched dbGet/dbPut Michael Davidsaver
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014 
Navigate by Thread:
Prev: Re: mbboDirect changes Andrew Johnson
Next: Re: [Merge] lp:~epics-core/epics-base/array-opt into lp:epics-base Andrew Johnson
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICSv4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·