LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Re: Linux 2.4.10-pre11 -- __builtin_expect
       [not found]   ` <9o6j9l$461$1@cesium.transmeta.com.suse.lists.linux.kernel>
@ 2001-09-18 10:44     ` Andi Kleen
  2001-09-18 11:13       ` Andreas Schwab
  0 siblings, 1 reply; 10+ messages in thread
From: Andi Kleen @ 2001-09-18 10:44 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: linux-kernel, torvalds

"H. Peter Anvin" <hpa@zytor.com> writes:

> Followup to:  <E15jBLy-0008UF-00@the-village.bc.nu>
> By author:    Alan Cox <alan@lxorguk.ukuu.org.uk>
> In newsgroup: linux.dev.kernel
> > 
> > You need gcc 2.96 or higher to build the pre11 tree. I doubt that was
> > intentional. Basically rip out all use of __builtin_expect
> > 
> 
> Perhaps we should have a header which does #define __builtin_expect(X)
> if your gcc version is 2.91-95?

__builtin_expect() is ugly to use directly. In x86-64 I'm using slightly
higher level primitives (likely() and unlikely()), which make the intend
more clear.

I sent Linus a patch to move them into generic code some time ago, but it 
was ignored. Here is it again for 2.4.10pre11 with the generic code changed 
to use them. Please consider applying.

More comments:

For kernel debugging I can only recommend to compile with 
-fno-reorder-blocks. Gcc output gone through the basic block reordering pass
is *really* unreadable.

A lot of the unlikely()s seem to be in front of BUGs. If BUG was moved out 
of line and marked __attribute__((noreturn)) this could be avoided, because
the reordering pass would already do the right thing. I didn't do that 
change yet.





-Andi


--- mm/slab.c-LIKELY	Tue Sep 18 03:37:30 2001
+++ mm/slab.c	Tue Sep 18 11:26:43 2001
@@ -1230,7 +1230,7 @@
 	objp = slabp->s_mem + slabp->free*cachep->objsize;
 	slabp->free=slab_bufctl(slabp)[slabp->free];
 
-	if (__builtin_expect(slabp->free == BUFCTL_END, 0)) {
+	if (unlikely(slabp->free == BUFCTL_END)) {
 		list_del(&slabp->list);
 		list_add(&slabp->list, &cachep->slabs_full);
 	}
@@ -1264,11 +1264,11 @@
 								\
 	slabs_partial = &(cachep)->slabs_partial;		\
 	entry = slabs_partial->next;				\
-	if (__builtin_expect(entry == slabs_partial, 0)) {	\
+	if (unlikely(entry == slabs_partial)) {	\
 		struct list_head * slabs_free;			\
 		slabs_free = &(cachep)->slabs_free;		\
 		entry = slabs_free->next;			\
-		if (__builtin_expect(entry == slabs_free, 0))	\
+		if (unlikely(entry == slabs_free))	\
 			goto alloc_new_slab;			\
 		list_del(entry);				\
 		list_add(entry, slabs_partial);			\
@@ -1291,11 +1291,11 @@
 		/* Get slab alloc is to come from. */
 		slabs_partial = &(cachep)->slabs_partial;
 		entry = slabs_partial->next;
-		if (__builtin_expect(entry == slabs_partial, 0)) {
+		if (unlikely(entry == slabs_partial)) {
 			struct list_head * slabs_free;
 			slabs_free = &(cachep)->slabs_free;
 			entry = slabs_free->next;
-			if (__builtin_expect(entry == slabs_free, 0))
+			if (unlikely(entry == slabs_free))
 				break;
 			list_del(entry);
 			list_add(entry, slabs_partial);
@@ -1436,11 +1436,11 @@
 	/* fixup slab chains */
 	{
 		int inuse = slabp->inuse;
-		if (__builtin_expect(!--slabp->inuse, 0)) {
+		if (unlikely(!--slabp->inuse)) {
 			/* Was partial or full, now empty. */
 			list_del(&slabp->list);
 			list_add(&slabp->list, &cachep->slabs_free);
-		} else if (__builtin_expect(inuse == cachep->num, 0)) {
+		} else if (unlikely(inuse == cachep->num)) {
 			/* Was full. */
 			list_del(&slabp->list);
 			list_add(&slabp->list, &cachep->slabs_partial);
--- mm/vmscan.c-LIKELY	Tue Sep 18 03:37:30 2001
+++ mm/vmscan.c	Tue Sep 18 11:22:09 2001
@@ -335,7 +335,7 @@
 	while (__max_scan && (entry = lru->prev) != lru) {
 		struct page * page;
 
-		if (__builtin_expect(current->need_resched, 0)) {
+		if (unlikely(current->need_resched)) {
 			spin_unlock(&pagemap_lru_lock);
 			schedule();
 			spin_lock(&pagemap_lru_lock);
@@ -344,7 +344,7 @@
 
 		page = list_entry(entry, struct page, lru);
 
-		if (__builtin_expect(!PageInactive(page) && !PageActive(page), 0))
+		if (unlikely(!PageInactive(page) && !PageActive(page)))
 			BUG();
 
 		if (PageTestandClearReferenced(page)) {
@@ -363,7 +363,7 @@
 		list_del(entry);
 		list_add_tail(entry, &inactive_local_lru);
 
-		if (__builtin_expect(!memclass(page->zone, classzone), 0))
+		if (unlikely(!memclass(page->zone, classzone)))
 			continue;
 
 		__max_scan--;
@@ -380,7 +380,7 @@
 		 * The page is locked. IO in progress?
 		 * Move it to the back of the list.
 		 */
-		if (__builtin_expect(TryLockPage(page), 0))
+		if (unlikely(TryLockPage(page)))
 			continue;
 
 		if (PageDirty(page) && is_page_cache_freeable(page)) {
@@ -456,10 +456,10 @@
 			}
 		}
 
-		if (__builtin_expect(!page->mapping, 0))
+		if (unlikely(!page->mapping))
 			BUG();
 
-		if (__builtin_expect(!spin_trylock(&pagecache_lock), 0)) {
+		if (unlikely(!spin_trylock(&pagecache_lock))) {
 			/* we hold the page lock so the page cannot go away from under us */
 			spin_unlock(&pagemap_lru_lock);
 
@@ -479,7 +479,7 @@
 		}
 
 		/* point of no return */
-		if (__builtin_expect(!PageSwapCache(page), 1))
+		if (likely(!PageSwapCache(page)))
 			__remove_inode_page(page);
 		else
 			__delete_from_swap_cache(page);
--- mm/page_alloc.c-LIKELY	Tue Sep 18 03:37:30 2001
+++ mm/page_alloc.c	Tue Sep 18 11:26:44 2001
@@ -372,7 +372,7 @@
 		return page;
 
 	zone = zonelist->zones;
-	if (__builtin_expect(freed, 1)) {
+	if (likely(freed)) {
 		for (;;) {
 			zone_t *z = *(zone++);
 			if (!z)
--- include/linux/kernel.h-LIKELY	Tue Sep 18 11:12:20 2001
+++ include/linux/kernel.h	Tue Sep 18 11:30:58 2001
@@ -171,4 +171,14 @@
 	char _f[20-2*sizeof(long)-sizeof(int)];	/* Padding: libc5 uses this.. */
 };
 
+
+/* This loses on a few early 2.96 snapshots, but hopefully nobody uses them anymore. */ 
+#if __GNUC__ > 2 || (__GNUC__ == 2 && _GNUC_MINOR__ == 96)
+#define likely(x)  __builtin_expect((x), !0) 
+#define unlikely(x)  __builtin_expect((x), 0) 
+#else
+#define likely(x) (x)
+#define unlikely(x) (x)
+#endif
+
 #endif

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux 2.4.10-pre11 -- __builtin_expect
  2001-09-18 10:44     ` Linux 2.4.10-pre11 -- __builtin_expect Andi Kleen
