pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: 915resolution support for DragonFly



Sergey Glushchenko wrote:
> Here is the patch against pkgsrc-2006Q4.
> 
> Sergey
> 
> +--- 915resolution.c.orig     2006-02-02 16:28:34.000000000 +0200
> ++++ 915resolution.c  2007-02-05 05:06:58.000000000 +0200
> +@@ -22,7 +22,28 @@
>   #include <string.h>
>   #include <sys/mman.h>
>   #include <fcntl.h>
> @@ -22,10 +20,29 @@ $NetBSD: patch-aa,v 1.2 2006/11/13 04:15
>  +#define OUTL(a, b)     outl(b, a)
>  +#define OUTB(a, b)     outb(b, a)
>  +#endif
> ++#ifdef __DragonFly__
> ++#include <cpu/cpufunc.h>
> ++#define OUTL(a, b)     outl(b, a)
> ++#define OUTB(a, b)     outb(b, a)
> ++#define memmem(a, b, c, d)      strstr(a, c)

This not correct and mem* is reserved for <string.h>. You could use
this implementation or roll your own.

/**
 * Similar to strstr() but for raw memory without NUL-termination.
 *
 * @param data The memory to scan.
 * @param data_size The length of data.
 * @param pattern The byte pattern to look for.
 * @param pattern_size The length of the pattern.
 * @return NULL if not found. Otherwise, the start address of the first match
 *         is returned.
 */
void *
compat_memmem(const void *data, size_t data_size,
        const void *pattern, size_t pattern_size)
{
        const char *next, *p, *pat;
        
        pat = pattern;
        for (p = data; NULL != p; p = next) {
                if (data_size < pattern_size) {
                        p = NULL;
                        break;
                }
                if (0 == memcmp(p, pattern, pattern_size)) {
                        break;
                }
                next = memchr(&p[1], pat[0], data_size - 1);
                data_size -= next - p;
        }
        return (void *) p;
}

-- 
Christian



Home | Main Index | Thread Index | Old Index