Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/sljit/dist/sljit_src Adapt code to compile ...
details: https://anonhg.NetBSD.org/src/rev/b54e9703616d
branches: trunk
changeset: 781915:b54e9703616d
user: alnsn <alnsn%NetBSD.org@localhost>
date: Sat Oct 06 19:23:01 2012 +0000
description:
Adapt code to compile with -D_KERNEL.
diffstat:
sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h | 41 +++++++++++++
sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h | 2 +
sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c | 35 +++++++++-
3 files changed, 73 insertions(+), 5 deletions(-)
diffs (155 lines):
diff -r f90458762ece -r b54e9703616d sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h
--- a/sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h Sat Oct 06 18:29:44 2012 +0000
+++ b/sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h Sat Oct 06 19:23:01 2012 +0000
@@ -51,6 +51,47 @@
/* #define SLJIT_CONFIG_AUTO 1 */
/* #define SLJIT_CONFIG_UNSUPPORTED 1 */
+#include <machine/sljitarch.h>
+
+#if defined(_KERNEL) && !defined(SLJIT_MALLOC)
+#define SLJIT_MALLOC(size) malloc((size), M_TEMP, M_WAITOK)
+#endif
+
+#if defined(_KERNEL) && !defined(SLJIT_FREE)
+#define SLJIT_FREE(ptr) free((ptr), M_TEMP)
+#endif
+
+#if defined(_KERNEL) && !defined(SLJIT_CACHE_FLUSH)
+#define SLJIT_CACHE_FLUSH(from, to)
+#endif
+
+#if defined(_KERNEL)
+#define SLJIT_UTIL_GLOBAL_LOCK 0
+#define SLJIT_EXECUTABLE_ALLOCATOR 0
+#define SLJIT_MALLOC_EXEC(sz) SLJIT_MALLOC(sz)
+#define SLJIT_FREE_EXEC(ptr) SLJIT_FREE(ptr)
+#endif
+
+#ifdef _KERNEL
+#ifdef DIAGNOSTIC
+#define SLJIT_DEBUG 1
+#else
+#define SLJIT_DEBUG 0
+#endif
+#endif
+
+#ifdef _KERNEL
+#define SLJIT_VERBOSE 0
+#endif
+
+#ifdef _KERNEL
+#include <sys/cdefs.h>
+#include <sys/malloc.h>
+#ifdef SLJIT_DEBUG
+#include <sys/systm.h>
+#endif
+#endif
+
/* --------------------------------------------------------------------- */
/* Utilities */
/* --------------------------------------------------------------------- */
diff -r f90458762ece -r b54e9703616d sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h
--- a/sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h Sat Oct 06 18:29:44 2012 +0000
+++ b/sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h Sat Oct 06 19:23:01 2012 +0000
@@ -123,9 +123,11 @@
#if !(defined SLJIT_STD_MACROS_DEFINED && SLJIT_STD_MACROS_DEFINED)
+#ifndef _KERNEL
/* These libraries are needed for the macros below. */
#include <stdlib.h>
#include <string.h>
+#endif
#endif /* STD_MACROS_DEFINED */
diff -r f90458762ece -r b54e9703616d sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c
--- a/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c Sat Oct 06 18:29:44 2012 +0000
+++ b/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c Sat Oct 06 19:23:01 2012 +0000
@@ -106,9 +106,9 @@
#else /* _WIN32 */
-#include <pthread.h>
+#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
-#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
+#include <pthread.h>
static pthread_mutex_t allocator_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -126,6 +126,8 @@
#if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
+#include <pthread.h>
+
static pthread_mutex_t global_mutex = PTHREAD_MUTEX_INITIALIZER;
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_grab_lock(void)
@@ -148,7 +150,10 @@
#if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)
-#ifdef _WIN32
+#ifdef _KERNEL
+#include <sys/param.h>
+#include <uvm/uvm.h>
+#elif defined(_WIN32)
#include "windows.h"
#else
#include <sys/mman.h>
@@ -168,6 +173,9 @@
#ifdef _WIN32
SYSTEM_INFO si;
#endif
+#ifdef _KERNEL
+ vaddr_t v;
+#endif
if (limit > max_limit || limit < 1)
return NULL;
@@ -179,7 +187,11 @@
}
#else
if (!sljit_page_align) {
+#ifdef _KERNEL
+ sljit_page_align = PAGE_SIZE;
+#else
sljit_page_align = sysconf(_SC_PAGESIZE);
+#endif
/* Should never happen. */
if (sljit_page_align < 0)
sljit_page_align = 4096;
@@ -194,7 +206,17 @@
if (!stack)
return NULL;
-#ifdef _WIN32
+#ifdef _KERNEL
+ v = uvm_km_alloc(kernel_map, max_limit, PAGE_SIZE, UVM_KMF_WIRED|UVM_KMF_ZERO);
+ base.ptr = (void *)v;
+ if (base.ptr == NULL) {
+ SLJIT_FREE(stack);
+ return NULL;
+ }
+ stack->base = base.uw;
+ stack->limit = stack->base + limit;
+ stack->max_limit = stack->base + max_limit;
+#elif defined(_WIN32)
base.ptr = VirtualAlloc(0, max_limit, MEM_RESERVE, PAGE_READWRITE);
if (!base.ptr) {
SLJIT_FREE(stack);
@@ -225,7 +247,10 @@
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack)
{
-#ifdef _WIN32
+#ifdef _KERNEL
+ uvm_km_free(kernel_map, (vaddr_t)stack->base,
+ stack->max_limit - stack->base, UVM_KMF_WIRED);
+#elif defined(_WIN32)
VirtualFree((void*)stack->base, 0, MEM_RELEASE);
#else
munmap((void*)stack->base, stack->max_limit - stack->base);
Home |
Main Index |
Thread Index |
Old Index