Although vdsp and gcc3.2 have good compatibility, there are still some differences. The following lists some differences and solutions:
1
, _ Builtin_exact CT (exp, Val)
:This is a built-in function of GCC, and vdsp does not have this function. It is used to provide branch prediction information for the compiler. Its return value is the value of the integer expression exp, And the Val value must be the compile time constant. The semantics of this built-in function is that the expected value of exp is Val. the compiler can sort the order of statement blocks according to this information, so that the program can be executed more efficiently as expected. Therefore, during transplantation, use: # DEFINE _ builtin_exact CT (exp, Val) (exp)
2
, _ Builtin_constant_p (exp)
:This built-in function is used to determine whether a value is a compilation constant. If the exp value of the parameter is a constant, the function returns 1; otherwise, 0. Many calculations or operations are more optimized when the parameter is a constant. In gnu c, the above method can be used to compile only the constant version or a very few version based on whether the parameter is a constant, in this way, it is both universal and can compile the optimal code when the parameter is a constant. Use # DEFINE _ builtin_constant_p (x) (0) for porting)
3
, _ Builtin_return_address (level)
:This built-in function returns the return address of the current function or its caller. The level parameter specifies the number of frames searched on the stack. 0 indicates the return address of the current function, 1 indicates the return address of the caller of the current function, and so on. In vdsp, only the return address of the current function can be obtained: # DEFINE _ builtin_return_address (level) ({void * ADDR;/ASM ("% 0 = rets ;": "= A" (ADDR); ADDR ;})
4
Jump 1f in assembly
Or jump 1b
Jump statements such:Vdsp does not support this method. You can only change the label to an absolute label and modify the corresponding jump statement.
5
. Macro in assembly
:Vdsp does not support. Macro. You must change it to the # define statement. If conditions such as # ifdef exist in the middle of. Macro, you must move these conditions out of the # define statement.
6
. Rept in assembly
:The most painful thing in the world is this, helpless. Use the most primitive method, copy/paste.
7
, _ Cmpxchg
Function:This function is written in Embedded Assembly, but cannot be compiled in vdsp. Therefore, it is rewritten in C. Although the efficiency is reduced, our goal is to first have a runable version, isn't it? /** Atomic compare and exchange. compare old with mem, if identical, * store new in mem. return the initial value in mem. success is * indicated by comparing return with old. */static inline unsigned long _ cmpxchg (volatile void * PTR, unsigned Long Old, unsigned long new, int size) {unsigned long TMP = 0; unsigned long flags = 0; unsigned long * P = (unsigned long *) PTR; local_irq_save (flags); switc H (size) {Case 1: TMP = (* P) & 0x000000ff; If (old! = New) (* P) = (* P) & 0xffffff00) | (New & 0x000000ff ); // _ ASM _ volatile _/("% 0 = B % 3 (z ); /n/t "//" cc = % 1 = % 0;/n/t "//" If! CC jump F1;/n/t "//" B % 3 = % 2;/n/t "//" F1:/n/t "//: "= & D" (TMP): "D" (old), "D" (new), "D" (* (unsigned char *) _ Xg (PTR )): "Memory"); break; Case 2: TMP = (* P) & 0x0000ffff; If (old! = New) (* P) = (* P) & 0xffff0000) | (New & 0x0000ffff ); // _ ASM _ volatile _/("% 0 = w % 3 (z ); /n/t "//" cc = % 1 = % 0;/n/t "//" If! CC jump F2;/n/t "//" S % 3 = % 2;/n/t "//" F2:/n/t "//: "= & D" (TMP): "D" (old), "D" (new), "D" (* (unsigned short *) _ Xg (PTR )): "Memory"); break; Case 4: TMP = * P; If (old! = New) (* P) = new; // _ ASM _ volatile _/("% 0 = % 3; /n/t "//" cc = % 1 = % 0;/n/t "//" If! CC jump F3;/n/t "//" % 3 = % 2;/n/t "//" F3:/n/t "//: "= & D" (TMP): "D" (old), "D" (new), "D" (* (unsigned int *) _ Xg (PTR )): "Memory"); break;} local_irq_restore (flags); Return TMP ;}
8
, Jiffies_64
Definition problems:In uClinux, jiffies_64 is defined as: # DEFINE _ jiffy_data _ attribute _ (Section (". data ") extern u64 _ jiffy_data jiffies_64; the definition itself is normal, but the kernel/Timer is being compiled. C has caused code compilation failure in other places. This is a very strange problem. The error prompt is: [error ea1008] "E:/temp/acc08143dff000/acc08143dff001. s ": 3601 '. epcdata': The symbol has already been defined and cannot be redefined. [error ea1008] "E:/temp/acc08143dff000/acc08143dff001. s ": 3608 '. epcdata. end': The symbol Has already been defined and cannot be redefined. However, if you change the definition to extern u64/* _ jiffy_data */jiffies_64, there is no problem. There are still some other problems, but they are not recorded in time and will be supplemented later.