@ 2001-09-18 11:13       ` Andreas Schwab
  2001-09-18 12:38         ` Andi Kleen
  2001-09-18 20:11         ` Horst von Brand
  0 siblings, 2 replies; 10+ messages in thread
From: Andreas Schwab @ 2001-09-18 11:13 UTC (permalink / raw)
  To: Andi Kleen; +Cc: H. Peter Anvin, linux-kernel, torvalds

Andi Kleen <ak@suse.de> writes:

|> +#define likely(x)  __builtin_expect((x), !0) 

IMHO, this should better be written as

#define likely(x) __builtin_expect(!!(x), 1)

because x is not required to be pure boolean, so any nonzero value of x is
as likely as 1.

Andreas.

-- 
Andreas Schwab                                  "And now for something
Andreas.Schwab@suse.de				completely different."
SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux 2.4.10-pre11 -- __builtin_expect
  2001-09-18 11:13       ` Andreas Schwab
@ 2001-09-18 12:38         ` Andi Kleen
  2001-09-26 23:54           ` James Antill
  2001-09-18 20:11         ` Horst von Brand
  1 sibling, 1 reply; 10+ messages in thread
From: Andi Kleen @ 2001-09-18 12:38 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Andi Kleen, H. Peter Anvin, linux-kernel, torvalds

On Tue, Sep 18, 2001 at 01:13:48PM +0200, Andreas Schwab wrote:
> Andi Kleen <ak@suse.de> writes:
> 
> |> +#define likely(x)  __builtin_expect((x), !0) 
> 
> IMHO, this should better be written as
> 
> #define likely(x) __builtin_expect(!!(x), 1)
> 
> because x is not required to be pure boolean, so any nonzero value of x is
> as likely as 1.

Good point. I somehow assumed that __builtin_expect would just signify
a boolean, but if I read gcc source correctly this was wrong.

Here is an updated patch.

-Andi


--- mm/slab.c-LIKELY	Tue Sep 18 03:37:30 2001
+++ mm/slab.c	Tue Sep 18 11:26:43 2001
@@ -1230,7 +1230,7 @@
 	objp = slabp->s_mem + slabp->free*cachep->objsize;
 	slabp->free=slab_bufctl(slabp)[slabp->free];
 
-	if (__builtin_expect(slabp->free == BUFCTL_END, 0)) {
+	if (unlikely(slabp->free == BUFCTL_END)) {
 		list_del(&slabp->list);
 		list_add(&slabp->list, &cachep->slabs_full);
 	}
@@ -1264,11 +1264,11 @@
 								\
 	slabs_partial = &(cachep)->slabs_partial;		\
 	entry = slabs_partial->next;				\
-	if (__builtin_expect(entry == slabs_partial, 0)) {	\
+	if (unlikely(entry == slabs_partial)) {	\
 		struct list_head * slabs_free;			\
 		slabs_free = &(cachep)->slabs_free;		\
 		entry = slabs_free->next;			\
-		if (__builtin_expect(entry == slabs_free, 0))	\
+		if (unlikely(entry == slabs_free))	\
 			goto alloc_new_slab;			\
 		list_del(entry);				\
 		list_add(entry, slabs_partial);			\
@@ -1291,11 +1291,11 @@
 		/* Get slab alloc is to come from. */
 		slabs_partial = &(cachep)->slabs_partial;
 		entry = slabs_partial->next;
-		if (__builtin_expect(entry == slabs_partial, 0)) {
+		if (unlikely(entry == slabs_partial)) {
 			struct list_head * slabs_free;
 			slabs_free = &(cachep)->slabs_free;
 			entry = slabs_free->next;
-			if (__builtin_expect(entry == slabs_free, 0))
+			if (unlikely(entry == slabs_free))
 				break;
 			list_del(entry);
 			list_add(entry, slabs_partial);
@@ -1436,11 +1436,11 @@
 	/* fixup slab chains */
 	{
 		int inuse = slabp->inuse;
-		if (__builtin_expect(!--slabp->inuse, 0)) {
+		if (unlikely(!--slabp->inuse)) {
 			/* Was partial or full, now empty. */
 			list_del(&slabp->list);
 			list_add(&slabp->list, &cachep->slabs_free);
-		} else if (__builtin_expect(inuse == cachep->num, 0)) {
+		} else if (unlikely(inuse == cachep->num)) {
 			/* Was full. */
 			list_del(&slabp->list);
 			list_add(&slabp->list, &cachep->slabs_partial);
--- mm/vmscan.c-LIKELY	Tue Sep 18 03:37:30 2001
+++ mm/vmscan.c	Tue Sep 18 11:22:09 2001
@@ -335,7 +335,7 @@
 	while (__max_scan && (entry = lru->prev) != lru) {
 		struct page * page;
 
-		if (__builtin_expect(current->need_resched, 0)) {
+		if (unlikely(current->need_resched)) {
 			spin_unlock(&pagemap_lru_lock);
 			schedule();
 			spin_lock(&pagemap_lru_lock);
@@ -344,7 +344,7 @@
 
 		page = list_entry(entry, struct page, lru);
 
-		if (__builtin_expect(!PageInactive(page) && !PageActive(page), 0))
+		if (unlikely(!PageInactive(page) && !PageActive(page)))
 			BUG();
 
 		if (PageTestandClearReferenced(page)) {
@@ -363,7 +363,7 @@
 		list_del(entry);
 		list_add_tail(entry, &inactive_local_lru);
 
-		if (__builtin_expect(!memclass(page->zone, classzone), 0))
+		if (unlikely(!memclass(page->zone, classzone)))
 			continue;
 
 		__max_scan--;
@@ -380,7 +380,7 @@
 		 * The page is locked. IO in progress?
 		 * Move it to the back of the list.
 		 */
-		if (__builtin_expect(TryLockPage(page), 0))
+		if (unlikely(TryLockPage(page)))
 			continue;
 
 		if (PageDirty(page) && is_page_cache_freeable(page)) {
@@ -456,10 +456,10 @@
 			}
 		}
 
-		if (__builtin_expect(!page->mapping, 0))
+		if (unlikely(!page->mapping))
 			BUG();
 
-		if (__builtin_expect(!spin_trylock(&pagecache_lock), 0)) {
+		if (unlikely(!spin_trylock(&pagecache_lock))) {
 			/* we hold the page lock so the page cannot go away from under us */
 			spin_unlock(&pagemap_lru_lock);
 
@@ -479,7 +479,7 @@
 		}
 
 		/* point of no return */
-		if (__builtin_expect(!PageSwapCache(page), 1))
+		if (likely(!PageSwapCache(page)))
 			__remove_inode_page(page);
 		else
 			__delete_from_swap_cache(page);
--- mm/page_alloc.c-LIKELY	Tue Sep 18 03:37:30 2001
+++ mm/page_alloc.c	Tue Sep 18 11:26:44 2001
@@ -372,7 +372,7 @@
 		return page;
 
 	zone = zonelist->zones;
-	if (__builtin_expect(freed, 1)) {
+	if (likely(freed)) {
 		for (;;) {
 			zone_t *z = *(zone++);
 			if (!z)
--- include/linux/kernel.h-LIKELY	Tue Sep 18 11:12:20 2001
+++ include/linux/kernel.h	Tue Sep 18 14:35:17 2001
@@ -171,4 +171,14 @@
 	char _f[20-2*sizeof(long)-sizeof(int)];	/* Padding: libc5 uses this.. */
 };
 
+
+/* This loses on a few early 2.96 snapshots, but hopefully nobody uses them anymore. */ 
+#if __GNUC__ > 2 || (__GNUC__ == 2 && _GNUC_MINOR__ == 96)
+#define likely(x)  __builtin_expect(!!(x), 1) 
+#define unlikely(x)  __builtin_expect((x), 0) 
+#else
+#define likely(x) (x)
+#define unlikely(x) (x)
+#endif
+
 #endif

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux 2.4.10-pre11 -- __builtin_expect 
  2001-09-18 11:13       ` Andreas Schwab
  2001-09-18 12:38         ` Andi Kleen
@ 2001-09-18 20:11         ` Horst von Brand
  1 sibling, 0 replies; 10+ messages in thread
