Commit 32735966 authored by 's avatar

Handle ucontext.h properly in Snow leopard.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@75 eb4d4688-79bd-11dd-afb4-1d65580434c0
parent b71aa943
This diff is collapsed.
......@@ -6,8 +6,13 @@
# OpenBSD doesn't have ucontext.h, but we can get PC from ucontext_t
# by using signal.h.
# The first argument of AC_PC_FROM_UCONTEXT will be invoked when we
# cannot find a way to obtain PC from ucontext.
AC_DEFUN([AC_PC_FROM_UCONTEXT],
[AC_MSG_CHECKING([how to access the program counter from a struct ucontext])
[AC_CHECK_HEADERS(ucontext.h)
AC_CHECK_HEADERS(sys/ucontext.h) # ucontext on OS X 10.6 (at least)
AC_MSG_CHECKING([how to access the program counter from a struct ucontext])
pc_fields=" uc_mcontext.gregs[[REG_PC]]" # Solaris x86 (32 + 64 bit)
pc_fields="$pc_fields uc_mcontext.gregs[[REG_EIP]]" # Linux (i386)
pc_fields="$pc_fields uc_mcontext.gregs[[REG_RIP]]" # Linux (x86_64)
......@@ -28,6 +33,15 @@ AC_DEFUN([AC_PC_FROM_UCONTEXT],
pc_field_found=false
for pc_field in $pc_fields; do
if ! $pc_field_found; then
if test "x$ac_cv_header_sys_ucontext_h" = xyes; then
AC_TRY_COMPILE([#define _GNU_SOURCE 1
#include <sys/ucontext.h>],
[ucontext_t u; return u.$pc_field == 0;],
AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field,
How to access the PC from a struct ucontext)
AC_MSG_RESULT([$pc_field])
pc_field_found=true)
else
AC_TRY_COMPILE([#define _GNU_SOURCE 1
#include <ucontext.h>],
[ucontext_t u; return u.$pc_field == 0;],
......@@ -36,6 +50,7 @@ AC_DEFUN([AC_PC_FROM_UCONTEXT],
AC_MSG_RESULT([$pc_field])
pc_field_found=true)
fi
fi
done
if ! $pc_field_found; then
pc_fields=" sc_eip" # OpenBSD (i386)
......@@ -52,5 +67,5 @@ AC_DEFUN([AC_PC_FROM_UCONTEXT],
done
fi
if ! $pc_field_found; then
AC_MSG_WARN(Could not find the PC. Will not output failed addresses...)
[$1]
fi])
......@@ -87,6 +87,9 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <sys/ucontext.h> header file. */
#undef HAVE_SYS_UCONTEXT_H
/* Define to 1 if you have the <sys/utsname.h> header file. */
#undef HAVE_SYS_UTSNAME_H
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment