/*
- * Copyright (C) 2008, 2009 Free Software Foundation
+ * Copyright (C) 2008-2013 Free Software Foundation, Inc.
* Written by Eric Blake and Bruno Haible
*
* This program is free software: you can redistribute it and/or modify
#include <stdlib.h>
+#include "zerosize-ptr.h"
#include "macros.h"
/* Calculating void * + int is not portable, so this wrapper converts
ASSERT (RAWMEMCHR (input + 1, 'a') == input + n - 1);
ASSERT (RAWMEMCHR (input + 1, 'e') == input + n - 2);
+ ASSERT (RAWMEMCHR (input + 1, 0x789abc00 | 'e') == input + n - 2);
ASSERT (RAWMEMCHR (input, '\0') == input + n);
}
}
+ /* Ensure that no unaligned oversized reads occur. */
+ {
+ char *page_boundary = (char *) zerosize_ptr ();
+ size_t i;
+
+ if (!page_boundary)
+ page_boundary = input + 4096;
+ memset (page_boundary - 512, '1', 511);
+ page_boundary[-1] = '2';
+ for (i = 1; i <= 512; i++)
+ ASSERT (RAWMEMCHR (page_boundary - i, (i * 0x01010100) | '2')
+ == page_boundary - 1);
+ }
+
free (input);
return 0;