jeffcoronza / ulib

Automatically exported from code.google.com/p/ulib
0 stars 0 forks source link

os_spinlock.h does not compile #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. tar xvzf ulib-2.0.0beta_src.tar.gz
2. cd ulib-svn
3. make

What is the expected output? What do you see instead?
lch@hyperstream:/DT/local/ulib-svn$ make
make -C src/
make[1]: Entering directory `/DT/local/ulib-svn/src'
make -C base/
make[2]: Entering directory `/DT/local/ulib-svn/src/base'
  AR    ../../lib/libbase.a
make[2]: Leaving directory `/DT/local/ulib-svn/src/base'
make -C ext1/
make[2]: Entering directory `/DT/local/ulib-svn/src/ext1'
make -C c++/
make[3]: Entering directory `/DT/local/ulib-svn/src/ext1/c++'
make[3]: Leaving directory `/DT/local/ulib-svn/src/ext1/c++'
make -C bloom_filter/
make[3]: Entering directory `/DT/local/ulib-svn/src/ext1/bloom_filter'
  AR    ../../../lib/libbfilter.a
make[3]: Leaving directory `/DT/local/ulib-svn/src/ext1/bloom_filter'
make -C comb/
make[3]: Entering directory `/DT/local/ulib-svn/src/ext1/comb'
  AR    ../../../lib/libcomb.a
make[3]: Leaving directory `/DT/local/ulib-svn/src/ext1/comb'
make -C console/
make[3]: Entering directory `/DT/local/ulib-svn/src/ext1/console'
  AR    ../../../lib/libconsole.a
make[3]: Leaving directory `/DT/local/ulib-svn/src/ext1/console'
make -C rng/
make[3]: Entering directory `/DT/local/ulib-svn/src/ext1/rng'
  AR    ../../../lib/librng.a
make[3]: Leaving directory `/DT/local/ulib-svn/src/ext1/rng'
make[2]: Leaving directory `/DT/local/ulib-svn/src/ext1'
make -C ext2/
make[2]: Entering directory `/DT/local/ulib-svn/src/ext2'
make -C thread
make[3]: Entering directory `/DT/local/ulib-svn/src/ext2/thread'
  AR    ../../../lib/libthread.a
make[3]: Leaving directory `/DT/local/ulib-svn/src/ext2/thread'
make -C osdep
make[3]: Entering directory `/DT/local/ulib-svn/src/ext2/osdep'
make[3]: Leaving directory `/DT/local/ulib-svn/src/ext2/osdep'
make -C reentrant
make[3]: Entering directory `/DT/local/ulib-svn/src/ext2/reentrant'
make[3]: Leaving directory `/DT/local/ulib-svn/src/ext2/reentrant'
make -C mapreduce
make[3]: Entering directory `/DT/local/ulib-svn/src/ext2/mapreduce'
  AR    ../../../lib/libmr.a
make[3]: Leaving directory `/DT/local/ulib-svn/src/ext2/mapreduce'
make[2]: Leaving directory `/DT/local/ulib-svn/src/ext2'
make[1]: Leaving directory `/DT/local/ulib-svn/src'
make -C lib/
make[1]: Entering directory `/DT/local/ulib-svn/lib'
make[1]: `libulib.a' is up to date.
make[1]: Leaving directory `/DT/local/ulib-svn/lib'
make -C test/
make[1]: Entering directory `/DT/local/ulib-svn/test'
-e   GEN    hash_chain_r1.test
In file included from ../include/ulib/os_typelock.h:30:0,
                 from ../include/ulib/os_regionlock.h:32,
                 from ../include/ulib/hash_chain_r.h:32,
                 from hash_chain_r1.cpp:3:
