lkml.org 
[lkml]   [1999]   [Jul]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 2.2.10-ac7 compile errors on Alpha
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 ????


I suggest:

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;
}


Cheers,
Dick Johnson
***** FILE SYSTEM WAS MODIFIED *****
Penguin : Linux version 2.2.6 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.


-
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/

\
 
 \ /
  Last update: 2005-03-22 13:52    [W:0.171 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site