mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-05-02 06:46:26 -04:00
tests: Provide memrchr() fallback for platforms that lack it
darwin does not provide memrchr(). Add a local fallback implementation guarded by HAVE_MEMRCHR. Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
This commit is contained in:
parent
2454dd0eec
commit
0815bd0a74
2 changed files with 15 additions and 0 deletions
|
|
@ -49,6 +49,7 @@ endforeach
|
|||
have_funcs = [
|
||||
'accept4',
|
||||
'getpeereid',
|
||||
'memrchr',
|
||||
'mkostemp',
|
||||
'posix_fallocate',
|
||||
'ppoll',
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
*/
|
||||
|
||||
#define _GNU_SOURCE /* For memrchr */
|
||||
#include "../config.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -36,6 +37,19 @@
|
|||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifndef HAVE_MEMRCHR
|
||||
static void *
|
||||
memrchr(const void *s, int c, size_t n)
|
||||
{
|
||||
const unsigned char *p = (const unsigned char *)s + n;
|
||||
while (n--) {
|
||||
if (*--p == (unsigned char)c)
|
||||
return (void *)p;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "wayland-client.h"
|
||||
#include "wayland-server.h"
|
||||
#include "test-runner.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue