This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compare function is not working for some strange reason (c6000 compiler)

I've been trying to debug this for a few hours now, but I seem to be missing something simple.  I have the following code:

#define ip_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr)

...

if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr)))
                  first = 0;

When I run it, the compare fails even though the two variables have the same value (see screen shot of debugger).  I've tried to read these variables different ways, but the compare always fails.  Maybe I've been staring at this too long...

Cache is disabled, and variables are located in L2 memory.

Compiler version 7.2.1, effective compiler version 7.3.0, little endian, output format is ELF.

CCS version 5.1.

This is my compiler output:


**** Build of configuration Debug for project enet_echo_evmc6a8143 ****

C:\ti\ccsv5\utils\bin\gmake -k all
'Building file: C:/myDspProjects/C6Ware_C6A814x/third_party/lwip-1.3.2/ports/c6a8143/lwiplib.c'
'Invoking: C6000 Compiler'
"C:/ti/ccsv5/tools/compiler/c6000/bin/cl6x" -mv6740 -g -O0 --define=_TMS320C6X --include_path="C:/ti/ccsv5/tools/compiler/c6000/include" --include_path="../../../../../../../include" --include_path="../../../../include" --include_path="../../../../../../../third_party/lwip-1.3.2" --include_path="../../../../../../../third_party/lwip-1.3.2/src/include" --include_path="../../../../../../../third_party/lwip-1.3.2/src/include/ipv4" --include_path="../../../../../../../third_party/lwip-1.3.2/src/include/lwip" --include_path="../../../../../../../third_party/lwip-1.3.2/ports/c6a8143/include" --include_path="../../../../../../../third_party/lwip-1.3.2/apps/echoserver_raw" --diag_warning=225 --abi=eabi --preproc_with_compile --preproc_dependency="lwiplib.pp"  "C:/myDspProjects/C6Ware_C6A814x/third_party/lwip-1.3.2/ports/c6a8143/lwiplib.c"
"../../../../../../../third_party/lwip-1.3.2/src/include/ipv4/lwip/ip_addr.h", line 49: warning: attribute "__packed__" ignored
"../../../../../../../third_party/lwip-1.3.2/src/include/ipv4/lwip/ip_addr.h", line 65: warning: attribute "__packed__" ignored
"../../../../../../../third_party/lwip-1.3.2/src/include/ipv4/lwip/ip.h", line 132: warning: attribute "__packed__" ignored
"../../../../../../../third_party/lwip-1.3.2/src/include/ipv4/lwip/icmp.h", line 85: warning: attribute "__packed__" ignored
"../../../../../../../third_party/lwip-1.3.2/src/include/lwip/tcp.h", line 236: warning: attribute "__packed__" ignored
"../../../../../../../third_party/lwip-1.3.2/src/include/lwip/udp.h", line 60: warning: attribute "__packed__" ignored
"../../../../../../../third_party/lwip-1.3.2/src/include/lwip/dhcp.h", line 109: warning: attribute "__packed__" ignored
"../../../../../../../third_party/lwip-1.3.2/src/include/netif/etharp.h", line 65: warning: attribute "__packed__" ignored
"../../../../../../../third_party/lwip-1.3.2/src/include/netif/etharp.h", line 82: warning: attribute "__packed__" ignored
"../../../../../../../third_party/lwip-1.3.2/src/include/netif/etharp.h", line 124: warning: attribute "__packed__" ignored
'Finished building: C:/myDspProjects/C6Ware_C6A814x/third_party/lwip-1.3.2/ports/c6a8143/lwiplib.c'
' '
'Building target: enet_echo_evmc6a8143.out'
'Invoking: C6000 Linker'
"C:/ti/ccsv5/tools/compiler/c6000/bin/cl6x" -mv6740 -g -O0 --define=_TMS320C6X --diag_warning=225 --abi=eabi -z -m"enet_echo_evmc6a8143.map" --warn_sections -i"C:/ti/ccsv5/tools/compiler/c6000/lib" -i"C:/ti/ccsv5/tools/compiler/c6000/include" --reread_libs --rom_model -o "enet_echo_evmc6a8143.out"  "./lwiplib.obj" "./echod.obj" "./src/echoApp.obj" -l"libc.a" "../c674.cmd"
<Linking>
'Finished building target: enet_echo_evmc6a8143.out'
' '

**** Build Finished ****

 

 

  • Maybe alignment issues? I think the screenshot shows &(iphdr->dest.addr) = 0x00800C1E and &(netif->ip_addr.addr) = 0x0080FBCC. The first one is not aligned to a 4 byte boundary. Maybe try a byte by byte compare like memcmp() to see if it makes any difference.

     

  • You were right Norman.  It was an alignment issue.  I'm working on a LWIP port for one of our DSP processors.  LWIP uses "packed" structures which were not being recognized by the compiler which caused the alignment issue.  Luckily, the C6000 compiler support GCC extensions.  After I enabled those, the problem was solved.