From: Horst von Brand @ 2001-09-18 20:11 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Andi Kleen, H. Peter Anvin, linux-kernel, torvalds

Andreas Schwab <schwab@suse.de> said:
> Andi Kleen <ak@suse.de> writes:
> |> +#define likely(x)  __builtin_expect((x), !0) 
> 
> IMHO, this should better be written as
> 
> #define likely(x) __builtin_expect(!!(x), 1)
> 
> because x is not required to be pure boolean, so any nonzero value of x is
> as likely as 1.


I don't think you are really thinking "likely", you are thinking "must_be"
-- 
Horst von Brand                             vonbrand@sleipnir.valparaiso.cl
Casilla 9G, Vin~a del Mar, Chile                               +56 32 672616

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux 2.4.10-pre11 -- __builtin_expect
  2001-09-18 12:38         ` Andi Kleen
@ 2001-09-26 23:54           ` James Antill
  2001-09-27 12:51             ` Andreas Schwab
  0 siblings, 1 reply; 10+ messages in thread
From: James Antill @ 2001-09-26 23:54 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-kernel

Andi Kleen <ak@suse.de> writes:

> Good point. I somehow assumed that __builtin_expect would just signify
> a boolean, but if I read gcc source correctly this was wrong.

 Yeh, it's a long so you'll get no cast warnings too.

> Here is an updated patch.

[snip ... ]

> --- include/linux/kernel.h-LIKELY	Tue Sep 18 11:12:20 2001
> +++ include/linux/kernel.h	Tue Sep 18 14:35:17 2001
> @@ -171,4 +171,14 @@
>  	char _f[20-2*sizeof(long)-sizeof(int)];	/* Padding: libc5 uses this.. */
>  };
>  
> +
> +/* This loses on a few early 2.96 snapshots, but hopefully nobody uses them anymore. */ 
> +#if __GNUC__ > 2 || (__GNUC__ == 2 && _GNUC_MINOR__ == 96)
> +#define likely(x)  __builtin_expect(!!(x), 1) 
> +#define unlikely(x)  __builtin_expect((x), 0) 

 unlikely() also needs to be...

#define unlikely(x)  __builtin_expect(!(x), 1) 

...or...

#define unlikely(x)  __builtin_expect(!!(x), 0) 

> +#else
> +#define likely(x) (x)
> +#define unlikely(x) (x)
> +#endif
> +
>  #endif

-- 
# James Antill -- james@and.org
:0:
* ^From: .*james@and\.org
/dev/null

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux 2.4.10-pre11 -- __builtin_expect
  2001-09-26 23:54           ` James Antill
