__builtin_expect in 1.9.1

Peter Wächtler <[email protected]>
Newsgroups gmane.linux.ngpt.devel
Message-ID <[email protected]>
I tried to compile ngpt-1.9.1 with gcc 2.95.3.

gcc -c -I. -O2 -pipe test_common.c
./libtool --mode=link --quiet gcc  -o test_pthread test_pthread.o test_common.o libpthread.la -lnsl
.libs/libpthread.so: undefined reference to `__builtin_expect'
collect2: ld returned 1 exit status


in shm_open.c:74

	if (__builtin_expect (flags, 0) != -1) {
	    flags |= FD_CLOEXEC;
	    flags = fcntl (fd, F_SETFD, flags);
	}

change to

! 
if ( flags != -1) {
	    flags |= FD_CLOEXEC;
	    flags = fcntl (fd, F_SETFD, flags);
	}


The __builtin_expect seems like a hint for speculative branching
(like unlikely() in the kernel)

Do you compile with gcc 3.x?


BTW, I get some funny looking warnings:

In file included from ngptc.c:31:
pth_p.h.in:171: warning: `pth_get_native_descr' redefined
_ON_THE_FLY_:113: warning: this is the location of the previous definition
pth_p.h.in:173: warning: `pth_get_current' redefined
_ON_THE_FLY_:110: warning: this is the location of the previous definition
./libtool --mode=link --quiet gcc  -o ngptc ngptc.o shm_open.o shm_unlink.o
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.