gcc bug?

Randy Yates qusraya@rtp.ericsson.se
Mon Jun 5 08:01:00 GMT 2000


Hi,

I'm using the gcc compiler,



 [qusraya@edgedsp1] ~ $ gcc -v
Reading specs from /apps/gnu/solaris2.7/lib/gcc-lib/sparc-sun-solaris2.7/2.7.2.2/specs
gcc version 2.7.2.2



under the Sun OS,



[qusraya@edgedsp1] ~ $ uname -a
SunOS edgedsp1 5.7 Generic sun4u sparc SUNW,Ultra-5_10



I have noticed that my structures are not packed as tightly
as they could be. When I try to tighten them up by specifying
fpack-struct, I get the following messages:



[qusraya@edgedsp1] /vobs/edgedsp_sw/src/EDGE/hostif $ gcc -c -Wall -fpack-struct -I. -I../../include  hostif.c
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 8: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 10: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 12: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 14: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 16: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 18: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 20: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 22: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 24: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 26: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 28: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 30: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 32: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 34: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 36: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 38: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 40: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 42: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 44: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 46: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 48: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 50: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 52: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 54: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 56: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 58: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 60: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 62: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 64: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 66: error: location counter not on word boundary
/usr/ccs/bin/as: "/home/unix/qusraya/tmp/cc4oa4Pq.s", line 72: error: location counter not on word boundary


This appears to be a bug, or rather is it that I'm doing something wrong? I also
tried using the __attribute__((packed)) but it made no difference on the size
of the structure. Here's the structure:


typedef struct {
   UINT16_T                application_address_high;     /* DSP application address (high word) */
   UINT16_T                application_address_low;      /* DSP application address (low word) */
   unsigned                reserved :  15;               /* DSP ready */
   unsigned                dr       :  1;
   unsigned                reservedb:  15;               /* DSP PLL clock mode */
   unsigned                pcm      :  1;
   UINT16_T                dsp_version;                  /* DSP version */
   UINT16_T                low_softbit_cache_threshold;  /* low softbit cache threshold */
   UINT16_T                adequate_softbit_cache_threshold; /* adequate softbit cache threshold */
} INITIALIZATION_TABLE_T __attribute__((packed));

This structure can be packed to 7 16-bit words but instead the compiler always
generates it in 8 16-bit words. The special type UINT16_T:

typedef unsigned short UINT16_T;

is defined is dsptypes.h.

I have attached hostif.c, hostif.h, and dsptypes.h in order to help
you reproduce this error. 

Any help, pointers, acknowledgements of guilt, etc. would be appreciated.
--
Randy Yates
DSP Engineer
Ericsson / Research Triangle Park, NC, USA
qusraya@rtp.ericsson.se, 919-472-1124
/******************************************************************************

   --- E R I C S S O N --

   Copyright 1999 by Ericsson Inc.  All rights reserved.  No part of
   this publication, or any software included with it, may be
   reproduced, stored in a retrieval system, or transmitted in any
   form or by any other means, including photocopying, electronic or
   mechanical recording, or otherwise, without prior written permission
   of the copyright holder.

   Ericsson Confidential and Proprietary information.

******************************************************************************/

/*-- Module Definitions --*/

/*-- Include Files --*/

#include <stdio.h>
#include <string.h>
#include "hostif.h"

/*-- public variables --*/

/*-- private variables --*/

/* host interface memory area */
#if defined(__TMS320C5XX__) 
#pragma DATA_SECTION(hostif, "HOSTIF_SECTION") /* put the hostif in its own section */
#endif 
HOST_INTERFACE_T hostif;

/* The command message array is in order of the commands 
   as defined in the command registers, going from least-significant
   bit to most-significant, and counting control registers 1 and 2
   as one 32-bit control register (control register 1 is the least-significant
   word). The message pointers here point inside of the EHPI. */