@ 2001-09-27 12:51             ` Andreas Schwab
  2001-09-27 15:41               ` James Antill
  0 siblings, 1 reply; 10+ messages in thread
From: Andreas Schwab @ 2001-09-27 12:51 UTC (permalink / raw)
  To: James Antill; +Cc: Andi Kleen, linux-kernel

James Antill <james@and.org> writes:

|> Andi Kleen <ak@suse.de> writes:
|> 
|> > Good point. I somehow assumed that __builtin_expect would just signify
|> > a boolean, but if I read gcc source correctly this was wrong.
|> 
|>  Yeh, it's a long so you'll get no cast warnings too.
|> 
|> > Here is an updated patch.
|> 
|> [snip ... ]
|> 
|> > --- include/linux/kernel.h-LIKELY	Tue Sep 18 11:12:20 2001
|> > +++ include/linux/kernel.h	Tue Sep 18 14:35:17 2001
|> > @@ -171,4 +171,14 @@
|> >  	char _f[20-2*sizeof(long)-sizeof(int)];	/* Padding: libc5 uses this.. */
|> >  };
|> >  
|> > +
|> > +/* This loses on a few early 2.96 snapshots, but hopefully nobody uses them anymore. */ 
|> > +#if __GNUC__ > 2 || (__GNUC__ == 2 && _GNUC_MINOR__ == 96)
|> > +#define likely(x)  __builtin_expect(!!(x), 1) 
|> > +#define unlikely(x)  __builtin_expect((x), 0) 
|> 
|>  unlikely() also needs to be...
|> 
|> #define unlikely(x)  __builtin_expect(!(x), 1) 
|> 
|> ...or...
|> 
|> #define unlikely(x)  __builtin_expect(!!(x), 0) 

