added mmap/munmap check to configure.ac
This commit is contained in:
parent
2c1b4448be
commit
3eac18548c
18
configure
vendored
18
configure
vendored
@ -17528,12 +17528,13 @@ fi
|
|||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
for ac_header in dlfcn.h
|
for ac_header in dlfcn.h sys/mman.h
|
||||||
do :
|
do :
|
||||||
ac_fn_c_check_header_mongrel "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default"
|
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||||
if test "x$ac_cv_header_dlfcn_h" = xyes; then :
|
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
|
||||||
|
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
|
||||||
cat >>confdefs.h <<_ACEOF
|
cat >>confdefs.h <<_ACEOF
|
||||||
#define HAVE_DLFCN_H 1
|
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
|
||||||
_ACEOF
|
_ACEOF
|
||||||
|
|
||||||
fi
|
fi
|
||||||
@ -17603,12 +17604,13 @@ _ACEOF
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
for ac_func in isatty
|
for ac_func in isatty mmap munmap
|
||||||
do :
|
do :
|
||||||
ac_fn_c_check_func "$LINENO" "isatty" "ac_cv_func_isatty"
|
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||||
if test "x$ac_cv_func_isatty" = xyes; then :
|
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
|
||||||
|
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
|
||||||
cat >>confdefs.h <<_ACEOF
|
cat >>confdefs.h <<_ACEOF
|
||||||
#define HAVE_ISATTY 1
|
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
|
||||||
_ACEOF
|
_ACEOF
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
dnl AC_PREREQ([2.67])
|
dnl AC_PREREQ([2.67])
|
||||||
|
|
||||||
dnl Make sure you change the version information
|
|
||||||
dnl in include/hcl/conf_*.h whenever you change the version
|
|
||||||
dnl here. Those files don't depend on autoconf, thus requiring
|
|
||||||
dnl manual change.
|
|
||||||
AC_INIT([hcl],[0.1.0],[Chung, Hyung-Hwan (hyunghwan.chung@gmail.com)],[],[http://code.abiyo.net/@hcl])
|
AC_INIT([hcl],[0.1.0],[Chung, Hyung-Hwan (hyunghwan.chung@gmail.com)],[],[http://code.abiyo.net/@hcl])
|
||||||
|
|
||||||
AC_CONFIG_HEADER([lib/hcl-cfg.h])
|
AC_CONFIG_HEADER([lib/hcl-cfg.h])
|
||||||
@ -121,7 +117,7 @@ dnl check header files.
|
|||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
AC_CHECK_HEADERS([stddef.h wchar.h wctype.h errno.h signal.h fcntl.h dirent.h])
|
AC_CHECK_HEADERS([stddef.h wchar.h wctype.h errno.h signal.h fcntl.h dirent.h])
|
||||||
AC_CHECK_HEADERS([time.h sys/time.h utime.h spawn.h execinfo.h ucontext.h])
|
AC_CHECK_HEADERS([time.h sys/time.h utime.h spawn.h execinfo.h ucontext.h])
|
||||||
AC_CHECK_HEADERS([dlfcn.h])
|
AC_CHECK_HEADERS([dlfcn.h sys/mman.h])
|
||||||
|
|
||||||
dnl check data types
|
dnl check data types
|
||||||
dnl AC_CHECK_TYPE([wchar_t],
|
dnl AC_CHECK_TYPE([wchar_t],
|
||||||
@ -137,7 +133,7 @@ AC_CHECK_FUNCS([backtrace backtrace_symbols])
|
|||||||
AC_CHECK_FUNCS([makecontext swapcontext getcontext setcontext])
|
AC_CHECK_FUNCS([makecontext swapcontext getcontext setcontext])
|
||||||
AC_CHECK_FUNCS([clock_nanosleep nanosleep usleep])
|
AC_CHECK_FUNCS([clock_nanosleep nanosleep usleep])
|
||||||
AC_CHECK_FUNCS([snprintf _vsnprintf _vsnwprintf])
|
AC_CHECK_FUNCS([snprintf _vsnprintf _vsnwprintf])
|
||||||
AC_CHECK_FUNCS([isatty])
|
AC_CHECK_FUNCS([isatty mmap munmap])
|
||||||
|
|
||||||
save_LIBS="$LIBS"
|
save_LIBS="$LIBS"
|
||||||
AC_SEARCH_LIBS([dlopen], [dl dld], [DL_LIBS="$ac_cv_search_dlopen"])
|
AC_SEARCH_LIBS([dlopen], [dl dld], [DL_LIBS="$ac_cv_search_dlopen"])
|
||||||
|
@ -93,6 +93,12 @@
|
|||||||
/* Define to 1 if you have the <memory.h> header file. */
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
#undef HAVE_MEMORY_H
|
#undef HAVE_MEMORY_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `mmap' function. */
|
||||||
|
#undef HAVE_MMAP
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `munmap' function. */
|
||||||
|
#undef HAVE_MUNMAP
|
||||||
|
|
||||||
/* Define to 1 if you have the `nanosleep' function. */
|
/* Define to 1 if you have the `nanosleep' function. */
|
||||||
#undef HAVE_NANOSLEEP
|
#undef HAVE_NANOSLEEP
|
||||||
|
|
||||||
@ -156,6 +162,9 @@
|
|||||||
/* Define to 1 if you have the `swapcontext' function. */
|
/* Define to 1 if you have the `swapcontext' function. */
|
||||||
#undef HAVE_SWAPCONTEXT
|
#undef HAVE_SWAPCONTEXT
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/mman.h> header file. */
|
||||||
|
#undef HAVE_SYS_MMAN_H
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
#undef HAVE_SYS_STAT_H
|
#undef HAVE_SYS_STAT_H
|
||||||
|
|
||||||
|
16
lib/hcl.c
16
lib/hcl.c
@ -128,13 +128,6 @@ int hcl_init (hcl_t* hcl, hcl_mmgr_t* mmgr, hcl_oow_t heapsz, const hcl_vmprim_t
|
|||||||
hcl->log.ptr = (hcl_ooch_t*)hcl_allocmem(hcl, (hcl->log.capa + 1) * HCL_SIZEOF(*hcl->log.ptr));
|
hcl->log.ptr = (hcl_ooch_t*)hcl_allocmem(hcl, (hcl->log.capa + 1) * HCL_SIZEOF(*hcl->log.ptr));
|
||||||
if (!hcl->log.ptr) goto oops;
|
if (!hcl->log.ptr) goto oops;
|
||||||
|
|
||||||
/*hcl->permheap = hcl_makeheap (hcl, what is the best size???);
|
|
||||||
if (!hcl->curheap) goto oops; */
|
|
||||||
hcl->curheap = hcl_makeheap(hcl, heapsz);
|
|
||||||
if (!hcl->curheap) goto oops;
|
|
||||||
hcl->newheap = hcl_makeheap(hcl, heapsz);
|
|
||||||
if (!hcl->newheap) goto oops;
|
|
||||||
|
|
||||||
if (hcl_rbt_init(&hcl->modtab, hcl, HCL_SIZEOF(hcl_ooch_t), 1) <= -1) goto oops;
|
if (hcl_rbt_init(&hcl->modtab, hcl, HCL_SIZEOF(hcl_ooch_t), 1) <= -1) goto oops;
|
||||||
modtab_inited = 1;
|
modtab_inited = 1;
|
||||||
hcl_rbt_setstyle(&hcl->modtab, hcl_getrbtstyle(HCL_RBT_STYLE_INLINE_COPIERS));
|
hcl_rbt_setstyle(&hcl->modtab, hcl_getrbtstyle(HCL_RBT_STYLE_INLINE_COPIERS));
|
||||||
@ -149,13 +142,20 @@ int hcl_init (hcl_t* hcl, hcl_mmgr_t* mmgr, hcl_oow_t heapsz, const hcl_vmprim_t
|
|||||||
hcl->proc_map_free_first = -1;
|
hcl->proc_map_free_first = -1;
|
||||||
hcl->proc_map_free_last = -1;
|
hcl->proc_map_free_last = -1;
|
||||||
|
|
||||||
|
/*hcl->permheap = hcl_makeheap (hcl, what is the best size???);
|
||||||
|
if (!hcl->curheap) goto oops; */
|
||||||
|
hcl->curheap = hcl_makeheap(hcl, heapsz);
|
||||||
|
if (!hcl->curheap) goto oops;
|
||||||
|
hcl->newheap = hcl_makeheap(hcl, heapsz);
|
||||||
|
if (!hcl->newheap) goto oops;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
oops:
|
oops:
|
||||||
if (modtab_inited) hcl_rbt_fini (&hcl->modtab);
|
|
||||||
if (hcl->newheap) hcl_killheap (hcl, hcl->newheap);
|
if (hcl->newheap) hcl_killheap (hcl, hcl->newheap);
|
||||||
if (hcl->curheap) hcl_killheap (hcl, hcl->curheap);
|
if (hcl->curheap) hcl_killheap (hcl, hcl->curheap);
|
||||||
if (hcl->permheap) hcl_killheap (hcl, hcl->permheap);
|
if (hcl->permheap) hcl_killheap (hcl, hcl->permheap);
|
||||||
|
if (modtab_inited) hcl_rbt_fini (&hcl->modtab);
|
||||||
if (hcl->log.ptr) hcl_freemem (hcl, hcl->log.ptr);
|
if (hcl->log.ptr) hcl_freemem (hcl, hcl->log.ptr);
|
||||||
hcl->log.capa = 0;
|
hcl->log.capa = 0;
|
||||||
return -1;
|
return -1;
|
||||||
|
48
lib/main.c
48
lib/main.c
@ -83,12 +83,15 @@
|
|||||||
# if defined(HAVE_SIGNAL_H)
|
# if defined(HAVE_SIGNAL_H)
|
||||||
# include <signal.h>
|
# include <signal.h>
|
||||||
# endif
|
# endif
|
||||||
|
# if defined(HAVE_SYS_MMAN_H)
|
||||||
|
# include <sys/mman.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
# include <errno.h>
|
# include <errno.h>
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
|
|
||||||
# include <sys/mman.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(HCL_DEFAULT_PFMODPREFIX)
|
#if !defined(HCL_DEFAULT_PFMODPREFIX)
|
||||||
@ -447,47 +450,62 @@ static hcl_ooi_t print_handler (hcl_t* hcl, hcl_iocmd_t cmd, void* arg)
|
|||||||
|
|
||||||
static void* alloc_heap (hcl_t* hcl, hcl_oow_t size)
|
static void* alloc_heap (hcl_t* hcl, hcl_oow_t size)
|
||||||
{
|
{
|
||||||
/* It's called when HCL creates a GC heap.
|
#if defined(HAVE_MMAP) && defined(HAVE_MUNMAP)
|
||||||
|
/* It's called via hcl_makeheap() when HCL creates a GC heap.
|
||||||
* The heap is large in size. I can use a different memory allocation
|
* The heap is large in size. I can use a different memory allocation
|
||||||
* function instead of an ordinary malloc */
|
* function instead of an ordinary malloc.
|
||||||
|
* upon failure, it doesn't require to set error information as hcl_makeheap()
|
||||||
|
* set the error number to HCL_EOOMEM. */
|
||||||
|
|
||||||
|
#if !defined(MAP_HUGETLB) && (defined(__amd64__) || defined(__x86_64__))
|
||||||
|
# define MAP_HUGETLB 0x40000
|
||||||
|
#endif
|
||||||
|
|
||||||
hcl_oow_t* ptr;
|
hcl_oow_t* ptr;
|
||||||
int flags;
|
int flags;
|
||||||
hcl_oow_t actual_size;
|
hcl_oow_t actual_size;
|
||||||
|
|
||||||
flags = MAP_PRIVATE | MAP_ANONYMOUS;
|
flags = MAP_PRIVATE | MAP_ANONYMOUS;
|
||||||
#if defined(MAP_HUGETLB)
|
|
||||||
flags |= MAP_HUGETLB;
|
|
||||||
#endif
|
|
||||||
#if defined(MAP_UNINITIALIZED)
|
|
||||||
flags |= MAP_UNINITIALIZED;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#if defined(MAP_HUGETLB)
|
||||||
|
flags |= MAP_HUGETLB;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MAP_UNINITIALIZED)
|
||||||
|
flags |= MAP_UNINITIALIZED;
|
||||||
|
#endif
|
||||||
|
|
||||||
actual_size = HCL_SIZEOF(hcl_oow_t) + size;
|
actual_size = HCL_SIZEOF(hcl_oow_t) + size;
|
||||||
actual_size = HCL_ALIGN_POW2(actual_size, 2 * 1024 * 1024);
|
actual_size = HCL_ALIGN_POW2(actual_size, 2 * 1024 * 1024);
|
||||||
ptr = (hcl_oow_t*)mmap(NULL, actual_size, PROT_READ | PROT_WRITE, flags, -1, 0);
|
ptr = (hcl_oow_t*)mmap(NULL, actual_size, PROT_READ | PROT_WRITE, flags, -1, 0);
|
||||||
if (ptr == MAP_FAILED)
|
if (ptr == MAP_FAILED)
|
||||||
{
|
{
|
||||||
#if defined(MAP_HUGETLB)
|
#if defined(MAP_HUGETLB)
|
||||||
flags &= ~MAP_HUGETLB;
|
flags &= ~MAP_HUGETLB;
|
||||||
ptr = (hcl_oow_t*)mmap(NULL, actual_size, PROT_READ | PROT_WRITE, flags, -1, 0);
|
ptr = (hcl_oow_t*)mmap(NULL, actual_size, PROT_READ | PROT_WRITE, flags, -1, 0);
|
||||||
if (ptr == MAP_FAILED) return HCL_NULL;
|
if (ptr == MAP_FAILED) return HCL_NULL;
|
||||||
#else
|
#else
|
||||||
return HCL_NULL;
|
return HCL_NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
*ptr = actual_size;
|
*ptr = actual_size;
|
||||||
|
|
||||||
return (void*)(ptr + 1);
|
return (void*)(ptr + 1);
|
||||||
/*return HCL_MMGR_ALLOC(hcl->mmgr, size);*/
|
|
||||||
|
#else
|
||||||
|
return HCL_MMGR_ALLOC(hcl->mmgr, size);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_heap (hcl_t* hcl, void* ptr)
|
static void free_heap (hcl_t* hcl, void* ptr)
|
||||||
{
|
{
|
||||||
|
#if defined(HAVE_MMAP) && defined(HAVE_MUNMAP)
|
||||||
hcl_oow_t* actual_ptr;
|
hcl_oow_t* actual_ptr;
|
||||||
actual_ptr = (hcl_oow_t*)ptr - 1;
|
actual_ptr = (hcl_oow_t*)ptr - 1;
|
||||||
munmap (actual_ptr, *actual_ptr);
|
munmap (actual_ptr, *actual_ptr);
|
||||||
/*return HCL_MMGR_FREE(hcl->mmgr, ptr);*/
|
#else
|
||||||
|
return HCL_MMGR_FREE(hcl->mmgr, ptr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int write_all (int fd, const char* ptr, hcl_oow_t len)
|
static int write_all (int fd, const char* ptr, hcl_oow_t len)
|
||||||
|
Loading…
Reference in New Issue
Block a user