const COMMAND_MESSAGE_T  command_messages[] = {
   {
      0,             /* the semaphore flag is not really a command */
      NULL,
      0,
      NULL},
   {
      DSP_OPERATING_MODE_COMMAND_MESSAGE_ID     ,
      &hostif.command_interface.dsp_operating_mode_command,
      sizeof(DSP_OPERATING_MODE_COMMAND_T),
      Command_Processor_DSP_Operating_Mode},
   {
      TFI_ASSIGNMENT_COMMAND_MESSAGE_ID         ,
      &hostif.command_interface.tfi_assignment_command,
      sizeof(TFI_ASSIGNMENT_COMMAND_T),
      Command_Processor_TFI_Assignment},
   {
      TX_BUFFER_READY_COMMAND_MESSAGE_ID        ,
      &hostif.command_interface.tx_buffer_ready_command,
      sizeof(TX_BUFFER_READY_COMMAND_T),
      Command_Processor_TX_Buffer_Ready},
   {
      RX_BUFFER_AVAILABLE_COMMAND_MESSAGE_ID        ,
      NULL,
      0,
      Command_Processor_RX_Buffer_Available},
   {
      DSP_DETECTION_MODE_COMMAND_MESSAGE_ID     ,
      &hostif.command_interface.dsp_detection_mode_command,
      sizeof(DSP_DETECTION_MODE_COMMAND_T    ),
      Command_Processor_DSP_Detection_Mode},
   {
      ACCESS_BURST_COMMAND_MESSAGE_ID           ,
      &hostif.command_interface.access_burst_command,
      sizeof(ACCESS_BURST_COMMAND_T          ),
      Command_Processor_Access_Burst},
   {
      USF_COMMAND_MESSAGE_ID                    ,
      &hostif.command_interface.usf_command,
      sizeof(USF_COMMAND_T                   ),
      Command_Processor_USF},
   {
      DSP_POWER_SAVINGS_COMMAND_MESSAGE_ID      ,
      &hostif.command_interface.dsp_power_savings_command,
      sizeof(DSP_POWER_SAVINGS_COMMAND_T     ),
      Command_Processor_DSP_Power_Savings},
   {
      RX_TIMESLOT_COUNT_COMMAND_MESSAGE_ID      ,
      &hostif.command_interface.rx_timeslot_count_command,
      sizeof(RX_TIMESLOT_COUNT_COMMAND_T     ),
      Command_Processor_RX_Timeslot_Count},
   {
      CLEAR_SOFTBIT_CACHE_COMMAND_MESSAGE_ID      ,
      NULL,
      0,
      Command_Processor_Clear_Softbit_Cache},
   {
      RX_PTCCHD_COMMAND_MESSAGE_ID      ,
      NULL,
      0,
      Command_Processor_RX_PTCCHD},
   {
      TRAINING_SEQUENCE_CODE_COMMAND_MESSAGE_ID ,
      &hostif.command_interface.training_sequence_code_command,
      sizeof(TRAINING_SEQUENCE_CODE_COMMAND_T),
      Command_Processor_Training_Sequence_Code},
   {
      DETECT_FCH_COMMAND_MESSAGE_ID             ,
      &hostif.command_interface.detect_fch_command,
      sizeof(DETECT_FCH_COMMAND_T            ),
      Command_Processor_Detect_FCH},
   {
      DETECT_SCH_COMMAND_MESSAGE_ID             ,
      &hostif.command_interface.detect_sch_command,
      sizeof(DETECT_SCH_COMMAND_T            ),
      Command_Processor_Detect_SCH}
};

/* The command message and command message data buffers used between the ISR 
   and Command_Processor */
COMMAND_MESSAGE_T command_message;
COMMAND_INTERFACE_UNION_T command_message_data;
      
/* The indication message array is in order of the indications
   as defined in the indication registers, going from least-significant
   bit to most-significant, and counting indication registers 1 and 2
   as one 32-bit control register (indication register 1 is the least-significant
   word). The message pointers here point inside of the EHPI. */