This is not needed, since only 0 is the likely value and !! does not
change that.

Andreas.

-- 
Andreas Schwab                                  "And now for something
Andreas.Schwab@suse.de				completely different."
SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux 2.4.10-pre11 -- __builtin_expect
  2001-09-27 12:51             ` Andreas Schwab
@ 2001-09-27 15:41               ` James Antill
  2001-09-27 16:28                 ` Andreas Schwab
  0 siblings, 1 reply; 10+ messages in thread
From: James Antill @ 2001-09-27 15:41 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Andi Kleen, linux-kernel

Andreas Schwab <schwab@suse.de> writes:

> James Antill <james@and.org> writes:
> 
> |>  unlikely() also needs to be...
> |> 
> |> #define unlikely(x)  __builtin_expect(!(x), 1) 
> |> 
> |> ...or...
> |> 
> |> #define unlikely(x)  __builtin_expect(!!(x), 0) 
> 
> This is not needed, since only 0 is the likely value and !! does not
> change that.

 Yes it is, given the code...

struct blah *ptr = NULL;

if (unlikely(ptr))

...you'll get a warning from gcc because you are implicitly converting
from a pointer to a long.

-- 
# James Antill -- james@and.org
:0:
* ^From: .*james@and\.org
/dev/null

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux 2.4.10-pre11 -- __builtin_expect
  2001-09-27 15:41               ` James Antill
