This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Question about StellarisWare, SW-RDK-S2E, stellarisif.c

stellarisif.c

static err_t
stellarisif_transmit(struct netif *netif, struct pbuf *p)
{
  int iBuf;
  unsigned char *pucBuf;
  unsigned long *pulBuf;
  struct pbuf *q;
  int iGather;
  unsigned long ulGather;
  unsigned char *pucGather;

........................... [omitted]

    /* Initialze a long pointer into the pbuf for 32-bit access. */
    pulBuf = (unsigned long *)&pucBuf[iBuf];

    /**
     * Copy words of pbuf data into the Tx FIFO, but don't go past
     * the end of the pbuf.
     *
     */
    while((iBuf + 4) <= q->len) {
      HWREG(ETH_BASE + MAC_O_DATA) = *pulBuf++;
      iBuf += 4;
    }

The above code is part of the latest version of the TI/Luminary StellarisWare.

I think it is a bug? And I hope to fix it with

  __packed unsigned long *pulBuf;


in the KEIL toolchain. (Tested.)

But due to my very limited C programming skill, I am afraid that, I might be doing something stupid. So I would like to learn something from our experts, please kindly give me some advices.

Is that, the __packed qualifier (in this case) leads to the lower performance?

Parents
  • And I hope to fix it with ... __packed

    IIRC, the Cortex-M3 CPU in the Luminary MCU's supports unaligned accesses. That is, no need to use __packed, it will only lead to less efficient code.

    According to the standards, doing this causes undefined behaviour, it is not permitted and cannot be done.

    Unless the code is only run on a very specific CPU that supports this, in which case this is OK.

Reply
  • And I hope to fix it with ... __packed

    IIRC, the Cortex-M3 CPU in the Luminary MCU's supports unaligned accesses. That is, no need to use __packed, it will only lead to less efficient code.

    According to the standards, doing this causes undefined behaviour, it is not permitted and cannot be done.

    Unless the code is only run on a very specific CPU that supports this, in which case this is OK.

Children