const INDICATION_MESSAGE_T  indication_messages[] = {
   {
      0,             /* the semaphore flag is not really an indication */
      NULL,
      0},
   {
      TX_PROCESSING_COMPLETE_INDICATION_MESSAGE_ID,
      NULL,
      0},
   {
      SOFTBIT_CACHE_STATE_INDICATION_MESSAGE_ID,
      &hostif.indication_interface.softbit_cache_state_indication,
      sizeof(SOFTBIT_CACHE_STATE_INDICATION_T)},
   {
      TX_BUFFER_AVAILABLE_INDICATION_MESSAGE_ID,
      NULL,
      0},
   {
      RX_BUFFER_READY_INDICATION_MESSAGE_ID,
      NULL,
      0},
   {
      DETECT_FCH_RESULT_INDICATION_MESSAGE_ID,
      &hostif.indication_interface.detect_fch_result_indication,
      sizeof(DETECT_FCH_RESULT_INDICATION_T)},
   {
      DETECT_SCH_RESULT_INDICATION_MESSAGE_ID,
      &hostif.indication_interface.detect_sch_result_indication,
      sizeof(DETECT_SCH_RESULT_INDICATION_T)},
   {
      USF_1ST_SLOT_INDICATION_MESSAGE_ID,
      &hostif.indication_interface.usf_1st_slot_indication,
      sizeof(USF_INDICATION_T)},
   {
      USF_2ND_SLOT_INDICATION_MESSAGE_ID,
      &hostif.indication_interface.usf_2nd_slot_indication,
      sizeof(USF_INDICATION_T)},
   {
      RX_PTCCHD_INDICATION_MESSAGE_ID,
      &hostif.rx_ptcchd_buffer,
      sizeof(RX_PTCCHD_BUFFER_T)}
};

/*-- public functions --*/

/******************************************************************************
   NAME
      Initialize_Host_Interface()

   AUTHOR
      Randy Yates

   DATE
      5-16-2000

   PARAMETERS
      void
      
   RETURN 
      Boolean value indicating whether or not the initialization
      was successful.
    
   DESCRIPTION
      This routine initializes the host interface as follows:

         1. zero all indications in the indication interface. 
         2. zero the message ID in the command_message structure
            which indicates there is no command to be processed. 
         3. initialize the message pointer in command_message to
            point to the command_message_data union.

******************************************************************************/

BOOL_T Initialize_Host_Interface(void)
{
   /*      1. zero all indications in the indication interface. */
   memset(&hostif.indication_interface, 0, sizeof(INDICATION_INTERFACE_T));

   /*      2. zero the message ID in the command_message structure 
            which indicates there is no command to be processed. */
   command_message.message_id = 0;

   /*      3. initialize the message pointer in command_message to
            point to the command_message_data union. */
   command_message.message = (UINT16_T*)(&command_message_data);

   return TRUE;
}

/******************************************************************************
   NAME
      ISR_Hostif()

   AUTHOR
      Randy Yates

   DATE
      5-16-2000

   PARAMETERS
      void
      
   RETURN 
      void
    
   DESCRIPTION
      This is the interrupt service routine for the host interface
      (EHPI) interrupt. The routine will go through the command
      registers and use the command_messages array to copy the
      control words into a local buffer for the commands whose 
      bits are set in the command register(s).

   NOTE
      In the current non-RTOS, POC version, we only process one command
      per interrupt. Later versions will have the ability to process
      multiple commands per interrupt. If more than one command is sent,
      the command in the most-significant bit of the 32-bit "virtual command
      register" will be the one that is processed.

******************************************************************************/
void ISR_Hostif(void)
{
   UINT16_T command_index;
   UINT32_T command_mask;
   UINT32_T virtual_command_register;

   /* Create a "virtual command register" that is all 32 bits of the two 16-bit command registers.  */
   virtual_command_register = (UINT32_T)(hostif.command_interface.command_register_1) | ((UINT32_T)(hostif.command_interface.command_register_2) << 16);

   /* For each bit in the command registers, copy command and data to the command_message and command_message_data buffers: */
   for (command_index = 1, command_mask = 1; command_index < 15; command_index++, command_mask <<= 1) {  /* note we skip the semaphore flag in bit 0 
                                                                                                            and we end at the bit before the ER2 (the most-significant
                                                                                                            bit of control word 1) since there are currently no 
                                                                                                            messages in control word 2. */
      if (virtual_command_register & command_mask) {

         /* copy command message data */
         memcpy(command_message.message, command_messages[command_index].message, command_messages[command_index].length);

         /* copy command message */
         command_message.message_id = command_messages[command_index].message_id;
         /* (the message pointer is initialized by the initialization routine to point to command_message_data) */
         command_message.length = command_messages[command_index].length;
         command_message.command_processor = command_messages[command_index].command_processor;
      }
   }

   /* reset the semaphore */
   hostif.command_interface.command_register_1 &= 0xFFFE;

   return;
}

