* of the GNU Lesser General Public License.
*/
-#include "ucw/lib.h"
-#include "ucw/threads.h"
-#include "ucw/sighandler.h"
-#include "ucw/lizard.h"
+#include <ucw/lib.h>
+#include <ucw/threads.h>
+#include <ucw/sighandler.h>
+#include <ucw/lizard.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <errno.h>
struct lizard_buffer {
- uns len;
+ uint len;
void *ptr;
};
}
static void
-lizard_realloc(struct lizard_buffer *buf, uns max_len)
+lizard_realloc(struct lizard_buffer *buf, uint max_len)
/* max_len needs to be aligned to CPU_PAGE_SIZE */
{
if (max_len <= buf->len)
buf->len = max_len;
buf->ptr = mmap(NULL, buf->len + CPU_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
if (buf->ptr == MAP_FAILED)
- die("mmap(anonymous, %d bytes): %m", (uns)(buf->len + CPU_PAGE_SIZE));
+ die("mmap(anonymous, %d bytes): %m", (uint)(buf->len + CPU_PAGE_SIZE));
if (mprotect(buf->ptr + buf->len, CPU_PAGE_SIZE, PROT_NONE) < 0)
die("mprotect: %m");
}
}
byte *
-lizard_decompress_safe(const byte *in, struct lizard_buffer *buf, uns expected_length)
- /* Decompresses in into buf, sets *ptr to the data, and returns the
- * uncompressed length. If an error has occured, -1 is returned and errno is
- * set. The buffer buf is automatically reallocated. SIGSEGV is caught in
- * case of buffer-overflow. The function is not re-entrant because of a
- * static longjmp handler. */
+lizard_decompress_safe(const byte *in, struct lizard_buffer *buf, uint expected_length)
{
- uns lock_offset = ALIGN_TO(expected_length + 3, CPU_PAGE_SIZE); // +3 due to the unaligned access
+ uint lock_offset = ALIGN_TO(expected_length + 3, CPU_PAGE_SIZE); // +3 due to the unaligned access
if (lock_offset > buf->len)
lizard_realloc(buf, lock_offset);
volatile ucw_sighandler_t old_handler = set_signal_handler(SIGSEGV, sigsegv_handler);