Module Name: src Committed By: alnsn Date: Sat Oct 6 19:23:01 UTC 2012
Modified Files: src/sys/external/bsd/sljit/dist/sljit_src: sljitConfig.h sljitConfigInternal.h sljitUtils.c Log Message: Adapt code to compile with -D_KERNEL. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 \ src/sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h \ src/sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h \ src/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h diff -u src/sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h:1.1.1.1 src/sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h:1.2 --- src/sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h:1.1.1.1 Sat Oct 6 18:24:25 2012 +++ src/sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h Sat Oct 6 19:23:01 2012 @@ -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 */ /* --------------------------------------------------------------------- */ Index: src/sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h diff -u src/sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h:1.1.1.1 src/sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h:1.2 --- src/sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h:1.1.1.1 Sat Oct 6 18:24:25 2012 +++ src/sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h Sat Oct 6 19:23:01 2012 @@ -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 */ Index: src/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c diff -u src/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c:1.1.1.1 src/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c:1.2 --- src/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c:1.1.1.1 Sat Oct 6 18:24:23 2012 +++ src/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c Sat Oct 6 19:23:01 2012 @@ -106,10 +106,10 @@ SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL #else /* _WIN32 */ -#include <pthread.h> - #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR) +#include <pthread.h> + static pthread_mutex_t allocator_mutex = PTHREAD_MUTEX_INITIALIZER; static SLJIT_INLINE void allocator_grab_lock(void) @@ -126,6 +126,8 @@ static SLJIT_INLINE void allocator_relea #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 @@ SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL #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 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_st #ifdef _WIN32 SYSTEM_INFO si; #endif +#ifdef _KERNEL + vaddr_t v; +#endif if (limit > max_limit || limit < 1) return NULL; @@ -179,7 +187,11 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_st } #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 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_st 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 struct sljit_st 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);