errata/329: PROPOSAL - 27.29: vpi_put_data not used in example

From: etf@boyd.com
Date: Mon Apr 05 2004 - 09:57:51 PDT

  • Next message: Stuart Sutherland: "errata/398: errata/398: suggested wording for vpi_handle_by_index()"

    I've attempted to compile this example, and found a few
    issues (which leads me to conclude that no one had tried
    it before). In any case, the following compiles without
    error on Solaris:

    ============================================================

    Here is an updated example.
    Please note that there is a cross reference in one of the comments.
    Also, the example in section 27.8 should reference this example.

    <pre>

    #include "vpi_user.h"

    #define NULL 0L

    extern PLI_INT32 consumer_restart(p_cb_data data);

    typedef struct myStruct *myStruct_p;
    typedef struct myStruct {
      PLI_INT32 d1;
      PLI_INT32 d2;
      myStruct_p next;
    } myStruct_s;
    myStruct_p firstWrk;

    PLI_INT32 consumer_save(p_cb_data data)
    {
      myStruct_p wrk;
      s_cb_data cbData;
      vpiHandle cbHdl;
      PLI_INT32 id = 0;
      PLI_INT32 cnt = 0;

      /* Get the number of structures */
      wrk = firstWrk;
      while (wrk)
        {
          cnt++;
          wrk = wrk->next;
        }

      /* now save the data */
      wrk = firstWrk;
      id = vpi_get(vpiSaveRestartID, NULL);

      /* save the number of data structures */
      vpi_put_data(id,(PLI_BYTE8 *)cnt,sizeof(PLI_INT32));

      /* Save the different data structures. Please note that
       * a pointer is being saved. While this is allowed, an
       * application must change it to something useful on a
       * restart.
       */
      while (wrk)
        {
          vpi_put_data(id,(PLI_BYTE8 *)wrk,sizeof(myStruct_s));
          wrk = wrk->next;
        }
      /* register a call for restart */
      /* We need the "id" so that the saved data can be
       * retrieved. Using the user_data field of the
       * callback structure is the easiest way to pass this
       * information to retrieval operation.
       */
      cbData.user_data = (PLI_BYTE8 *)id;
      cbData.reason = cbStartOfRestart;

      /* Please see 27.8 vpi_get_data() for a description of
       * how the callback routine can be used to retrieve the
       * data.
       */
      cbData.cb_rtn = consumer_restart;

      cbData.value = NULL;
      cbData.time = NULL;
      cbHdl = vpi_register_cb(&cbData);
      vpi_free_object(cbHdl);
      return(0);
    }

    </pre>

    http://boydtechinc.com/cgi-bin/issueproposal.pl?cmd=view&database=default&pr=329



    This archive was generated by hypermail 2.1.4 : Mon Apr 05 2004 - 09:57:52 PDT and
    sponsored by Boyd Technology, Inc.