/******************************************************************************
   NAME
      Command_Processor()

   AUTHOR
      Randy Yates

   DATE
      5-16-2000

   PARAMETERS
      void
      
   RETURN 
      void
    
   DESCRIPTION
      This is the top-level command processing routine for processing
      the incoming host commands coming from the EHPI. This routine 
      should be called from the top-level idle loop to process the 
      messages that have arrived. It uses the common buffers 
      "command_message" and "command_message_data" that are 
      shared between ISR_Hostif() and this routine to pass information. 

******************************************************************************/
void Command_Processor(void)
{
   if (command_message.message_id) {
      command_message.command_processor(command_message.message);
   }
   return;
}

/******************************************************************************
   NAME
      Indication_Processor()

   AUTHOR
      Randy Yates

   DATE
      5-16-2000

   PARAMETERS
      INDICATION_MESSAGE_T *indication_message = a pointer to the indication message
      
   RETURN 
      boolean indicating whether or not the indication was successfully sent
    
   DESCRIPTION
      This routine handles sending indication messages to the host
      over the host interface (the EHPI). This routine should NOT
      be called from an interrupt handler (it ain't re-entrant). 
      A FALSE return value indicates the host has not yet read the
      prior indication message as indicated by the semaphore flag.

******************************************************************************/

BOOL_T Indication_Processor(INDICATION_MESSAGE_T *indication_message)
{
   /* Check the semaphore flag to see if the host has read prior message */
   if (hostif.indication_interface.indication_register_1 & 0x0001) {
      /* host has not processed previous message */
      return FALSE;
   }

   /* copy indication message data into the EHPI */
   memcpy(indication_messages[indication_message->message_id].message, indication_message->message, indication_message->length);

   /* set the appropriate indication register bit and the semaphore bit */
   hostif.indication_interface.indication_register_1 = (1 << indication_message->message_id) | 1;

   /* Generate the EHPI interrupt to the host */
   /* ???? */

   return TRUE;
}

/*-- private functions --*/

void Command_Processor_DSP_Operating_Mode(void *msg)
{
   return;
}

void Command_Processor_TFI_Assignment(void *msg)
{
   return;
}

void Command_Processor_TX_Buffer_Ready(void *msg)
{
   return;
}

void Command_Processor_RX_Buffer_Available(void *msg)
{
   return;
}

void Command_Processor_DSP_Detection_Mode(void *msg)
{
   return;
}

void Command_Processor_Access_Burst(void *msg)
{
   return;
}

void Command_Processor_USF(void *msg)
{
   return;
}

void Command_Processor_DSP_Power_Savings(void *msg)
{
   return;
}

void Command_Processor_RX_Timeslot_Count(void *msg)
{
   return;
}

void Command_Processor_Clear_Softbit_Cache(void *msg)
{
   return;
}

void Command_Processor_RX_PTCCHD(void *msg)
{
   return;
}

void Command_Processor_Training_Sequence_Code(void *msg)
{
   return;
}

void Command_Processor_Detect_FCH(void *msg)
{
   return;
}

void Command_Processor_Detect_SCH(void *msg)
{
   return;
}



More information about the Gcc-bugs mailing list