[fossil-users] coding style guidelines: c89
Hi, fossil currently does not build in a ANSI C-89 environment - a requirement of the coding style guidelines ([1], point 16). There's an obvious build error in http_ssl.c (C++ style comments), but there's something more in sha1.c... When adding a -std=c89 to the generated Makefile with gcc as the compiler, I end up getting (ignoring the C++ style comment at line 87) ./bld/sha1_.c:104: error: expected ')' before ':' token ./bld/sha1_.c:104: error: expected ')' before ':' token ./bld/sha1_.c:104: error: expected ')' before ':' token ./bld/sha1_.c:104: error: expected ')' before ':' token ./bld/sha1_.c:104: error: expected ')' before ':' token ./bld/sha1_.c:104: error: expected ')' before ':' token ./bld/sha1_.c:104: error: expected ')' before ':' token ./bld/sha1_.c:104: error: expected ')' before ':' token ./bld/sha1_.c:104: error: expected ')' before ':' token ./bld/sha1_.c:104: error: expected ')' before ':' token ./bld/sha1_.c:104: error: expected ')' before ':' token ./bld/sha1_.c:104: error: expected ')' before ':' token ./bld/sha1_.c:104: error: expected ')' before ':' token ./bld/sha1_.c:104: error: expected ')' before ':' token ./bld/sha1_.c:104: error: expected ')' before ':' token ./bld/sha1_.c:104: error: expected ')' before ':' token (and many, many, many, many more lines like that). This seems to be because of the calls to asm() ... I don't know how to fix that. FYI, after preprocessing, the first instruction of line 104 looks like: qq[4]+=((qq[1](qq[2]^qq[3]))^qq[3])+(block[0] = (({ unsigned int y; asm(rorl %1,%0 : =r (y) : I (8), 0 (block[0])); y; })0xFF00FF00) |(({ unsigned int y; asm(roll %1,%0 : =r (y) : I (8), 0 (block[0])); y; })0x00FF00FF))+0x5A827999+({ unsigned int y; asm(roll %1,%0 : =r (y) : I (5), 0 (qq[0])); y; }); [1] http://fossil-scm.org/index.html/doc/trunk/www/style.wiki ___ fossil-users mailing list fossil-users@lists.fossil-scm.org http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users
Re: [fossil-users] coding style guidelines: c89
On Tue, Sep 06, 2011 at 04:21:43PM -0400, Martin S. Weber wrote: When adding a -std=c89 to the generated Makefile with gcc as the compiler, I end up getting (ignoring the C++ style comment at line 87) That was part of http://fossil-scm.org/index.html/info/f2ede7da6d70851 I don't get that commit -- both GCC 4.1 and 4.5 certainly do use the rotate instructions. As such I am strongly in favour of just reverting that change... Joerg ___ fossil-users mailing list fossil-users@lists.fossil-scm.org http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users
Re: [fossil-users] coding style guidelines: c89
On Tue, Sep 6, 2011 at 4:21 PM, Martin S. Weber martin.we...@nist.gov wrote: (and many, many, many, many more lines like that). This seems to be because of the calls to asm() ... I don't know how to fix that. FYI, after preprocessing, the first instruction of line 104 looks like: qq[4]+=((qq[1](qq[2]^qq[3]))^qq[3])+(block[0] = (({ unsigned int y; asm(rorl %1,%0 : =r (y) : I (8), 0 (block[0])); y; })0xFF00FF00) |(({ unsigned int y; asm(roll %1,%0 : =r (y) : I (8), 0 (block[0])); y; })0x00FF00FF))+0x5A827999+({ unsigned int y; asm(roll %1,%0 : =r (y) : I (5), 0 (qq[0])); y; }); The asm() calls are being used to invoke the rotate instructions. C does not have operators for peforming bitwise rotation of an operand and emulating a rotate using shifts is messy and very ineficient: unsigned int rotateLeft(unsigned int x, unsigned int n) { unsigned int t; t = x (SIZEOFINT - n); return ((x n) | t); } ___ fossil-users mailing list fossil-users@lists.fossil-scm.org http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users
Re: [fossil-users] coding style guidelines: c89
On Sep 6, 2011, at 11:19 PM, Ron Wilson wrote: The asm() calls are being used to invoke the rotate instructions. C does not have operators for peforming bitwise rotation of an operand and emulating a rotate using shifts is messy and very ineficient: unsigned int rotateLeft(unsigned int x, unsigned int n) { unsigned int t; t = x (SIZEOFINT - n); return ((x n) | t); } FYI, $ gcc -O2 -S rotate.c $ cat rotate.s … _rotateLeft: Leh_func_begin1: pushq %rbp Ltmp0: movq%rsp, %rbp Ltmp1: movb%sil, %cl movl%edi, %eax roll%cl, %eax popq%rbp ret Leh_func_end1: .. $ gcc --version i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00) (This is GCC with LLVM backend (default on OS X Lion)). -- Dmitry Chestnykh ___ fossil-users mailing list fossil-users@lists.fossil-scm.org http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users
Re: [fossil-users] coding style guidelines: c89
I guess I'm too used to dealing with dumb compilers. 1. Does it work with the C89 restrictions turned on? 2. Does C89 support inline functions? 3. If not, will it handle the folowing correctly? #define rotateLeft(x,n) { unsigned int t; t = x (SIZEOFINT - n); x = (x n) | t; } /* bitwise rotate x by n bits left */ On Tue, Sep 6, 2011 at 5:47 PM, Dmitry Chestnykh dmi...@codingrobots.com wrote: FYI, $ gcc -O2 -S rotate.c $ cat rotate.s … _rotateLeft: Leh_func_begin1: pushq %rbp Ltmp0: movq %rsp, %rbp Ltmp1: movb %sil, %cl movl %edi, %eax roll %cl, %eax popq %rbp ret Leh_func_end1: .. $ gcc --version i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00) ___ fossil-users mailing list fossil-users@lists.fossil-scm.org http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users