fi
+for ac_header in windows.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default"
+if test "x$ac_cv_header_windows_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_WINDOWS_H 1
+_ACEOF
+
+fi
+
+done
+
+
# Check for the fcntl function.
if test -n "${with_target_subdir}"; then
case "${host}" in
#include <mach-o/dyld.h>
#endif
+#ifdef HAVE_WINDOWS_H
+#ifndef WIN32_MEAN_AND_LEAN
+#define WIN32_MEAN_AND_LEAN
+#endif
+
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+
+#include <windows.h>
+#endif
+
#include "backtrace.h"
#include "internal.h"
#endif /* !HAVE_DECL__PGMPTR */
+#ifdef HAVE_WINDOWS_H
+
+#define FILENAME_BUF_SIZE (MAX_PATH)
+
+static char *
+windows_get_executable_path (char *buf, backtrace_error_callback error_callback,
+ void *data)
+{
+ size_t got;
+ int error;
+
+ got = GetModuleFileNameA (NULL, buf, FILENAME_BUF_SIZE - 1);
+ error = GetLastError ();
+ if (got == 0
+ || (got == FILENAME_BUF_SIZE - 1 && error == ERROR_INSUFFICIENT_BUFFER))
+ {
+ error_callback (data,
+ "could not get the filename of the current executable",
+ error);
+ return NULL;
+ }
+ return buf;
+}
+
+#else /* !defined (HAVE_WINDOWS_H) */
+
+#define windows_get_executable_path(buf, error_callback, data) NULL
+#define FILENAME_BUF_SIZE 64
+
+#endif /* !defined (HAVE_WINDOWS_H) */
+
/* Initialize the fileline information from the executable. Returns 1
on success, 0 on failure. */
int called_error_callback;
int descriptor;
const char *filename;
- char buf[64];
+ char buf[FILENAME_BUF_SIZE];
if (!state->threaded)
failed = state->fileline_initialization_failed;
descriptor = -1;
called_error_callback = 0;
- for (pass = 0; pass < 9; ++pass)
+ for (pass = 0; pass < 10; ++pass)
{
int does_not_exist;
case 8:
filename = macho_get_executable_path (state, error_callback, data);
break;
+ case 9:
+ filename = windows_get_executable_path (buf, error_callback, data);
+ break;
default:
abort ();
}