@ 2001-09-27 16:28                 ` Andreas Schwab
  2001-10-04 18:52                   ` Richard Henderson
  0 siblings, 1 reply; 10+ messages in thread
From: Andreas Schwab @ 2001-09-27 16:28 UTC (permalink / raw)
  To: James Antill; +Cc: Andi Kleen, linux-kernel

James Antill <james@and.org> writes:

|> Andreas Schwab <schwab@suse.de> writes:
|> 
|> > James Antill <james@and.org> writes:
|> > 
|> > |>  unlikely() also needs to be...
|> > |> 
|> > |> #define unlikely(x)  __builtin_expect(!(x), 1) 
|> > |> 
|> > |> ...or...
|> > |> 
|> > |> #define unlikely(x)  __builtin_expect(!!(x), 0) 
|> > 
|> > This is not needed, since only 0 is the likely value and !! does not
|> > change that.
|> 
|>  Yes it is, given the code...
|> 
|> struct blah *ptr = NULL;
|> 
|> if (unlikely(ptr))
|> 
|> ...you'll get a warning from gcc because you are implicitly converting
|> from a pointer to a long.

You're right, seems like __builtin_expect is really only defined for pure
boolean values.

Andreas.

-- 
Andreas Schwab                                  "And now for something
Andreas.Schwab@suse.de				completely different."
SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux 2.4.10-pre11 -- __builtin_expect
  2001-09-27 16:28                 ` Andreas Schwab
@ 2001-10-04 18:52                   ` Richard Henderson
  2001-10-08  6:17                     ` James Antill
  0 siblings, 1 reply; 10+ messages in thread
From: Richard Henderson @ 2001-10-04 18:52 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: James Antill, Andi Kleen, linux-kernel

On Thu, Sep 27, 2001 at 06:28:08PM +0200, Andreas Schwab wrote:
> You're right, seems like __builtin_expect is really only defined for pure
> boolean values.

I think the documentation mentions the current deficiency in that area.
It is _supposed_ to be defined for all integral and pointer types, but
that is hard with the current built-in infrastructure in the C front end.


r~

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux 2.4.10-pre11 -- __builtin_expect
  2001-10-04 18:52                   ` Richard Henderson
@ 2001-10-08  6:17                     ` James Antill
  0 siblings, 0 replies; 10+ messages in thread
From: James Antill @ 2001-10-08  6:17 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Andreas Schwab, Andi Kleen, linux-kernel

Richard Henderson <rth@twiddle.net> writes:

> On Thu, Sep 27, 2001 at 06:28:08PM +0200, Andreas Schwab wrote:
> > You're right, seems like __builtin_expect is really only defined for pure
> > boolean values.
> 
> I think the documentation mentions the current deficiency in that area.
> It is _supposed_ to be defined for all integral and pointer types, but
> that is hard with the current built-in infrastructure in the C front end.

 The documentation in the info files doesn't suggest that, in fact it
says...

    Since you are limited to integral expressions for EXP, you should
    use constructions such as

          if (__builtin_expect (ptr != NULL, 1))
            error ();

     when testing pointer or floating-point values.

-- 
# James Antill -- james@and.org
:0:
* ^From: .*james@and\.org
/dev/null

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2001-10-08  6:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20010918031813.57E1062ABC@oscar.casa.dyndns.org.suse.lists.linux.kernel>
     [not found] ` <E15jBLy-0008UF-00@the-village.bc.nu.suse.lists.linux.kernel>
     [not found]   ` <9o6j9l$461$1@cesium.transmeta.com.suse.lists.linux.kernel>
2001-09-18 10:44     ` Linux 2.4.10-pre11 -- __builtin_expect Andi Kleen
2001-09-18 11:13       ` Andreas Schwab
2001-09-18 12:38         ` Andi Kleen
2001-09-26 23:54           ` James Antill
2001-09-27 12:51             ` Andreas Schwab
2001-09-27 15:41               ` James Antill
2001-09-27 16:28                 ` Andreas Schwab
2001-10-04 18:52                   ` Richard Henderson
2001-10-08  6:17                     ` James Antill
2001-09-18 20:11         ` Horst von Brand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).