From: sawssen BT <bts...@ho...> - 2010-11-29 12:36:07
|
i need a help please !!! this is the file.h // *************bit_operations.h*******************// #if defined(__cplusplus) extern "C" { #endif /*! \brief Find the bit position of the highest set bit in a word \param bits The word to be searched \return The bit number of the highest set bit, or -1 if the word is zero. */ static __inline__ int top_bit(unsigned int bits) { #if defined(SPANDSP_USE_86_ASM) int res; __asm__ (" xorl %[res],%[res];\n" " decl %[res];\n" " bsrl %[bits],%[res]\n" : [res] "=&r" (res) : [bits] "rm" (bits)); return res; #elif defined(__ppc__) || defined(__powerpc__) int res; __asm__ ("cntlzw %[res],%[bits];\n" : [res] "=&r" (res) : [bits] "r" (bits)); return 31 - res; #elif defined(_M_IX86) /* Visual Studio i386 */ __asm { xor eax, eax dec eax bsr eax, bits } #elif defined(_M_X64) /* Visual Studio x86_64 */ /* TODO: Need the appropriate x86_64 code */ int res; if (bits == 0) return -1; res = 0; if (bits & 0xFFFF0000) { bits &= 0xFFFF0000; res += 16; } if (bits & 0xFF00FF00) { bits &= 0xFF00FF00; res += 8; } if (bits & 0xF0F0F0F0) { bits &= 0xF0F0F0F0; res += 4; } if (bits & 0xCCCCCCCC) { bits &= 0xCCCCCCCC; res += 2; } if (bits & 0xAAAAAAAA) { bits &= 0xAAAAAAAA; res += 1; } return res; #else int res; if (bits == 0) return -1; res = 0; if (bits & 0xFFFF0000) { bits &= 0xFFFF0000; res += 16; } if (bits & 0xFF00FF00) { bits &= 0xFF00FF00; res += 8; } if (bits & 0xF0F0F0F0) { bits &= 0xF0F0F0F0; res += 4; } if (bits & 0xCCCCCCCC) { bits &= 0xCCCCCCCC; res += 2; } if (bits & 0xAAAAAAAA) { bits &= 0xAAAAAAAA; res += 1; } return res; #endif } And this is the file.i /*******************bit_operations.i ******************/ /* bit_operations.i */ %module bit_operations %{ #include "spandsp/telephony.h" #include "spandsp/bit_operations.h" %} #if defined(__i386__) || defined(__x86_64__) #if !defined(__SUNPRO_C) || (__SUNPRO_C >= 0x0590) #define SPANDSP_USE_86_ASM #endif #endif #if defined(HAVE_CONFIG_H) %include "config.h" #endif #include <inttypes.h> #include <stdlib.h> #include <fcntl.h> #include <string.h> #include <assert.h> #include <memory.h> %include "telephony.i" %include "spandsp/bit_operations.h" ******************* test compiling : home/foip# swig -java bit_operations.i spandsp/bit_operations.h:47: Error: Syntax error in input(1). line 47 in spandsp/bit_operations : static __inline__ int top_bit(unsigned int bits) ************************* I think the error is in the syntax code __inline__ but i don't know who i can corrige it .please i need a help:( |