../include/ulib/os_spinlock.h: In function ‘void 
spin_lock_ticket(ticket_lock_t*)’:
../include/ulib/os_spinlock.h:302:37: error: expected primary-expression before 
‘.’ token
../include/ulib/os_spinlock.h: In function ‘void 
spin_wrlock_ticket(ticket_rwlock_t*)’:
../include/ulib/os_spinlock.h:357:39: error: expected primary-expression before 
‘.’ token
../include/ulib/os_spinlock.h: In function ‘void 
spin_wrunlock_ticket(ticket_rwlock_t*)’:
../include/ulib/os_spinlock.h:375:39: error: expected primary-expression before 
‘.’ token
../include/ulib/os_spinlock.h: In function ‘void 
spin_rdlock_ticket(ticket_rwlock_t*)’:
../include/ulib/os_spinlock.h:403:39: error: expected primary-expression before 
‘.’ token
make[1]: *** [hash_chain_r1.test] Error 1
make[1]: Leaving directory `/DT/local/ulib-svn/test'
make: *** [all] Error 2

What version of the product are you using? On what operating system?
Ubuntu 12.04.2 LTS

Please provide any additional information below.

Here the generated code. There is a ".head_tail" instead of "inc.head_tail":

static __always_inline void spin_lock_ticket(ticket_lock_t *lock)
{
    register union ticket_lock inc = { .head_tail = 1 << TICKET_SHIFT };

#ifdef LARGE_CPUSET
    inc.head_tail = atomic_fetchadd32(&lock->tickets, inc.head_tail);
#else
    inc.head_tail = atomic_fetchadd16(&lock->tickets, inc.head_tail);
#endif
[...]

Original issue reported on code.google.com by laurent....@gmail.com on 4 Apr 2013 at 1:42

GoogleCodeExporter commented 9 years ago
Thanks for reporting. Could you tell me which version of gcc did you use? I 
can't reproduce your error here with gcc 4.7.1, and the designators are 
supported by the c99 and c11 standards. Anyway, I just committed a patch that 
explicitly specifying the gnu99 standard for compiling. Please tell me if that 
solves your problem.

Original comment by eric.zltan@gmail.com on 5 Apr 2013 at 1:00

GoogleCodeExporter commented 9 years ago
Hi,

My gcc version is 4.6.3:

lch@hyperstream:/DT/local/ulib-svn$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--enable-gnu-unique-object --enable-plugin --enable-objc-gc
--disable-werror --with-arch-32=i686 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

I just take the source from svn, but compilation fail at same point:

-e   GEN    hash_chain_r1.test
In file included from ../include/ulib/os_typelock.h:30:0,
                 from ../include/ulib/os_regionlock.h:32,
                 from ../include/ulib/hash_chain_r.h:32,
                 from hash_chain_r1.cpp:3:
../include/ulib/os_spinlock.h: In function ‘void
spin_lock_ticket(ticket_lock_t*)’:
../include/ulib/os_spinlock.h:302:37: error: expected primary-expression
before ‘.’ token
../include/ulib/os_spinlock.h: In function ‘void
spin_wrlock_ticket(ticket_rwlock_t*)’:
../include/ulib/os_spinlock.h:357:39: error: expected primary-expression
before ‘.’ token
../include/ulib/os_spinlock.h: In function ‘void
spin_wrunlock_ticket(ticket_rwlock_t*)’:
../include/ulib/os_spinlock.h:375:39: error: expected primary-expression
before ‘.’ token
../include/ulib/os_spinlock.h: In function ‘void
spin_rdlock_ticket(ticket_rwlock_t*)’:
../include/ulib/os_spinlock.h:403:39: error: expected primary-expression
before ‘.’ token

I can do some more tests for you, if you wish

Original comment by laurent....@gmail.com on 8 Apr 2013 at 8:22

GoogleCodeExporter commented 9 years ago
It happens that the standard C++ doesn't support initialization with struct 
designators, though newer g++'s and Intel C++ compiler do. It should compile 
now.

Original comment by eric.zltan@gmail.com on 9 Apr 2013 at 3:20

GoogleCodeExporter commented 9 years ago
Thanks, its fixed :-)

But I have this small issue (I comment this line, and it's ok)

-e   GEN    hash_chain_r_bench.test
hash_chain_r_bench.cpp: In function ‘void constant_insert(long int, long
int)’:
hash_chain_r_bench.cpp:54:55: error: variable ‘it’ set but not used
[-Werror=unused-but-set-variable]
cc1plus: all warnings being treated as errors

Original comment by laurent....@gmail.com on 10 Apr 2013 at 10:00

GoogleCodeExporter commented 9 years ago
Hi Laurent,

You can simply ignore this warning. Actually, the variable 'it' is to tell the 
compiler not to optimize the statement out, which is required for some 
compilers.

Original comment by eric.zltan@gmail.com on 10 Apr 2013 at 10:10