Messages in this thread | | | Date | Fri, 02 Jul 1999 17:11:09 -0400 | From | Jeff Garzik <> | Subject | Re: 2.2.10-ac7 compile errors on Alpha |
| |
"Richard B. Johnson" wrote: > > On Fri, 2 Jul 1999, Matthew Wilcox wrote: > > > On Fri, Jul 02, 1999 at 07:53:40PM +0100, Alan Cox wrote: > > > > 1) SLAB_DEBUG_SUPPORT (in mm/slab.c) does not work on Alpha (or any > > > > other non-i386 architecture, I presume) for lack of a memchr() > > > > > > Care to submit a memchr 8) > > > > For the architectures which don't have it, let's have a na\"\ive one in C. > > Since it's debug code, who cares, right? > > > > void *memchr(const void *s, int c, size_t n) > > { > > while (n-- != 0) { > > if (c == (char *)s++) { > > return s-1; > ^^^^^^_______ here???? > > } > > } > > return NULL; > > } > > 's' is declared as a (void *). > What is the value of a (void *) -1 ????
See a gcc manual on void ptr arithmetic: http://egcs.cygnus.com/onlinedocs/gcc_4.html#SEC78
> void *memchr(const void *s, int c, size_t n) > { > register char *p = (char *) s; > while(n--) > if(c == *p++) > return (void *) (--p); > return NULL; > }
Isn't declaring something a 'register char' a really bad idea these days? Something about taking away a register for the compiler to optimize with. A smart compiler should also make 'p' completely disappear...
Jeff
-- My, my, this here Anakin guy Maybe Vader someday later, now he's just a small fry He left his home and kissed his mommy goodbye Saying "Soon I'm gonna be a Jedi"...
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |