Diff for /embedaddon/pcre/sljit/sljitUtils.c between versions 1.1.1.3 and 1.1.1.4

version 1.1.1.3, 2012/10/09 09:19:18 version 1.1.1.4, 2013/07/22 08:25:57
Line 106  SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_release Line 106  SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_release
   
 #else /* _WIN32 */  #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;  static pthread_mutex_t allocator_mutex = PTHREAD_MUTEX_INITIALIZER;
   
 static SLJIT_INLINE void allocator_grab_lock(void)  static SLJIT_INLINE void allocator_grab_lock(void)
Line 126  static SLJIT_INLINE void allocator_release_lock(void) Line 126  static SLJIT_INLINE void allocator_release_lock(void)
   
 #if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)  #if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
   
   #include <pthread.h>
   
 static pthread_mutex_t global_mutex = PTHREAD_MUTEX_INITIALIZER;  static pthread_mutex_t global_mutex = PTHREAD_MUTEX_INITIALIZER;
   
 SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_grab_lock(void)  SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_grab_lock(void)
Line 146  SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_release Line 148  SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_release
 /*  Stack                                                                   */  /*  Stack                                                                   */
 /* ------------------------------------------------------------------------ */  /* ------------------------------------------------------------------------ */
   
#if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)#if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK) || (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
   
 #ifdef _WIN32  #ifdef _WIN32
 #include "windows.h"  #include "windows.h"
 #else  #else
   /* Provides mmap function. */
 #include <sys/mman.h>  #include <sys/mman.h>
   /* For detecting the page size. */
 #include <unistd.h>  #include <unistd.h>
   
   #ifndef MAP_ANON
   
   #include <fcntl.h>
   
   /* Some old systems does not have MAP_ANON. */
   static sljit_si dev_zero = -1;
   
   #if (defined SLJIT_SINGLE_THREADED && SLJIT_SINGLE_THREADED)
   
   static SLJIT_INLINE sljit_si open_dev_zero(void)
   {
           dev_zero = open("/dev/zero", O_RDWR);
           return dev_zero < 0;
   }
   
   #else /* SLJIT_SINGLE_THREADED */
   
   #include <pthread.h>
   
   static pthread_mutex_t dev_zero_mutex = PTHREAD_MUTEX_INITIALIZER;
   
   static SLJIT_INLINE sljit_si open_dev_zero(void)
   {
           pthread_mutex_lock(&dev_zero_mutex);
           dev_zero = open("/dev/zero", O_RDWR);
           pthread_mutex_unlock(&dev_zero_mutex);
           return dev_zero < 0;
   }
   
   #endif /* SLJIT_SINGLE_THREADED */
   
 #endif  #endif
   
   #endif
   
   #endif /* SLJIT_UTIL_STACK || SLJIT_EXECUTABLE_ALLOCATOR */
   
   #if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)
   
 /* Planning to make it even more clever in the future. */  /* Planning to make it even more clever in the future. */
static sljit_w sljit_page_align = 0;static sljit_sw sljit_page_align = 0;
   
 SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_uw limit, sljit_uw max_limit)  SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_uw limit, sljit_uw max_limit)
 {  {
Line 195  SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CAL Line 237  SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CAL
                 return NULL;                  return NULL;
   
 #ifdef _WIN32  #ifdef _WIN32
        base.ptr = VirtualAlloc(0, max_limit, MEM_RESERVE, PAGE_READWRITE);        base.ptr = VirtualAlloc(NULL, max_limit, MEM_RESERVE, PAGE_READWRITE);
         if (!base.ptr) {          if (!base.ptr) {
                 SLJIT_FREE(stack);                  SLJIT_FREE(stack);
                 return NULL;                  return NULL;
Line 208  SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CAL Line 250  SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CAL
                 return NULL;                  return NULL;
         }          }
 #else  #else
        base.ptr = mmap(0, max_limit, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);#ifdef MAP_ANON
         base.ptr = mmap(NULL, max_limit, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
 #else
         if (dev_zero < 0) {
                 if (open_dev_zero()) {
                         SLJIT_FREE(stack);
                         return NULL;
                 }
         }
         base.ptr = mmap(NULL, max_limit, PROT_READ | PROT_WRITE, MAP_PRIVATE, dev_zero, 0);
 #endif
         if (base.ptr == MAP_FAILED) {          if (base.ptr == MAP_FAILED) {
                 SLJIT_FREE(stack);                  SLJIT_FREE(stack);
                 return NULL;                  return NULL;
Line 233  SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_st Line 285  SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_st
         SLJIT_FREE(stack);          SLJIT_FREE(stack);
 }  }
   
SLJIT_API_FUNC_ATTRIBUTE sljit_w SLJIT_CALL sljit_stack_resize(struct sljit_stack* stack, sljit_uw new_limit)SLJIT_API_FUNC_ATTRIBUTE sljit_sw SLJIT_CALL sljit_stack_resize(struct sljit_stack* stack, sljit_uw new_limit)
 {  {
         sljit_uw aligned_old_limit;          sljit_uw aligned_old_limit;
         sljit_uw aligned_new_limit;          sljit_uw aligned_new_limit;
Line 262  SLJIT_API_FUNC_ATTRIBUTE sljit_w SLJIT_CALL sljit_stac Line 314  SLJIT_API_FUNC_ATTRIBUTE sljit_w SLJIT_CALL sljit_stac
         }          }
         aligned_new_limit = (new_limit + sljit_page_align) & ~sljit_page_align;          aligned_new_limit = (new_limit + sljit_page_align) & ~sljit_page_align;
         aligned_old_limit = (stack->limit + sljit_page_align) & ~sljit_page_align;          aligned_old_limit = (stack->limit + sljit_page_align) & ~sljit_page_align;
           /* If madvise is available, we release the unnecessary space. */
   #if defined(MADV_DONTNEED)
         if (aligned_new_limit < aligned_old_limit)          if (aligned_new_limit < aligned_old_limit)
                   madvise((void*)aligned_new_limit, aligned_old_limit - aligned_new_limit, MADV_DONTNEED);
   #elif defined(POSIX_MADV_DONTNEED)
           if (aligned_new_limit < aligned_old_limit)
                 posix_madvise((void*)aligned_new_limit, aligned_old_limit - aligned_new_limit, POSIX_MADV_DONTNEED);                  posix_madvise((void*)aligned_new_limit, aligned_old_limit - aligned_new_limit, POSIX_MADV_DONTNEED);
   #endif
         stack->limit = new_limit;          stack->limit = new_limit;
         return 0;          return 0;
 #endif  #endif

Removed from v.1.1.1.3  
changed lines
  Added in v.1.1.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>