OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/gnu-old/gdb-7.1/sim/m32c
    from Rev 834 to Rev 842
    Reverse comparison

Rev 834 → Rev 842

/sample.ld
0,0 → 1,41
/* sample2.ld --- linker script for sample2.x
 
Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
Contributed by Red Hat, Inc.
 
This file is part of the GNU simulators.
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
 
/* See the 'sample2.x' target in Makefile.in. */
 
ENTRY(_start)
 
MEMORY {
RAM1 (w) : ORIGIN = 0xc800, LENGTH = 0x0200
RAM2 (w) : ORIGIN = 0xca56, LENGTH = 0x1000
ROM (w) : ORIGIN = 0x30000, LENGTH = 0x1000
}
 
SECTIONS {
.data : {
*(.data*)
} > RAM1
.text : {
*(.text*)
} > RAM2
.fardata : {
*(.fardata*)
} > ROM
}
/trace.c
0,0 → 1,313
/* trace.c --- tracing output for the M32C simulator.
 
Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
Contributed by Red Hat, Inc.
 
This file is part of the GNU simulators.
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
 
 
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
 
#include "bfd.h"
#include "dis-asm.h"
#include "m32c-desc.h"
 
#include "cpu.h"
#include "mem.h"
#include "load.h"
 
static int
sim_dis_read (bfd_vma memaddr, bfd_byte * ptr, unsigned int length,
struct disassemble_info *info)
{
mem_get_blk (memaddr, ptr, length);
return 0;
}
 
/* Filter out (in place) symbols that are useless for disassembly.
COUNT is the number of elements in SYMBOLS.
Return the number of useful symbols. */
 
static long
remove_useless_symbols (asymbol ** symbols, long count)
{
register asymbol **in_ptr = symbols, **out_ptr = symbols;
 
while (--count >= 0)
{
asymbol *sym = *in_ptr++;
 
if (strstr (sym->name, "gcc2_compiled"))
continue;
if (sym->name == NULL || sym->name[0] == '\0')
continue;
if (sym->flags & (BSF_DEBUGGING))
continue;
if (bfd_is_und_section (sym->section)
|| bfd_is_com_section (sym->section))
continue;
 
*out_ptr++ = sym;
}
return out_ptr - symbols;
}
 
static int
compare_symbols (const PTR ap, const PTR bp)
{
const asymbol *a = *(const asymbol **) ap;
const asymbol *b = *(const asymbol **) bp;
 
if (bfd_asymbol_value (a) > bfd_asymbol_value (b))
return 1;
else if (bfd_asymbol_value (a) < bfd_asymbol_value (b))
return -1;
return 0;
}
 
static char opbuf[1000];
 
static int
op_printf (char *buf, char *fmt, ...)
{
int ret;
va_list ap;
 
va_start (ap, fmt);
ret = vsprintf (opbuf + strlen (opbuf), fmt, ap);
va_end (ap);
return ret;
}
 
static bfd *current_bfd;
 
void
sim_disasm_init (bfd * prog)
{
current_bfd = prog;
}
 
typedef struct Files
{
struct Files *next;
char *filename;
int nlines;
char **lines;
char *data;
} Files;
Files *files = 0;
 
static char *
load_file_and_line (const char *filename, int lineno)
{
Files *f;
for (f = files; f; f = f->next)
if (strcmp (f->filename, filename) == 0)
break;
if (!f)
{
int i;
struct stat s;
const char *found_filename, *slash;
 
found_filename = filename;
while (1)
{
if (stat (found_filename, &s) == 0)
break;
slash = strchr (found_filename, '/');
if (!slash)
return "";
found_filename = slash + 1;
}
 
f = (Files *) malloc (sizeof (Files));
f->next = files;
files = f;
f->filename = strdup (filename);
f->data = (char *) malloc (s.st_size + 2);
FILE *file = fopen (found_filename, "rb");
fread (f->data, 1, s.st_size, file);
f->data[s.st_size] = 0;
fclose (file);
 
f->nlines = 1;
for (i = 0; i < s.st_size; i++)
if (f->data[i] == '\n')
f->nlines++;
f->lines = (char **) malloc (f->nlines * sizeof (char *));
f->lines[0] = f->data;
f->nlines = 1;
for (i = 0; i < s.st_size; i++)
if (f->data[i] == '\n')
{
f->lines[f->nlines] = f->data + i + 1;
while (*f->lines[f->nlines] == ' '
|| *f->lines[f->nlines] == '\t')
f->lines[f->nlines]++;
f->nlines++;
f->data[i] = 0;
}
}
if (lineno < 1 || lineno > f->nlines)
return "";
return f->lines[lineno - 1];
}
 
void
sim_disasm_one ()
{
static int initted = 0;
static asymbol **symtab = 0;
static int symcount = 0;
static int last_sym = -1;
static struct disassemble_info info;
int storage, sym, bestaddr;
int min, max, i;
static asection *code_section = 0;
static bfd_vma code_base = 0;
asection *s;
int save_trace = trace;
 
static const char *prev_filename = "";
static int prev_lineno = 0;
const char *filename;
const char *functionname;
unsigned int lineno;
 
int mypc = get_reg (pc);
 
if (current_bfd == 0)
return;
 
trace = 0;
 
if (!initted)
{
initted = 1;
memset (&info, 0, sizeof (info));
INIT_DISASSEMBLE_INFO (info, stdout, op_printf);
info.read_memory_func = sim_dis_read;
info.arch = bfd_get_arch (current_bfd);
info.mach = bfd_get_mach (current_bfd);
if (info.mach == 0)
{
info.arch = bfd_arch_m32c;
info.mach = default_machine;
}
disassemble_init_for_target (&info);
 
storage = bfd_get_symtab_upper_bound (current_bfd);
if (storage > 0)
{
symtab = (asymbol **) malloc (storage);
symcount = bfd_canonicalize_symtab (current_bfd, symtab);
symcount = remove_useless_symbols (symtab, symcount);
qsort (symtab, symcount, sizeof (asymbol *), compare_symbols);
}
for (s = current_bfd->sections; s; s = s->next)
{
if (s->flags & SEC_CODE || code_section == 0)
{
code_section = s;
code_base = bfd_section_lma (current_bfd, s);
break;
}
}
}
 
filename = functionname = 0;
lineno = 0;
if (bfd_find_nearest_line
(current_bfd, code_section, symtab, mypc - code_base, &filename,
&functionname, &lineno))
{
if (filename && functionname && lineno)
{
if (lineno != prev_lineno || strcmp (prev_filename, filename))
{
char *the_line = load_file_and_line (filename, lineno);
const char *slash = strrchr (filename, '/');
if (!slash)
slash = filename;
else
slash++;
printf
("========================================"
"=====================================\n");
printf ("\033[37;41m %s:%d: \033[33;40m %s\033[K\033[0m\n",
slash, lineno, the_line);
}
prev_lineno = lineno;
prev_filename = filename;
}
}
 
{
min = -1;
max = symcount;
while (min < max - 1)
{
bfd_vma sa;
sym = (min + max) / 2;
sa = bfd_asymbol_value (symtab[sym]);
/*printf("checking %4d %08x %s\n",
sym, sa, bfd_asymbol_name (symtab[sym])); */
if (sa > mypc)
max = sym;
else if (sa < mypc)
min = sym;
else
{
min = sym;
break;
}
}
if (min != -1 && min != last_sym)
{
bestaddr = bfd_asymbol_value (symtab[min]);
printf ("\033[43;30m%s", bfd_asymbol_name (symtab[min]));
if (bestaddr != mypc)
printf ("+%d", mypc - bestaddr);
printf (":\t\t\t\033[0m\n");
last_sym = min;
#if 0
if (trace == 1)
if (strcmp (bfd_asymbol_name (symtab[min]), "abort") == 0
|| strcmp (bfd_asymbol_name (symtab[min]), "exit") == 0)
trace = 0;
#endif
}
}
 
opbuf[0] = 0;
printf ("\033[33m%06x: ", mypc);
max = print_insn_m32c (mypc, &info);
for (i = 0; i < max; i++)
printf ("%02x", mem_get_qi (mypc + i));
for (; i < 6; i++)
printf (" ");
printf ("%-16s ", opbuf);
 
printf ("\033[0m\n");
trace = save_trace;
}
trace.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: misc.h =================================================================== --- misc.h (nonexistent) +++ misc.h (revision 842) @@ -0,0 +1,25 @@ +/* misc.h --- interface to miscellaneous utility functions for M32C simulator. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +int bcd2int (int bcd, int w); +int int2bcd (int val, int w); + +char *comma (unsigned int u);
misc.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: configure =================================================================== --- configure (nonexistent) +++ configure (revision 842) @@ -0,0 +1,5878 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.64. +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software +# Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error ERROR [LINENO LOG_FD] +# --------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with status $?, using 1 if that was 0. +as_fn_error () +{ + as_status=$?; test $as_status -eq 0 && as_status=1 + if test "$3"; then + as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + fi + $as_echo "$as_me: error: $1" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= +PACKAGE_URL= + +ac_unique_file="Makefile.in" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='LTLIBOBJS +LIBOBJS +cgen_breaks +REPORT_BUGS_TEXI +REPORT_BUGS_TO +PKGVERSION +sim_profile +sim_trace +sim_stdio +sim_debug +sim_cflags +sim_bswap +MAINT +EGREP +GREP +CPP +CATOBJEXT +GENCAT +INSTOBJEXT +DATADIRNAME +CATALOGS +POSUB +GMSGFMT +XGETTEXT +INCINTL +LIBINTL_DEP +LIBINTL +USE_NLS +RANLIB +AR +HDEFINES +CC_FOR_BUILD +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +target_os +target_vendor +target_cpu +target +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +WERROR_CFLAGS +WARN_CFLAGS +sim_xor_endian +sim_stdcall +sim_smp +sim_reserved_bits +sim_regparm +sim_packages +sim_inline +sim_hw +sim_hw_objs +sim_hw_cflags +sim_default_model +sim_scache +sim_float +sim_hostendian +sim_endian +sim_bitsize +sim_assert +sim_alignment +sim_environment +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +with_zlib +enable_maintainer_mode +enable_sim_bswap +enable_sim_cflags +enable_sim_debug +enable_sim_stdio +enable_sim_trace +enable_sim_profile +with_pkgversion +with_bugurl +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information." + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] + --target=TARGET configure for building compilers for TARGET [HOST] +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-maintainer-mode Enable developer functionality. + --enable-sim-bswap Use Host specific BSWAP instruction. + --enable-sim-cflags=opts Extra CFLAGS for use in building simulator + --enable-sim-debug=opts Enable debugging flags + --enable-sim-stdio Specify whether to use stdio for console input/output. + --enable-sim-trace=opts Enable tracing flags + --enable-sim-profile=opts Enable profiling flags + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-zlib include zlib support (auto/yes/no) default=auto + --with-pkgversion=PKG Use PKG in the version string in place of "GDB" + --with-bugurl=URL Direct users to URL to report a bug + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to the package provider. +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +configure +generated by GNU Autoconf 2.64 + +Copyright (C) 2009 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + return $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + return $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + return $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_header_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + return $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_func +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.64. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + ac_site_file1=$CONFIG_SITE +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +ac_config_headers="$ac_config_headers config.h:config.in" + + +# This file contains common code used by all simulators. +# +# SIM_AC_COMMON invokes AC macros used by all simulators and by the common +# directory. It is intended to be invoked before any target specific stuff. +# SIM_AC_OUTPUT is a cover function to AC_OUTPUT to generate the Makefile. +# It is intended to be invoked last. +# +# The simulator's configure.in should look like: +# +# dnl Process this file with autoconf to produce a configure script. +# sinclude(../common/aclocal.m4) +# AC_PREREQ(2.5)dnl +# AC_INIT(Makefile.in) +# +# SIM_AC_COMMON +# +# ... target specific stuff ... +# +# SIM_AC_OUTPUT + +# Include global overrides and fixes for Autoconf. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +sim_inline="-DDEFAULT_INLINE=0" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# intl sister-directory configuration rules. +# + +# The idea behind this macro is that there's no need to repeat all the +# autoconf probes done by the intl directory - it's already done them +# for us. In fact, there's no need even to look at the cache for the +# answers. All we need to do is nab a few pieces of information. +# The intl directory is set up to make this easy, by generating a +# small file which can be sourced as a shell script; then we produce +# the necessary substitutions and definitions for this directory. + + + +# Autoconf M4 include file defining utility macros for complex Canadian +# cross builds. + + + + + + + + + +#### +# _NCN_TOOL_PREFIXES: Some stuff that oughtta be done in AC_CANONICAL_SYSTEM +# or AC_INIT. +# These demand that AC_CANONICAL_SYSTEM be called beforehand. + +#### +# NCN_STRICT_CHECK_TOOLS(variable, progs-to-check-for,[value-if-not-found],[path]) +# Like plain AC_CHECK_TOOLS, but require prefix if build!=host. + + +#### +# NCN_STRICT_CHECK_TARGET_TOOLS(variable, progs-to-check-for,[value-if-not-found],[path]) +# Like CVS Autoconf AC_CHECK_TARGET_TOOLS, but require prefix if build!=target. + + + +# Backported from Autoconf 2.5x; can go away when and if +# we switch. Put the OS path separator in $PATH_SEPARATOR. + + + + +# ACX_HAVE_GCC_FOR_TARGET +# Check if the variable GCC_FOR_TARGET really points to a GCC binary. + + +# ACX_CHECK_INSTALLED_TARGET_TOOL(VAR, PROG) +# Searching for installed target binutils. We need to take extra care, +# else we may find the wrong assembler, linker, etc., and lose. +# +# First try --with-build-time-tools, if specified. +# +# For build != host, we ask the installed GCC for the name of the tool it +# uses, and accept it if it is an absolute path. This is because the +# only good choice for a compiler is the same GCC version that is being +# installed (or we couldn't make target libraries), and we assume that +# on the host system we'll have not only the same GCC version, but also +# the same binutils version. +# +# For build == host, search the same directories that the installed +# compiler will search. We used to do this for the assembler, linker, +# and nm only; for simplicity of configuration, however, we extend this +# criterion to tools (such as ar and ranlib) that are never invoked by +# the compiler, to avoid mismatches. +# +# Also note we have to check MD_EXEC_PREFIX before checking the user's path +# if build == target. This makes the most sense only when bootstrapping, +# but we also do so when build != host. In this case, we hope that the +# build and host systems will have similar contents of MD_EXEC_PREFIX. +# +# If we do not find a suitable binary, then try the user's path. + + +### +# AC_PROG_CPP_WERROR +# Used for autoconf 2.5x to force AC_PREPROC_IFELSE to reject code which +# triggers warnings from the preprocessor. Will be in autoconf 2.58. +# For now, using this also overrides header checks to use only the +# preprocessor (matches 2.13 behavior; matching 2.58's behavior is a +# bit harder from here). +# Eventually autoconf will default to checking headers with the compiler +# instead, and we'll have to do this differently. + +# AC_PROG_CPP_WERROR + +# Test for GNAT. +# We require the gnatbind program, and a compiler driver that +# understands Ada. We use the user's CC setting, already found, +# and possibly add $1 to the command-line parameters. +# +# Sets the shell variable have_gnat to yes or no as appropriate, and +# substitutes GNATBIND and GNATMAKE. + + + + + + + + + + + + + + + + + + + + + + + + + +# Bugs in autoconf 2.59 break the call to SIM_AC_COMMON, hack around +# it by inlining the macro's contents. +# This file contains common code used by all simulators. +# +# common.m4 invokes AC macros used by all simulators and by the common +# directory. It is intended to be included before any target specific +# stuff. SIM_AC_OUTPUT is a cover function to AC_OUTPUT to generate +# the Makefile. It is intended to be invoked last. +# +# The simulator's configure.in should look like: +# +# dnl Process this file with autoconf to produce a configure script. +# AC_PREREQ(2.5)dnl +# AC_INIT(Makefile.in) +# AC_CONFIG_HEADER(config.h:config.in) +# +# sinclude(../common/aclocal.m4) +# sinclude(../common/common.m4) +# +# ... target specific stuff ... + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + for ac_t in install-sh install.sh shtool; do + if test -f "$ac_dir/$ac_t"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/$ac_t -c" + break 2 + fi + done +done +if test -z "$ac_aux_dir"; then + as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if test "${ac_cv_build+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if test "${ac_cv_host+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 +$as_echo_n "checking target system type... " >&6; } +if test "${ac_cv_target+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "x$target_alias" = x; then + ac_cv_target=$ac_cv_host +else + ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || + as_fn_error "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 +$as_echo "$ac_cv_target" >&6; } +case $ac_cv_target in +*-*-*) ;; +*) as_fn_error "invalid value of canonical target" "$LINENO" 5;; +esac +target=$ac_cv_target +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_target +shift +target_cpu=$1 +target_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +target_os=$* +IFS=$ac_save_IFS +case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac + + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. +# By default was `s,x,x', remove it if useless. +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "no acceptable C compiler found in \$PATH +See \`config.log' for more details." "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + rm -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out conftest.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +if test -z "$ac_file"; then : + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ as_fn_set_status 77 +as_fn_error "C compiler cannot create executables +See \`config.log' for more details." "$LINENO" 5; }; } +fi +ac_exeext=$ac_cv_exeext + +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out conftest.out +ac_clean_files=$ac_clean_files_save +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." "$LINENO" 5; } +fi +rm -f conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if test "${ac_cv_objext+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot compute suffix of object files: cannot compile +See \`config.log' for more details." "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + +# Put a plausible default for CC_FOR_BUILD in Makefile. +if test "x$cross_compiling" = "xno"; then + CC_FOR_BUILD='$(CC)' +else + CC_FOR_BUILD=gcc +fi + + + + +AR=${AR-ar} + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_RANLIB+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + + +ALL_LINGUAS= +# If we haven't got the data from the intl directory, +# assume NLS is disabled. +USE_NLS=no +LIBINTL= +LIBINTL_DEP= +INCINTL= +XGETTEXT= +GMSGFMT= +POSUB= + +if test -f ../../intl/config.intl; then + . ../../intl/config.intl +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NLS is requested" >&5 +$as_echo_n "checking whether NLS is requested... " >&6; } +if test x"$USE_NLS" != xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define ENABLE_NLS 1" >>confdefs.h + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for catalogs to be installed" >&5 +$as_echo_n "checking for catalogs to be installed... " >&6; } + # Look for .po and .gmo files in the source directory. + CATALOGS= + XLINGUAS= + for cat in $srcdir/po/*.gmo $srcdir/po/*.po; do + # If there aren't any .gmo files the shell will give us the + # literal string "../path/to/srcdir/po/*.gmo" which has to be + # weeded out. + case "$cat" in *\**) + continue;; + esac + # The quadruple backslash is collapsed to a double backslash + # by the backticks, then collapsed again by the double quotes, + # leaving us with one backslash in the sed expression (right + # before the dot that mustn't act as a wildcard). + cat=`echo $cat | sed -e "s!$srcdir/po/!!" -e "s!\\\\.po!.gmo!"` + lang=`echo $cat | sed -e "s!\\\\.gmo!!"` + # The user is allowed to set LINGUAS to a list of languages to + # install catalogs for. If it's empty that means "all of them." + if test "x$LINGUAS" = x; then + CATALOGS="$CATALOGS $cat" + XLINGUAS="$XLINGUAS $lang" + else + case "$LINGUAS" in *$lang*) + CATALOGS="$CATALOGS $cat" + XLINGUAS="$XLINGUAS $lang" + ;; + esac + fi + done + LINGUAS="$XLINGUAS" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LINGUAS" >&5 +$as_echo "$LINGUAS" >&6; } + + + DATADIRNAME=share + + INSTOBJEXT=.mo + + GENCAT=gencat + + CATOBJEXT=.gmo + +fi + +# Check for common headers. +# FIXME: Seems to me this can cause problems for i386-windows hosts. +# At one point there were hardcoded AC_DEFINE's if ${host} = i386-*-windows*. + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if test "${ac_cv_path_GREP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if test "${ac_cv_header_stdc+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_header in stdlib.h string.h strings.h unistd.h time.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +for ac_header in sys/time.h sys/resource.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +for ac_header in fcntl.h fpu_control.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +for ac_header in dlfcn.h errno.h sys/stat.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +for ac_func in getrusage time sigaction __setfpucw +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +eval as_val=\$$as_ac_var + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +# Check for socket libraries +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for bind in -lsocket" >&5 +$as_echo_n "checking for bind in -lsocket... " >&6; } +if test "${ac_cv_lib_socket_bind+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char bind (); +int +main () +{ +return bind (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_socket_bind=yes +else + ac_cv_lib_socket_bind=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_bind" >&5 +$as_echo "$ac_cv_lib_socket_bind" >&6; } +if test "x$ac_cv_lib_socket_bind" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSOCKET 1 +_ACEOF + + LIBS="-lsocket $LIBS" + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 +$as_echo_n "checking for gethostbyname in -lnsl... " >&6; } +if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnsl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gethostbyname (); +int +main () +{ +return gethostbyname (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_nsl_gethostbyname=yes +else + ac_cv_lib_nsl_gethostbyname=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 +$as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } +if test "x$ac_cv_lib_nsl_gethostbyname" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBNSL 1 +_ACEOF + + LIBS="-lnsl $LIBS" + +fi + + +# BFD conditionally uses zlib, so we must link it in if libbfd does, by +# using the same condition. + + # See if the user specified whether he wants zlib support or not. + +# Check whether --with-zlib was given. +if test "${with_zlib+set}" = set; then : + withval=$with_zlib; +else + with_zlib=auto +fi + + + if test "$with_zlib" != "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5 +$as_echo_n "checking for library containing zlibVersion... " >&6; } +if test "${ac_cv_search_zlibVersion+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char zlibVersion (); +int +main () +{ +return zlibVersion (); + ; + return 0; +} +_ACEOF +for ac_lib in '' z; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_zlibVersion=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_zlibVersion+set}" = set; then : + break +fi +done +if test "${ac_cv_search_zlibVersion+set}" = set; then : + +else + ac_cv_search_zlibVersion=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5 +$as_echo "$ac_cv_search_zlibVersion" >&6; } +ac_res=$ac_cv_search_zlibVersion +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + for ac_header in zlib.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" +if test "x$ac_cv_header_zlib_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_ZLIB_H 1 +_ACEOF + +fi + +done + +fi + + if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then + as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5 + fi + fi + + +. ${srcdir}/../../bfd/configure.host + + + +USE_MAINTAINER_MODE=no +# Check whether --enable-maintainer-mode was given. +if test "${enable_maintainer_mode+set}" = set; then : + enableval=$enable_maintainer_mode; case "${enableval}" in + yes) MAINT="" USE_MAINTAINER_MODE=yes ;; + no) MAINT="#" ;; + *) as_fn_error "\"--enable-maintainer-mode does not take a value\"" "$LINENO" 5; MAINT="#" ;; +esac +if test x"$silent" != x"yes" && test x"$MAINT" = x""; then + echo "Setting maintainer mode" 6>&1 +fi +else + MAINT="#" +fi + + + +# Check whether --enable-sim-bswap was given. +if test "${enable_sim_bswap+set}" = set; then : + enableval=$enable_sim_bswap; case "${enableval}" in + yes) sim_bswap="-DWITH_BSWAP=1 -DUSE_BSWAP=1";; + no) sim_bswap="-DWITH_BSWAP=0";; + *) as_fn_error "\"--enable-sim-bswap does not take a value\"" "$LINENO" 5; sim_bswap="";; +esac +if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then + echo "Setting bswap flags = $sim_bswap" 6>&1 +fi +else + sim_bswap="" +fi + + + +# Check whether --enable-sim-cflags was given. +if test "${enable_sim_cflags+set}" = set; then : + enableval=$enable_sim_cflags; case "${enableval}" in + yes) sim_cflags="-O2 -fomit-frame-pointer";; + trace) as_fn_error "\"Please use --enable-sim-debug instead.\"" "$LINENO" 5; sim_cflags="";; + no) sim_cflags="";; + *) sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;; +esac +if test x"$silent" != x"yes" && test x"$sim_cflags" != x""; then + echo "Setting sim cflags = $sim_cflags" 6>&1 +fi +else + sim_cflags="" +fi + + + +# Check whether --enable-sim-debug was given. +if test "${enable_sim_debug+set}" = set; then : + enableval=$enable_sim_debug; case "${enableval}" in + yes) sim_debug="-DDEBUG=7 -DWITH_DEBUG=7";; + no) sim_debug="-DDEBUG=0 -DWITH_DEBUG=0";; + *) sim_debug="-DDEBUG='(${enableval})' -DWITH_DEBUG='(${enableval})'";; +esac +if test x"$silent" != x"yes" && test x"$sim_debug" != x""; then + echo "Setting sim debug = $sim_debug" 6>&1 +fi +else + sim_debug="" +fi + + + +# Check whether --enable-sim-stdio was given. +if test "${enable_sim_stdio+set}" = set; then : + enableval=$enable_sim_stdio; case "${enableval}" in + yes) sim_stdio="-DWITH_STDIO=DO_USE_STDIO";; + no) sim_stdio="-DWITH_STDIO=DONT_USE_STDIO";; + *) as_fn_error "\"Unknown value $enableval passed to --enable-sim-stdio\"" "$LINENO" 5; sim_stdio="";; +esac +if test x"$silent" != x"yes" && test x"$sim_stdio" != x""; then + echo "Setting stdio flags = $sim_stdio" 6>&1 +fi +else + sim_stdio="" +fi + + + +# Check whether --enable-sim-trace was given. +if test "${enable_sim_trace+set}" = set; then : + enableval=$enable_sim_trace; case "${enableval}" in + yes) sim_trace="-DTRACE=1 -DWITH_TRACE=-1";; + no) sim_trace="-DTRACE=0 -DWITH_TRACE=0";; + [-0-9]*) + sim_trace="-DTRACE='(${enableval})' -DWITH_TRACE='(${enableval})'";; + [a-z]*) + sim_trace="" + for x in `echo "$enableval" | sed -e "s/,/ /g"`; do + if test x"$sim_trace" = x; then + sim_trace="-DWITH_TRACE='(TRACE_$x" + else + sim_trace="${sim_trace}|TRACE_$x" + fi + done + sim_trace="$sim_trace)'" ;; +esac +if test x"$silent" != x"yes" && test x"$sim_trace" != x""; then + echo "Setting sim trace = $sim_trace" 6>&1 +fi +else + sim_trace="" +fi + + + +# Check whether --enable-sim-profile was given. +if test "${enable_sim_profile+set}" = set; then : + enableval=$enable_sim_profile; case "${enableval}" in + yes) sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1";; + no) sim_profile="-DPROFILE=0 -DWITH_PROFILE=0";; + [-0-9]*) + sim_profile="-DPROFILE='(${enableval})' -DWITH_PROFILE='(${enableval})'";; + [a-z]*) + sim_profile="" + for x in `echo "$enableval" | sed -e "s/,/ /g"`; do + if test x"$sim_profile" = x; then + sim_profile="-DWITH_PROFILE='(PROFILE_$x" + else + sim_profile="${sim_profile}|PROFILE_$x" + fi + done + sim_profile="$sim_profile)'" ;; +esac +if test x"$silent" != x"yes" && test x"$sim_profile" != x""; then + echo "Setting sim profile = $sim_profile" 6>&1 +fi +else + sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1" +fi + + + + +# Check whether --with-pkgversion was given. +if test "${with_pkgversion+set}" = set; then : + withval=$with_pkgversion; case "$withval" in + yes) as_fn_error "package version not specified" "$LINENO" 5 ;; + no) PKGVERSION= ;; + *) PKGVERSION="($withval) " ;; + esac +else + PKGVERSION="(GDB) " + +fi + + + + + +# Check whether --with-bugurl was given. +if test "${with_bugurl+set}" = set; then : + withval=$with_bugurl; case "$withval" in + yes) as_fn_error "bug URL not specified" "$LINENO" 5 ;; + no) BUGURL= + ;; + *) BUGURL="$withval" + ;; + esac +else + BUGURL="http://www.gnu.org/software/gdb/bugs/" + +fi + + case ${BUGURL} in + "") + REPORT_BUGS_TO= + REPORT_BUGS_TEXI= + ;; + *) + REPORT_BUGS_TO="<$BUGURL>" + REPORT_BUGS_TEXI=@uref{`echo "$BUGURL" | sed 's/@/@@/g'`} + ;; + esac; + + + + +cat >>confdefs.h <<_ACEOF +#define PKGVERSION "$PKGVERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define REPORT_BUGS_TO "$REPORT_BUGS_TO" +_ACEOF + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 +$as_echo_n "checking return type of signal handlers... " >&6; } +if test "${ac_cv_type_signal+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include + +int +main () +{ +return *(signal (0, 0)) (0) == 1; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_type_signal=int +else + ac_cv_type_signal=void +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 +$as_echo "$ac_cv_type_signal" >&6; } + +cat >>confdefs.h <<_ACEOF +#define RETSIGTYPE $ac_cv_type_signal +_ACEOF + + + + + +sim_link_files= +sim_link_links= + +sim_link_links=tconfig.h +if test -f ${srcdir}/tconfig.in +then + sim_link_files=tconfig.in +else + sim_link_files=../common/tconfig.in +fi + +# targ-vals.def points to the libc macro description file. +case "${target}" in +*-*-*) TARG_VALS_DEF=../common/nltvals.def ;; +esac +sim_link_files="${sim_link_files} ${TARG_VALS_DEF}" +sim_link_links="${sim_link_links} targ-vals.def" + + +for ac_header in sys/select.h termios.h sys/socket.h netinet/in.h netinet/tcp.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +ac_sources="$sim_link_files" +ac_dests="$sim_link_links" +while test -n "$ac_sources"; do + set $ac_dests; ac_dest=$1; shift; ac_dests=$* + set $ac_sources; ac_source=$1; shift; ac_sources=$* + ac_config_links_1="$ac_config_links_1 $ac_dest:$ac_source" +done +ac_config_links="$ac_config_links $ac_config_links_1" + +cgen_breaks="" +if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then +cgen_breaks="break cgen_rtx_error"; +fi + +ac_config_files="$ac_config_files Makefile.sim:Makefile.in" + +ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in" + +ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in" + +ac_config_commands="$ac_config_commands Makefile" + +ac_config_commands="$ac_config_commands stamp-h" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: ${CONFIG_STATUS=./config.status} +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error ERROR [LINENO LOG_FD] +# --------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with status $?, using 1 if that was 0. +as_fn_error () +{ + as_status=$?; test $as_status -eq 0 && as_status=1 + if test "$3"; then + as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + fi + $as_echo "$as_me: error: $1" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by $as_me, which was +generated by GNU Autoconf 2.64. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_links="$ac_config_links" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration links: +$config_links + +Configuration commands: +$config_commands + +Report bugs to the package provider." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.64, + with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2009 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;; + "$ac_config_links_1") CONFIG_LINKS="$CONFIG_LINKS $ac_config_links_1" ;; + "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;; + "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;; + ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;; + "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;; + "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;; + + *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_LINKS+set}" = set || CONFIG_LINKS=$config_links + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\).*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\).*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ + || as_fn_error "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_t=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_t"; then + break + elif $ac_last_try; then + as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :L $CONFIG_LINKS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin" \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + esac \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$tmp/config.h" "$ac_file" \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error "could not create -" "$LINENO" 5 + fi + ;; + :L) + # + # CONFIG_LINK + # + + if test "$ac_source" = "$ac_file" && test "$srcdir" = '.'; then + : + else + # Prefer the file from the source tree if names are identical. + if test "$ac_source" = "$ac_file" || test ! -r "$ac_source"; then + ac_source=$srcdir/$ac_source + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: linking $ac_source to $ac_file" >&5 +$as_echo "$as_me: linking $ac_source to $ac_file" >&6;} + + if test ! -r "$ac_source"; then + as_fn_error "$ac_source: file not found" "$LINENO" 5 + fi + rm -f "$ac_file" + + # Try a relative symlink, then a hard link, then a copy. + case $srcdir in + [\\/$]* | ?:[\\/]* ) ac_rel_source=$ac_source ;; + *) ac_rel_source=$ac_top_build_prefix$ac_source ;; + esac + ln -s "$ac_rel_source" "$ac_file" 2>/dev/null || + ln "$ac_source" "$ac_file" 2>/dev/null || + cp -p "$ac_source" "$ac_file" || + as_fn_error "cannot link or copy $ac_source to $ac_file" "$LINENO" 5 + fi + ;; + :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..." + rm -f Makesim1.tmp Makesim2.tmp Makefile + sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' Makesim1.tmp + sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' Makesim2.tmp + sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \ + -e '/^## COMMON_POST_/ r Makesim2.tmp' \ + Makefile + rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp + ;; + "stamp-h":C) echo > stamp-h ;; + + esac +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit $? +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + +
configure Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sample.S =================================================================== --- sample.S (nonexistent) +++ sample.S (revision 842) @@ -0,0 +1,29 @@ +;;; sample.S --- simple test program for M32C simulator +;;; +;;; Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;;; Contributed by Red Hat, Inc. +;;; +;;; This file is part of the GNU simulators. +;;; +;;; This program is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see . + +;;; See the 'sample.x' and sample.mot targets in Makefile.in. + + .text + + .global _start +_start: + mov.w #0x1234,r1 + mov.w r1,r3 | sha.w #-8,r3 | sha.w #-7,r3 + brk
sample.S Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: Makefile.in =================================================================== --- Makefile.in (nonexistent) +++ Makefile.in (revision 842) @@ -0,0 +1,91 @@ +#### Makefile.in --- Makefile template for the M32C simulator + +### Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +### Contributed by Red Hat, Inc. +### +### This file is part of the GNU simulators. +### +### This program is free software; you can redistribute it and/or modify +### it under the terms of the GNU General Public License as published by +### the Free Software Foundation; either version 3 of the License, or +### (at your option) any later version. +### +### This program is distributed in the hope that it will be useful, +### but WITHOUT ANY WARRANTY; without even the implied warranty of +### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +### GNU General Public License for more details. +### +### You should have received a copy of the GNU General Public License +### along with this program. If not, see . + +## COMMON_PRE_CONFIG_FRAG + +SIM_EXTRA_CFLAGS = -Wall -DTIMER_A + +SIM_RUN_OBJS = \ + main.o \ + $(ENDLIST) + +SIM_OBJS = \ + gdb-if.o \ + int.o \ + load.o \ + mem.o \ + misc.o \ + reg.o \ + r8c.o \ + m32c.o \ + srcdest.o \ + syscalls.o \ + trace.o \ + $(ENDLIST) + +# SIM_EXTRA_ALL = sample.x sample2.x + +LIBS = $B/bfd/libbfd.a $B/libiberty/libiberty.a + +## COMMON_POST_CONFIG_FRAG + +arch = m32c + +r8c.c : r8c.opc opc2c + ./opc2c -l r8c.out $(srcdir)/r8c.opc > r8c.c + +m32c.c : m32c.opc opc2c + ./opc2c -l m32c.out $(srcdir)/m32c.opc > m32c.c + +opc2c : opc2c.o safe-fgets.o + $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ + +sample.x : $(srcdir)/sample.S $(srcdir)/sample.ld + ../../gcc/xgcc $(CPUFLAGS) -B../../gcc/ -c $(srcdir)/sample.S -o sample.o + ../../ld/ld-new sample.o -o sample.x -T$(srcdir)/sample.ld + +sample.mot : sample.x + ../../binutils/objcopy --srec-forceS3 -O srec sample.x sample.mot + +sample2.x : sample2.o gloss.o $(srcdir)/sample.ld + ../../ld/ld-new sample2.o gloss.o -o sample2.x -T$(srcdir)/sample.ld + +sample2.o : $(srcdir)/sample2.c + ../../gcc/xgcc $(CPUFLAGS) -B../../gcc/ -c $(srcdir)/sample2.c -o sample2.o + +gloss.o : $(srcdir)/gloss.S + ../../gcc/xgcc $(CPUFLAGS) -B../../gcc/ -c $(srcdir)/gloss.S -o gloss.o + +encodings: + grep '/\* [01]' $(srcdir)/r8c.opc | sort + +gdb-if.o : cpu.h mem.h load.h syscalls.h +int.o : int.h cpu.h mem.h +load.o : load.h cpu.h mem.h +main.o : cpu.h mem.h misc.h load.h +mem.o : mem.h cpu.h syscalls.h +misc.o : cpu.h misc.h +opc2c.o : safe-fgets.h +reg.o : cpu.h +safe-fgets.o : safe-fgets.h +srcdest.c : cpu.h mem.h +syscalls.c : cpu.h mem.h syscalls.h + +r8c.o : cpu.h mem.h misc.h int.h Index: sample2.c =================================================================== --- sample2.c (nonexistent) +++ sample2.c (revision 842) @@ -0,0 +1,28 @@ +/* sample2.c --- main source for sample2.x test program for M32C simulator + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + +/* See the 'sample2.x' target in Makefile.in. */ +void exit (int); + +start () +{ + foo (1, 2, 3, 4); + exit (5); +}
sample2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: m32c.opc =================================================================== --- m32c.opc (nonexistent) +++ m32c.opc (revision 842) @@ -0,0 +1,2141 @@ +/* m32c.opc --- semantics for m32c opcodes. -*- mode: c -*- + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +#include +#include + +#include "cpu.h" +#include "mem.h" +#include "misc.h" +#include "int.h" + +#define AU __attribute__((unused)) + +#define tprintf if (trace) printf + +static unsigned char +getbyte () +{ + int tsave = trace; + unsigned char b; + + if (trace == 1) + trace = 0; + b = mem_get_pc (); + regs.r_pc ++; + trace = tsave; + return b; +} + +#define M32C_ONLY() /* FIXME: add something here */ + +#define GETBYTE() (op[opi++] = getbyte()) + +#define UNSUPPORTED() unsupported("unsupported", m32c_opcode_pc) +#define NOTYET() unsupported("unimplemented", m32c_opcode_pc) + +static void +unsupported (char *tag, int orig_pc) +{ + int i; + printf("%s opcode at %08x\n", tag, orig_pc); + regs.r_pc = orig_pc; + for (i=0; i<2; i++) + { + int b = mem_get_pc(); + printf(" %s", bits(b>>4, 4)); + printf(" %s", bits(b, 4)); + regs.r_pc ++; + } + printf("\n"); + regs.r_pc = orig_pc; + for (i=0; i<6; i++) + { + printf(" %02x", mem_get_pc ()); + regs.r_pc ++; + } + printf("\n"); + exit(1); +} + +static int +IMM(int bytes) +{ + int rv = 0; + switch (bytes) + { + case 1: + rv = mem_get_qi (get_reg(pc)); + break; + case 2: + rv = mem_get_hi (get_reg(pc)); + break; + case 3: + rv = mem_get_psi (get_reg(pc)); + break; + case 4: + rv = mem_get_si (get_reg(pc)); + break; + } + regs.r_pc += bytes; + return rv; +} + +#define IMM4() (immm >= 8 ? 7 - immm : immm + 1) + +#define NO_PREFIX() PREFIX(0,0,0) + +/* Indicate which sorts of prefixes are allowed for the current + opcode. */ +void +prefix (src_allowed, dest_allowed, index_bytewidth) +{ + /* At the moment, we don't do anything with this information. We + just wanted to get the information entered in some + machine-readable form while we were going through all the + opcodes. */ +} + +#define MATH_OP(dc,s,c,op) \ +{ \ + int ma, mb; \ + ma = get_src(dc); \ + mb = s & b2mask[dc.bytes]; \ + ll = (long long)ma op (long long)mb op c; \ + tprintf("0x%x " #op " 0x%x " #op " 0x%x = 0x%llx\n", ma, mb, c, ll); \ + ma = sign_ext (ma, dc.bytes * 8); \ + mb = sign_ext (s, dc.bytes * 8); \ + v = ma op mb op c; \ + tprintf("%d " #op " %d " #op " %d = %d\n", ma, mb, c, v); \ + set_oszc (v, dc.bytes, (1 op 1) ? (ll > b2mask[dc.bytes]) : (ll >= 0)); \ + put_dest (dc, v); \ +} + +#define LOGIC_OP(dc,s,op) \ +{ \ + int ma, mb; \ + ma = get_src(dc); \ + mb = s & b2mask[dc.bytes]; \ + v = ma op mb; \ + tprintf("0x%x " #op " 0x%x = 0x%x\n", ma, mb, v); \ + set_sz (v, dc.bytes); \ + put_dest (dc, v); \ +} + +#define BIT_OP(dc,bit,expr) \ + b = get_bit2 (dc, bitindex == -1 ? bit : bitindex); \ + v = expr; \ + tprintf ("b=%d, bit=%d, carry=%d, %s = %d\n", \ + b, bitindex == -1 ? bit : bitindex, carry, #expr, v); \ + put_bit2 (dc, bitindex == -1 ? bit : bitindex, v); + +#define BIT_OPC(dc,bit,expr) \ + b = get_bit2 (dc, bitindex == -1 ? bit : bitindex); \ + v = expr; \ + tprintf ("b=%d, bit=%d, carry=%d, %s = %d\n", \ + b, bitindex == -1 ? bit : bitindex, carry, #expr, v); \ + set_c (v); + +#define carry (FLAG_C ? 1 : 0) + +static void +cmp (int d, int s, int bytes) +{ + int a, b, f=0; + a = d - s; + b = sign_ext (d, bytes*8) - sign_ext (s, bytes*8); + tprintf ("cmp: %x - %x = %08x, %x - %x = %d\n", + d, s, a, + sign_ext(d,bytes*8), sign_ext(s,bytes*8), b); + + if (b == 0) + f |= FLAGBIT_Z; + if (b & b2signbit[bytes]) + f |= FLAGBIT_S; + if ((d & b2mask[bytes]) >= (s & b2mask[bytes])) + f |= FLAGBIT_C; + if (b < b2minsigned[bytes] || b > b2maxsigned[bytes]) + f |= FLAGBIT_O; + + set_flags (FLAGBIT_Z | FLAGBIT_S | FLAGBIT_O | FLAGBIT_C, f); +} + +static void +dadd_op (int ddd, int dd, int sss, int ss, int imm, int add, int cy, int w) +{ + srcdest sc, dc; + int a, b=0, res; + + prefix (0, 0, 0); + + if (!imm) + { + sc = decode_src23 (sss, ss, w+1); + b = get_src (sc); + } + dc = decode_dest23 (ddd, dd, w+1); + a = get_src (dc); + if (imm) + b = IMM(w+1); + + a = bcd2int(a, w); + b = bcd2int(b, w); + + tprintf("decimal: %d %s %d", a, add?"+":"-", b); + if (cy) + tprintf(" c=%d", carry); + + if (add) + { + res = a + b; + if (cy) + res += carry; + cy = res > (w ? 9999 : 99); + } + else + { + res = a - b; + if (cy) + res -= (1-carry); + cy = res >= 0; + if (res < 0) + res += w ? 10000 : 100; + } + + res = int2bcd (res, w); + tprintf(" = %x\n", res); + + set_szc (res, w+1, cy); + + put_dest (dc, res); +} +#define DADDV(A,C) dadd_op(ddd, dd, sss, ss, 0, A, C, w) +#define DADDI(A,C) dadd_op(ddd, dd, 0, 0, 1, A, C, w) + +static void +div_op (int sss, int ss, int u, int x, int bytes) +{ + srcdest sc; + int s, v, a, b; + + if (sss == -1) + s = IMM(bytes); + else + { + sc = decode_dest23 (sss, ss, bytes); + s = get_src (sc); + } + + v = get_reg (bytes > 1 ? r2r0 : r0); + + if (!u) + { + /* FIXME? do we sign extend a0/a1 to .L? Docs say zero extend. */ + s = sign_ext (s, bytes*8); + v = sign_ext (v, bytes*8); + } + + if (s == 0) + { + set_flags (FLAGBIT_O, FLAGBIT_O); + return; + } + + if (u) + { + a = (unsigned int)v / (unsigned int)s; + b = (unsigned int)v % (unsigned int)s; + } + else + { + a = v / s; + b = v % s; + } + if (x) + { + if ((s > 0 && b < 0) + || (s < 0 && b > 0)) + { + a --; + b += s; + } + } + tprintf ("%d / %d = %d rem %d\n", v, s, a, b); + if ((!u && (a > b2maxsigned[bytes] + || a < b2minsigned[bytes])) + || (u && (a > b2mask[bytes]))) + set_flags (FLAGBIT_O, FLAGBIT_O); + else + set_flags (FLAGBIT_O, 0); + + switch (bytes) + { + case 1: + put_reg (r0l, a); + put_reg (r0h, b); + break; + case 2: + put_reg (r0, a); + put_reg (r2, b); + break; + case 4: + put_reg (r2r0, a); + break; + } +} + +static void +index_op (int sss, int ss, int do_s, int do_d, int scale, int w) +{ + srcdest sc = decode_src23 (sss, ss, w+1); + int v = get_src (sc) * scale; + tprintf("%d = %d * %d, %d %d\n", v, get_src(sc), scale, do_s, do_d); + decode_index (do_s * v, do_d * v); +} +#define INDEXOP(scale,do_s,do_d) \ + index_op (sss, ss, do_s, do_d, scale, w); goto next_opcode + +static void +rot_op (srcdest sd, int rotc, int count) +{ + int mask = (sd.bytes == 2) ? 0xffff : 0xff; + int msb = (sd.bytes == 2) ? 0x8000 : 0x80; + int v = get_src (sd); + int c = carry, ct; + + tprintf("%s %x by %d\n", rotc ? "rotc" : "rot", v, count); + tprintf (": %s %d\n", bits(v, 8*sd.bytes), c); + while (count > 0) + { + ct = (v & msb) ? 1 : 0; + v <<= 1; + v |= rotc ? c : ct; + v &= mask; + c = ct; + tprintf (": %s %d\n", bits(v, 8*sd.bytes), c); + count --; + } + while (count < 0) + { + ct = v & 1; + v >>= 1; + v |= (rotc ? c : ct) * msb; + c = ct; + tprintf (": %s %d\n", bits(v, 8*sd.bytes), c); + count ++; + } + put_dest (sd, v); + set_szc (v, sd.bytes, c); +} + +static void +shift_op (srcdest sd, int arith, int count, int setc) +{ + int mask = (sd.bytes == 2) ? 0xffff : 0xff; + int msb = (sd.bytes == 2) ? 0x8000 : 0x80; + int v = get_src (sd); + int c = 0; + int o = 0; + + if (sd.bytes == 4) + { + mask = 0xffffffffU; + msb = 0x80000000U; + } + + tprintf("%s %x by %d\n", arith ? "sha" : "shl", v, count); + tprintf (": %s %d %d\n", bits(v, 8*sd.bytes), c, o); + while (count > 0) + { + c = (v & msb) ? 1 : 0; + v <<= 1; + v &= mask; + if (c != ((v & msb) ? 1 : 0)) + o = 1; + tprintf (": %s %d %d\n", bits(v, 8*sd.bytes), c, o); + count --; + } + while (count < 0) + { + c = v & 1; + if (arith) + v = (v & msb) | (v >> 1); + else + v = (v >> 1) & (msb - 1); + tprintf (": %s %d %d\n", bits(v, 8*sd.bytes), c, o); + count ++; + } + put_dest (sd, v); + set_sz (v, sd.bytes); + if (setc) + set_c (c); + set_flags (FLAGBIT_O, o ? FLAGBIT_O : 0); +} + +static int pcs[16]; +static int ipcs = 0; + +int +decode_m32c() +{ + unsigned char op[40]; + int opi; + int v, a, b; + long long ll; + srcdest sc, dc; + int imm; + int bitindex = -1; + int t0, t1=0, t2, t3=0; + int ta0, ta1, dif; + + step_result = M32C_MAKE_STEPPED (); + + decode_indirect (0, 0); + decode_index (0, 0); + +next_opcode: + opi = 0; + m32c_opcode_pc = get_reg (pc); + + tprintf("trace: decode pc = %06x\n", m32c_opcode_pc); + + if (m32c_opcode_pc == 0) + { + int i; + printf("Abort: PC is zero, here from:\n"); + for (i=0; i<4; i++) + printf(" 0x%06x\n", pcs[(ipcs+15-i)%16]); + return M32C_MAKE_HIT_BREAK (); + } + pcs[ipcs++] = m32c_opcode_pc; + ipcs %= 16; + + /** VARY sss 000 001 010 011 100 */ + /** VARY ddd 000 001 010 011 100 */ + + /** 0000 1001 indirect dest */ + + decode_indirect (0, 1); + goto next_opcode; + + /** 0100 0001 indirect src */ + + decode_indirect (1, 0); + goto next_opcode; + + /** 0100 1001 indirect src and dest */ + + decode_indirect (1, 1); + goto next_opcode; + + /** 1010 ddd w dd01 1111 ABS.size dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + v = sign_ext (get_src (dc), w?16:8); + a = v<0 ? -v : v; + tprintf("abs(%d) = %d\n", v, a); + set_osz(a, w+1); + put_dest (dc, a); + + /** 0000 0001 1000 ddd w dd10 1110 ADC.size #IMM,dest */ + + prefix (0, 0, 0); + dc = decode_dest23 (ddd, dd, w+1); + imm = IMM (w+1); + MATH_OP (dc, imm, carry, +); + + /** 0000 0001 1sss ddd w dd ss 0100 ADC.size src,dest */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, w+1); + dc = decode_dest23 (ddd, dd, w+1); + b = get_src (sc); + MATH_OP (dc, b, carry, +); + + /** 1011 ddd w dd01 1110 ADCF.size dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + MATH_OP (dc, 0, carry, +); + + /** 1000 ddd w dd10 1110 ADD.size:G #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23(ddd, dd, w+1); + imm = IMM(w+1); + MATH_OP (dc, imm, 0, +); + + /** 1000 ddd0 dd11 0001 ADD.L:G #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23(ddd, dd, 4); + imm = IMM(4); + MATH_OP (dc, imm, 0, +); + + /** 111L ddd w dd11 immm ADD.size:Q #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23(ddd, dd, L ? 4 : (w+1)); + imm = sign_ext (immm, 4); + MATH_OP (dc, imm, 0, +); + + /** 00dd 011w ADD.size:S #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest2(dd, w+1); + imm = IMM (w+1); + MATH_OP (dc, imm, 0, +); + + /** 10i0 110d ADD.L:S #IMM,A0/A1 */ + + prefix (0, 0, 0); + dc = reg_sd (d ? a1 : a0); + imm = i ? 2 : 1; + MATH_OP (dc, imm, 0, +); + + /** 1sss ddd w dd ss 1000 ADD.size:G src,dest */ + + prefix (1, 1, 0); + sc = decode_src23(sss, ss, w+1); + dc = decode_dest23(ddd, dd, w+1); + b = get_src (sc); + MATH_OP (dc, b, 0, +); + + /** 1sss ddd1 dd ss 0010 ADD.L:G src,dest */ + + prefix (1, 1, 0); + sc = decode_src23(sss, ss, 4); + dc = decode_dest23(ddd, dd, 4); + b = get_src (sc); + MATH_OP (dc, b, 0, +); + + /** 1011 0110 0001 0011 ADD.L:G #IMM16,SP */ + + prefix (0, 0, 0); + dc = reg_sd (sp); + b = sign_ext (IMM(2), 16); + MATH_OP (dc, b, 0, +); + + /** 01ii 001i ADD.L:Q #IMM3,SP */ + + prefix (0, 0, 0); + dc = reg_sd (sp); + b = ii * 2 + i + 1; + MATH_OP (dc, b, 0, +); + + /** 1011 0110 0000 0011 ADD.L:S #IMM8,SP */ + + prefix (0, 0, 0); + dc = reg_sd (sp); + b = sign_ext (IMM(1), 8); + MATH_OP (dc, b, 0, +); + + /** 1000 ddd0 dd01 0001 ADDX #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23(ddd, dd, 4); + imm = sign_ext (IMM(1), 8); + MATH_OP (dc, imm, 0, +); + + /** 1sss ddd0 dd ss 0010 ADDX src,dest */ + + prefix (1, 1, 0); + sc = decode_src23(sss, ss, 1); + dc = decode_dest23(ddd, dd, 4); + b = sign_ext (get_src (sc), 8); + MATH_OP (dc, b, 0, +); + + /** 1111 ddd w dd01 immm ADJNZ.size #IMM,dest,label */ + + prefix (0, 0, 0); + dc = decode_dest23 (ddd, dd, w+1); + v = get_src (dc); + imm = sign_ext(immm, 4); + tprintf("%d + %d = %d\n", v, imm, v+imm); + v += imm; + put_dest (dc, v); + a = sign_ext (IMM(1), 8); + if ((v & (w ? 0xffff : 0xff)) != 0) + { + tprintf("jmp: %x + 2 + %d = ", get_reg (pc), a); + put_reg (pc, m32c_opcode_pc + 2 + a); + tprintf("%x\n", get_reg (pc)); + } + + /** 1000 ddd w dd11 1111 AND.size:G #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23(ddd, dd, w+1); + imm = IMM(w+1); + LOGIC_OP (dc, imm, &); + + /** 01dd 110w AND.size:S #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest2(dd, w+1); + imm = IMM (w+1); + LOGIC_OP (dc, imm, &); + + /** 1sss ddd w dd ss 1101 AND.size:G src,dest */ + + prefix (1, 1, 0); + sc = decode_src23(sss, ss, w+1); + dc = decode_dest23(ddd, dd, w+1); + b = get_src (sc); + LOGIC_OP (dc, b, &); + + /** 0000 0001 1101 sss0 ss00 1bit BAND src */ + + sc = decode_src23 (sss, ss, 1); + BIT_OPC (sc, bit, b & carry); + + /** 1101 ddd0 dd11 0bit BCLR dest */ + + dc = decode_dest23 (ddd, dd, 1); + BIT_OP (dc, bit, 0); + + /** 1100 ddd w dd10 1110 BITINDEX.size src */ + + prefix (0, 0, 0); + dc = decode_dest23 (ddd, dd, w+1); + bitindex = get_src (dc); + tprintf ("bitindex set to %d\n", bitindex); + goto next_opcode; + + /** 1101 ddd0 dd01 0bit BMcnd dest */ + + prefix (0, 0, 0); + dc = decode_dest23 (ddd, dd, 1); + if (condition_true (IMM (1))) + put_bit2 (dc, bit, 1); + else + put_bit2 (dc, bit, 0); + + /** 1101 1001 0c10 1cnd BMcnd C */ + + prefix (0, 0, 0); + if (condition_true (c * 8 + cnd)) + set_c (1); + else + set_c (0); + + /** 0000 0001 1101 sss0 ss01 1bit BNAND src */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 1); + BIT_OPC (sc, bit, (!b) & carry); + + /** 0000 0001 1101 sss0 ss11 0bit BNOR src */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 1); + BIT_OPC (sc, bit, (!b) | carry); + + /** 1101 ddd0 dd01 1bit BNOT dest */ + + prefix (0, 0, 0); + dc = decode_dest23 (ddd, dd, 1); + BIT_OP (dc, bit, !b); + + /** 0000 0001 1101 sss0 ss00 0bit BNTST src */ + + prefix (0, 0, 0); + sc = decode_dest23 (sss, ss, 1); + b = get_bit2 (sc, bit); + set_zc (!b, !b); + + /** 0000 0001 1101 sss0 ss11 1bit BNXOR src */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 1); + BIT_OPC (sc, bit, !b ^ carry); + + /** 0000 0001 1101 sss0 ss10 0bit BOR src */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 1); + BIT_OPC (sc, bit, b | carry); + + /** 0000 0000 BRK */ + + /* We report the break to our caller with the PC still pointing at the + breakpoint instruction. */ + put_reg (pc, m32c_opcode_pc); + if (verbose) + printf("[break]\n"); + if (in_gdb || (regs.r_intbl == 0 && regs.r_intbh == 0)) + return M32C_MAKE_HIT_BREAK (); + if (mem_get_qi (0xFFFFE7) == 0xff) + trigger_based_interrupt (0); + else + trigger_fixed_interrupt (0xFFFFE4); + + /** 1111 1110 GBRK */ + + /* This alternate break, which is not part of the chip's opcode set, + is here in case you need to debug a program that itself uses the + chip's BRK opcode. You'll need to modify your copy of GDB to use + this opcode instead of the real BRK. */ + + /* GDB Break. */ + /* We report the break to our caller with the PC still pointing at the + breakpoint instruction. */ + put_reg (pc, m32c_opcode_pc); + if (verbose) + printf("[gdb break]\n"); + return M32C_MAKE_HIT_BREAK (); + + /** 0000 1000 BRK2 */ + + if (verbose) + printf("[break2]\n"); + if (in_gdb) + return M32C_MAKE_HIT_BREAK (); + if (mem_get_qi (0xFFFFE7) == 0xff) + trigger_based_interrupt (0); + else + trigger_fixed_interrupt (0xFFFFE4); + + /** 1101 ddd0 dd11 1bit BSET dest */ + + dc = decode_dest23 (ddd, dd, 1); + BIT_OP (dc, bit, 1); + + /** 1101 sss0 ss00 0bit BTST:G src */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 1); + b = get_bit2 (sc, bit); + set_zc (!b, b); + + /** 00bb 101b BTST:S src */ + + sc = decode_src23 (3, 3, 1); /* bit,base:19 */ + b = get_bit2 (sc, bb*2 + b); + set_zc (!b, b); + + /** 1101 ddd0 dd10 0bit BTSTC dest */ + + prefix (0, 0, 0); + sc = decode_dest23 (ddd, dd, 1); + b = get_bit2 (sc, bit); + set_zc (!b, b); + put_bit2 (sc, bit, 0); + + /** 1101 ddd0 dd10 1bit BTSTS dest */ + + prefix (0, 0, 0); + sc = decode_dest23 (ddd, dd, 1); + b = get_bit2 (sc, bit); + set_zc (!b, b); + put_bit2 (sc, bit, 1); + + /** 0000 0001 1101 sss0 ss10 1bit BXOR src */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 1); + BIT_OPC (sc, bit, b ^ carry); + + /** 0000 0001 1000 ddd w dd11 1110 CLIP.size #IMM1,#IMM2,dest */ + + prefix (0, 0, 0); + dc = decode_dest23 (ddd, dd, w+1); + a = sign_ext (IMM(w+1), w*8+8); + b = sign_ext (IMM(w+1), w*8+8); + v = sign_ext (get_src (dc), w*8+8); + tprintf("clip %d <= %d <= %d : ", a, v, b); + if (a > v) + v = a; + if (v > b) + v = b; + tprintf("%d\n", v); + put_dest (dc, v); + + /** 1001 ddd w dd10 1110 CMP.size:G #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + v = get_src (dc); + imm = IMM(w+1); + cmp (v, imm, w+1); + + /** 1010 ddd0 dd11 0001 CMP.L:G #IMM32,dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, 4); + v = get_src (dc); + imm = IMM(4); + cmp (v, imm, 4); + + /** 1110 ddd w dd01 immm CMP.size:Q #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + v = get_src (dc); + immm = sign_ext (immm, 4); + cmp (v, immm, w+1); + + /** 01dd 011w CMP.size:S #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest2 (dd, w+1); + v = get_src (dc); + imm = sign_ext (IMM(w+1),w*8+8); + cmp (v, imm, w+1); + + /** 1sss ddd w dd ss 0110 CMP.size:G src,dest */ + + prefix (1, 1, 0); + sc = decode_src23 (sss, ss, w+1); + dc = decode_dest23 (ddd, dd, w+1); + a = get_src (dc); + b = get_src (sc); + cmp (a, b, w+1); + + /** 1sss ddd1 dd ss 0001 CMP.L:G src,dest */ + + prefix (1, 1, 0); + sc = decode_src23 (sss, ss, 4); + dc = decode_dest23 (ddd, dd, 4); + a = get_src (dc); + b = get_src (sc); + cmp (a, b, 4); + + /** 01dd 000w CMP.size:S src,R0/R0L */ + + prefix (0, 1, 0); + dc = decode_dest2 (dd, w+1); + a = get_reg (w ? r0 : r0l); + b = get_src (dc); + cmp (a, b, w+1); + + /** 1010 ddd0 dd01 0001 CMPX #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, 4); + v = get_src (dc); + imm = sign_ext (IMM(1), 8); + cmp (v, imm, 4); + + /** 0000 0001 1000 ddd w dd00 1110 DADC.size #IMM,dest */ + + DADDI(1,1); + + /** 0000 0001 1sss ddd w dd ss 1000 DADC.size src,dest */ + + DADDV(1,1); + + /** 0000 0001 1000 ddd w dd01 1110 DADD.size #IMM,dest */ + + DADDI(1,0); + + /** 0000 0001 1sss ddd w dd ss 0000 DADD.size src,dest */ + + DADDV(1,0); + + /** 1011 ddd w dd00 1110 DEC.size dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + a = get_src (dc); + v = a-1; + tprintf ("%x -- = %x\n", a, v); + set_sz (v, w+1); + put_dest (dc, v); + + /** 1011 0000 010w 0011 DIV.size #IMM */ + + prefix (0, 0, 0); + div_op (-1, 0, 0, 0, w+1); + + /** 1000 sss w ss01 1110 DIV.size src */ + + prefix (0, 1, 0); + div_op (sss, ss, 0, 0, w+1); + + /** 0000 0001 1010 sss1 ss01 1111 DIV.L src */ + + M32C_ONLY(); + prefix (0, 0, 0); + div_op (sss, ss, 0, 0, 4); + + /** 1011 0000 000w 0011 DIVU.size #IMM */ + + prefix (0, 0, 0); + div_op (-1, 0, 1, 0, w+1); + + /** 1000 sss w ss00 1110 DIVU.size src */ + + prefix (0, 1, 0); + div_op (sss, ss, 1, 0, w+1); + + /** 0000 0001 1010 sss1 ss00 1111 DIVU.L src */ + + M32C_ONLY(); + prefix (0, 0, 0); + div_op (sss, ss, 1, 0, 4); + + /** 1011 0010 010w 0011 DIVX.size #IMM */ + + prefix (0, 0, 0); + div_op (-1, 0, 0, 1, w+1); + + /** 1001 sss w ss01 1110 DIVX.size src */ + + prefix (0, 1, 0); + div_op (sss, ss, 0, 1, w+1); + + /** 0000 0001 1010 sss1 ss10 1111 DIVX.L src */ + + M32C_ONLY(); + prefix (0, 0, 0); + div_op (sss, ss, 0, 1, 4); + + /** 0000 0001 1001 ddd w dd00 1110 DSBB.size #IMM,dest */ + + DADDI(0,1); + + /** 0000 0001 1sss ddd w dd ss 1010 DSBB.size src,dest */ + + DADDV(0,1); + + /** 0000 0001 1001 ddd w dd01 1110 DSUB.size #IMM,dest */ + + DADDI(0,0); + + /** 0000 0001 1sss ddd w dd ss 0010 DSUB.size src,dest */ + + DADDV(0,0); + + /** 1110 1100 ENTER #IMM */ + + imm = IMM(1); + put_reg (sp, get_reg (sp) - 4); + mem_put_si (get_reg (sp), get_reg (fb)); + put_reg (fb, get_reg (sp)); + put_reg (sp, get_reg (sp) - imm); + + /** 1111 1100 EXITD */ + + put_reg (sp, get_reg (fb)); + put_reg (fb, mem_get_si (get_reg (sp))); + put_reg (sp, get_reg (sp) + 4); + put_reg (pc, mem_get_si (get_reg (sp))); + put_reg (sp, get_reg (sp) + 4); + + /** 1100 ddd w dd01 1110 EXTS.size dest */ + + prefix (0, 0, 0); + dc = decode_dest23 (ddd, dd, w+1); + v = sign_ext (get_src (dc), (w+1)*8); + dc = widen_sd (dc); + put_dest (dc, v); + set_sz (v, (w+1)*2); + + /** 0000 0001 1sss ddd0 dd ss 0111 EXTS.B src,dest */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 1); + dc = decode_dest23 (ddd, dd, 2); + v = sign_ext (get_src (sc), 8); + put_dest (dc, v); + set_sz (v, 16); + + /** 0000 0001 1sss ddd0 dd ss 1011 EXTZ src,dest */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 1); + dc = decode_dest23 (ddd, dd, 2); + v = get_src (sc); + put_dest (dc, v); + set_sz (v, 16); + + /** 1101 0011 1110 1dst FCLR dest */ + + set_flags (1 << dst, 0); + + /** 1001 1111 FREIT */ + + NOTYET(); + + /** 1101 0001 1110 1dst FSET dest */ + + set_flags (1 << dst, 1 << dst); + + /** 1010 ddd w dd00 1110 INC.size dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + a = get_src (dc); + v = a+1; + tprintf ("%x ++ = %x\n", a, v); + set_sz (v, w+1); + put_dest (dc, v); + + /** 1000 sss0 ss0w 0011 INDEXB.size src */ + INDEXOP(1, 1, 1); + /** 1010 sss0 ss0w 0011 INDEXBD.size src */ + INDEXOP(1, 0, 1); + /** 1100 sss0 ss0w 0011 INDEXBS.size src */ + INDEXOP(1, 1, 0); + /** 1001 sss0 ss1w 0011 INDEXL.size src */ + INDEXOP(4, 1, 1); + /** 1011 sss0 ss1w 0011 INDEXLD.size src */ + INDEXOP(4, 0, 1); + /** 1001 sss0 ss0w 0011 INDEXLS.size src */ + INDEXOP(4, 1, 0); + /** 1000 sss0 ss1w 0011 INDEXW.size src */ + INDEXOP(2, 1, 1); + /** 1010 sss0 ss1w 0011 INDEXWD.size src */ + INDEXOP(2, 0, 1); + /** 1100 sss0 ss1w 0011 INDEXWS.size src */ + INDEXOP(2, 1, 0); + + /** 1011 1110 vector00 INT #IMM */ + + prefix (0, 0, 0); + trigger_based_interrupt (vector); + + /** 1011 1111 INTO */ + + prefix (0, 0, 0); + if (FLAG_O) + trigger_fixed_interrupt (0xffffe0); + + /** 1ccc 101c Jcnd label */ + + prefix (0, 0, 0); + v = sign_ext (IMM(1), 8); + if (condition_true (ccc*2+c)) + put_reg (pc, m32c_opcode_pc + 1 + v); + + /** 01dd 101d JMP.S label */ + + prefix (0, 0, 0); + put_reg (pc, m32c_opcode_pc + (dd*2+d) + 2); + + /** 1011 1011 JMP.B label */ + + prefix (0, 0, 0); + imm = sign_ext (IMM(1), 8); + if (imm == -1) + { + if (verbose) + printf("[jmp-to-self detected as exit]\n"); + return M32C_MAKE_HIT_BREAK (); + } + put_reg (pc, m32c_opcode_pc + 1 + imm); + + /** 1100 1110 JMP.W label */ + + prefix (0, 0, 0); + imm = sign_ext (IMM(2), 16); + put_reg (pc, m32c_opcode_pc + 1 + imm); + + /** 1100 1100 JMP.A label */ + + prefix (0, 0, 0); + imm = IMM(3); + put_reg (pc, imm); + + /** 1100 sss1 ss00 1111 JMPI.W src */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 2); + a = get_src (sc); + a = sign_ext (a, 16); + put_reg (pc, m32c_opcode_pc + a); + + /** 1000 sss0 ss00 0001 JMPI.A src */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 3); + a = get_src (sc); + put_reg (pc, a); + + /** 1101 1100 JMPS #IMM8 */ + + prefix (0, 0, 0); + imm = IMM(1); + a = 0xff0000 + mem_get_hi (0xfffe00 - imm * 2); + put_reg (pc, a); + + /** 1100 1111 JSR.W label */ + + prefix (0, 0, 0); + imm = sign_ext (IMM(2), 16); + put_reg (sp, get_reg (sp) - 4); + mem_put_si (get_reg (sp), get_reg (pc)); + put_reg (pc, m32c_opcode_pc + imm + 1); + + /** 1100 1101 JSR.A label */ + + prefix (0, 0, 0); + imm = IMM(3); + put_reg (sp, get_reg (sp) - 4); + mem_put_si (get_reg (sp), get_reg (pc)); + put_reg (pc, imm); + + /** 1100 sss1 ss01 1111 JSRI.W src */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 2); + a = get_src (sc); + a = sign_ext (a, 16); + put_reg (sp, get_reg (sp) - 4); + mem_put_si (get_reg (sp), get_reg (pc)); + put_reg (pc, m32c_opcode_pc + a); + + /** 1001 sss0 ss00 0001 JSRI.A src */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 3); + a = get_src (sc); + put_reg (sp, get_reg (sp) - 4); + mem_put_si (get_reg (sp), get_reg (pc)); + put_reg (pc, a); + + /** 1101 1101 JSRS #IMM8 */ + + prefix (0, 0, 0); + imm = IMM(1); + a = 0xff0000 + mem_get_hi (0xfffe00 - imm * 2); + put_reg (sp, get_reg (sp) - 4); + mem_put_si (get_reg (sp), get_reg (pc)); + put_reg (pc, a); + + /** 1101 0101 1010 1dst LDC #IMM16,dest */ + + imm = IMM(2); + dc = decode_cr_b (dst, CR_B_DCT0); + put_dest (dc, imm); + + /** 1101 0101 0010 1dst LDC #IMM24,dest */ + + imm = IMM(3); + dc = decode_cr_b (dst, CR_B_INTB); + put_dest (dc, imm); + + /** 1101 0101 0110 1dst LDC #IMM24,dest */ + + imm = IMM(3); + dc = decode_cr_b (dst, CR_B_DMA0); + put_dest (dc, imm); + + /** 0000 0001 1101 sss1 ss00 1dst LDC src,dest */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 2); + dc = decode_cr_b (dst, CR_B_DCT0); + a = get_src (sc); + put_dest (dc, a); + + /** 1101 sss1 ss00 0dst LDC src,dest */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 3); + dc = decode_cr_b (dst, CR_B_INTB); + a = get_src (sc); + put_dest (dc, a); + + /** 0000 0001 1101 sss1 ss00 0dst LDC src,dest */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 3); + dc = decode_cr_b (dst, CR_B_DMA0); + a = get_src (sc); + put_dest (dc, a); + + /** 1011 0110 1100 0011 LDCTX */ + + NOTYET(); + + /** 1101 0101 1110 1imm LDIPL #IMM */ + + set_flags (0x7000, imm*0x1000); + + /** 0000 0001 1000 ddd w dd11 1111 MAX.size #IMM,dest */ + + prefix (0, 0, 0); + w++; + dc = decode_dest23 (ddd, dd, w); + imm = sign_ext (IMM(w), w*8); + a = sign_ext (get_src (dc), w*8); + tprintf ("max %d %d\n", imm, a); + if (imm > a) + put_dest (dc, imm); + + /** 0000 0001 1sss ddd w dd ss 1101 MAX.size src,dest */ + + prefix (0, 0, 0); + w++; + sc = decode_src23 (sss, ss, w); + dc = decode_dest23 (ddd, dd, w); + b = sign_ext (get_src (sc), w*8); + a = sign_ext (get_src (dc), w*8); + tprintf ("max %d %d\n", b, a); + if (b > a) + put_dest (dc, b); + + /** 0000 0001 1000 ddd w dd10 1111 MIN.size #IMM,dest */ + + prefix (0, 0, 0); + w++; + dc = decode_dest23 (ddd, dd, w); + imm = sign_ext (IMM(w), w*8); + a = sign_ext (get_src (dc), w*8); + tprintf ("min %d %d\n", imm, a); + if (imm < a) + put_dest (dc, imm); + + /** 0000 0001 1sss ddd w dd ss 1100 MIN.size src,dest */ + + prefix (0, 0, 0); + w++; + sc = decode_src23 (sss, ss, w); + dc = decode_dest23 (ddd, dd, w); + b = sign_ext (get_src (sc), w*8); + a = sign_ext (get_src (dc), w*8); + tprintf ("min %d %d\n", b, a); + if (b < a) + put_dest (dc, b); + + /** 1001 ddd w dd10 1111 MOV.size:G #IMM,dest */ + + dc = decode_dest23 (ddd, dd, w+1); + imm = IMM(w+1); + v = imm; + tprintf("%x = %x\n", v, v); + set_sz(v, w+1); + put_dest (dc, v); + + /** 1011 ddd0 dd11 0001 MOV.L:G #IMM,dest */ + + dc = decode_dest23 (ddd, dd, 4); + imm = IMM(4); + v = imm; + tprintf("%x = %x\n", v, v); + set_sz(v, 4); + put_dest (dc, v); + + /** 1111 ddd w dd10 immm MOV.size:Q #IMM4,dest */ + + dc = decode_dest23 (ddd, dd, w+1); + imm = sign_ext (immm, 4); + v = imm; + tprintf("%x = %d\n", v, v); + set_sz(v, w+1); + put_dest (dc, v); + + /** 00dd 010w MOV.size:S #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest2 (dd, w+1); + imm = IMM(w+1); + put_dest (dc, imm); + set_sz (imm, w+1); + + /** 10w1 110d MOV.size:S #IMM,a0/a1 */ + + imm = IMM(w ? 3 : 2); + put_reg (d ? a1 : a0, imm); + set_sz (imm & addr_mask, w+1); + + /** 00dd 001w MOV.size:Z #0,dest */ + + prefix (0, 1, 0); + dc = decode_dest2 (dd, w+1); + put_dest (dc, 0); + set_sz (0, w+1); + + /** 1sss ddd w dd ss 1011 MOV.size:G src,dest */ + + prefix (1, 1, 0); + sc = decode_src23 (sss, ss, w+1); + dc = decode_dest23 (ddd, dd, w+1); + v = get_src (sc); + put_dest (dc, v); + set_sz (v, w+1); + + /** 1sss ddd1 dd ss 0011 MOV.L:G src,dest */ + + prefix (1, 1, 0); + sc = decode_src23 (sss, ss, 4); + dc = decode_dest23 (ddd, dd, 4); + v = get_src (sc); + put_dest (dc, v); + set_sz (v, 4); + + /** VARY SS 01 10 11 */ + /** 00SS 100w MOV.size:S src,R0L/R0 */ + + prefix (0, 1, 0); + sc = decode_dest2 (SS, w+1); + v = get_src (sc); + put_reg (w ? r0 : r0l, v); + set_sz (v, w+1); + + /** 01ss 111w MOV.size:S src,R1L/R1 */ + + prefix (0, 1, 0); + sc = decode_dest2 (ss, w+1); + v = get_src (sc); + put_reg (w ? r1 : r1l, v); + set_sz (v, w+1); + + /** VARY DD 01 10 11 */ + /** 00DD 000w MOV.size:S R0L/R0,dest */ + + prefix (0, 1, 0); + dc = decode_dest2 (DD, w+1); + v = get_reg (w ? r0 : r0l); + put_dest (dc, v); + set_sz (v, w+1); + + /** 01ss 100d MOV.L:S src,A0/A1 */ + + prefix (0, 1, 0); + sc = decode_dest2 (ss, 4); + v = get_src (sc); + put_reg (d ? a1 : a0, v); + set_sz (v, 4); + + /** 1011 ddd w dd00 1111 MOV.size:G dsp:8[SP], dest */ + + prefix (0, 0, 0); + imm = IMM(1); + dc = decode_dest23 (ddd, dd, w+1); + a = get_reg (sp) + sign_ext (imm, 8); + a &= addr_mask; + if (w) + v = mem_get_hi (a); + else + v = mem_get_qi (a); + put_dest (dc, v); + set_sz (v, w+1); + + /** 1010 sss w ss00 1111 MOV.size:G src,dsp:8[SP] */ + + prefix (0, 0, 0); + sc = decode_dest23 (sss, ss, w+1); + imm = IMM(1); + a = get_reg (sp) + sign_ext (imm, 8); + a &= addr_mask; + v = get_src (sc); + if (w) + mem_put_hi (a, v); + else + mem_put_qi (a, v); + set_sz (v, w+1); + + /** 1101 sss1 ss01 1dst MOVA src,dest */ + + static reg_id map[8] = { r2r0, r3r1, a0, a1 }; + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 1); + if (!sc.mem || !map[dst]) + UNSUPPORTED(); + put_reg (map[dst], sc.u.addr); + + /** 0000 0001 1011 ddd0 dd hl 1110 MOVdir R0L,dest */ + + prefix (0, 0, 0); + dc = decode_dest23 (ddd, dd, 1); + a = get_src (dc); + b = get_reg (r0l); + switch (hl) + { + case 0: a = (a & 0xf0) | (b & 0x0f); break; + case 1: a = (a & 0xf0) | ((b>>4) & 0x0f); break; + case 2: a = (a & 0x0f) | ((b & 0x0f)<<4); break; + case 3: a = (a & 0x0f) | (b & 0xf0); break; + } + put_dest (dc, a); + + /** 0000 0001 1010 sss0 ss hl 1110 MOVdir src,R0L */ + + prefix (0, 0, 0); + sc = decode_dest23 (sss, ss, 1); + a = get_reg (r0l); + b = get_src (dc); + switch (hl) + { + case 0: a = (a & 0xf0) | (b & 0x0f); break; + case 1: a = (a & 0xf0) | ((b>>4) & 0x0f); break; + case 2: a = (a & 0x0f) | ((b & 0x0f)<<4); break; + case 3: a = (a & 0x0f) | (b & 0xf0); break; + } + put_reg (r0l, a); + + /** 1011 ddd0 dd01 0001 MOVX #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, 4); + imm = sign_ext (IMM(1), 8); + put_dest (dc, imm); + set_sz (imm, 1); + + /** 1000 ddd w dd01 1111 MUL.size #IMM,dest */ + + prefix (0, 1, 0); + w ++; + dc = decode_dest23 (ddd, dd, w); + v = sign_ext (get_src (dc), w*8); + imm = sign_ext (IMM(w), w*8); + tprintf("%d * %d = %d\n", v, imm, v*imm); + v *= imm; + dc = widen_sd (dc); + put_dest (dc, v); + + /** 1sss ddd w dd ss 1100 MUL.size src,dest */ + + prefix (1, 1, 0); + w ++; + sc = decode_src23 (sss, ss, w); + dc = decode_dest23 (ddd, dd, w); + a = sign_ext (get_src (sc), w*8); + b = sign_ext (get_src (dc), w*8); + tprintf("%d * %d = %d\n", a, b, a*b); + v = a * b; + dc = widen_sd (dc); + put_dest (dc, v); + + /** 0000 0001 1000 sss1 ss01 1111 MUL.L src,R2R0 */ + + M32C_ONLY(); + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 4); + a = sign_ext (get_src (sc), 32); + b = sign_ext (get_reg (r2r0), 32); + ll = (long long)a * (long long)b; + tprintf("%d * %d = %lld (%llx)\n", a, b, ll, ll); + if (ll < b2minsigned[4] || ll > b2maxsigned[4]) + set_flags (FLAGBIT_O, FLAGBIT_O); + else + set_flags (FLAGBIT_O, 0); + put_reg (r2r0, (int)ll); + + /** 1100 sss1 ss11 1110 MULEX src */ + + prefix (0, 1, 0); + sc = decode_dest23 (sss, ss, 2); + a = sign_ext (get_src (sc), 16); + b = sign_ext (get_reg (r2r0), 32); + ll = (long long)a * (long long)b; + tprintf("%d * %d = %lld (%llx)\n", a, b, ll, ll); + put_reg (r2r0, (int)ll); + put_reg (r1, (int)(ll >> 32)); + + /** 1000 ddd w dd00 1111 MULU.size #IMM,dest */ + + prefix (0, 1, 0); + w ++; + dc = decode_dest23 (ddd, dd, w); + v = get_src (dc); + imm = IMM(w); + tprintf("%d * %d = %d\n", v, imm, v*imm); + v *= imm; + dc = widen_sd (dc); + put_dest (dc, v); + + /** 1sss ddd w dd ss 0100 MULU.size src,dest */ + + prefix (1, 1, 0); + w ++; + sc = decode_src23 (sss, ss, w); + dc = decode_dest23 (ddd, dd, w); + a = get_src (sc); + b = get_src (dc); + tprintf("%d * %d = %d\n", a, b, a*b); + v = a * b; + dc = widen_sd (dc); + put_dest (dc, v); + + /** 0000 0001 1000 sss1 ss00 1111 MULU.L src,R2R0 */ + + M32C_ONLY(); + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, 4); + a = get_src (sc); + b = get_reg (r2r0); + ll = (long long)a * (long long)b; + tprintf("%d * %d = %lld (%llx)\n", a, b, ll, ll); + if (ll < b2minsigned[4] || ll > b2maxsigned[4]) + set_flags (FLAGBIT_O, FLAGBIT_O); + else + set_flags (FLAGBIT_O, 0); + put_reg (r2r0, (int)ll); + + /** 1010 ddd w dd10 1111 NEG.size dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + a = sign_ext (get_src (dc), (w+1)*8); + v = -a; + tprintf("%d * -1 = %d\n", a, v); + set_oszc(v, w+1, v==0); + put_dest (dc, v); + + /** 1101 1110 NOP */ + + tprintf("nop\n"); + + /** 1010 ddd w dd01 1110 NOT.size dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + a = get_src (dc); + v = ~a; + tprintf("~ %x = %x\n", a, v); + set_sz(v, w+1); + put_dest (dc, v); + + /** 1000 ddd w dd10 1111 OR.size:G #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23(ddd, dd, w+1); + imm = IMM(w+1); + LOGIC_OP (dc, imm, |); + + /** 01dd 010w OR.size:S #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest2(dd, w+1); + imm = IMM (w+1); + LOGIC_OP (dc, imm, |); + + /** 1sss ddd w dd ss 0101 OR.size:G src,dest */ + + prefix (1, 1, 0); + sc = decode_src23(sss, ss, w+1); + dc = decode_dest23(ddd, dd, w+1); + b = get_src (sc); + LOGIC_OP (dc, b, |); + + /** 1011 ddd w dd10 1111 POP.size dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + if (w) + a = mem_get_hi (get_reg (sp)); + else + a = mem_get_qi (get_reg (sp)); + put_reg (sp, get_reg (sp) + 2); + tprintf("pop%s: %x\n", w ? "hi" : "qi", a); + put_dest (dc, a); + + /** 1101 0011 1010 1dst POPC dest */ + + prefix (0, 0, 0); + dc = decode_cr_b (dst, CR_B_DCT0); + a = mem_get_hi (get_reg (sp)); + put_reg (sp, get_reg (sp) + 2); + tprintf("pophi: %x\n", a); + put_dest (dc, a); + + /** 1101 0011 0010 1dst POPC dest */ + + prefix (0, 0, 0); + dc = decode_cr_b (dst, CR_B_INTB); + a = mem_get_si (get_reg (sp)); + put_reg (sp, get_reg (sp) + 4); + tprintf("popsi: %x\n", a); + put_dest (dc, a); + + /** 1000 1110 POPM dest */ + + static int map[] = { r0, r1, r2, r3, a0, a1, sb, fb }; + prefix (0, 0, 0); + imm = IMM(1); + tprintf("popm: %x\n", imm); + for (a=0; a<4; a++) + if (imm & (1<> 32)); + + /** 1011 ddd w dd10 1110 ROLC.size dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + rot_op (dc, 1, 1); + + /** 1010 ddd w dd10 1110 RORC.size dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + rot_op (dc, 1, -1); + + /** 1110 ddd w dd10 immm ROT.size #IMM, dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + rot_op (dc, IMM4(), -1); + + /** 1010 ddd w dd11 1111 ROT.size R1H,dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + a = sign_ext (get_reg (r1h), 8); + rot_op (dc, a, -1); + + /** 1101 1111 RTS */ + + put_reg (pc, mem_get_si (get_reg (sp))); + put_reg (sp, get_reg (sp) + 4); + + /** 0000 0001 1001 ddd w dd10 1110 SBB.size #IMM, dest */ + + prefix (0, 0, 0); + dc = decode_dest23 (ddd, dd, w+1); + imm = IMM (w+1); + MATH_OP (dc, imm, !carry, -); + + /** 0000 0001 1sss ddd w dd ss 0110 SBB.size src,dest */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, w+1); + dc = decode_dest23 (ddd, dd, w+1); + MATH_OP (dc, get_src (sc), !carry, -); + + /** 1101 ddd1 dd11 cond SCcond dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, 2); + if (condition_true (cond)) + put_dest (dc, 1); + else + put_dest (dc, 0); + + /** 1011 1000 110w 0011 SCMPU.size */ + + ta0 = get_reg (a0); + ta1 = get_reg (a1); + + for (;;) + { + t0 = mem_get_qi (ta0); + t2 = mem_get_qi (ta1); + if (w) + { + t1 = mem_get_qi (ta0 + 1); + t3 = mem_get_qi (ta1 + 1); + } + dif = t0 - t2; + if (dif == 0 && t0 != 0 && w) + dif = t1 - t3; + set_oszc (dif, 1, dif > 0); + + ta0 += w ? 2 : 1; + ta1 += w ? 2 : 1; + + if (t0 == 0 || t0 != t2) + break; + if (w && (t1 == 0 || t1 != t3)) + break; + } + + /** 1111 ddd w dd00 immm SHA.size #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + shift_op (dc, 1, IMM4(), 1); + + /** 1010 ddd0 dd10 0001 SHA.L #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, 4); + imm = sign_ext (IMM(1), 8); + shift_op (dc, 1, imm, 1); + + /** 1011 ddd w dd11 1110 SHA.size R1H,dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + a = sign_ext (get_reg (r1h), 8); + shift_op (dc, 1, a, 1); + + /** 1100 ddd0 dd01 0001 SHA.L R1H,dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, 4); + a = sign_ext (get_reg (r1h), 8); + shift_op (dc, 1, a, 1); + + /** 1100 ddd0 dd10 0001 SHANC.L #IMM,dest */ + + M32C_ONLY(); + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, 4); + imm = sign_ext (IMM(1), 8); + shift_op (dc, 1, imm, 0); + + /** 1110 ddd w dd00 immm SHL.size #IMM, dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + shift_op (dc, 0, IMM4(), 1); + + /** 1001 ddd0 dd10 0001 SHL.L #IMM, dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, 4); + imm = sign_ext (IMM(1), 8); + shift_op (dc, 0, imm, 1); + + /** 1010 ddd w dd11 1110 SHL.size R1H,dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + a = sign_ext (get_reg (r1h), 8); + shift_op (dc, 0, a, 1); + + /** 1100 ddd0 dd00 0001 SHL.L R1H,dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, 4); + a = sign_ext (get_reg (r1h), 8); + shift_op (dc, 0, a, 1); + + /** 1000 ddd0 dd10 0001 SHLNC.L #IMM,dest */ + + M32C_ONLY(); + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, 4); + imm = sign_ext (IMM(1), 8); + shift_op (dc, 0, imm, 0); + + /** 1011 0010 100w 0011 SIN.size */ + + v = get_reg (a0); + a = get_reg (a1); + b = get_reg (r3); + if (b) for (;b;) + { + if (w) + mem_put_hi(a, mem_get_hi (v)); + else + mem_put_qi(a, mem_get_qi (v)); + a += w ? 2 : 1; + b --; + } + put_reg (a0, v); + put_reg (a1, a); + put_reg (r3, b); + + /** 1011 0110 100w 0011 SMOVB.size */ + + v = get_reg (a0); + a = get_reg (a1); + b = get_reg (r3); + if (b) for (;b;) + { + if (w) + mem_put_hi(a, mem_get_hi (v)); + else + mem_put_qi(a, mem_get_qi (v)); + v -= w ? 2 : 1; + a -= w ? 2 : 1; + b --; + } + put_reg (a0, v); + put_reg (a1, a); + put_reg (r3, b); + + /** 1011 0000 100w 0011 SMOVF.size */ + + v = get_reg (a0); + a = get_reg (a1); + b = get_reg (r3); + if (b) for (;b;) + { + if (w) + mem_put_hi(a, mem_get_hi (v)); + else + mem_put_qi(a, mem_get_qi (v)); + v += w ? 2 : 1; + a += w ? 2 : 1; + b --; + } + put_reg (a0, v); + put_reg (a1, a); + put_reg (r3, b); + + /** 1011 1000 100w 0011 SMOVU.size */ + + v = get_reg (a0); + a = get_reg (a1); + do + { + if (w) + mem_put_hi(a, (t0 = mem_get_hi (v))); + else + mem_put_qi(a, (t0 = mem_get_qi (v))); + v += w ? 2 : 1; + a += w ? 2 : 1; + if (t0 == 0 + || (w && ((t0 & 0xff) == 0 || (t0 & 0xff00) == 0))) + break; + } while (1); + put_reg (a0, v); + put_reg (a1, a); + + /** 1011 0100 100w 0011 SOUT.size */ + + v = get_reg (a0); + a = get_reg (a1); + b = get_reg (r3); + for (;b;) + { + if (w) + mem_put_hi(a, mem_get_hi (v)); + else + mem_put_qi(a, mem_get_qi (v)); + v += w ? 2 : 1; + b --; + } + put_reg (a0, v); + put_reg (a1, a); + put_reg (r3, b); + + /** 1011 1000 000w 0011 SSTR.size */ + + a = get_reg (a1); + b = get_reg (r3); + v = get_reg (w ? r0 : r0l); + for (;b;) + { + if (w) + mem_put_hi(a, v); + else + mem_put_qi(a, v); + a += w ? 2 : 1; + b --; + } + put_reg (a1, a); + put_reg (r3, b); + + /** 0000 0001 1101 ddd1 dd01 0src STC src,dest */ + + prefix (0, 0, 0); + dc = decode_dest23 (ddd, dd, 4); + sc = decode_cr_b (src, CR_B_DMA0); + a = get_src (sc); + put_dest (dc, a); + + /** 0000 0001 1101 ddd1 dd01 1src STC src,dest */ + + prefix (0, 0, 0); + dc = decode_dest23 (ddd, dd, 2); + sc = decode_cr_b (src, CR_B_DCT0); + a = get_src (sc); + put_dest (dc, a); + + /** 1101 ddd1 dd01 0src STC src,dest */ + + prefix (0, 0, 0); + dc = decode_dest23 (ddd, dd, 4); + sc = decode_cr_b (src, CR_B_INTB); + a = get_src (sc); + put_dest (dc, a); + + /** 1011 0110 1101 0011 STCX abs16,abs24 */ + + NOTYET(); + + /** 1001 ddd w dd01 1111 STNZ.size #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + imm = IMM(w+1); + if (! FLAG_Z) + put_dest (dc, imm); + + /** 1001 ddd w dd00 1111 STZ.size #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + imm = IMM(w+1); + if (FLAG_Z) + put_dest (dc, imm); + + /** 1001 ddd w dd11 1111 STZX.size #IMM1,#IMM2,dest */ + + prefix (0, 1, 0); + dc = decode_dest23 (ddd, dd, w+1); + a = IMM(w+1); + b = IMM(w+1); + if (FLAG_Z) + put_dest (dc, a); + else + put_dest (dc, b); + + /** 1000 ddd w dd11 1110 SUB.size:G #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23(ddd, dd, w+1); + imm = IMM(w+1); + MATH_OP (dc, imm, 0, -); + + /** 1001 ddd0 dd11 0001 SUB.L:G #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23(ddd, dd, 4); + imm = IMM(4); + MATH_OP (dc, imm, 0, -); + + /** 00dd 111w SUB.size:S #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest2(dd, w+1); + imm = IMM (w+1); + MATH_OP (dc, imm, 0, -); + + /** 1sss ddd w dd ss 1010 SUB.size:G src,dest */ + + prefix (1, 1, 0); + sc = decode_src23(sss, ss, w+1); + dc = decode_dest23(ddd, dd, w+1); + b = get_src (sc); + MATH_OP (dc, b, 0, -); + + /** 1sss ddd1 dd ss 0000 SUB.L:G src,dest */ + + prefix (1, 1, 0); + sc = decode_src23(sss, ss, 4); + dc = decode_dest23(ddd, dd, 4); + b = get_src (sc); + MATH_OP (dc, b, 0, -); + + /** 1001 ddd0 dd01 0001 SUBX #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23(ddd, dd, 4); + imm = sign_ext (IMM(1), 8); + MATH_OP (dc, imm, 0, -); + + /** 1sss ddd0 dd ss 0000 SUBX src,dest */ + + prefix (1, 1, 0); + sc = decode_src23(sss, ss, 1); + dc = decode_dest23(ddd, dd, 4); + b = sign_ext (get_src (sc), 8); + MATH_OP (dc, b, 0, -); + + /** 1001 ddd w dd11 1110 TST.size:G #IMM,dest */ + + prefix (0, 0, 0); + dc = decode_dest23 (ddd, dd, w+1); + imm = IMM(w+1); + a = get_src (dc); + v = a & imm; + set_sz (v, w+1); + + /** 00dd 110w TST.size:S #IMM,dest */ + + prefix (0, 0, 0); + dc = decode_dest2 (dd, w+1); + imm = IMM(w+1); + a = get_src (dc); + v = a & imm; + set_sz (v, w+1); + + /** 0000 0001 1sss ddd w dd ss 1001 TST.size:G src,dest */ + + prefix (0, 0, 0); + sc = decode_src23 (sss, ss, w+1); + dc = decode_dest23 (ddd, dd, w+1); + b = get_src (sc); + a = get_src (dc); + v = a & b; + set_sz (v, w+1); + + /** 1111 1111 UND */ + + trigger_fixed_interrupt (0xffffdc); + + /** 1011 0010 0000 0011 WAIT */ + + ; + + /** 1101 ddd w dd00 1src XCHG.size src,dest */ + + dc = decode_dest23 (ddd, dd, w+1); + sc = decode_src3 (src, w+1); + a = get_src (dc); + b = get_src (sc); + put_dest (dc, b); + put_dest (sc, a); + + /** 1001 ddd w dd00 1110 XOR.size #IMM,dest */ + + prefix (0, 1, 0); + dc = decode_dest23(ddd, dd, w+1); + imm = IMM(w+1); + LOGIC_OP (dc, imm, ^); + + /** 1sss ddd w dd ss 1001 XOR.size src,dest */ + + prefix (1, 1, 0); + sc = decode_src23(sss, ss, w+1); + dc = decode_dest23(ddd, dd, w+1); + b = get_src (sc); + LOGIC_OP (dc, b, ^); + +/** */ + + return step_result; +} Index: trace.h =================================================================== --- trace.h (nonexistent) +++ trace.h (revision 842) @@ -0,0 +1,23 @@ +/* trace.h --- interface to tracing output for the M32C simulator. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +void sim_disasm_init (bfd * prog); +extern void sim_disasm_one (void);
trace.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: gloss.S =================================================================== --- gloss.S (nonexistent) +++ gloss.S (revision 842) @@ -0,0 +1,32 @@ +;;; gloss.S --- system calls for sample2.x +;;; +;;; Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;;; Contributed by Red Hat, Inc. +;;; +;;; This file is part of the GNU simulators. +;;; +;;; This program is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see . + +;;; See the 'sample2.x' target in Makefile.in. + .global _exit +_exit: + mov.b #1,r0l + ste.b r0l,0xe0000 + rts + + .global _foo +_foo: + mov.b #2,r0l + ste.b r0l,0xe0000 + rts
gloss.S Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: blinky.S =================================================================== --- blinky.S (nonexistent) +++ blinky.S (revision 842) @@ -0,0 +1,34 @@ +;;; blinky.S --- sample program to blink LED's on M32C simulator +;;; +;;; Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;;; Contributed by Red Hat, Inc. +;;; +;;; This file is part of the GNU simulators. +;;; +;;; This program is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see . + + .text + + .global _start +_start: + mov.w #0xe1,a0 +top: + sub.w #1,r0 + mov.b r0h,[a0] + + mov.w #1000,r1 +loop: + adjnz.w #-1,r1,loop + + jmp.w top
blinky.S Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: syscall.h =================================================================== --- syscall.h (nonexistent) +++ syscall.h (revision 842) @@ -0,0 +1,50 @@ +/* Copied from libgloss */ +/* General use syscall.h file. + The more ports that use this file, the simpler sim/common/nltvals.def + remains. */ + +#ifndef LIBGLOSS_SYSCALL_H +#define LIBGLOSS_SYSCALL_H + +/* Note: This file may be included by assembler source. */ + +/* These should be as small as possible to allow a port to use a trap type + instruction, which the system call # as the trap (the d10v for instance + supports traps 0..31). An alternative would be to define one trap for doing + system calls, and put the system call number in a register that is not used + for the normal calling sequence (so that you don't have to shift down the + arguments to add the system call number). Obviously, if these system call + numbers are ever changed, all of the simulators and potentially user code + will need to be updated. */ + +/* There is no current need for the following: SYS_execv, SYS_creat, SYS_wait, + etc. etc. Don't add them. */ + +/* These are required by the ANSI C part of newlib (excluding system() of + course). */ +#define SYS_exit 1 +#define SYS_open 2 +#define SYS_close 3 +#define SYS_read 4 +#define SYS_write 5 +#define SYS_lseek 6 +#define SYS_unlink 7 +#define SYS_getpid 8 +#define SYS_kill 9 +#define SYS_fstat 10 +/*#define SYS_sbrk 11 - not currently a system call, but reserved. */ + +/* ARGV support. */ +#define SYS_argvlen 12 +#define SYS_argv 13 + +/* These are extras added for one reason or another. */ +#define SYS_chdir 14 +#define SYS_stat 15 +#define SYS_chmod 16 +#define SYS_utime 17 +#define SYS_time 18 +#define SYS_gettimeofday 19 +#define SYS_times 20 +#define SYS_link 21 +#endif
syscall.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: load.c =================================================================== --- load.c (nonexistent) +++ load.c (revision 842) @@ -0,0 +1,129 @@ +/* load.c --- loading object files into the M32C simulator. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +#include +#include +#include + +#include "bfd.h" + +#include "cpu.h" +#include "mem.h" + +int (*decode_opcode) () = 0; +int default_machine = 0; + +void +m32c_set_mach (unsigned long mach) +{ + switch (mach) + { + case bfd_mach_m16c: + m32c_set_cpu (CPU_M16C); + if (verbose) + fprintf (stderr, "[cpu: r8c/m16c]\n"); + break; + case bfd_mach_m32c: + m32c_set_cpu (CPU_M32C); + if (verbose) + fprintf (stderr, "[cpu: m32cm/m32c]\n"); + break; + default: + fprintf (stderr, "unknown m32c machine type 0x%lx\n", mach); + decode_opcode = 0; + break; + } +} + +void +m32c_load (bfd * prog) +{ + asection *s; + unsigned long mach = bfd_get_mach (prog); + unsigned long highest_addr_loaded = 0; + + if (mach == 0 && default_machine != 0) + mach = default_machine; + + m32c_set_mach (mach); + + for (s = prog->sections; s; s = s->next) + { +#if 0 + /* This was a good idea until we started storing the RAM data in + ROM, at which point everything was all messed up. The code + remains as a reminder. */ + if ((s->flags & SEC_ALLOC) && !(s->flags & SEC_READONLY)) + { + if (strcmp (bfd_get_section_name (prog, s), ".stack")) + { + int secend = + bfd_get_section_size (s) + bfd_section_lma (prog, s); + if (heaptop < secend && bfd_section_lma (prog, s) < 0x10000) + { + heaptop = heapbottom = secend; + } + } + } +#endif + if (s->flags & SEC_LOAD) + { + char *buf; + bfd_size_type size; + + size = bfd_get_section_size (s); + if (size <= 0) + continue; + + bfd_vma base = bfd_section_lma (prog, s); + if (verbose) + fprintf (stderr, "[load a=%08x s=%08x %s]\n", + (int) base, (int) size, bfd_get_section_name (prog, s)); + buf = (char *) malloc (size); + bfd_get_section_contents (prog, s, buf, 0, size); + mem_put_blk (base, buf, size); + free (buf); + if (highest_addr_loaded < base + size - 1 && size >= 4) + highest_addr_loaded = base + size - 1; + } + } + + if (strcmp (bfd_get_target (prog), "srec") == 0) + { + heaptop = heapbottom = 0; + switch (mach) + { + case bfd_mach_m16c: + if (highest_addr_loaded > 0x10000) + regs.r_pc = mem_get_si (0x000ffffc) & membus_mask; + else + regs.r_pc = mem_get_si (0x000fffc) & membus_mask; + break; + case bfd_mach_m32c: + regs.r_pc = mem_get_si (0x00fffffc) & membus_mask; + break; + } + } + else + regs.r_pc = prog->start_address; + if (verbose) + fprintf (stderr, "[start pc=%08x]\n", (unsigned int) regs.r_pc); +}
load.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: safe-fgets.c =================================================================== --- safe-fgets.c (nonexistent) +++ safe-fgets.c (revision 842) @@ -0,0 +1,69 @@ +/* safe-fgets.c --- like fgets, but allocates its own static buffer. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +#include +#include + +#include "safe-fgets.h" + +static char *line_buf = 0; +static int line_buf_size = 0; + +#define LBUFINCR 100 + +char * +safe_fgets (FILE * f) +{ + char *line_ptr; + + if (line_buf == 0) + { + line_buf = (char *) malloc (LBUFINCR); + line_buf_size = LBUFINCR; + } + + /* points to last byte */ + line_ptr = line_buf + line_buf_size - 1; + + /* so we can see if fgets put a 0 there */ + *line_ptr = 1; + if (fgets (line_buf, line_buf_size, f) == 0) + return 0; + + /* we filled the buffer? */ + while (line_ptr[0] == 0 && line_ptr[-1] != '\n') + { + /* Make the buffer bigger and read more of the line */ + line_buf_size += LBUFINCR; + line_buf = (char *) realloc (line_buf, line_buf_size); + + /* points to last byte again */ + line_ptr = line_buf + line_buf_size - 1; + /* so we can see if fgets put a 0 there */ + *line_ptr = 1; + + if (fgets (line_buf + line_buf_size - LBUFINCR - 1, LBUFINCR + 1, f) == + 0) + return 0; + } + + return line_buf; +}
safe-fgets.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: load.h =================================================================== --- load.h (nonexistent) +++ load.h (revision 842) @@ -0,0 +1,27 @@ +/* load.h --- interface to loading object files into the M32C simulator. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +#include "bfd.h" + +extern int default_machine; + +void m32c_set_mach (int mach); +void m32c_load (bfd *);
load.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: timer_a.h =================================================================== --- timer_a.h (nonexistent) +++ timer_a.h (revision 842) @@ -0,0 +1,14 @@ +typedef struct +{ + int count; + int reload; + int prescale; + int tcspr; + unsigned char bsr; + unsigned char mode; + unsigned char ic; +} Timer_A; + +extern Timer_A timer_a; + +extern void update_timer_a ();
timer_a.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: config.in =================================================================== --- config.in (nonexistent) +++ config.in (revision 842) @@ -0,0 +1,119 @@ +/* config.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +#undef ENABLE_NLS + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_ERRNO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FPU_CONTROL_H + +/* Define to 1 if you have the `getrusage' function. */ +#undef HAVE_GETRUSAGE + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +#undef HAVE_LIBNSL + +/* Define to 1 if you have the `socket' library (-lsocket). */ +#undef HAVE_LIBSOCKET + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_TCP_H + +/* Define to 1 if you have the `sigaction' function. */ +#undef HAVE_SIGACTION + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_RESOURCE_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_TERMIOS_H + +/* Define to 1 if you have the `time' function. */ +#undef HAVE_TIME + +/* Define to 1 if you have the header file. */ +#undef HAVE_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_ZLIB_H + +/* Define to 1 if you have the `__setfpucw' function. */ +#undef HAVE___SETFPUCW + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Additional package description */ +#undef PKGVERSION + +/* Bug reporting address */ +#undef REPORT_BUGS_TO + +/* Define as the return type of signal handlers (`int' or `void'). */ +#undef RETSIGTYPE + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS Index: safe-fgets.h =================================================================== --- safe-fgets.h (nonexistent) +++ safe-fgets.h (revision 842) @@ -0,0 +1,27 @@ +/* safe-fgets.h --- interface to safe version of fgets. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +#ifndef _safe_gets_h_ +#define _safe_gets_h_ + +char *safe_fgets (FILE * f); + +#endif
safe-fgets.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: int.c =================================================================== --- int.c (nonexistent) +++ int.c (revision 842) @@ -0,0 +1,76 @@ +/* int.c --- M32C interrupt handling. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +#include "int.h" +#include "cpu.h" +#include "mem.h" + +static void +trigger_interrupt (int addr, int clear_u) +{ + int s = get_reg (sp); + int f = get_reg (flags); + int p = get_reg (pc); + + if (clear_u) + set_flags (FLAGBIT_U, 0); + set_flags (FLAGBIT_I | FLAGBIT_D, 0); + + if (A16) + { + s -= 4; + put_reg (sp, s); + mem_put_hi (s, p); + mem_put_qi (s + 2, f); + mem_put_qi (s + 3, ((f >> 4) & 0x0f) | (p >> 16)); + } + else + { + s -= 6; + put_reg (sp, s); + mem_put_si (s, p); + mem_put_hi (s + 4, f); + } + put_reg (pc, mem_get_psi (addr)); +} + +void +trigger_fixed_interrupt (int addr) +{ + trigger_interrupt (addr, 1); +} + +void +trigger_based_interrupt (int vector) +{ + int addr = get_reg (intb) + vector * 4; + trigger_interrupt (addr, vector <= 31); +} + +void +trigger_peripheral_interrupt (int vector, int icaddr) +{ + unsigned char old_ic = mem_get_qi (icaddr); + int addr = get_reg (intb) + vector * 4; + trigger_interrupt (addr, 1); + put_reg (flags, (get_reg (flags) & 0x8fff) | ((old_ic & 7) << 12)); + mem_put_qi (icaddr, old_ic & ~ 0x08); +}
int.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: cpu.h =================================================================== --- cpu.h (nonexistent) +++ cpu.h (revision 842) @@ -0,0 +1,228 @@ +/* cpu.h --- declarations for the M32C core. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +extern int verbose; +extern int trace; +extern int enable_counting; + +extern int in_gdb; + +typedef unsigned char QI; +typedef unsigned short HI; +typedef unsigned long SI; +typedef unsigned long long DI; + +#define CPU_R8C 0x11 +#define CPU_M16C 0x12 +#define CPU_M32CM 0x23 +#define CPU_M32C 0x24 +extern int m32c_cpu; +void m32c_set_cpu (int cpu); + +#define A16 (m32c_cpu & 0x10) +#define A24 (m32c_cpu & 0x20) + +typedef struct +{ + HI r_r0; + HI r_r2; + HI r_r1; + HI r_r3; + SI r_a0; + SI r_a1; + SI r_sb; + SI r_fb; +} reg_bank_type; + +typedef struct +{ + reg_bank_type r[2]; + QI r_intbh; + HI r_intbl; + SI r_usp; + SI r_isp; + SI r_pc; + HI r_flags; +} regs_type; + +extern regs_type regs; +extern int addr_mask; +extern int membus_mask; + +#define FLAGBIT_C 0x0001 +#define FLAGBIT_D 0x0002 +#define FLAGBIT_Z 0x0004 +#define FLAGBIT_S 0x0008 +#define FLAGBIT_B 0x0010 +#define FLAGBIT_O 0x0020 +#define FLAGBIT_I 0x0040 +#define FLAGBIT_U 0x0080 + +#define REG_BANK (regs.r_flags & FLAG_B ? 1 : 0) + +typedef enum +{ + mem, + r0, r0h, r0l, + r1, r1h, r1l, + r2, r2r0, + r3, r3r1, + r3r1r2r0, + r3r2r1r0, + a0, + a1, a1a0, + sb, fb, + intb, intbl, intbh, + sp, usp, isp, pc, flags, + num_regs +} reg_id; + +extern char *reg_names[]; +extern int reg_bytes[]; + +extern unsigned int b2mask[]; +extern unsigned int b2signbit[]; +extern int b2maxsigned[]; +extern int b2minsigned[]; + +/* address of the opcode that just decoded, and thus caused the + exception. */ +extern int m32c_opcode_pc; + +void init_regs (void); +void stack_heap_stats (void); +void set_pointer_width (int bytes); +unsigned int get_reg (reg_id id); +DI get_reg_ll (reg_id id); +void put_reg (reg_id id, unsigned int value); +void put_reg_ll (reg_id id, DI value); + +void set_flags (int mask, int newbits); +void set_oszc (int value, int bytes, int c); +void set_szc (int value, int bytes, int c); +void set_osz (int value, int bytes); +void set_sz (int value, int bytes); +void set_zc (int z, int c); +void set_c (int c); + +const char *bits (int v, int b); + +typedef struct +{ + QI bytes; + QI mem; + HI mask; + union + { + unsigned int addr; + reg_id reg; + } u; +} srcdest; + +void decode_indirect (int src_indirect, int dest_indirect); +void decode_index (int src_addend, int dest_addend); + +/* r8c */ +srcdest decode_srcdest4 (int destcode, int bw); +srcdest decode_dest3 (int destcode, int bw); +srcdest decode_src2 (int srccode, int bw, int d); +srcdest decode_dest1 (int destcode, int bw); +srcdest decode_jumpdest (int destcode, int w); +srcdest decode_cr (int crcode); +srcdest decode_cr_b (int crcode, int bank); +#define CR_B_DCT0 0 +#define CR_B_INTB 1 +#define CR_B_DMA0 2 + +/* m32c */ +srcdest decode_dest23 (int ddd, int dd, int bytes); +srcdest decode_src23 (int sss, int ss, int bytes); +srcdest decode_src3 (int sss, int bytes); +srcdest decode_dest2 (int dd, int bytes); + +srcdest widen_sd (srcdest sd); +srcdest reg_sd (reg_id reg); + +/* Mask has the one appropriate bit set. */ +srcdest decode_bit (int destcode); +srcdest decode_bit11 (int op0); +int get_bit (srcdest sd); +void put_bit (srcdest sd, int val); +int get_bit2 (srcdest sd, int bit); +void put_bit2 (srcdest sd, int bit, int val); + +int get_src (srcdest sd); +void put_dest (srcdest sd, int value); + +int condition_true (int cond_id); + +#define FLAG(f) (regs.r_flags & f ? 1 : 0) +#define FLAG_C FLAG(FLAGBIT_C) +#define FLAG_D FLAG(FLAGBIT_D) +#define FLAG_Z FLAG(FLAGBIT_Z) +#define FLAG_S FLAG(FLAGBIT_S) +#define FLAG_B FLAG(FLAGBIT_B) +#define FLAG_O FLAG(FLAGBIT_O) +#define FLAG_I FLAG(FLAGBIT_I) +#define FLAG_U FLAG(FLAGBIT_U) + +/* Instruction step return codes. + Suppose one of the decode_* functions below returns a value R: + - If M32C_STEPPED (R), then the single-step completed normally. + - If M32C_HIT_BREAK (R), then the program hit a breakpoint. + - If M32C_EXITED (R), then the program has done an 'exit' system + call, and the exit code is M32C_EXIT_STATUS (R). + - If M32C_STOPPED (R), then a signal (number M32C_STOP_SIG (R)) was + generated. + + For building step return codes: + - M32C_MAKE_STEPPED is the return code for finishing a normal step. + - M32C_MAKE_HIT_BREAK is the return code for hitting a breakpoint. + - M32C_MAKE_EXITED (C) is the return code for exiting with status C. + - M32C_MAKE_STOPPED (S) is the return code for stopping on signal S. */ +#define M32C_MAKE_STEPPED() (0) +#define M32C_MAKE_HIT_BREAK() (1) +#define M32C_MAKE_EXITED(c) (((int) (c) << 8) + 2) +#define M32C_MAKE_STOPPED(s) (((int) (s) << 8) + 3) + +#define M32C_STEPPED(r) ((r) == M32C_MAKE_STEPPED ()) +#define M32C_HIT_BREAK(r) ((r) == M32C_MAKE_HIT_BREAK ()) +#define M32C_EXITED(r) (((r) & 0xff) == 2) +#define M32C_EXIT_STATUS(r) ((r) >> 8) +#define M32C_STOPPED(r) (((r) & 0xff) == 3) +#define M32C_STOP_SIG(r) ((r) >> 8) + +/* The step result for the current step. Global to allow + communication between the stepping function and the system + calls. */ +extern int step_result; + +/* Used to detect heap/stack collisions */ +extern unsigned int heaptop; +extern unsigned int heapbottom; + +/* Points to one of the below functions, set by m32c_load(). */ +extern int (*decode_opcode) (); + +extern int decode_r8c (); +extern int decode_m32c (); + +extern void trace_register_changes ();
cpu.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: syscalls.c =================================================================== --- syscalls.c (nonexistent) +++ syscalls.c (revision 842) @@ -0,0 +1,334 @@ +/* syscalls.c --- implement system calls for the M32C simulator. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +#include +#include +#include +#include +#include + +#include "gdb/callback.h" + +#include "cpu.h" +#include "mem.h" +#include "syscalls.h" + +#include "syscall.h" + +/* The current syscall callbacks we're using. */ +static struct host_callback_struct *callbacks; + +void +set_callbacks (struct host_callback_struct *cb) +{ + callbacks = cb; +} + + +/* A16 ABI: arg1 in r1l (QI) or r1 (HI) or stack + arg2 in r2 (HI) or stack + arg3..N on stack + padding: none + + A24 ABI: arg1 in r0l (QI) or r0 (HI) or stack + arg2..N on stack + padding: qi->hi + + return value in r0l (QI) r0 (HI) r2r0 (SI) + structs: pointer pushed on stack last + +*/ + +int argp, stackp; + +static int +arg (int bytes) +{ + int rv = 0; + argp++; + if (A16) + { + switch (argp) + { + case 1: + if (bytes == 1) + return get_reg (r1l); + if (bytes == 2) + return get_reg (r1); + break; + case 2: + if (bytes == 2) + return get_reg (r2); + break; + } + } + else + { + switch (argp) + { + case 1: + if (bytes == 1) + return get_reg (r0l); + if (bytes == 2) + return get_reg (r0); + break; + } + } + if (bytes == 0) + bytes = 2; + switch (bytes) + { + case 1: + rv = mem_get_qi (get_reg (sp) + stackp); + if (A24) + stackp++; + break; + case 2: + rv = mem_get_hi (get_reg (sp) + stackp); + break; + case 3: + rv = mem_get_psi (get_reg (sp) + stackp); + if (A24) + stackp++; + break; + case 4: + rv = mem_get_si (get_reg (sp) + stackp); + break; + } + stackp += bytes; + return rv; +} + +static void +read_target (char *buffer, int address, int count, int asciiz) +{ + char byte; + while (count > 0) + { + byte = mem_get_qi (address++); + *buffer++ = byte; + if (asciiz && (byte == 0)) + return; + count--; + } +} + +static void +write_target (char *buffer, int address, int count, int asciiz) +{ + char byte; + while (count > 0) + { + byte = *buffer++; + mem_put_qi (address++, byte); + if (asciiz && (byte == 0)) + return; + count--; + } +} + +#define PTRSZ (A16 ? 2 : 3) + +static char *callnames[] = { + "SYS_zero", + "SYS_exit", + "SYS_open", + "SYS_close", + "SYS_read", + "SYS_write", + "SYS_lseek", + "SYS_unlink", + "SYS_getpid", + "SYS_kill", + "SYS_fstat", + "SYS_sbrk", + "SYS_argvlen", + "SYS_argv", + "SYS_chdir", + "SYS_stat", + "SYS_chmod", + "SYS_utime", + "SYS_time", + "SYS_gettimeofday", + "SYS_times", + "SYS_link" +}; + +void +m32c_syscall (int id) +{ + static char buf[256]; + int rv; + + argp = 0; + stackp = A16 ? 3 : 4; + if (trace) + printf ("\033[31m/* SYSCALL(%d) = %s */\033[0m\n", id, callnames[id]); + switch (id) + { + case SYS_exit: + { + int ec = arg (2); + if (verbose) + printf ("[exit %d]\n", ec); + step_result = M32C_MAKE_EXITED (ec); + } + break; + + case SYS_open: + { + int path = arg (PTRSZ); + int oflags = arg (2); + int cflags = arg (2); + + read_target (buf, path, 256, 1); + if (trace) + printf ("open(\"%s\",0x%x,%#o) = ", buf, oflags, cflags); + + if (callbacks) + /* The callback vector ignores CFLAGS. */ + rv = callbacks->open (callbacks, buf, oflags); + else + { + int h_oflags = 0; + + if (oflags & 0x0001) + h_oflags |= O_WRONLY; + if (oflags & 0x0002) + h_oflags |= O_RDWR; + if (oflags & 0x0200) + h_oflags |= O_CREAT; + if (oflags & 0x0008) + h_oflags |= O_APPEND; + if (oflags & 0x0400) + h_oflags |= O_TRUNC; + rv = open (buf, h_oflags, cflags); + } + if (trace) + printf ("%d\n", rv); + put_reg (r0, rv); + } + break; + + case SYS_close: + { + int fd = arg (2); + + if (callbacks) + rv = callbacks->close (callbacks, fd); + else if (fd > 2) + rv = close (fd); + else + rv = 0; + if (trace) + printf ("close(%d) = %d\n", fd, rv); + put_reg (r0, rv); + } + break; + + case SYS_read: + { + int fd = arg (2); + int addr = arg (PTRSZ); + int count = arg (2); + + if (count > sizeof (buf)) + count = sizeof (buf); + if (callbacks) + rv = callbacks->read (callbacks, fd, buf, count); + else + rv = read (fd, buf, count); + if (trace) + printf ("read(%d,%d) = %d\n", fd, count, rv); + if (rv > 0) + write_target (buf, addr, rv, 0); + put_reg (r0, rv); + } + break; + + case SYS_write: + { + int fd = arg (2); + int addr = arg (PTRSZ); + int count = arg (2); + + if (count > sizeof (buf)) + count = sizeof (buf); + if (trace) + printf ("write(%d,0x%x,%d)\n", fd, addr, count); + read_target (buf, addr, count, 0); + if (trace) + fflush (stdout); + if (callbacks) + rv = callbacks->write (callbacks, fd, buf, count); + else + rv = write (fd, buf, count); + if (trace) + printf ("write(%d,%d) = %d\n", fd, count, rv); + put_reg (r0, rv); + } + break; + + case SYS_getpid: + put_reg (r0, 42); + break; + + case SYS_gettimeofday: + { + int tvaddr = arg (PTRSZ); + struct timeval tv; + + rv = gettimeofday (&tv, 0); + if (trace) + printf ("gettimeofday: %ld sec %ld usec to 0x%x\n", tv.tv_sec, + tv.tv_usec, tvaddr); + mem_put_si (tvaddr, tv.tv_sec); + mem_put_si (tvaddr + 4, tv.tv_usec); + put_reg (r0, rv); + } + break; + + case SYS_kill: + { + int pid = arg (2); + int sig = arg (2); + if (pid == 42) + { + if (verbose) + printf ("[signal %d]\n", sig); + step_result = M32C_MAKE_STOPPED (sig); + } + } + break; + + case 11: + { + int heaptop_arg = arg (PTRSZ); + if (trace) + printf ("sbrk: heap top set to %x\n", heaptop_arg); + heaptop = heaptop_arg; + if (heapbottom == 0) + heapbottom = heaptop_arg; + } + break; + + } +}
syscalls.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: int.h =================================================================== --- int.h (nonexistent) +++ int.h (revision 842) @@ -0,0 +1,24 @@ +/* int.h --- interface to M32C interrupt handling. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +extern void trigger_fixed_interrupt (int addr); +extern void trigger_based_interrupt (int vector); +extern void trigger_peripheral_interrupt (int vector, int icaddr);
int.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: syscalls.h =================================================================== --- syscalls.h (nonexistent) +++ syscalls.h (revision 842) @@ -0,0 +1,24 @@ +/* syscalls.h --- interface to syscalls for the M32C sim. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +struct host_callback_struct; +extern void set_callbacks (struct host_callback_struct *); +extern void m32c_syscall (int id);
syscalls.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: configure.in =================================================================== --- configure.in (nonexistent) +++ configure.in (revision 842) @@ -0,0 +1,33 @@ +dnl Process this file with autoconf to produce a configure script. + +dnl Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +dnl Contributed by Red Hat, Inc. +dnl +dnl This file is part of the GNU simulators. +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program. If not, see . +dnl +AC_PREREQ(2.5)dnl +AC_INIT(Makefile.in) +AC_CONFIG_HEADER(config.h:config.in) + +sinclude(../common/aclocal.m4) + +# Bugs in autoconf 2.59 break the call to SIM_AC_COMMON, hack around +# it by inlining the macro's contents. +sinclude(../common/common.m4) + +AC_CHECK_HEADERS(sys/select.h termios.h sys/socket.h netinet/in.h netinet/tcp.h) + +SIM_AC_OUTPUT
configure.in Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ChangeLog =================================================================== --- ChangeLog (nonexistent) +++ ChangeLog (revision 842) @@ -0,0 +1,169 @@ +2010-01-20 DJ Delorie + + * m32c.opc (MATH_OP): When doing subtraction, also set carry if + the result is zero. + +2010-01-09 Ralf Wildenhues + + * configure: Regenerate. + +2009-08-22 Ralf Wildenhues + + * config.in: Regenerate. + * configure: Likewise. + + * configure: Regenerate. + +2009-08-14 DJ Delorie + + * configure.in: Check for sys/select.h, termios.h, sys/socket.h, + netinet/in.h, and netinet/tcp.h. + * configure: Regenerate. + * config.in: Add those headers. + * main.c: Check for them. + (setup_tcp_console): Disable if no networking. + (main): Note missing networking or termios. + * mem.c: Check for those headers. + (stdin_ready): Disable if no termios. + (m32c_sim_restore_console): Disable if no termios. + (mem_get_byte): Disable console input if no termios. + +2009-01-06 Joel Sherrill + + * r8c.opc, m32c.opc: Add parentheses to remove warnings. + +2008-10-01 DJ Delorie + + * int.c (trigger_peripheral_interrupt): Clear interrupt pending + bit when peripheral interrupts are serviced. + +2008-07-11 Hans-Peter Nilsson + + * configure: Regenerate to track ../common/common.m4 changes. + * config.in: Ditto. + +2008-06-16 DJ Delorie + + * m32c.opc (BRK, GDBBRK): Remove debug logic. + * main.c (main): Add option to set raw console. + * mem.h (m32c_use_raw_console): Declare. + * mem.c (m32c_sim_restore_console): Only restore console if it's + been previously set. + (m32c_use_raw_console): Define. + (mem_get_byte): Set raw console if m32c_use_raw_console is set. + +2008-06-06 Vladimir Prus + Daniel Jacobowitz + Joseph Myers + + * configure: Regenerate. + +2008-06-06 DJ Delorie + + * Makefile.in: Add Timer A support. + * cpu.h (m32c_opcode_pc): New. + (in_gdb): New. + * gdb-if.c (sim_open): Add Timer A support. Support unbuffered + console. + * int.c (trigger_interrupt): Manage the U flag properly. + (trigger_based_interrupt): Likewise. + (trigger_fixed_interrupt): New. + (trigger_peripheral_interrupt): New. + * int.h (trigger_peripheral_interrupt): New. + * m32c.opc: Use m32c_opcode_pc throughout, as needed. + (decode_m32c): Detect jump-to-zero with traceback. + (BRK): Try to do the right thing, keeping track of whether we're + in gdb or not, and if the user has provided a handler or not. + (GBRK): Alternate break opcode for gdb, in case the user's app + needs to use BRK for itself. + (BRK2): Implement. + * main.c: Add Timer A support. Support TCP-based console. + (setup_tcp_console): New. + (main): Add Timer A support. Support TCP-based console. + * mem.h (m32c_sim_restore_console): New. + * mem.c: Add Timer A support. Support TCP-based console. + (mem_ptr): Enhance NULL pointer detection. + (stdin_ready): New. + (m32c_sim_restore_console): New. + (mem_get_byte): Check for console input ready. + (update_timer_a): New. + * r8c.opc (SSTR): Use r0l, not r0h. + (REIT): Fix return frame logic. + * reg.c (print_flags): New. + (trace_register_changes): Use it. + (m32c_dump_all_registers): New. + * timer_a.h: New. + + * load.c: Fix indentation. + * trace.c: Fix indentation. + * trace.h: Fix indentation. + +2006-06-26 DJ Delorie + + * r8c.opc (decode_r8c): Don't bother reading the destination + before moving a constant into it. Fix borrow comparison for SUB. + +2006-06-13 Richard Earnshaw + + * configure: Regenerated. + +2006-06-05 Daniel Jacobowitz + + * configure: Regenerated. + +2006-05-31 Daniel Jacobowitz + + * configure: Regenerated. + +2006-03-13 DJ Delorie + + * mem.c (mem_put_byte): Hook simulated UART to stdout. + (mem_put_hi): Hook in simulated trace port. + (mem_get_byte): Hook in simulated uart control port. + * opc2c: Be more picky about matching special comments. + * r8c.opc (shift_op): Limit shift counts to -16..16. + (BMcnd): Map conditional codes. + * reg.c (condition_true): Mask condition code to 4 bits. + * syscalls.c: Include local syscall.h. + * syscall.h: New, copied from libgloss. + +2005-10-06 Jim Blandy + + Simulator for Renesas M32C and M16C, by DJ Delorie , + with further work from Jim Blandy and + Kevin Buettner . + + * ChangeLog: New. + * Makefile.in: New. + * blinky.S: New. + * config.in: New. + * configure: New. + * configure.in: New. + * cpu.h: New. + * gdb-if.c: New. + * gloss.S: New. + * int.c: New. + * int.h: New. + * load.c: New. + * load.h: New. + * m32c.opc: New. + * main.c: New. + * mem.c: New. + * mem.h: New. + * misc.c: New. + * misc.h: New. + * opc2c.c: New. + * r8c.opc: New. + * reg.c: New. + * safe-fgets.c: New. + * safe-fgets.h: New. + * sample.S: New. + * sample.ld: New. + * sample2.c: New. + * srcdest.c: New. + * syscalls.c: New. + * syscalls.h: New. + * trace.c: New. + * trace.h: New. + +
ChangeLog Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: opc2c.c =================================================================== --- opc2c.c (nonexistent) +++ opc2c.c (revision 842) @@ -0,0 +1,726 @@ +/* opc2c.c --- generate C simulator code from from .opc file + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +#include +#include +#include +#include + +#include "safe-fgets.h" + +static int errors = 0; + +#define MAX_BYTES 10 + +typedef struct +{ + int varyno:16; + int byte:8; + int shift:8; +} VaryRef; + +typedef struct +{ + char nbytes; + char dbytes; + char id[MAX_BYTES * 8 + 1]; + unsigned char var_start[MAX_BYTES * 8 + 1]; + struct + { + unsigned char decodable_mask; + unsigned char decodable_bits; + } b[MAX_BYTES]; + char *comment; + int lineno; + int nlines; + char **lines; + struct Indirect *last_ind; + int semantics_label; + int nvaries; + VaryRef *vary; +} opcode; + +int n_opcodes; +opcode **opcodes; +opcode *op; + +typedef struct +{ + char *name; + int nlen; + unsigned char mask; + int n_patterns; + unsigned char *patterns; +} Vary; + +Vary **vary = 0; +int n_varies = 0; + +unsigned char cur_bits[MAX_BYTES + 1]; + +char *orig_filename; + +FILE *sim_log = 0; +#define lprintf if (sim_log) fprintf + +opcode prefix_text, suffix_text; + +typedef enum +{ + T_unused, + T_op, + T_indirect, + T_done +} OpType; + +typedef struct Indirect +{ + OpType type; + union + { + struct Indirect *ind; + opcode *op; + } u; +} Indirect; + +Indirect indirect[256]; + +static int +next_varybits (int bits, opcode * op, int byte) +{ + int mask = op->b[byte].decodable_mask; + int i; + + for (i = 0; i < 8; i++) + if (!(mask & (1 << i))) + { + if (bits & (1 << i)) + { + bits &= ~(1 << i); + } + else + { + bits |= (1 << i); + return bits; + } + } + return 0; +} + +static int +valid_varybits (int bits, opcode * op, int byte) +{ + if (op->nvaries) + { + int vn; + for (vn = 0; vn < op->nvaries; vn++) + { + int found = 0; + int i; + int ob; + + if (byte != op->vary[vn].byte) + continue; + Vary *v = vary[op->vary[vn].varyno]; + ob = (bits >> op->vary[vn].shift) & v->mask; + lprintf (sim_log, "varybits: vary %s ob %x\n", v->name, ob); + + for (i = 0; i < v->n_patterns; i++) + if (ob == v->patterns[i]) + { + lprintf (sim_log, " found at %d\n", i); + found = 1; + break; + } + if (!found) + return 0; + } + } + return 1; +} + +char * +prmb (int mask, int bits) +{ + static char buf[8][30]; + static int bn = 0; + char *bp; + + bn = (bn + 1) % 8; + bp = buf[bn]; + int i; + for (i = 0; i < 8; i++) + { + int bit = 0x80 >> i; + if (!(mask & bit)) + *bp++ = '-'; + else if (bits & bit) + *bp++ = '1'; + else + *bp++ = '0'; + if (i % 4 == 3) + *bp++ = ' '; + } + *--bp = 0; + return buf[bn]; +} + +static int +op_cmp (const void *va, const void *vb) +{ + const opcode *a = *(const opcode **) va; + const opcode *b = *(const opcode **) vb; + + if (a->nbytes != b->nbytes) + return a->nbytes - b->nbytes; + + return strcmp (a->id, b->id); +} + +void +dump_lines (opcode * op, int level, Indirect * ind) +{ + char *varnames[40]; + int i, vn = 0; + + if (op->semantics_label) + { + printf ("%*sgoto op_semantics_%d;\n", level, "", op->semantics_label); + return; + } + + if (ind != op->last_ind) + { + static int labelno = 0; + labelno++; + printf ("%*sop_semantics_%d:\n", level, "", labelno); + op->semantics_label = labelno; + } + + if (op->comment) + { + level += 2; + printf ("%*s{\n", level, ""); + printf ("%*s %s\n", level, "", op->comment); + } + + for (i = 0; i < op->nbytes * 8;) + { + if (isalpha (op->id[i])) + { + int byte = i >> 3; + int mask = 0; + int shift = 0; + char name[33]; + char *np = name; + while (op->id[i] && isalpha (op->id[i])) + { + mask = (mask << 1) | 1; + shift = 7 - (i & 7); + *np++ = op->id[i++]; + if (op->var_start[i]) + break; + } + *np = 0; + varnames[vn++] = strdup (name); + printf ("#line %d \"%s\"\n", op->lineno, orig_filename); + if (mask & ~0xff) + { + fprintf (stderr, "Error: variable %s spans bytes: %s\n", + name, op->comment); + errors++; + } + else if (shift && (mask != 0xff)) + printf ("%*s int %s AU = (op[%d] >> %d) & 0x%02x;\n", + level, "", name, byte, shift, mask); + else if (mask != 0xff) + printf ("%*s int %s AU = op[%d] & 0x%02x;\n", + level, "", name, byte, mask); + else + printf ("%*s int %s AU = op[%d];\n", level, "", name, byte); + } + else + i++; + } + if (op->comment) + { + printf ("%*s if (trace) {\n", level, ""); + printf ("%*s printf(\"\\033[33m%%s\\033[0m ", level, ""); + for (i = 0; i < op->nbytes; i++) + printf (" %%02x"); + printf ("\\n\""); + printf (",\n%*s \"%s\"", level, "", op->comment); + for (i = 0; i < op->nbytes; i++) + { + if (i == 0) + printf (",\n%*s op[%d]", level, "", i); + else + printf (", op[%d]", i); + } + printf (");\n"); + for (i = 0; i < vn; i++) + printf ("%*s printf(\" %s = 0x%%x%s\", %s);\n", level, "", + varnames[i], (i < vn - 1) ? "," : "\\n", varnames[i]); + printf ("%*s }\n", level, ""); + } + printf ("#line %d \"%s\"\n", op->lineno + 1, orig_filename); + for (i = 0; i < op->nlines; i++) + printf ("%*s%s", level, "", op->lines[i]); + if (op->comment) + printf ("%*s}\n", level, ""); +} + +void +store_opcode_bits (opcode * op, int byte, Indirect * ind) +{ + int bits = op->b[byte].decodable_bits; + + do + { + if (!valid_varybits (bits, op, byte)) + continue; + + switch (ind[bits].type) + { + case T_unused: + if (byte == op->dbytes - 1) + { + ind[bits].type = T_op; + ind[bits].u.op = op; + op->last_ind = ind; + break; + } + else + { + int i2; + ind[bits].type = T_indirect; + ind[bits].u.ind = (Indirect *) malloc (256 * sizeof (Indirect)); + for (i2 = 0; i2 < 256; i2++) + ind[bits].u.ind[i2].type = T_unused; + store_opcode_bits (op, byte + 1, ind[bits].u.ind); + } + break; + + case T_indirect: + if (byte < op->dbytes - 1) + store_opcode_bits (op, byte + 1, ind[bits].u.ind); + break; + + case T_op: + break; + + case T_done: + break; + } + } + while ((bits = next_varybits (bits, op, byte)) != 0); +} + +void +emit_indirect (Indirect * ind, int byte) +{ + int unsup = 0; + int j, n, mask; + + mask = 0; + for (j = 0; j < 256; j++) + { + switch (ind[j].type) + { + case T_indirect: + mask = 0xff; + break; + case T_op: + mask |= ind[j].u.op->b[byte].decodable_mask; + break; + case T_done: + case T_unused: + break; + } + } + + printf ("%*s GETBYTE();\n", byte * 6, ""); + printf ("%*s switch (op[%d] & 0x%02x) {\n", byte * 6, "", byte, mask); + for (j = 0; j < 256; j++) + if ((j & ~mask) == 0) + { + switch (ind[j].type) + { + case T_done: + break; + case T_unused: + unsup = 1; + break; + case T_op: + for (n = j; n < 256; n++) + if ((n & ~mask) == 0 + && ind[n].type == T_op && ind[n].u.op == ind[j].u.op) + { + ind[n].type = T_done; + printf ("%*s case 0x%02x:\n", byte * 6, "", n); + } + for (n = byte; n < ind[j].u.op->nbytes - 1; n++) + printf ("%*s GETBYTE();\n", byte * 6, ""); + dump_lines (ind[j].u.op, byte * 6 + 6, ind); + printf ("%*s break;\n", byte * 6, ""); + break; + case T_indirect: + printf ("%*s case 0x%02x:\n", byte * 6, "", j); + emit_indirect (ind[j].u.ind, byte + 1); + printf ("%*s break;\n", byte * 6, ""); + break; + } + } + if (unsup) + printf ("%*s default: UNSUPPORTED(); break;\n", byte * 6, ""); + printf ("%*s }\n", byte * 6, ""); +} + +static char * +pv_dup (char *p, char *ep) +{ + int n = ep - p; + char *rv = (char *) malloc (n + 1); + memcpy (rv, p, n); + rv[n] = 0; + return rv; +} + +static unsigned char +str2mask (char *str, char *ep) +{ + unsigned char rv = 0; + while (str < ep) + { + rv *= 2; + if (*str == '1') + rv += 1; + str++; + } + return rv; +} + +static void +process_vary (char *line) +{ + char *cp, *ep; + Vary *v = (Vary *) malloc (sizeof (Vary)); + + n_varies++; + if (vary) + vary = (Vary **) realloc (vary, n_varies * sizeof (Vary *)); + else + vary = (Vary **) malloc (n_varies * sizeof (Vary *)); + vary[n_varies - 1] = v; + + cp = line; + + for (cp = line; isspace (*cp); cp++); + for (ep = cp; *ep && !isspace (*ep); ep++); + + v->name = pv_dup (cp, ep); + v->nlen = strlen (v->name); + v->mask = (1 << v->nlen) - 1; + + v->n_patterns = 0; + v->patterns = (unsigned char *) malloc (1); + while (1) + { + for (cp = ep; isspace (*cp); cp++); + if (!isdigit (*cp)) + break; + for (ep = cp; *ep && !isspace (*ep); ep++); + v->n_patterns++; + v->patterns = (unsigned char *) realloc (v->patterns, v->n_patterns); + v->patterns[v->n_patterns - 1] = str2mask (cp, ep); + } +} + +static int +fieldcmp (opcode * op, int bit, char *name) +{ + int n = strlen (name); + if (memcmp (op->id + bit, name, n) == 0 + && (!isalpha (op->id[bit + n]) || op->var_start[bit + n])) + return 1; + return 0; +} + +static void +log_indirect (Indirect * ind, int byte) +{ + int i, j; + char *last_c = 0; + + for (i = 0; i < 256; i++) + { + + for (j = 0; j < byte; j++) + fprintf (sim_log, "%s ", prmb (255, cur_bits[j])); + fprintf (sim_log, "%s ", prmb (255, i)); + + switch (ind[i].type) + { + case T_op: + case T_done: + if (last_c && (ind[i].u.op->comment == last_c)) + fprintf (sim_log, "''\n"); + else + fprintf (sim_log, "%s\n", ind[i].u.op->comment); + last_c = ind[i].u.op->comment; + break; + case T_unused: + fprintf (sim_log, "unused\n"); + break; + case T_indirect: + fprintf (sim_log, "indirect\n"); + cur_bits[byte] = i; + log_indirect (ind[i].u.ind, byte + 1); + last_c = 0; + break; + } + } +} + +int +main (int argc, char **argv) +{ + char *line; + FILE *in; + int lineno = 0; + int i; + VaryRef *vlist; + + if (argc > 2 && strcmp (argv[1], "-l") == 0) + { + sim_log = fopen (argv[2], "w"); + fprintf (stderr, "sim_log: %s\n", argv[2]); + argc -= 2; + argv += 2; + } + + if (argc < 2) + { + fprintf (stderr, "usage: opc2c infile.opc > outfile.opc\n"); + exit (1); + } + + orig_filename = argv[1]; + in = fopen (argv[1], "r"); + if (!in) + { + fprintf (stderr, "Unable to open file %s for reading\n", argv[1]); + perror ("The error was"); + exit (1); + } + + n_opcodes = 0; + opcodes = (opcode **) malloc (sizeof (opcode *)); + op = &prefix_text; + op->lineno = 1; + while ((line = safe_fgets (in)) != 0) + { + lineno++; + if (strncmp (line, " /** ", 6) == 0 + && (isdigit (line[6]) || memcmp (line + 6, "VARY", 4) == 0)) + line += 2; + if (line[0] == '/' && line[1] == '*' && line[2] == '*') + { + if (strncmp (line, "/** */", 6) == 0) + { + op = &suffix_text; + op->lineno = lineno; + } + else if (strncmp (line, "/** VARY ", 9) == 0) + process_vary (line + 9); + else + { + char *lp; + int i, bit, byte; + int var_start = 1; + + n_opcodes++; + opcodes = + (opcode **) realloc (opcodes, n_opcodes * sizeof (opcode *)); + op = (opcode *) malloc (sizeof (opcode)); + opcodes[n_opcodes - 1] = op; + + op->nbytes = op->dbytes = 0; + memset (op->id, 0, sizeof (op->id)); + memset (op->var_start, 0, sizeof (op->var_start)); + for (i = 0; i < MAX_BYTES; i++) + { + op->b[i].decodable_mask = 0; + op->b[i].decodable_bits = 0; + } + op->comment = strdup (line); + op->comment[strlen (op->comment) - 1] = 0; + while (op->comment[0] && isspace (op->comment[0])) + op->comment++; + op->lineno = lineno; + op->nlines = 0; + op->lines = 0; + op->last_ind = 0; + op->semantics_label = 0; + op->nvaries = 0; + op->vary = 0; + + i = 0; + for (lp = line + 4; *lp; lp++) + { + bit = 7 - (i & 7); + byte = i >> 3; + + if (strncmp (lp, "*/", 2) == 0) + break; + else if ((lp[0] == ' ' && lp[1] == ' ') || (lp[0] == '\t')) + break; + else if (*lp == ' ') + var_start = 1; + else + { + if (*lp == '0' || *lp == '1') + { + op->b[byte].decodable_mask |= 1 << bit; + var_start = 1; + if (op->dbytes < byte + 1) + op->dbytes = byte + 1; + } + else if (var_start) + { + op->var_start[i] = 1; + var_start = 0; + } + if (*lp == '1') + op->b[byte].decodable_bits |= 1 << bit; + + op->nbytes = byte + 1; + op->id[i++] = *lp; + } + } + } + } + else + { + op->nlines++; + if (op->lines) + op->lines = + (char **) realloc (op->lines, op->nlines * sizeof (char *)); + else + op->lines = (char **) malloc (op->nlines * sizeof (char *)); + op->lines[op->nlines - 1] = strdup (line); + } + } + + { + int i, j; + for (i = 0; i < n_varies; i++) + { + Vary *v = vary[i]; + lprintf (sim_log, "V[%s] %d\n", v->name, v->nlen); + for (j = 0; j < v->n_patterns; j++) + lprintf (sim_log, " P %02x\n", v->patterns[j]); + } + } + + for (i = n_opcodes - 2; i >= 0; i--) + { + if (opcodes[i]->nlines == 0) + { + opcodes[i]->nlines = opcodes[i + 1]->nlines; + opcodes[i]->lines = opcodes[i + 1]->lines; + } + } + + for (i = 0; i < 256; i++) + indirect[i].type = T_unused; + + qsort (opcodes, n_opcodes, sizeof (opcodes[0]), op_cmp); + + vlist = (VaryRef *) malloc (n_varies * sizeof (VaryRef)); + + for (i = 0; i < n_opcodes; i++) + { + int j, b, v; + + for (j = 0; j < opcodes[i]->nbytes; j++) + lprintf (sim_log, "%s ", + prmb (opcodes[i]->b[j].decodable_mask, + opcodes[i]->b[j].decodable_bits)); + lprintf (sim_log, " %s\n", opcodes[i]->comment); + + for (j = 0; j < opcodes[i]->nbytes; j++) + { + for (b = 0; b < 8; b++) + if (isalpha (opcodes[i]->id[j * 8 + b])) + for (v = 0; v < n_varies; v++) + if (fieldcmp (opcodes[i], j * 8 + b, vary[v]->name)) + { + int nv = opcodes[i]->nvaries++; + if (nv) + opcodes[i]->vary = + (VaryRef *) realloc (opcodes[i]->vary, + (nv + 1) * sizeof (VaryRef)); + else + opcodes[i]->vary = + (VaryRef *) malloc ((nv + 1) * sizeof (VaryRef)); + + opcodes[i]->vary[nv].varyno = v; + opcodes[i]->vary[nv].byte = j; + opcodes[i]->vary[nv].shift = 8 - b - vary[v]->nlen; + lprintf (sim_log, "[vary %s shift %d]\n", + vary[v]->name, opcodes[i]->vary[nv].shift); + } + + } + } + + for (i = 0; i < n_opcodes; i++) + { + int i2; + int bytes = opcodes[i]->dbytes; + + lprintf (sim_log, "\nmask:"); + for (i2 = 0; i2 < opcodes[i]->nbytes; i2++) + lprintf (sim_log, " %02x", opcodes[i]->b[i2].decodable_mask); + lprintf (sim_log, "%*s%s\n", 13 - 3 * opcodes[i]->nbytes, "", + opcodes[i]->comment); + + lprintf (sim_log, "bits:"); + for (i2 = 0; i2 < opcodes[i]->nbytes; i2++) + lprintf (sim_log, " %02x", opcodes[i]->b[i2].decodable_bits); + lprintf (sim_log, "%*s(%s) %d byte%s\n", 13 - 3 * opcodes[i]->nbytes, + "", opcodes[i]->id, bytes, bytes == 1 ? "" : "s"); + + store_opcode_bits (opcodes[i], 0, indirect); + } + + dump_lines (&prefix_text, 0, 0); + + emit_indirect (indirect, 0); + + dump_lines (&suffix_text, 0, 0); + + if (sim_log) + log_indirect (indirect, 0); + + return errors; +}
opc2c.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: srcdest.c =================================================================== --- srcdest.c (nonexistent) +++ srcdest.c (revision 842) @@ -0,0 +1,778 @@ +/* srcdest.c --- decoding M32C addressing modes. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +#include +#include + +#include "cpu.h" +#include "mem.h" + +static int src_indirect = 0; +static int dest_indirect = 0; +static int src_addend = 0; +static int dest_addend = 0; + +static int +disp8 () +{ + int rv; + int tsave = trace; + + if (trace == 1) + trace = 0; + rv = mem_get_qi (get_reg (pc)); + regs.r_pc++; + trace = tsave; + return rv; +} + +static int +disp16 () +{ + int rv; + int tsave = trace; + + if (trace == 1) + trace = 0; + rv = mem_get_hi (get_reg (pc)); + regs.r_pc += 2; + trace = tsave; + return rv; +} + +static int +disp24 () +{ + int rv; + int tsave = trace; + + if (trace == 1) + trace = 0; + rv = mem_get_psi (get_reg (pc)); + regs.r_pc += 3; + trace = tsave; + return rv; +} + +static int +disp20 () +{ + return disp24 () & 0x000fffff; +} + +const char * +bits (int v, int b) +{ + static char buf[17]; + char *bp = buf + 16; + *bp = 0; + while (b) + { + *--bp = (v & 1) ? '1' : '0'; + v >>= 1; + b--; + } + return bp; +} + +static const char *the_bits = 0; + +void +decode_indirect (int si, int di) +{ + src_indirect = si; + dest_indirect = di; + if (trace && (si || di)) + printf ("indirect: s:%d d:%d\n", si, di); +} + +void +decode_index (int sa, int da) +{ + src_addend = sa; + dest_addend = da; + if (trace && (sa || da)) + printf ("index: s:%d d:%d\n", sa, da); +} + +srcdest +decode_srcdest4 (int destcode, int bw) +{ + srcdest sd; + sd.bytes = bw ? 2 : 1; + sd.mem = (destcode >= 6) ? 1 : 0; + static const char *dc_wnames[16] = { "r0", "r1", "r2", "r3", + "a0", "a1", "[a0]", "[a1]", + "disp8[a0]", "disp8[a1]", "disp8[sb]", "disp8[fb]", + "disp16[a0]", "disp16[a1]", "disp16[sb]", "disp16" + }; + static const char *dc_bnames[4] = { "r0l", "r0h", "r1l", "r1h" };; + + if (trace) + { + const char *n = dc_wnames[destcode]; + if (bw == 0 && destcode <= 3) + n = dc_bnames[destcode]; + if (!the_bits) + the_bits = bits (destcode, 4); + printf ("decode: %s (%d) : %s\n", the_bits, destcode, n); + the_bits = 0; + } + + switch (destcode) + { + case 0x0: + sd.u.reg = bw ? r0 : r0l; + break; + case 0x1: + sd.u.reg = bw ? r1 : r0h; + break; + case 0x2: + sd.u.reg = bw ? r2 : r1l; + break; + case 0x3: + sd.u.reg = bw ? r3 : r1h; + break; + case 0x4: + sd.u.reg = a0; + break; + case 0x5: + sd.u.reg = a1; + break; + case 0x6: + sd.u.addr = get_reg (a0); + break; + case 0x7: + sd.u.addr = get_reg (a1); + break; + case 0x8: + sd.u.addr = get_reg (a0) + disp8 (); + break; + case 0x9: + sd.u.addr = get_reg (a1) + disp8 (); + break; + case 0xa: + sd.u.addr = get_reg (sb) + disp8 (); + break; + case 0xb: + sd.u.addr = get_reg (fb) + sign_ext (disp8 (), 8); + break; + case 0xc: + sd.u.addr = get_reg (a0) + disp16 (); + break; + case 0xd: + sd.u.addr = get_reg (a1) + disp16 (); + break; + case 0xe: + sd.u.addr = get_reg (sb) + disp16 (); + break; + case 0xf: + sd.u.addr = disp16 (); + break; + default: + abort (); + } + if (sd.mem) + sd.u.addr &= addr_mask; + return sd; +} + +srcdest +decode_jumpdest (int destcode, int w) +{ + srcdest sd; + sd.bytes = w ? 2 : 3; + sd.mem = (destcode >= 6) ? 1 : 0; + static const char *dc_wnames[16] = { "r0", "r1", "r2", "r3", + "a0", "a1", "[a0]", "[a1]", + "disp8[a0]", "disp8[a1]", "disp8[sb]", "disp8[fb]", + "disp20[a0]", "disp20[a1]", "disp16[sb]", "abs16" + }; + static const char *dc_anames[4] = { "r0l", "r0h", "r1l", "r1h" }; + + if (trace) + { + const char *n = dc_wnames[destcode]; + if (w == 0 && destcode <= 3) + n = dc_anames[destcode]; + if (!the_bits) + the_bits = bits (destcode, 4); + printf ("decode: %s : %s\n", the_bits, n); + the_bits = 0; + } + + switch (destcode) + { + case 0x0: + sd.u.reg = w ? r0 : r2r0; + break; + case 0x1: + sd.u.reg = w ? r1 : r2r0; + break; + case 0x2: + sd.u.reg = w ? r2 : r3r1; + break; + case 0x3: + sd.u.reg = w ? r3 : r3r1; + break; + case 0x4: + sd.u.reg = w ? a0 : a1a0; + break; + case 0x5: + sd.u.reg = w ? a1 : a1a0; + break; + case 0x6: + sd.u.addr = get_reg (a0); + break; + case 0x7: + sd.u.addr = get_reg (a1); + break; + case 0x8: + sd.u.addr = get_reg (a0) + disp8 (); + break; + case 0x9: + sd.u.addr = get_reg (a1) + disp8 (); + break; + case 0xa: + sd.u.addr = get_reg (sb) + disp8 (); + break; + case 0xb: + sd.u.addr = get_reg (fb) + sign_ext (disp8 (), 8); + break; + case 0xc: + sd.u.addr = get_reg (a0) + disp20 (); + break; + case 0xd: + sd.u.addr = get_reg (a1) + disp20 (); + break; + case 0xe: + sd.u.addr = get_reg (sb) + disp16 (); + break; + case 0xf: + sd.u.addr = disp16 (); + break; + default: + abort (); + } + if (sd.mem) + sd.u.addr &= addr_mask; + return sd; +} + +srcdest +decode_dest3 (int destcode, int bw) +{ + static char map[8] = { -1, -1, -1, 1, 0, 10, 11, 15 }; + + the_bits = bits (destcode, 3); + return decode_srcdest4 (map[destcode], bw); +} + +srcdest +decode_src2 (int srccode, int bw, int d) +{ + static char map[4] = { 0, 10, 11, 15 }; + + the_bits = bits (srccode, 2); + return decode_srcdest4 (srccode ? map[srccode] : 1 - d, bw); +} + +static struct +{ + reg_id b_regno; + reg_id w_regno; + int is_memory; + int disp_bytes; + char *name; +} modes23[] = +{ + { + a0, a0, 1, 0, "[A0]"}, /* 0 0 0 0 0 */ + { + a1, a1, 1, 0, "[A1]"}, /* 0 0 0 0 1 */ + { + a0, a0, 0, 0, "A0"}, /* 0 0 0 1 0 */ + { + a1, a1, 0, 0, "A1"}, /* 0 0 0 1 1 */ + { + a0, a0, 1, 1, "dsp:8[A0]"}, /* 0 0 1 0 0 */ + { + a1, a1, 1, 1, "dsp:8[A1]"}, /* 0 0 1 0 1 */ + { + sb, sb, 1, 1, "dsp:8[SB]"}, /* 0 0 1 1 0 */ + { + fb, fb, 1, -1, "dsp:8[FB]"}, /* 0 0 1 1 1 */ + { + a0, a0, 1, 2, "dsp:16[A0]"}, /* 0 1 0 0 0 */ + { + a1, a1, 1, 2, "dsp:16[A1]"}, /* 0 1 0 0 1 */ + { + sb, sb, 1, 2, "dsp:16[SB]"}, /* 0 1 0 1 0 */ + { + fb, fb, 1, -2, "dsp:16[FB]"}, /* 0 1 0 1 1 */ + { + a0, a0, 1, 3, "dsp:24[A0]"}, /* 0 1 1 0 0 */ + { + a1, a1, 1, 3, "dsp:24[A1]"}, /* 0 1 1 0 1 */ + { + mem, mem, 1, 3, "abs24"}, /* 0 1 1 1 0 */ + { + mem, mem, 1, 2, "abs16"}, /* 0 1 1 1 1 */ + { + r0h, r2, 0, 0, "R0H/R2"}, /* 1 0 0 0 0 */ + { + r1h, r3, 0, 0, "R1H/R3"}, /* 1 0 0 0 1 */ + { + r0l, r0, 0, 0, "R0L/R0"}, /* 1 0 0 1 0 */ + { + r1l, r1, 0, 0, "R1L/R1"}, /* 1 0 0 1 1 */ +}; + +static srcdest +decode_sd23 (int bbb, int bb, int bytes, int ind, int add) +{ + srcdest sd; + int code = (bbb << 2) | bb; + + if (code >= sizeof (modes23) / sizeof (modes23[0])) + abort (); + + if (trace) + { + char *b1 = ""; + char *b2 = ""; + char ad[30]; + if (ind) + { + b1 = "["; + b2 = "]"; + } + if (add) + sprintf (ad, "%+d", add); + else + ad[0] = 0; + if (!the_bits) + the_bits = bits (code, 4); + printf ("decode: %s (%d) : %s%s%s%s\n", the_bits, code, b1, + modes23[code].name, ad, b2); + the_bits = 0; + } + + sd.bytes = bytes; + sd.mem = modes23[code].is_memory; + if (sd.mem) + { + if (modes23[code].w_regno == mem) + sd.u.addr = 0; + else + sd.u.addr = get_reg (modes23[code].w_regno); + switch (modes23[code].disp_bytes) + { + case 1: + sd.u.addr += disp8 (); + break; + case 2: + sd.u.addr += disp16 (); + break; + case -1: + sd.u.addr += sign_ext (disp8 (), 8); + break; + case -2: + sd.u.addr += sign_ext (disp16 (), 16); + break; + case 3: + sd.u.addr += disp24 (); + break; + default: + break; + } + if (add) + sd.u.addr += add; + if (ind) + sd.u.addr = mem_get_si (sd.u.addr & membus_mask); + sd.u.addr &= membus_mask; + } + else + { + sd.u.reg = (bytes > 1) ? modes23[code].w_regno : modes23[code].b_regno; + if (bytes == 3 || bytes == 4) + { + switch (sd.u.reg) + { + case r0: + sd.u.reg = r2r0; + break; + case r1: + sd.u.reg = r3r1; + break; + case r2: + abort (); + case r3: + abort (); + default:; + } + } + + } + return sd; +} + +srcdest +decode_dest23 (int ddd, int dd, int bytes) +{ + return decode_sd23 (ddd, dd, bytes, dest_indirect, dest_addend); +} + +srcdest +decode_src23 (int sss, int ss, int bytes) +{ + return decode_sd23 (sss, ss, bytes, src_indirect, src_addend); +} + +srcdest +decode_dest2 (int dd, int bytes) +{ + /* r0l/r0, abs16, dsp:8[SB], dsp:8[FB] */ + static char map[4] = { 0x12, 0x0f, 0x06, 0x07 }; + + the_bits = bits (dd, 2); + return decode_sd23 (map[dd] >> 2, map[dd] & 3, bytes, dest_indirect, + dest_addend); +} + +srcdest +decode_src3 (int sss, int bytes) +{ + /* r0, r1, a0, a1, r2, r3, N/A, N/A */ + static char map[8] = { 0x12, 0x13, 0x02, 0x03, 0x10, 0x11, 0, 0 }; + + the_bits = bits (sss, 3); + return decode_sd23 (map[sss] >> 2, map[sss] & 3, bytes, src_indirect, + src_addend); +} + +srcdest +decode_dest1 (int destcode, int bw) +{ + the_bits = bits (destcode, 1); + return decode_srcdest4 (destcode, bw); +} + +srcdest +decode_cr (int crcode) +{ + static int regcode[] = { 0, intbl, intbh, flags, isp, sp, sb, fb }; + srcdest sd; + sd.mem = 0; + sd.bytes = 2; + sd.u.reg = regcode[crcode & 7]; + return sd; +} + +srcdest +decode_cr_b (int crcode, int bank) +{ + /* FIXME: intbl, intbh, isp */ + static int regcode[3][8] = { + {0, 0, flags, 0, 0, 0, 0, 0}, + {intb, sp, sb, fb, 0, 0, 0, isp}, + {0, 0, 0, 0, 0, 0, 0, 0} + }; + srcdest sd; + sd.mem = 0; + sd.bytes = bank ? 3 : 2; + sd.u.reg = regcode[bank][crcode & 7]; + return sd; +} + +srcdest +widen_sd (srcdest sd) +{ + sd.bytes *= 2; + if (!sd.mem) + switch (sd.u.reg) + { + case r0l: + sd.u.reg = r0; + break; + case r0: + sd.u.reg = r2r0; + break; + case r1l: + sd.u.reg = r1; + break; + case r1: + sd.u.reg = r3r1; + break; + case a0: + if (A16) + sd.u.reg = a1a0; + break; + default: + break; + } + return sd; +} + +srcdest +reg_sd (reg_id reg) +{ + srcdest rv; + rv.bytes = reg_bytes[reg]; + rv.mem = 0; + rv.u.reg = reg; + return rv; +} + +int +get_src (srcdest sd) +{ + int v; + if (sd.mem) + { + switch (sd.bytes) + { + case 1: + v = mem_get_qi (sd.u.addr); + break; + case 2: + v = mem_get_hi (sd.u.addr); + break; + case 3: + v = mem_get_psi (sd.u.addr); + break; + case 4: + v = mem_get_si (sd.u.addr); + break; + default: + abort (); + } + } + else + { + v = get_reg (sd.u.reg); + switch (sd.bytes) + { + case 1: + v &= 0xff; + break; + case 2: + v &= 0xffff; + break; + case 3: + v &= 0xffffff; + break; + } + } + return v; +} + +void +put_dest (srcdest sd, int v) +{ + if (sd.mem) + { + switch (sd.bytes) + { + case 1: + mem_put_qi (sd.u.addr, v); + break; + case 2: + mem_put_hi (sd.u.addr, v); + break; + case 3: + mem_put_psi (sd.u.addr, v); + break; + case 4: + mem_put_si (sd.u.addr, v); + break; + } + } + else + { + switch (sd.bytes) + { + case 1: + v &= 0xff; + break; + case 2: + v &= 0xffff; + break; + case 3: + v &= 0xffffff; + break; + } + put_reg (sd.u.reg, v); + } +} + +srcdest +decode_bit (int destcode) +{ + srcdest sd; + int addr = 0; + static const char *dc_names[] = { "r0", "r1", "r2", "r3", + "a0", "a1", "[a0]", "[a1]", + "disp8[a0]", "disp8[a1]", "disp8[sb]", "disp8[fb]", + "disp16[a0]", "disp16[a1]", "disp16[sb]", "abs16" + }; + + if (trace) + { + const char *the_bits = bits (destcode, 4); + printf ("decode: %s : %s\n", the_bits, dc_names[destcode]); + } + + switch (destcode) + { + case 0: + sd.u.reg = r0; + break; + case 1: + sd.u.reg = r1; + break; + case 2: + sd.u.reg = r2; + break; + case 3: + sd.u.reg = r3; + break; + case 4: + sd.u.reg = a0; + break; + case 5: + sd.u.reg = a1; + break; + case 6: + addr = get_reg (a0); + break; + case 7: + addr = get_reg (a1); + break; + case 8: + addr = get_reg (a0) + disp8 (); + break; + case 9: + addr = get_reg (a1) + disp8 (); + break; + case 10: + addr = get_reg (sb) * 8 + disp8 (); + break; + case 11: + addr = get_reg (fb) * 8 + sign_ext (disp8 (), 8); + break; + case 12: + addr = get_reg (a0) + disp16 (); + break; + case 13: + addr = get_reg (a1) + disp16 (); + break; + case 14: + addr = get_reg (sb) + disp16 (); + break; + case 15: + addr = disp16 (); + break; + } + + if (destcode < 6) + { + int d = disp8 (); + sd.mem = 0; + sd.mask = 1 << (d & 0x0f); + } + else + { + addr &= addr_mask; + sd.mem = 1; + sd.mask = 1 << (addr & 7); + sd.u.addr = addr >> 3; + } + return sd; +} + +srcdest +decode_bit11 (int op0) +{ + srcdest sd; + sd.mask = 1 << (op0 & 7); + sd.mem = 1; + sd.u.addr = get_reg (sb) + disp8 (); + return sd; +} + +int +get_bit (srcdest sd) +{ + int b; + if (sd.mem) + b = mem_get_qi (sd.u.addr) & sd.mask; + else + b = get_reg (sd.u.reg) & sd.mask; + return b ? 1 : 0; +} + +void +put_bit (srcdest sd, int val) +{ + int b; + if (sd.mem) + b = mem_get_qi (sd.u.addr); + else + b = get_reg (sd.u.reg); + if (val) + b |= sd.mask; + else + b &= ~sd.mask; + if (sd.mem) + mem_put_qi (sd.u.addr, b); + else + put_reg (sd.u.reg, b); +} + +int +get_bit2 (srcdest sd, int bit) +{ + int b; + if (sd.mem) + b = mem_get_qi (sd.u.addr + (bit >> 3)) & (1 << (bit & 7)); + else + b = get_reg (sd.u.reg) & (1 << bit); + return b ? 1 : 0; +} + +void +put_bit2 (srcdest sd, int bit, int val) +{ + int b; + if (sd.mem) + b = mem_get_qi (sd.u.addr + (bit >> 3)); + else + b = get_reg (sd.u.reg); + if (val) + b |= (1 << (bit & 7)); + else + b &= ~(1 << (bit & 7)); + if (sd.mem) + mem_put_qi (sd.u.addr + (bit >> 3), b); + else + put_reg (sd.u.reg, b); +}
srcdest.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: reg.c =================================================================== --- reg.c (nonexistent) +++ reg.c (revision 842) @@ -0,0 +1,679 @@ +/* reg.c --- register set model for M32C simulator. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +#include +#include +#include + +#include "cpu.h" + +int verbose = 0; +int trace = 0; +int enable_counting = 0; +int in_gdb = 1; + +regs_type regs; +int addr_mask = 0xffff; +int membus_mask = 0xfffff; +int m32c_cpu = 0; +int step_result; +unsigned int heapbottom = 0; +unsigned int heaptop = 0; + +char *reg_names[] = { + "mem", + "r0", "r0h", "r0l", + "r1", "r1h", "r1l", + "r2", "r2r0", + "r3", "r3r1", + "r3r1r2r0", + "r3r2r1r0", + "a0", + "a1", "a1a0", + "sb", "fb", + "intb", "intbl", "intbh", + "sp", "usp", "isp", "pc", "flags" +}; + +int reg_bytes[] = { + 0, + 2, 1, 1, + 2, 1, 1, + 2, 4, + 2, 4, + 8, + 8, + 2, + 2, 4, + 2, 2, + 2, 1, 3, + 2, 2, 2, 3, 2 +}; + + +unsigned int b2mask[] = { 0, 0xff, 0xffff, 0xffffff, 0xffffffff }; +unsigned int b2signbit[] = { 0, (1 << 7), (1 << 15), (1 << 24), (1 << 31) }; +int b2maxsigned[] = { 0, 0x7f, 0x7fff, 0x7fffff, 0x7fffffff }; +int b2minsigned[] = { 0, -128, -32768, -8388608, -2147483647 - 1 }; + +static regs_type oldregs; + +int m32c_opcode_pc; + +void +init_regs (void) +{ + memset (®s, 0, sizeof (regs)); + memset (&oldregs, 0, sizeof (oldregs)); +} + +void +set_pointer_width (int bytes) +{ + if (bytes == 2) + { + addr_mask = 0xffff; + membus_mask = 0x000fffff; + reg_bytes[a0] = reg_bytes[a1] = reg_bytes[sb] = reg_bytes[fb] = + reg_bytes[sp] = reg_bytes[usp] = reg_bytes[isp] = 2; + } + else + { + addr_mask = 0xffffff; + membus_mask = 0x00ffffff; + reg_bytes[a0] = reg_bytes[a1] = reg_bytes[sb] = reg_bytes[fb] = + reg_bytes[sp] = reg_bytes[usp] = reg_bytes[isp] = 3; + } +} + +void +m32c_set_cpu (int cpu) +{ + switch (cpu) + { + case CPU_R8C: + case CPU_M16C: + set_pointer_width (2); + decode_opcode = decode_r8c; + break; + case CPU_M32CM: + case CPU_M32C: + set_pointer_width (3); + decode_opcode = decode_m32c; + break; + default: + abort (); + } + m32c_cpu = cpu; +} + +static unsigned int +get_reg_i (reg_id id) +{ + reg_bank_type *b = regs.r + (FLAG_B ? 1 : 0); + + switch (id) + { + case r0: + return b->r_r0; + case r0h: + return b->r_r0 >> 8; + case r0l: + return b->r_r0 & 0xff; + case r1: + return b->r_r1; + case r1h: + return b->r_r1 >> 8; + case r1l: + return b->r_r1 & 0xff; + case r2: + return b->r_r2; + case r2r0: + return b->r_r2 * 65536 + b->r_r0; + case r3: + return b->r_r3; + case r3r1: + return b->r_r3 * 65536 + b->r_r1; + + case a0: + return b->r_a0 & addr_mask; + case a1: + return b->r_a1 & addr_mask; + case a1a0: + return (b->r_a1 & 0xffff) * 65536 | (b->r_a0 & 0xffff); + + case sb: + return b->r_sb & addr_mask; + case fb: + return b->r_fb & addr_mask; + + case intb: + return regs.r_intbh * 65536 + regs.r_intbl; + case intbl: + return regs.r_intbl; + case intbh: + return regs.r_intbh; + + case sp: + return ((regs.r_flags & FLAGBIT_U) ? regs.r_usp : regs. + r_isp) & addr_mask; + case usp: + return regs.r_usp & addr_mask; + case isp: + return regs.r_isp & addr_mask; + + case pc: + return regs.r_pc & membus_mask; + case flags: + return regs.r_flags; + default: + abort (); + } +} + +unsigned int +get_reg (reg_id id) +{ + unsigned int rv = get_reg_i (id); + if (trace > ((id != pc && id != fb && id != sp) ? 0 : 1)) + printf ("get_reg (%s) = %0*x\n", reg_names[id], reg_bytes[id] * 2, rv); + return rv; +} + +DI +get_reg_ll (reg_id id) +{ + reg_bank_type *b = regs.r + (FLAG_B ? 1 : 0); + + switch (id) + { + case r3r1r2r0: + return ((DI) b->r_r3 << 48 + | (DI) b->r_r1 << 32 | (DI) b->r_r2 << 16 | (DI) b->r_r0); + case r3r2r1r0: + return ((DI) b->r_r3 << 48 + | (DI) b->r_r2 << 32 | (DI) b->r_r1 << 16 | (DI) b->r_r0); + default: + return get_reg (id); + } +} + +static int highest_sp = 0, lowest_sp = 0xffffff; + +void +stack_heap_stats () +{ + printf ("heap: %08x - %08x (%d bytes)\n", heapbottom, heaptop, + heaptop - heapbottom); + printf ("stack: %08x - %08x (%d bytes)\n", lowest_sp, highest_sp, + highest_sp - lowest_sp); +} + +void +put_reg (reg_id id, unsigned int v) +{ + if (trace > ((id != pc) ? 0 : 1)) + printf ("put_reg (%s) = %0*x\n", reg_names[id], reg_bytes[id] * 2, v); + + reg_bank_type *b = regs.r + (FLAG_B ? 1 : 0); + switch (id) + { + case r0: + b->r_r0 = v; + break; + case r0h: + b->r_r0 = (b->r_r0 & 0xff) | (v << 8); + break; + case r0l: + b->r_r0 = (b->r_r0 & 0xff00) | (v & 0xff); + break; + case r1: + b->r_r1 = v; + break; + case r1h: + b->r_r1 = (b->r_r1 & 0xff) | (v << 8); + break; + case r1l: + b->r_r1 = (b->r_r1 & 0xff00) | (v & 0xff); + break; + case r2: + b->r_r2 = v; + break; + case r2r0: + b->r_r0 = v & 0xffff; + b->r_r2 = v >> 16; + break; + case r3: + b->r_r3 = v; + break; + case r3r1: + b->r_r1 = v & 0xffff; + b->r_r3 = v >> 16; + break; + + case a0: + b->r_a0 = v & addr_mask; + break; + case a1: + b->r_a1 = v & addr_mask; + break; + case a1a0: + b->r_a0 = v & 0xffff; + b->r_a1 = v >> 16; + break; + + case sb: + b->r_sb = v & addr_mask; + break; + case fb: + b->r_fb = v & addr_mask; + break; + + case intb: + regs.r_intbl = v & 0xffff; + regs.r_intbh = v >> 16; + break; + case intbl: + regs.r_intbl = v & 0xffff; + break; + case intbh: + regs.r_intbh = v & 0xff; + break; + + case sp: + { + SI *spp; + if (regs.r_flags & FLAGBIT_U) + spp = ®s.r_usp; + else + spp = ®s.r_isp; + *spp = v & addr_mask; + if (*spp < heaptop) + { + printf ("collision: pc %08lx heap %08x stack %08lx\n", regs.r_pc, + heaptop, *spp); + exit (1); + } + if (*spp < lowest_sp) + lowest_sp = *spp; + if (*spp > highest_sp) + highest_sp = *spp; + break; + } + case usp: + regs.r_usp = v & addr_mask; + break; + case isp: + regs.r_isp = v & addr_mask; + break; + + case pc: + regs.r_pc = v & membus_mask; + break; + case flags: + regs.r_flags = v; + break; + default: + abort (); + } +} + +int +condition_true (int cond_id) +{ + int f; + if (A16) + { + static const char *cond_name[] = { + "C", "C&!Z", "Z", "S", + "!C", "!(C&!Z)", "!Z", "!S", + "(S^O)|Z", "O", "!(S^O)", "unk", + "!((S^O)|Z)", "!O", "S^O", "unk" + }; + switch (cond_id & 15) + { + case 0: + f = FLAG_C; + break; /* GEU/C */ + case 1: + f = FLAG_C & !FLAG_Z; + break; /* GTU */ + case 2: + f = FLAG_Z; + break; /* EQ/Z */ + case 3: + f = FLAG_S; + break; /* N */ + case 4: + f = !FLAG_C; + break; /* LTU/NC */ + case 5: + f = !(FLAG_C & !FLAG_Z); + break; /* LEU */ + case 6: + f = !FLAG_Z; + break; /* NE/NZ */ + case 7: + f = !FLAG_S; + break; /* PZ */ + + case 8: + f = (FLAG_S ^ FLAG_O) | FLAG_Z; + break; /* LE */ + case 9: + f = FLAG_O; + break; /* O */ + case 10: + f = !(FLAG_S ^ FLAG_O); + break; /* GE */ + case 12: + f = !((FLAG_S ^ FLAG_O) | FLAG_Z); + break; /* GT */ + case 13: + f = !FLAG_O; + break; /* NO */ + case 14: + f = FLAG_S ^ FLAG_O; + break; /* LT */ + + default: + f = 0; + break; + } + if (trace) + printf ("cond[%d] %s = %s\n", cond_id, cond_name[cond_id & 15], + f ? "true" : "false"); + } + else + { + static const char *cond_name[] = { + "!C", "LEU", "!Z", "PZ", + "!O", "GT", "GE", "?", + "C", "GTU", "Z", "N", + "O", "LE", "LT", "!?" + }; + switch (cond_id & 15) + { + case 0: + f = !FLAG_C; + break; /* LTU/NC */ + case 1: + f = !(FLAG_C & !FLAG_Z); + break; /* LEU */ + case 2: + f = !FLAG_Z; + break; /* NE/NZ */ + case 3: + f = !FLAG_S; + break; /* PZ */ + + case 4: + f = !FLAG_O; + break; /* NO */ + case 5: + f = !((FLAG_S ^ FLAG_O) | FLAG_Z); + break; /* GT */ + case 6: + f = !(FLAG_S ^ FLAG_O); + break; /* GE */ + + case 8: + f = FLAG_C; + break; /* GEU/C */ + case 9: + f = FLAG_C & !FLAG_Z; + break; /* GTU */ + case 10: + f = FLAG_Z; + break; /* EQ/Z */ + case 11: + f = FLAG_S; + break; /* N */ + + case 12: + f = FLAG_O; + break; /* O */ + case 13: + f = (FLAG_S ^ FLAG_O) | FLAG_Z; + break; /* LE */ + case 14: + f = FLAG_S ^ FLAG_O; + break; /* LT */ + + default: + f = 0; + break; + } + if (trace) + printf ("cond[%d] %s = %s\n", cond_id, cond_name[cond_id & 15], + f ? "true" : "false"); + } + return f; +} + +void +set_flags (int mask, int newbits) +{ + int i; + regs.r_flags &= ~mask; + regs.r_flags |= newbits & mask; + if (trace) + { + printf ("flags now \033[32m %d", (regs.r_flags >> (A16 ? 8 : 12)) & 7); + for (i = 7; i >= 0; i--) + if (regs.r_flags & (1 << i)) + putchar ("CDZSBOIU"[i]); + else + putchar ('-'); + printf ("\033[0m\n"); + } +} + +void +set_oszc (int value, int b, int c) +{ + int mask = b2mask[b]; + int f = 0; + + if (c) + f |= FLAGBIT_C; + if ((value & mask) == 0) + f |= FLAGBIT_Z; + if (value & b2signbit[b]) + f |= FLAGBIT_S; + if ((value > b2maxsigned[b]) || (value < b2minsigned[b])) + f |= FLAGBIT_O; + set_flags (FLAGBIT_Z | FLAGBIT_S | FLAGBIT_O | FLAGBIT_C, f); +} + +void +set_szc (int value, int b, int c) +{ + int mask = b2mask[b]; + int f = 0; + + if (c) + f |= FLAGBIT_C; + if ((value & mask) == 0) + f |= FLAGBIT_Z; + if (value & b2signbit[b]) + f |= FLAGBIT_S; + set_flags (FLAGBIT_Z | FLAGBIT_S | FLAGBIT_C, f); +} + +void +set_osz (int value, int b) +{ + int mask = b2mask[b]; + int f = 0; + + if ((value & mask) == 0) + f |= FLAGBIT_Z; + if (value & b2signbit[b]) + f |= FLAGBIT_S; + if (value & ~mask && (value & ~mask) != ~mask) + f |= FLAGBIT_O; + set_flags (FLAGBIT_Z | FLAGBIT_S | FLAGBIT_O, f); +} + +void +set_sz (int value, int b) +{ + int mask = b2mask[b]; + int f = 0; + + if ((value & mask) == 0) + f |= FLAGBIT_Z; + if (value & b2signbit[b]) + f |= FLAGBIT_S; + set_flags (FLAGBIT_Z | FLAGBIT_S, f); +} + +void +set_zc (int z, int c) +{ + set_flags (FLAGBIT_C | FLAGBIT_Z, + (c ? FLAGBIT_C : 0) | (z ? FLAGBIT_Z : 0)); +} + +void +set_c (int c) +{ + set_flags (FLAGBIT_C, c ? FLAGBIT_C : 0); +} + +void +put_reg_ll (reg_id id, DI v) +{ + reg_bank_type *b = regs.r + (FLAG_B ? 1 : 0); + + switch (id) + { + case r3r1r2r0: + b->r_r3 = v >> 48; + b->r_r1 = v >> 32; + b->r_r2 = v >> 16; + b->r_r0 = v; + break; + case r3r2r1r0: + b->r_r3 = v >> 48; + b->r_r2 = v >> 32; + b->r_r1 = v >> 16; + b->r_r0 = v; + break; + default: + put_reg (id, v); + } +} + +static void +print_flags (int f) +{ + int i; + static char fn[] = "CDZSBOIU"; + printf ("%d.", (f >> 12) & 7); + for (i = 7; i >= 0; i--) + if (f & (1 << i)) + putchar (fn[i]); +} + +#define TRC(f,n, id) \ + if (oldregs.f != regs.f) \ + { \ + printf(" %s %0*x:%0*x", n, \ + reg_bytes[id]*2, (unsigned int)oldregs.f, \ + reg_bytes[id]*2, (unsigned int)regs.f); \ + oldregs.f = regs.f; \ + } + +void +trace_register_changes () +{ + if (!trace) + return; + printf ("\033[36mREGS:"); + TRC (r[0].r_r0, "r0", r0); + TRC (r[0].r_r1, "r1", r1); + TRC (r[0].r_r2, "r2", r2); + TRC (r[0].r_r3, "r3", r3); + TRC (r[0].r_a0, "a0", a0); + TRC (r[0].r_a1, "a1", a1); + TRC (r[0].r_sb, "sb", sb); + TRC (r[0].r_fb, "fb", fb); + TRC (r[1].r_r0, "r0'", r0); + TRC (r[1].r_r1, "r1'", r1); + TRC (r[1].r_r2, "r2'", r2); + TRC (r[1].r_r3, "r3'", r3); + TRC (r[1].r_a0, "a0'", a0); + TRC (r[1].r_a1, "a1'", a1); + TRC (r[1].r_sb, "sb'", sb); + TRC (r[1].r_fb, "fb'", fb); + TRC (r_intbh, "intbh", intbh); + TRC (r_intbl, "intbl", intbl); + TRC (r_usp, "usp", usp); + TRC (r_isp, "isp", isp); + TRC (r_pc, "pc", pc); + if (oldregs.r_flags != regs.r_flags) + { + printf (" flags "); + print_flags (oldregs.r_flags); + printf (":"); + print_flags (regs.r_flags); + } + printf ("\033[0m\n"); +} + +#define DRC(f, n, id) \ + printf(" %-3s %0*x", n, \ + reg_bytes[id]*2, (unsigned int)regs.f); \ + +void +m32c_dump_all_registers () +{ + printf ("\033[36mREGS:"); + DRC (r[0].r_r0, "r0", r0); + DRC (r[0].r_r1, "r1", r1); + DRC (r[0].r_r2, "r2", r2); + DRC (r[0].r_r3, "r3", r3); + DRC (r[0].r_a0, "a0", a0); + DRC (r[0].r_a1, "a1", a1); + DRC (r[0].r_sb, "sb", sb); + DRC (r[0].r_fb, "fb", fb); + printf ("\n "); + DRC (r[1].r_r0, "r0'", r0); + DRC (r[1].r_r1, "r1'", r1); + DRC (r[1].r_r2, "r2'", r2); + DRC (r[1].r_r3, "r3'", r3); + DRC (r[1].r_a0, "a0'", a0); + DRC (r[1].r_a1, "a1'", a1); + DRC (r[1].r_sb, "sb'", sb); + DRC (r[1].r_fb, "fb'", fb); + printf (" \n"); + DRC (r_intbh, "intbh", intbh); + DRC (r_intbl, "intbl", intbl); + DRC (r_usp, "usp", usp); + DRC (r_isp, "isp", isp); + DRC (r_pc, "pc", pc); + printf (" flags "); + print_flags (regs.r_flags); + printf ("\033[0m\n"); + /*sim_disasm_one (); */ +}
reg.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mem.c =================================================================== --- mem.c (nonexistent) +++ mem.c (revision 842) @@ -0,0 +1,614 @@ +/* mem.c --- memory for M32C simulator. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_SYS_SELECT_H +#include +#endif +#ifdef HAVE_TERMIOS_H +#include +#endif + +#include "mem.h" +#include "cpu.h" +#include "syscalls.h" +#include "misc.h" +#ifdef TIMER_A +#include "int.h" +#include "timer_a.h" +#endif + +#define L1_BITS (10) +#define L2_BITS (10) +#define OFF_BITS (12) + +#define L1_LEN (1 << L1_BITS) +#define L2_LEN (1 << L2_BITS) +#define OFF_LEN (1 << OFF_BITS) + +static unsigned char **pt[L1_LEN]; + +#ifdef HAVE_TERMIOS_H +int m32c_console_ifd = 0; +#endif +int m32c_console_ofd = 1; +#ifdef HAVE_TERMIOS_H +int m32c_use_raw_console = 0; +#endif + +#ifdef TIMER_A +Timer_A timer_a; +#endif + +/* [ get=0/put=1 ][ byte size ] */ +static unsigned int mem_counters[2][5]; + +#define COUNT(isput,bytes) \ + if (verbose && enable_counting) mem_counters[isput][bytes]++ + +void +init_mem (void) +{ + int i, j; + + for (i = 0; i < L1_LEN; i++) + if (pt[i]) + { + for (j = 0; j < L2_LEN; j++) + if (pt[i][j]) + free (pt[i][j]); + free (pt[i]); + } + memset (pt, 0, sizeof (pt)); + memset (mem_counters, 0, sizeof (mem_counters)); +} + +static unsigned char * +mem_ptr (address) +{ + static int recursing = 0; + int pt1 = (address >> (L2_BITS + OFF_BITS)) & ((1 << L1_BITS) - 1); + int pt2 = (address >> OFF_BITS) & ((1 << L2_BITS) - 1); + int pto = address & ((1 << OFF_BITS) - 1); + + if (address == 0 && !recursing) + { + recursing = 1; + put_reg (pc, m32c_opcode_pc); + printf ("NULL pointer dereference at pc=0x%x\n", get_reg (pc)); + step_result = M32C_MAKE_HIT_BREAK (); +#if 0 + /* This code can be re-enabled to help diagnose NULL pointer + bugs that aren't debuggable in GDB. */ + m32c_dump_all_registers (); + exit (1); +#endif + } + + if (pt[pt1] == 0) + pt[pt1] = (unsigned char **) calloc (L2_LEN, sizeof (char **)); + if (pt[pt1][pt2] == 0) + { + pt[pt1][pt2] = (unsigned char *) malloc (OFF_LEN); + memset (pt[pt1][pt2], 0, OFF_LEN); + } + + return pt[pt1][pt2] + pto; +} + +static void +used (int rstart, int i, int j) +{ + int rend = i << (L2_BITS + OFF_BITS); + rend += j << OFF_BITS; + if (rstart == 0xe0000 && rend == 0xe1000) + return; + printf ("mem: %08x - %08x (%dk bytes)\n", rstart, rend - 1, + (rend - rstart) / 1024); +} + +static char * +mcs (int isput, int bytes) +{ + return comma (mem_counters[isput][bytes]); +} + +void +mem_usage_stats () +{ + int i, j; + int rstart = 0; + int pending = 0; + + for (i = 0; i < L1_LEN; i++) + if (pt[i]) + { + for (j = 0; j < L2_LEN; j++) + if (pt[i][j]) + { + if (!pending) + { + pending = 1; + rstart = (i << (L2_BITS + OFF_BITS)) + (j << OFF_BITS); + } + } + else if (pending) + { + pending = 0; + used (rstart, i, j); + } + } + else + { + if (pending) + { + pending = 0; + used (rstart, i, 0); + } + } + /* mem foo: 123456789012 123456789012 123456789012 123456789012 + 123456789012 */ + printf (" byte short pointer long" + " fetch\n"); + printf ("mem get: %12s %12s %12s %12s %12s\n", mcs (0, 1), mcs (0, 2), + mcs (0, 3), mcs (0, 4), mcs (0, 0)); + printf ("mem put: %12s %12s %12s %12s\n", mcs (1, 1), mcs (1, 2), + mcs (1, 3), mcs (1, 4)); +} + +static int tpr = 0; +static void +s (int address, char *dir) +{ + if (tpr == 0) + printf ("MEM[%0*x] %s", membus_mask == 0xfffff ? 5 : 6, address, dir); + tpr++; +} + +#define S(d) if (trace) s(address, d) +static void +e () +{ + if (!trace) + return; + tpr--; + if (tpr == 0) + printf ("\n"); +} + +#define E() if (trace) e() + +extern int m32c_disassemble; + +void +mem_put_byte (int address, unsigned char value) +{ + unsigned char *m; + address &= membus_mask; + m = mem_ptr (address); + if (trace) + printf (" %02x", value); + *m = value; + switch (address) + { + case 0x00e1: + { + static int old_led = -1; + static char *led_on[] = + { "\033[31m O ", "\033[32m O ", "\033[34m O " }; + static char *led_off[] = { "\033[0m · ", "\033[0m · ", "\033[0m · " }; + int i; + if (old_led != value) + { + fputs (" ", stdout); + for (i = 0; i < 3; i++) + if (value & (1 << i)) + fputs (led_off[i], stdout); + else + fputs (led_on[i], stdout); + fputs ("\033[0m\r", stdout); + fflush (stdout); + old_led = value; + } + } + break; +#ifdef TIMER_A + /* M32C Timer A */ + case 0x346: /* TA0low */ + timer_a.count = (timer_a.count & 0xff00) | value; + timer_a.reload = timer_a.count; + break; + case 0x347: /* TA0high */ + timer_a.count = (timer_a.count & 0x00ff) | (value << 8); + timer_a.reload = timer_a.count; + break; + case 0x340: /* TABSR */ + timer_a.bsr = value; + break; + case 0x356: /* TA0MR */ + timer_a.mode = value; + break; + case 0x35f: /* TCSPR */ + timer_a.tcspr = value; + break; + case 0x006c: /* TA0IC */ + timer_a.ic = value; + break; + + /* R8C Timer RA */ + case 0x100: /* TRACR */ + timer_a.bsr = value; + break; + case 0x102: /* TRAMR */ + timer_a.mode = value; + break; + case 0x104: /* TRA */ + timer_a.count = value; + timer_a.reload = value; + break; + case 0x103: /* TRAPRE */ + timer_a.tcspr = value; + break; + case 0x0056: /* TA0IC */ + timer_a.ic = value; + break; +#endif + + case 0x2ea: /* m32c uart1tx */ + case 0x3aa: /* m16c uart1tx */ + { + static int pending_exit = 0; + if (value == 0) + { + if (pending_exit) + { + step_result = M32C_MAKE_EXITED (value); + return; + } + pending_exit = 1; + } + else + { + write (m32c_console_ofd, &value, 1); + } + } + break; + + case 0x400: + m32c_syscall (value); + break; + + case 0x401: + putchar (value); + break; + + case 0x402: + printf ("SimTrace: %06lx %02x\n", regs.r_pc, value); + break; + + case 0x403: + printf ("SimTrap: %06lx %02x\n", regs.r_pc, value); + abort (); + } +} + +void +mem_put_qi (int address, unsigned char value) +{ + S ("<="); + mem_put_byte (address, value & 0xff); + E (); + COUNT (1, 1); +} + +void +mem_put_hi (int address, unsigned short value) +{ + if (address == 0x402) + { + printf ("SimTrace: %06lx %04x\n", regs.r_pc, value); + return; + } + S ("<="); + mem_put_byte (address, value & 0xff); + mem_put_byte (address + 1, value >> 8); + E (); + COUNT (1, 2); +} + +void +mem_put_psi (int address, unsigned long value) +{ + S ("<="); + mem_put_byte (address, value & 0xff); + mem_put_byte (address + 1, (value >> 8) & 0xff); + mem_put_byte (address + 2, value >> 16); + E (); + COUNT (1, 3); +} + +void +mem_put_si (int address, unsigned long value) +{ + S ("<="); + mem_put_byte (address, value & 0xff); + mem_put_byte (address + 1, (value >> 8) & 0xff); + mem_put_byte (address + 2, (value >> 16) & 0xff); + mem_put_byte (address + 3, (value >> 24) & 0xff); + E (); + COUNT (1, 4); +} + +void +mem_put_blk (int address, void *bufptr, int nbytes) +{ + S ("<="); + if (enable_counting) + mem_counters[1][1] += nbytes; + while (nbytes--) + mem_put_byte (address++, *(unsigned char *) bufptr++); + E (); +} + +unsigned char +mem_get_pc () +{ + unsigned char *m = mem_ptr (regs.r_pc & membus_mask); + COUNT (0, 0); + return *m; +} + +#ifdef HAVE_TERMIOS_H +static int console_raw = 0; +static struct termios oattr; + +static int +stdin_ready () +{ + fd_set ifd; + int n; + struct timeval t; + + t.tv_sec = 0; + t.tv_usec = 0; + FD_ZERO (&ifd); + FD_SET (m32c_console_ifd, &ifd); + n = select (1, &ifd, 0, 0, &t); + return n > 0; +} + +void +m32c_sim_restore_console () +{ + if (console_raw) + tcsetattr (m32c_console_ifd, TCSANOW, &oattr); + console_raw = 0; +} +#endif + +static unsigned char +mem_get_byte (int address) +{ + unsigned char *m; + address &= membus_mask; + m = mem_ptr (address); + switch (address) + { +#ifdef HAVE_TERMIOS_H + case 0x2ed: /* m32c uart1c1 */ + case 0x3ad: /* m16c uart1c1 */ + + if (!console_raw && m32c_use_raw_console) + { + struct termios attr; + tcgetattr (m32c_console_ifd, &attr); + tcgetattr (m32c_console_ifd, &oattr); + /* We want each key to be sent as the user presses them. */ + attr.c_lflag &= ~(ICANON | ECHO | ECHOE); + tcsetattr (m32c_console_ifd, TCSANOW, &attr); + console_raw = 1; + atexit (m32c_sim_restore_console); + } + + if (stdin_ready ()) + return 0x02; /* tx empty and rx full */ + else + return 0x0a; /* transmitter empty */ + + case 0x2ee: /* m32c uart1 rx */ + { + char c; + read (m32c_console_ifd, &c, 1); + if (m32c_console_ifd == 0 && c == 3) /* Ctrl-C */ + { + printf ("Ctrl-C!\n"); + exit (0); + } + + if (m32c_console_ifd != 1) + { + if (isgraph (c)) + printf ("\033[31m%c\033[0m", c); + else + printf ("\033[31m%02x\033[0m", c); + } + return c; + } +#endif + +#ifdef TIMER_A + case 0x346: /* TA0low */ + return timer_a.count & 0xff; + case 0x347: /* TA0high */ + return (timer_a.count >> 8) & 0xff; + case 0x104: /* TRA */ + return timer_a.count; +#endif + + default: + /* In case both cases above are not included. */ + ; + } + + S ("=>"); + if (trace) + printf (" %02x", *m); + E (); + return *m; +} + +unsigned char +mem_get_qi (int address) +{ + unsigned char rv; + S ("=>"); + rv = mem_get_byte (address); + COUNT (0, 1); + E (); + return rv; +} + +unsigned short +mem_get_hi (int address) +{ + unsigned short rv; + S ("=>"); + rv = mem_get_byte (address); + rv |= mem_get_byte (address + 1) * 256; + COUNT (0, 2); + E (); + return rv; +} + +unsigned long +mem_get_psi (int address) +{ + unsigned long rv; + S ("=>"); + rv = mem_get_byte (address); + rv |= mem_get_byte (address + 1) * 256; + rv |= mem_get_byte (address + 2) * 65536; + COUNT (0, 3); + E (); + return rv; +} + +unsigned long +mem_get_si (int address) +{ + unsigned long rv; + S ("=>"); + rv = mem_get_byte (address); + rv |= mem_get_byte (address + 1) << 8; + rv |= mem_get_byte (address + 2) << 16; + rv |= mem_get_byte (address + 3) << 24; + COUNT (0, 4); + E (); + return rv; +} + +void +mem_get_blk (int address, void *bufptr, int nbytes) +{ + S ("=>"); + if (enable_counting) + mem_counters[0][1] += nbytes; + while (nbytes--) + *(char *) bufptr++ = mem_get_byte (address++); + E (); +} + +int +sign_ext (int v, int bits) +{ + if (bits < 32) + { + v &= (1 << bits) - 1; + if (v & (1 << (bits - 1))) + v -= (1 << bits); + } + return v; +} + +#if TIMER_A +void +update_timer_a () +{ + if (timer_a.bsr & 1) + { + timer_a.prescale--; + if (timer_a.prescale < 0) + { + if (A24) + { + switch (timer_a.mode & 0xc0) + { + case 0x00: + timer_a.prescale = 0; + break; + case 0x40: + timer_a.prescale = 8; + break; + case 0x80: + timer_a.prescale = timer_a.tcspr & 0x0f; + break; + case 0xc0: + timer_a.prescale = 32; + break; + } + } + else + { + timer_a.prescale = timer_a.tcspr; + } + timer_a.count--; + if (timer_a.count < 0) + { + timer_a.count = timer_a.reload; + if (timer_a.ic & 7) + { + if (A24) + mem_put_qi (0x6c, timer_a.ic | 0x08); + else + mem_put_qi (0x56, timer_a.ic | 0x08); + } + } + } + } + + if (regs.r_flags & FLAGBIT_I /* interrupts enabled */ + && timer_a.ic & 0x08 /* timer A interrupt triggered */ + && (timer_a.ic & 0x07) > ((regs.r_flags >> 12) & 0x07)) + { + if (A24) + trigger_peripheral_interrupt (12, 0x06c); + else + trigger_peripheral_interrupt (22, 0x056); + } +} +#endif
mem.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mem.h =================================================================== --- mem.h (nonexistent) +++ mem.h (revision 842) @@ -0,0 +1,45 @@ +/* mem.h --- interface to memory for M32C simulator. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +void init_mem (void); +void mem_usage_stats (void); + +void mem_put_qi (int address, unsigned char value); +void mem_put_hi (int address, unsigned short value); +void mem_put_psi (int address, unsigned long value); +void mem_put_si (int address, unsigned long value); + +void mem_put_blk (int address, void *bufptr, int nbytes); + +unsigned char mem_get_pc (); + +unsigned char mem_get_qi (int address); +unsigned short mem_get_hi (int address); +unsigned long mem_get_psi (int address); +unsigned long mem_get_si (int address); + +void mem_get_blk (int address, void *bufptr, int nbytes); + +int sign_ext (int v, int bits); + +void m32c_sim_restore_console (); + +extern int m32c_use_raw_console;
mem.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: main.c =================================================================== --- main.c (nonexistent) +++ main.c (revision 842) @@ -0,0 +1,240 @@ +/* main.c --- main function for stand-alone M32C simulator. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_SYS_SOCKET_H +#ifdef HAVE_NETINET_IN_H +#ifdef HAVE_NETINET_TCP_H +#define HAVE_networking +#endif +#endif +#endif + +#ifdef HAVE_networking +#include +#include +#include +#endif + + +#include "bfd.h" + +#include "cpu.h" +#include "mem.h" +#include "misc.h" +#include "load.h" +#include "trace.h" +#ifdef TIMER_A +#include "int.h" +#include "timer_a.h" +#endif + +#ifdef HAVE_networking +extern int m32c_console_ofd; +extern int m32c_console_ifd; +#endif + +int m32c_disassemble = 0; +static unsigned int cycles = 0; + +static void +done (int exit_code) +{ + if (verbose) + { + stack_heap_stats (); + mem_usage_stats (); + printf ("insns: %14s\n", comma (cycles)); + } + exit (exit_code); +} + +#ifdef HAVE_networking +static void +setup_tcp_console (char *portname) +{ + int port = atoi (portname); + struct sockaddr_in address; + int isocket; + socklen_t as; + unsigned char *a; + + if (port < 1024) + { + printf ("invalid port number %d\n", port); + exit (1); + } + printf ("waiting for tcp console on port %d\n", port); + + memset (&address, 0, sizeof (address)); + address.sin_family = AF_INET; + address.sin_port = htons (port); + + isocket = socket (AF_INET, SOCK_STREAM, 0); + if (isocket < 0) + { + perror ("socket"); + exit (1); + } + + if (bind (isocket, (struct sockaddr *) &address, sizeof (address))) + { + perror ("bind"); + exit (1); + } + listen (isocket, 2); + + printf ("waiting for connection...\n"); + as = sizeof (address); + m32c_console_ifd = accept (isocket, (struct sockaddr *) &address, &as); + if (m32c_console_ifd == -1) + { + perror ("accept"); + exit (1); + } + a = (unsigned char *) (&address.sin_addr.s_addr); + printf ("connection from %d.%d.%d.%d\n", a[0], a[1], a[2], a[3]); + m32c_console_ofd = m32c_console_ifd; +} +#endif + +int +main (int argc, char **argv) +{ + int o; + int save_trace; + bfd *prog; +#ifdef HAVE_networking + char *console_port_s = 0; +#endif + + setbuf (stdout, 0); + + in_gdb = 0; + + while ((o = getopt (argc, argv, "tc:vdm:C")) != -1) + switch (o) + { + case 't': + trace++; + break; + case 'c': +#ifdef HAVE_networking + console_port_s = optarg; +#else + fprintf (stderr, "Nework console not available in this build.\n"); +#endif + break; + case 'C': +#ifdef HAVE_TERMIOS_H + m32c_use_raw_console = 1; +#else + fprintf (stderr, "Raw console not available in this build.\n"); +#endif + break; + case 'v': + verbose++; + break; + case 'd': + m32c_disassemble++; + break; + case 'm': + if (strcmp (optarg, "r8c") == 0 || strcmp (optarg, "m16c") == 0) + default_machine = bfd_mach_m16c; + else if (strcmp (optarg, "m32cm") == 0 + || strcmp (optarg, "m32c") == 0) + default_machine = bfd_mach_m32c; + else + { + fprintf (stderr, "Invalid machine: %s\n", optarg); + exit (1); + } + break; + case '?': + fprintf (stderr, + "usage: run [-v] [-C] [-c port] [-t] [-d] [-m r8c|m16c|m32cm|m32c]" + " program\n"); + exit (1); + } + + prog = bfd_openr (argv[optind], 0); + if (!prog) + { + fprintf (stderr, "Can't read %s\n", argv[optind]); + exit (1); + } + + if (!bfd_check_format (prog, bfd_object)) + { + fprintf (stderr, "%s not a m32c program\n", argv[optind]); + exit (1); + } + + save_trace = trace; + trace = 0; + m32c_load (prog); + trace = save_trace; + +#ifdef HAVE_networking + if (console_port_s) + setup_tcp_console (console_port_s); +#endif + + sim_disasm_init (prog); + + while (1) + { + int rc; + + if (trace) + printf ("\n"); + + if (m32c_disassemble) + sim_disasm_one (); + + enable_counting = verbose; + cycles++; + rc = decode_opcode (); + enable_counting = 0; + + if (M32C_HIT_BREAK (rc)) + done (1); + else if (M32C_EXITED (rc)) + done (M32C_EXIT_STATUS (rc)); + else + assert (M32C_STEPPED (rc)); + + trace_register_changes (); + +#ifdef TIMER_A + update_timer_a (); +#endif + } +}
main.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: gdb-if.c =================================================================== --- gdb-if.c (nonexistent) +++ gdb-if.c (revision 842) @@ -0,0 +1,704 @@ +/* gdb.c --- sim interface to GDB. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +#include +#include +#include +#include +#include + +#include "ansidecl.h" +#include "gdb/callback.h" +#include "gdb/remote-sim.h" +#include "gdb/signals.h" +#include "gdb/sim-m32c.h" + +#include "cpu.h" +#include "mem.h" +#include "load.h" +#include "syscalls.h" +#ifdef TIMER_A +#include "timer_a.h" +#endif + +/* I don't want to wrap up all the minisim's data structures in an + object and pass that around. That'd be a big change, and neither + GDB nor run needs that ability. + + So we just have one instance, that lives in global variables, and + each time we open it, we re-initialize it. */ +struct sim_state +{ + const char *message; +}; + +static struct sim_state the_minisim = { + "This is the sole m32c minisim instance. See libsim.a's global variables." +}; + +static int open; + +SIM_DESC +sim_open (SIM_OPEN_KIND kind, + struct host_callback_struct *callback, + struct bfd *abfd, char **argv) +{ + setbuf (stdout, 0); + if (open) + fprintf (stderr, "m32c minisim: re-opened sim\n"); + + /* The 'run' interface doesn't use this function, so we don't care + about KIND; it's always SIM_OPEN_DEBUG. */ + if (kind != SIM_OPEN_DEBUG) + fprintf (stderr, "m32c minisim: sim_open KIND != SIM_OPEN_DEBUG: %d\n", + kind); + + if (abfd) + m32c_set_mach (bfd_get_mach (abfd)); + + /* We can use ABFD, if non-NULL to select the appropriate + architecture. But we only support the r8c right now. */ + + set_callbacks (callback); + + /* We don't expect any command-line arguments. */ + + init_mem (); + init_regs (); + + open = 1; + return &the_minisim; +} + +static void +check_desc (SIM_DESC sd) +{ + if (sd != &the_minisim) + fprintf (stderr, "m32c minisim: desc != &the_minisim\n"); +} + +void +sim_close (SIM_DESC sd, int quitting) +{ + check_desc (sd); + + /* Not much to do. At least free up our memory. */ + init_mem (); + + open = 0; +} + +static bfd * +open_objfile (const char *filename) +{ + bfd *prog = bfd_openr (filename, 0); + + if (!prog) + { + fprintf (stderr, "Can't read %s\n", filename); + return 0; + } + + if (!bfd_check_format (prog, bfd_object)) + { + fprintf (stderr, "%s not a m32c program\n", filename); + return 0; + } + + return prog; +} + + +SIM_RC +sim_load (SIM_DESC sd, char *prog, struct bfd * abfd, int from_tty) +{ + check_desc (sd); + + if (!abfd) + abfd = open_objfile (prog); + if (!abfd) + return SIM_RC_FAIL; + + m32c_load (abfd); + + return SIM_RC_OK; +} + +SIM_RC +sim_create_inferior (SIM_DESC sd, struct bfd * abfd, char **argv, char **env) +{ + check_desc (sd); + + if (abfd) + m32c_load (abfd); + + return SIM_RC_OK; +} + +int +sim_read (SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length) +{ + check_desc (sd); + + if (mem == 0) + return 0; + + mem_get_blk ((int) mem, buf, length); + + return length; +} + +int +sim_write (SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length) +{ + check_desc (sd); + + mem_put_blk ((int) mem, buf, length); + + return length; +} + + +/* Read the LENGTH bytes at BUF as an little-endian value. */ +static DI +get_le (unsigned char *buf, int length) +{ + DI acc = 0; + while (--length >= 0) + acc = (acc << 8) + buf[length]; + + return acc; +} + +/* Store VAL as a little-endian value in the LENGTH bytes at BUF. */ +static void +put_le (unsigned char *buf, int length, DI val) +{ + int i; + + for (i = 0; i < length; i++) + { + buf[i] = val & 0xff; + val >>= 8; + } +} + +static int +check_regno (enum m32c_sim_reg regno) +{ + return 0 <= regno && regno < m32c_sim_reg_num_regs; +} + +static size_t +mask_size (int addr_mask) +{ + switch (addr_mask) + { + case 0xffff: + return 2; + case 0xfffff: + case 0xffffff: + return 3; + default: + fprintf (stderr, + "m32c minisim: addr_mask_size: unexpected mask 0x%x\n", + addr_mask); + return sizeof (addr_mask); + } +} + +static size_t +reg_size (enum m32c_sim_reg regno) +{ + switch (regno) + { + case m32c_sim_reg_r0_bank0: + case m32c_sim_reg_r1_bank0: + case m32c_sim_reg_r2_bank0: + case m32c_sim_reg_r3_bank0: + case m32c_sim_reg_r0_bank1: + case m32c_sim_reg_r1_bank1: + case m32c_sim_reg_r2_bank1: + case m32c_sim_reg_r3_bank1: + case m32c_sim_reg_flg: + case m32c_sim_reg_svf: + return 2; + + case m32c_sim_reg_a0_bank0: + case m32c_sim_reg_a1_bank0: + case m32c_sim_reg_fb_bank0: + case m32c_sim_reg_sb_bank0: + case m32c_sim_reg_a0_bank1: + case m32c_sim_reg_a1_bank1: + case m32c_sim_reg_fb_bank1: + case m32c_sim_reg_sb_bank1: + case m32c_sim_reg_usp: + case m32c_sim_reg_isp: + return mask_size (addr_mask); + + case m32c_sim_reg_pc: + case m32c_sim_reg_intb: + case m32c_sim_reg_svp: + case m32c_sim_reg_vct: + return mask_size (membus_mask); + + case m32c_sim_reg_dmd0: + case m32c_sim_reg_dmd1: + return 1; + + case m32c_sim_reg_dct0: + case m32c_sim_reg_dct1: + case m32c_sim_reg_drc0: + case m32c_sim_reg_drc1: + return 2; + + case m32c_sim_reg_dma0: + case m32c_sim_reg_dma1: + case m32c_sim_reg_dsa0: + case m32c_sim_reg_dsa1: + case m32c_sim_reg_dra0: + case m32c_sim_reg_dra1: + return 3; + + default: + fprintf (stderr, "m32c minisim: unrecognized register number: %d\n", + regno); + return -1; + } +} + +int +sim_fetch_register (SIM_DESC sd, int regno, unsigned char *buf, int length) +{ + size_t size; + + check_desc (sd); + + if (!check_regno (regno)) + return 0; + + size = reg_size (regno); + if (length == size) + { + DI val; + + switch (regno) + { + case m32c_sim_reg_r0_bank0: + val = regs.r[0].r_r0; + break; + case m32c_sim_reg_r1_bank0: + val = regs.r[0].r_r1; + break; + case m32c_sim_reg_r2_bank0: + val = regs.r[0].r_r2; + break; + case m32c_sim_reg_r3_bank0: + val = regs.r[0].r_r3; + break; + case m32c_sim_reg_a0_bank0: + val = regs.r[0].r_a0; + break; + case m32c_sim_reg_a1_bank0: + val = regs.r[0].r_a1; + break; + case m32c_sim_reg_fb_bank0: + val = regs.r[0].r_fb; + break; + case m32c_sim_reg_sb_bank0: + val = regs.r[0].r_sb; + break; + case m32c_sim_reg_r0_bank1: + val = regs.r[1].r_r0; + break; + case m32c_sim_reg_r1_bank1: + val = regs.r[1].r_r1; + break; + case m32c_sim_reg_r2_bank1: + val = regs.r[1].r_r2; + break; + case m32c_sim_reg_r3_bank1: + val = regs.r[1].r_r3; + break; + case m32c_sim_reg_a0_bank1: + val = regs.r[1].r_a0; + break; + case m32c_sim_reg_a1_bank1: + val = regs.r[1].r_a1; + break; + case m32c_sim_reg_fb_bank1: + val = regs.r[1].r_fb; + break; + case m32c_sim_reg_sb_bank1: + val = regs.r[1].r_sb; + break; + + case m32c_sim_reg_usp: + val = regs.r_usp; + break; + case m32c_sim_reg_isp: + val = regs.r_isp; + break; + case m32c_sim_reg_pc: + val = regs.r_pc; + break; + case m32c_sim_reg_intb: + val = regs.r_intbl * 65536 + regs.r_intbl; + break; + case m32c_sim_reg_flg: + val = regs.r_flags; + break; + + /* These registers aren't implemented by the minisim. */ + case m32c_sim_reg_svf: + case m32c_sim_reg_svp: + case m32c_sim_reg_vct: + case m32c_sim_reg_dmd0: + case m32c_sim_reg_dmd1: + case m32c_sim_reg_dct0: + case m32c_sim_reg_dct1: + case m32c_sim_reg_drc0: + case m32c_sim_reg_drc1: + case m32c_sim_reg_dma0: + case m32c_sim_reg_dma1: + case m32c_sim_reg_dsa0: + case m32c_sim_reg_dsa1: + case m32c_sim_reg_dra0: + case m32c_sim_reg_dra1: + return 0; + + default: + fprintf (stderr, "m32c minisim: unrecognized register number: %d\n", + regno); + return -1; + } + + put_le (buf, length, val); + } + + return size; +} + +int +sim_store_register (SIM_DESC sd, int regno, unsigned char *buf, int length) +{ + size_t size; + + check_desc (sd); + + if (!check_regno (regno)) + return 0; + + size = reg_size (regno); + + if (length == size) + { + DI val = get_le (buf, length); + + switch (regno) + { + case m32c_sim_reg_r0_bank0: + regs.r[0].r_r0 = val & 0xffff; + break; + case m32c_sim_reg_r1_bank0: + regs.r[0].r_r1 = val & 0xffff; + break; + case m32c_sim_reg_r2_bank0: + regs.r[0].r_r2 = val & 0xffff; + break; + case m32c_sim_reg_r3_bank0: + regs.r[0].r_r3 = val & 0xffff; + break; + case m32c_sim_reg_a0_bank0: + regs.r[0].r_a0 = val & addr_mask; + break; + case m32c_sim_reg_a1_bank0: + regs.r[0].r_a1 = val & addr_mask; + break; + case m32c_sim_reg_fb_bank0: + regs.r[0].r_fb = val & addr_mask; + break; + case m32c_sim_reg_sb_bank0: + regs.r[0].r_sb = val & addr_mask; + break; + case m32c_sim_reg_r0_bank1: + regs.r[1].r_r0 = val & 0xffff; + break; + case m32c_sim_reg_r1_bank1: + regs.r[1].r_r1 = val & 0xffff; + break; + case m32c_sim_reg_r2_bank1: + regs.r[1].r_r2 = val & 0xffff; + break; + case m32c_sim_reg_r3_bank1: + regs.r[1].r_r3 = val & 0xffff; + break; + case m32c_sim_reg_a0_bank1: + regs.r[1].r_a0 = val & addr_mask; + break; + case m32c_sim_reg_a1_bank1: + regs.r[1].r_a1 = val & addr_mask; + break; + case m32c_sim_reg_fb_bank1: + regs.r[1].r_fb = val & addr_mask; + break; + case m32c_sim_reg_sb_bank1: + regs.r[1].r_sb = val & addr_mask; + break; + + case m32c_sim_reg_usp: + regs.r_usp = val & addr_mask; + break; + case m32c_sim_reg_isp: + regs.r_isp = val & addr_mask; + break; + case m32c_sim_reg_pc: + regs.r_pc = val & membus_mask; + break; + case m32c_sim_reg_intb: + regs.r_intbl = (val & membus_mask) & 0xffff; + regs.r_intbh = (val & membus_mask) >> 16; + break; + case m32c_sim_reg_flg: + regs.r_flags = val & 0xffff; + break; + + /* These registers aren't implemented by the minisim. */ + case m32c_sim_reg_svf: + case m32c_sim_reg_svp: + case m32c_sim_reg_vct: + case m32c_sim_reg_dmd0: + case m32c_sim_reg_dmd1: + case m32c_sim_reg_dct0: + case m32c_sim_reg_dct1: + case m32c_sim_reg_drc0: + case m32c_sim_reg_drc1: + case m32c_sim_reg_dma0: + case m32c_sim_reg_dma1: + case m32c_sim_reg_dsa0: + case m32c_sim_reg_dsa1: + case m32c_sim_reg_dra0: + case m32c_sim_reg_dra1: + return 0; + + default: + fprintf (stderr, "m32c minisim: unrecognized register number: %d\n", + regno); + return -1; + } + } + + return size; +} + +void +sim_info (SIM_DESC sd, int verbose) +{ + check_desc (sd); + + printf ("The m32c minisim doesn't collect any statistics.\n"); +} + +static volatile int stop; +static enum sim_stop reason; +int siggnal; + + +/* Given a signal number used by the M32C bsp (that is, newlib), + return a target signal number used by GDB. */ +int +m32c_signal_to_target (int m32c) +{ + switch (m32c) + { + case 4: + return TARGET_SIGNAL_ILL; + + case 5: + return TARGET_SIGNAL_TRAP; + + case 10: + return TARGET_SIGNAL_BUS; + + case 11: + return TARGET_SIGNAL_SEGV; + + case 24: + return TARGET_SIGNAL_XCPU; + + case 2: + return TARGET_SIGNAL_INT; + + case 8: + return TARGET_SIGNAL_FPE; + + case 6: + return TARGET_SIGNAL_ABRT; + } + + return 0; +} + + +/* Take a step return code RC and set up the variables consulted by + sim_stop_reason appropriately. */ +void +handle_step (int rc) +{ + if (M32C_STEPPED (rc) || M32C_HIT_BREAK (rc)) + { + reason = sim_stopped; + siggnal = TARGET_SIGNAL_TRAP; + } + else if (M32C_STOPPED (rc)) + { + reason = sim_stopped; + siggnal = m32c_signal_to_target (M32C_STOP_SIG (rc)); + } + else + { + assert (M32C_EXITED (rc)); + reason = sim_exited; + siggnal = M32C_EXIT_STATUS (rc); + } +} + + +void +sim_resume (SIM_DESC sd, int step, int sig_to_deliver) +{ + check_desc (sd); + + if (sig_to_deliver != 0) + { + fprintf (stderr, + "Warning: the m32c minisim does not implement " + "signal delivery yet.\n" "Resuming with no signal.\n"); + } + + if (step) + { + handle_step (decode_opcode ()); +#ifdef TIMER_A + update_timer_a (); +#endif + } + else + { + /* We don't clear 'stop' here, because then we would miss + interrupts that arrived on the way here. Instead, we clear + the flag in sim_stop_reason, after GDB has disabled the + interrupt signal handler. */ + for (;;) + { + if (stop) + { + stop = 0; + reason = sim_stopped; + siggnal = TARGET_SIGNAL_INT; + break; + } + + int rc = decode_opcode (); +#ifdef TIMER_A + update_timer_a (); +#endif + + if (!M32C_STEPPED (rc)) + { + handle_step (rc); + break; + } + } + } + m32c_sim_restore_console (); +} + +int +sim_stop (SIM_DESC sd) +{ + stop = 1; + + return 1; +} + +void +sim_stop_reason (SIM_DESC sd, enum sim_stop *reason_p, int *sigrc_p) +{ + check_desc (sd); + + *reason_p = reason; + *sigrc_p = siggnal; +} + +void +sim_do_command (SIM_DESC sd, char *cmd) +{ + check_desc (sd); + + char *p = cmd; + + /* Skip leading whitespace. */ + while (isspace (*p)) + p++; + + /* Find the extent of the command word. */ + for (p = cmd; *p; p++) + if (isspace (*p)) + break; + + /* Null-terminate the command word, and record the start of any + further arguments. */ + char *args; + if (*p) + { + *p = '\0'; + args = p + 1; + while (isspace (*args)) + args++; + } + else + args = p; + + if (strcmp (cmd, "trace") == 0) + { + if (strcmp (args, "on") == 0) + trace = 1; + else if (strcmp (args, "off") == 0) + trace = 0; + else + printf ("The 'sim trace' command expects 'on' or 'off' " + "as an argument.\n"); + } + else if (strcmp (cmd, "verbose") == 0) + { + if (strcmp (args, "on") == 0) + verbose = 1; + else if (strcmp (args, "off") == 0) + verbose = 0; + else + printf ("The 'sim verbose' command expects 'on' or 'off'" + " as an argument.\n"); + } + else + printf ("The 'sim' command expects either 'trace' or 'verbose'" + " as a subcommand.\n"); +}
gdb-if.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: r8c.opc =================================================================== --- r8c.opc (nonexistent) +++ r8c.opc (revision 842) @@ -0,0 +1,1593 @@ +/* r8c.opc --- semantics for r8c opcodes. -*- mode: c -*- + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +#include +#include + +#include "cpu.h" +#include "mem.h" +#include "misc.h" +#include "int.h" + +#define AU __attribute__((unused)) + +#define tprintf if (trace) printf + +static unsigned char +getbyte () +{ + int tsave = trace; + unsigned char b; + + if (trace == 1) + trace = 0; + b = mem_get_pc (); + regs.r_pc ++; + trace = tsave; + return b; +} + +#define M16C_ONLY() /* FIXME: add something here */ + +#define GETBYTE() (op[opi++] = getbyte()) + +#define UNSUPPORTED() unsupported("unsupported", orig_pc) +#define NOTYET() unsupported("unimplemented", orig_pc) + +static void +unsupported (char *tag, int orig_pc) +{ + int i; + printf("%s opcode at %08x\n", tag, orig_pc); + regs.r_pc = orig_pc; + for (i=0; i<2; i++) + { + int b = mem_get_pc(); + printf(" %s", bits(b>>4, 4)); + printf(" %s", bits(b, 4)); + regs.r_pc ++; + } + printf("\n"); + regs.r_pc = orig_pc; + for (i=0; i<6; i++) + { + printf(" %02x", mem_get_pc ()); + regs.r_pc ++; + } + printf("\n"); + exit(1); +} + +static int +IMM(bw) +{ + int rv = getbyte (); + if (bw) + rv = rv + 256 * getbyte(); + if (bw == 2) + rv = rv + 65536 * getbyte(); + return rv; +} + +#define IMM4() (immm >= 8 ? 7 - immm : immm + 1) + +#define UNARY_SOP \ + dc = decode_srcdest4 (dest, w); \ + v = sign_ext (get_src (dc), w?16:8); + +#define UNARY_UOP \ + dc = decode_srcdest4 (dest, w); \ + v = get_src (dc); + +#define BINARY_SOP \ + sc = decode_srcdest4 (srcx, w); \ + dc = decode_srcdest4 (dest, w); \ + a = sign_ext (get_src (sc), w?16:8); \ + b = sign_ext (get_src (dc), w?16:8); + +#define BINARY_UOP \ + sc = decode_srcdest4 (srcx, w); \ + dc = decode_srcdest4 (dest, w); \ + a = get_src (sc); \ + b = get_src (dc); + +#define carry (FLAG_C ? 1 : 0) + +static void +cmp (int d, int s, int w) +{ + int a, b, f=0; + int mask = w ? 0xffff : 0xff; + a = d - s; + b = sign_ext (d, w?16:8) - sign_ext (s, w?16:8); + tprintf ("cmp: %x - %x = %08x, %x - %x = %d\n", + d, s, a, + sign_ext(d,w?16:8), sign_ext(s,w?16:8), b); + + if (b == 0) + f |= FLAGBIT_Z; + if (b & (w ? 0x8000 : 0x80)) + f |= FLAGBIT_S; + if ((d & mask) >= (s & mask)) + f |= FLAGBIT_C; + if (b < (w ? -32768 : -128) || b > (w ? 32767 : 127)) + f |= FLAGBIT_O; + + set_flags (FLAGBIT_Z | FLAGBIT_S | FLAGBIT_O | FLAGBIT_C, f); +} + +static void +div_op (int s, int u, int x, int w) +{ + srcdest sc; + int v, a, b; + + if (s == -1) + s = IMM(w); + else + { + sc = decode_srcdest4 (s, w); + s = get_src (sc); + } + + v = get_reg (w ? r2r0 : r0); + + if (!u) + { + s = sign_ext (s, w ? 16 : 8); + v = sign_ext (v, w ? 16 : 8); + } + + if (s == 0) + { + set_flags (FLAGBIT_O, FLAGBIT_O); + return; + } + + if (u) + { + a = (unsigned int)v / (unsigned int)s; + b = (unsigned int)v % (unsigned int)s; + } + else + { + a = v / s; + b = v % s; + } + if (x) + { + if ((s > 0 && b < 0) + || (s < 0 && b > 0)) + { + a --; + b += s; + } + } + tprintf ("%d / %d = %d rem %d\n", v, s, a, b); + if ((!u && (a > (w ? 32767 : 127) + || a < (w ? -32768 : -129))) + || (u && (a > (w ? 65536 : 255)))) + set_flags (FLAGBIT_O, FLAGBIT_O); + else + set_flags (FLAGBIT_O, 0); + + put_reg (w ? r0 : r0l, a); + put_reg (w ? r2 : r0h, b); +} + +static void +rot_op (srcdest sd, int rotc, int count) +{ + int mask = (sd.bytes == 2) ? 0xffff : 0xff; + int msb = (sd.bytes == 2) ? 0x8000 : 0x80; + int v = get_src (sd); + int c = carry, ct; + + tprintf("%s %x by %d\n", rotc ? "rotc" : "rot", v, count); + tprintf (": %s %d\n", bits(v, 8*sd.bytes), c); + while (count > 0) + { + ct = (v & msb) ? 1 : 0; + v <<= 1; + v |= rotc ? c : ct; + v &= mask; + c = ct; + tprintf (": %s %d\n", bits(v, 8*sd.bytes), c); + count --; + } + while (count < 0) + { + ct = v & 1; + v >>= 1; + v |= (rotc ? c : ct) * msb; + c = ct; + tprintf (": %s %d\n", bits(v, 8*sd.bytes), c); + count ++; + } + put_dest (sd, v); + set_szc (v, sd.bytes, c); +} + +static void +shift_op (srcdest sd, int arith, int count) +{ + int mask = (sd.bytes == 2) ? 0xffff : 0xff; + int msb = (sd.bytes == 2) ? 0x8000 : 0x80; + int v = get_src (sd); + int c = 0; + + if (sd.bytes == 4) + { + mask = 0xffffffffU; + msb = 0x80000000U; + if (count > 16 || count < -16) + { + fprintf(stderr, "Error: SI shift of %d undefined\n", count); + exit(1); + } + if (count > 16) + count = (count - 1) % 16 + 1; + if (count < -16) + count = -((-count - 1) % 16 + 1); + } + + tprintf("%s %x by %d\n", arith ? "sha" : "shl", v, count); + tprintf (": %s %d\n", bits(v, 8*sd.bytes), c); + while (count > 0) + { + c = (v & msb) ? 1 : 0; + v <<= 1; + v &= mask; + tprintf (": %s %d\n", bits(v, 8*sd.bytes), c); + count --; + } + while (count < 0) + { + c = v & 1; + if (arith) + v = (v & msb) | (v >> 1); + else + v = (v >> 1) & (msb - 1); + tprintf (": %s %d\n", bits(v, 8*sd.bytes), c); + count ++; + } + put_dest (sd, v); + set_szc (v, sd.bytes, c); +} + +#define MATH_OP(dc,s,c,op,carryrel) \ + a = get_src(dc); \ + b = s & b2mask[dc.bytes]; \ + v2 = a op b op c; \ + tprintf("0x%x " #op " 0x%x " #op " 0x%x = 0x%x\n", a, b, c, v2); \ + a = sign_ext (a, dc.bytes * 8); \ + b = sign_ext (s, dc.bytes * 8); \ + v = a op b op c; \ + tprintf("%d " #op " %d " #op " %d = %d\n", a, b, c, v); \ + set_oszc (v, dc.bytes, v2 carryrel); \ + put_dest (dc, v2); + +#define BIT_OP(field,expr) \ + dc = decode_bit (field); \ + b = get_bit (dc); \ + v = expr; \ + tprintf ("b=%d, carry=%d, %s = %d\n", b, carry, #expr, v); \ + put_bit (dc, v); + +#define BIT_OPC(field,expr) \ + dc = decode_bit (field); \ + b = get_bit (dc); \ + v = expr; \ + tprintf ("b=%d, carry=%d, %s = %d\n", b, carry, #expr, v); \ + set_c (v); + +/* The "BMcnd dest" opcode uses a different encoding for the */ +/* condition than other opcodes. */ +static int bmcnd_cond_map[] = { + 0, 1, 2, 3, 8, 9, 10, 11, 4, 5, 6, 7, 12, 13, 14, 15 +}; + +int +decode_r8c() +{ + unsigned char op[40]; + int opi = 0; + int v, v2, a, b; + int orig_pc = get_reg (pc); + srcdest sc, dc; + int imm; + + step_result = M32C_MAKE_STEPPED (); + + tprintf("trace: decode pc = %05x\n", orig_pc); + + /** VARY dst 011 100 101 110 111 */ + + /** 0111 011w 1111 dest ABS.size dest */ + + UNARY_SOP; + a = v<0 ? -v : v; + tprintf("abs(%d) = %d\n", v, a); + set_osz(a, w+1); + put_dest (dc, a); + + /** 0111 011w 0110 dest ADC.size #IMM,dest */ + + dc = decode_srcdest4(dest, w); + imm = IMM(w); + MATH_OP (dc, imm, carry, +, > (w?0xffff:0xff)); + + /** 1011 000w srcx dest ADC.size src,dest */ + + sc = decode_srcdest4(srcx, w); + dc = decode_srcdest4(dest, w); + b = get_src (sc); + MATH_OP (dc, b, carry, +, > (w?0xffff:0xff)); + + /** 0111 011w 1110 dest ADCF.size dest */ + + dc = decode_srcdest4(dest, w); + MATH_OP (dc, 0, carry, +, > (w?0xffff:0xff)); + + /** 0111 011w 0100 dest ADD.size:G #imm,dest */ + + dc = decode_srcdest4(dest, w); + imm = IMM(w); + MATH_OP (dc, imm, 0, +, > (w?0xffff:0xff)); + + /** 1100 100w immm dest ADD.size:Q #IMM,dest */ + + dc = decode_srcdest4(dest, w); + imm = sign_ext (immm, 4); + MATH_OP (dc, imm, 0, +, > (w?0xffff:0xff)); + + /** 1000 0dst ADD.B:S #IMM8,dst */ + + imm = IMM(0); + dc = decode_dest3 (dst, 0); + MATH_OP (dc, imm, 0, +, > 0xff); + + /** 1010 000w srcx dest ADD.size:G src,dest */ + + sc = decode_srcdest4(srcx, w); + dc = decode_srcdest4(dest, w); + b = get_src (sc); + MATH_OP (dc, b, 0, +, > (w?0xffff:0xff)); + + /** 0010 0d sr ADD.B:S src,R0L/R0H */ + + sc = decode_src2 (sr, 0, d); + dc = decode_dest1 (d, 0); + b = get_src (sc); + MATH_OP (dc, b, 0, +, > 0xff); + + /** 0111 110w 1110 1011 ADD.size:G #IMM,sp */ + + dc = reg_sd (sp); + imm = sign_ext (IMM(w), w?16:8); + MATH_OP (dc, imm, 0, +, > 0xffff); + + /** 0111 1101 1011 immm ADD.size:Q #IMM,sp */ + + dc = reg_sd (sp); + imm = sign_ext (immm, 4); + MATH_OP (dc, imm, 0, +, > 0xffff); + + /** 1111 100w immm dest ADJNZ.size #IMM,dest,label */ + + UNARY_UOP; + imm = sign_ext(immm, 4); + tprintf("%x + %d = %x\n", v, imm, v+imm); + v += imm; + put_dest (dc, v); + a = sign_ext (IMM(0), 8); + if ((v & (w ? 0xffff : 0xff)) != 0) + { + tprintf("jmp: %x + 2 + %d = ", get_reg (pc), a); + put_reg (pc, orig_pc + 2 + a); + tprintf("%x\n", get_reg (pc)); + } + + /** 0111 011w 0010 dest AND.size:G #IMM,dest */ + + UNARY_UOP; + imm = IMM(w); + tprintf ("%x & %x = %x\n", v, imm, v & imm); + v &= imm; + set_sz (v, w+1); + put_dest (dc, v); + + /** 1001 0dst AND.B:S #IMM8,dest */ + + imm = IMM(0); + dc = decode_dest3 (dst, 0); + v = get_src (dc); + tprintf("%x & %x = %x\n", v, imm, v & imm); + v &= imm; + set_sz (v, 1); + put_dest (dc, v); + + /** 1001 000w srcx dest AND.size:G src.dest */ + + BINARY_UOP; + tprintf ("%x & %x = %x\n", a, b, a & b); + v = a & b; + set_sz (v, w+1); + put_dest (dc, v); + + /** 0001 0d sr AND.B:S src,R0L/R0H */ + + sc = decode_src2 (sr, 0, d); + dc = decode_dest1 (d, 0); + a = get_src (sc); + b = get_src (dc); + v = a & b; + tprintf("%x & %x = %x\n", a, b, v); + set_sz (v, 1); + put_dest (dc, v); + + /** 0111 1110 0100 srcx BAND src */ + + BIT_OPC (srcx, b & carry); + + /** 0111 1110 1000 dest BCLR:G dest */ + + dc = decode_bit (dest); + put_bit (dc, 0); + + /** 0100 0bit BCLR:S bit,base:11[SB] */ + + dc = decode_bit11 (bit); + put_bit (dc, 0); + + /** 0111 1110 0010 dest BMcnd dest */ + + dc = decode_bit (dest); + if (condition_true (bmcnd_cond_map [IMM (0) & 15])) + put_bit (dc, 1); + else + put_bit (dc, 0); + + /** 0111 1101 1101 cond BMcnd C */ + + if (condition_true (cond)) + set_c (1); + else + set_c (0); + + /** 0111 1110 0101 srcx BNAND src */ + + BIT_OPC (srcx, (!b) & carry); + + /** 0111 1110 0111 srcx BNOR src */ + + BIT_OPC (srcx, (!b) | carry); + + /** 0111 1110 1010 dest BNOT:G dest */ + + BIT_OP (dest, !b); + + /** 0101 0bit BNOT:S bit,base:11[SB] */ + + dc = decode_bit11 (bit); + put_bit (dc, !get_bit (dc)); + + /** 0111 1110 0011 srcx BNTST src */ + + dc = decode_bit (srcx); + b = get_bit (dc); + set_zc (!b, !b); + + /** 0111 1110 1101 srcx BNXOR src */ + + BIT_OPC (srcx, !b ^ carry); + + /** 0111 1110 0110 srcx BOR src */ + + BIT_OPC (srcx, b | carry); + + /** 0000 0000 BRK */ + + /* We report the break to our caller with the PC still pointing at the + breakpoint instruction. */ + put_reg (pc, orig_pc); + if (verbose) + printf("[break]\n"); + return M32C_MAKE_HIT_BREAK (); + + /** 0111 1110 1001 dest BSET:G dest */ + + dc = decode_bit (dest); + put_bit (dc, 1); + + /** 0100 1bit BSET:S bit,base:11[SB] */ + + dc = decode_bit11 (bit); + put_bit (dc, 1); + + /** 0111 1110 1011 srcx BTST:G src */ + + dc = decode_bit (srcx); + b = get_bit (dc); + set_zc (!b, b); + + /** 0101 1bit BTST:S bit,base:11[SB] */ + + dc = decode_bit11 (bit); + b = get_bit (dc); + set_zc (!b, b); + + /** 0111 1110 0000 dest BTSTC dest */ + + dc = decode_bit (dest); + b = get_bit (dc); + set_zc (!b, b); + put_bit (dc, 0); + + /** 0111 1110 0001 dest BTSTS dest */ + + dc = decode_bit (dest); + b = get_bit (dc); + set_zc (!b, b); + put_bit (dc, 1); + + /** 0111 1110 1100 srcx BXOR src */ + + BIT_OPC (srcx, b ^ carry); + + /** 0111 011w 1000 dest CMP.size:G #IMM,dest */ + + UNARY_UOP; + imm = IMM(w); + cmp (v, imm, w); + + /** 1101 000w immm dest CMP.size:Q #IMM,dest */ + + UNARY_UOP; + immm = sign_ext (immm, 4); + cmp (v, immm, w); + + /** 1110 0dst CMP.B:S #IMM8,dest */ + + imm = IMM(0); + dc = decode_dest3 (dst, 0); + v = get_src (dc); + cmp (v, imm, 0); + + /** 1100 000w srcx dest CMP.size:G src,dest */ + + BINARY_UOP; + cmp(b, a, w); + + /** 0011 1d sr CMP.B:S src,R0L/R0H */ + + sc = decode_src2 (sr, 0, d); + dc = decode_dest1 (d, 0); + a = get_src (sc); + b = get_src (dc); + cmp (b, a, 0); + + /** 0111 110w 1110 i1c s DADC,DADD,DSBB,DSUB */ + + /* w = width, i = immediate, c = carry, s = subtract */ + + int src = i ? IMM(w) : get_reg (w ? r1 : r0h); + int dest = get_reg (w ? r0 : r0l); + int res; + + src = bcd2int(src, w); + dest = bcd2int(dest, w); + + tprintf("decimal: %d %s %d", dest, s?"-":"+", src); + if (c) + tprintf(" c=%d", carry); + + if (!s) + { + res = dest + src; + if (c) + res += carry; + c = res > (w ? 9999 : 99); + } + else + { + res = dest - src; + if (c) + res -= (1-carry); + c = res >= 0; + if (res < 0) + res += w ? 10000 : 100; + } + + res = int2bcd (res, w); + tprintf(" = %x\n", res); + + set_szc (res, w+1, c); + + put_reg (w ? r0 : r0l, res); + + /** 1010 1dst DEC.B dest */ + + dc = decode_dest3 (dst, 0); + v = get_src (dc); + tprintf("%x -- = %x\n", v, v-1); + v --; + set_sz (v, 1); + put_dest (dc, v); + + /** 1111 d010 DEC.W dest */ + + v = get_reg (d ? a1 : a0); + tprintf("%x -- = %x\n", v, v-1); + v --; + set_sz (v, 2); + put_reg (d ? a1 : a0, v); + + /** 0111 110w 1110 0001 DIV.size #IMM */ + + div_op (-1, 0, 0, w); + + /** 0111 011w 1101 srcx DIV.size src */ + + div_op (srcx, 0, 0, w); + + /** 0111 110w 1110 0000 DIVU.size #IMM */ + + div_op (-1, 1, 0, w); + + /** 0111 011w 1100 srcx DIVU.size src */ + + div_op (srcx, 1, 0, w); + + /** 0111 110w 1110 0011 DIVX.size #IMM */ + + div_op (-1, 0, 1, w); + + /** 0111 011w 1001 srcx DIVX.size src */ + + div_op (srcx, 0, 1, w); + + /** 0111 1100 1111 0010 ENTER #IMM8 */ + + imm = IMM(0); + put_reg (sp, get_reg (sp) - 2); + mem_put_hi (get_reg (sp), get_reg (fb)); + put_reg (fb, get_reg (sp)); + put_reg (sp, get_reg (sp) - imm); + + /** 0111 1101 1111 0010 EXITD */ + + put_reg (sp, get_reg (fb)); + put_reg (fb, mem_get_hi (get_reg (sp))); + put_reg (sp, get_reg (sp) + 2); + put_reg (pc, mem_get_psi (get_reg (sp))); + put_reg (sp, get_reg (sp) + 3); + + /** 0111 1100 0110 dest EXTS.B dest */ + + dc = decode_srcdest4 (dest, 0); + v = sign_ext (get_src (dc), 8); + dc = widen_sd (dc); + put_dest (dc, v); + set_sz (v, 1); + + /** 0111 1100 1111 0011 EXTS.W R0 */ + + v = sign_ext (get_reg (r0), 16); + put_reg (r2r0, v); + set_sz (v, 2); + + /** 1110 1011 0flg 0101 FCLR dest */ + + set_flags (1 << flg, 0); + + /** 1110 1011 0flg 0100 FSET dest */ + + set_flags (1 << flg, 1 << flg); + + /** 1010 0dst INC.B dest */ + + dc = decode_dest3 (dst, 0); + v = get_src (dc); + tprintf("%x ++ = %x\n", v, v+1); + v ++; + set_sz (v, 1); + put_dest (dc, v); + + /** 1011 d010 INC.W dest */ + + v = get_reg (d ? a1 : a0); + tprintf("%x ++ = %x\n", v, v+1); + v ++; + set_sz (v, 2); + put_reg (d ? a1 : a0, v); + + /** 1110 1011 11vector INT #imm */ + + trigger_based_interrupt (vector); + + /** 1111 0110 INTO */ + + if (FLAG_O) + trigger_fixed_interrupt (0xffe0); + + /** 0110 1cnd Jcnd label */ + + v = sign_ext (IMM(0), 8); + if (condition_true (cnd)) + put_reg (pc, orig_pc + 1 + v); + + /** 0111 1101 1100 cond Jcnd label */ + + v = sign_ext (IMM(0), 8); + if (condition_true (cond)) + put_reg (pc, orig_pc + 2 + v); + + /** 0110 0dsp JMP.S label */ + + put_reg (pc, orig_pc + 2 + dsp); + + /** 1111 1110 JMP.B label */ + + imm = sign_ext (IMM(0), 8); + if (imm == -1) + { + if (verbose) + printf("[jmp-to-self detected as exit]\n"); + return M32C_MAKE_HIT_BREAK (); + } + put_reg (pc, orig_pc + 1 + imm); + + /** 1111 0100 JMP.W label */ + + imm = sign_ext (IMM(1), 16); + put_reg (pc, orig_pc + 1 + imm); + + /** 1111 1100 JMP.A label */ + + imm = IMM(2); + put_reg (pc, imm); + + /** 0111 1101 0010 srcx JMPI.W src */ + + sc = decode_jumpdest (srcx, 1); + a = get_src (sc); + a = sign_ext (a, 16); + put_reg (pc, orig_pc + a); + + /** 0111 1101 0000 srcx JMPI.A src */ + + sc = decode_jumpdest (srcx, 0); + a = get_src (sc); + put_reg (pc, a); + + /** 1110 1110 JMPS #IMM8 */ + + M16C_ONLY(); + + imm = IMM(0); + a = 0xf0000 + mem_get_hi (0xffffe - imm * 2); + put_reg (pc, a); + + /** 1111 0101 JSR.W label */ + + imm = sign_ext (IMM(1), 16); + put_reg (sp, get_reg (sp) - 3); + mem_put_psi (get_reg (sp), get_reg (pc)); + put_reg (pc, orig_pc + imm + 1); + + /** 1111 1101 JSR.A label */ + + imm = IMM(2); + put_reg (sp, get_reg (sp) - 3); + mem_put_psi (get_reg (sp), get_reg (pc)); + put_reg (pc, imm); + + /** 0111 1101 0011 srcx JSRI.W src */ + + sc = decode_jumpdest (srcx, 1); + a = get_src (sc); + a = sign_ext (a, 16); + + put_reg (sp, get_reg (sp) - 3); + mem_put_psi (get_reg (sp), get_reg (pc)); + put_reg (pc, orig_pc + a); + + /** 0111 1101 0001 srcx JSRI.A src */ + + sc = decode_jumpdest (srcx, 0); + a = get_src (sc); + + put_reg (sp, get_reg (sp) - 3); + mem_put_psi (get_reg (sp), get_reg (pc)); + put_reg (pc, a); + + /** 1110 1111 JSRS #IMM8 */ + + M16C_ONLY(); + + imm = IMM(0); + a = 0xf0000 + mem_get_hi (0xffffe - imm * 2); + + put_reg (sp, get_reg (sp) - 3); + mem_put_psi (get_reg (sp), get_reg (pc)); + put_reg (pc, a); + + /** 1110 1011 0reg 0000 LDC #IMM16,dest */ + + dc = decode_cr (reg); + imm = IMM(1); + put_dest (dc, imm); + + /** 0111 1010 1reg srcx LDC src,dest */ + + dc = decode_cr (reg); + sc = decode_srcdest4 (srcx,1); + put_dest (dc, get_src (sc)); + + /** 0111 1100 1111 0000 LDCTX abs16,abs20 */ + + NOTYET(); + + /** 0111 010w 1000 dest LDE.size abs20,dest */ + + dc = decode_srcdest4 (dest, w); + imm = IMM(2); + if (w) + v = mem_get_hi (imm); + else + v = mem_get_qi (imm); + put_dest (dc, v); + + /** 0111 010w 1001 dest LDE.size dsp:20[a0], dest */ + + dc = decode_srcdest4 (dest, w); + imm = IMM(2) + get_reg (a0); + if (w) + v = mem_get_hi (imm); + else + v = mem_get_qi (imm); + put_dest (dc, v); + + /** 0111 010w 1010 dest LDE.size [a1a0],dest */ + + dc = decode_srcdest4 (dest, w); + imm = get_reg (a1a0); + if (w) + v = mem_get_hi (imm); + else + v = mem_get_qi (imm); + put_dest (dc, v); + + /** 0111 1101 1010 0imm LDIPL #IMM */ + + set_flags (0x700, imm*0x100); + + /** 0111 010w 1100 dest MOV.size:G #IMM,dest */ + + dc = decode_srcdest4 (dest, w); + imm = IMM(w); + v = imm; + tprintf("%x = %x\n", v, v); + set_sz(v, w+1); + put_dest (dc, v); + + /** 1101 100w immm dest MOV.size:Q #IMM,dest */ + + dc = decode_srcdest4 (dest, w); + v = sign_ext (immm, 4); + tprintf ("%x = %x\n", v, v); + set_sz (v, w+1); + put_dest (dc, v); + + /** 1100 0dst MOV.B:S #IMM8,dest */ + + imm = IMM(0); + dc = decode_dest3 (dst, 0); + v = imm; + tprintf("%x = %x\n", v, v); + set_sz (v, 1); + put_dest (dc, v); + + /** 1w10 d010 MOV.size:S #IMM,dest */ + + /* Note that for w, 0=W and 1=B unlike the usual meaning. */ + v = IMM(1-w); + tprintf("%x = %x\n", v, v); + set_sz (v, 2-w); + put_reg (d ? a1 : a0, v); + + /** 1011 0dst MOV.B:Z #0,dest */ + + dc = decode_dest3 (dst, 0); + v = 0; + set_sz (v, 1); + put_dest (dc, v); + + /** 0111 001w srcx dest MOV.size:G src,dest */ + + sc = decode_srcdest4 (srcx, w); + dc = decode_srcdest4 (dest, w); + v = get_src (sc); + set_sz (v, w+1); + put_dest (dc, v); + + /** 0011 0d sr MOV.B:S src,dest */ + + sc = decode_src2 (sr, 0, d); + v = get_src (sc); + set_sz (v, 1); + put_reg (d ? a1 : a0, v); + + /** 0000 0s ds MOV.B:S R0L/R0H,dest */ + + if (ds == 0) + UNSUPPORTED(); + dc = decode_src2 (ds, 0, s); + v = get_reg (s ? r0h : r0l); + set_sz (v, 1); + put_dest (dc, v); + + /** 0000 1d sr MOV.B:S src,R0L/R0H */ + + sc = decode_src2 (sr, 0, d); + v = get_src (sc); + set_sz (v, 1); + put_reg (d ? r0h : r0l, v); + + /** 0111 010w 1011 dest MOV.size:G dsp:8[SP], dest */ + + dc = decode_srcdest4 (dest, w); + imm = IMM(0); + a = get_reg (sp) + sign_ext (imm, 8); + a &= addr_mask; + if (w) + v = mem_get_hi (a); + else + v = mem_get_qi (a); + set_sz (v, w+1); + put_dest (dc, v); + + /** 0111 010w 0011 srcx MOV.size:G src, disp8[SP] */ + + sc = decode_srcdest4 (srcx, w); + imm = IMM(0); + a = get_reg (sp) + sign_ext (imm, 8); + a &= addr_mask; + v = get_src (sc); + if (w) + mem_put_hi (a, v); + else + mem_put_qi (a, v); + set_sz (v, w+1); + + /** 1110 1011 0reg 1src MOVA src,dest */ + + static reg_id map[] = { r0, r1, r2, r3, a0, a1, 0, 0 }; + sc = decode_srcdest4 (8 + src, 0); + put_reg (map[reg], sc.u.addr); + + /** 0111 1100 10hl dest MOVdir R0L,dest */ + + if (dest == 0 || dest == 4 || dest == 5) + UNSUPPORTED(); + dc = decode_srcdest4 (dest, 0); + a = get_src (dc); + b = get_reg (r0l); + switch (hl) + { + case 0: a = (a & 0xf0) | (b & 0x0f); break; + case 1: a = (a & 0xf0) | ((b>>4) & 0x0f); break; + case 2: a = (a & 0x0f) | ((b & 0x0f)<<4); break; + case 3: a = (a & 0x0f) | (b & 0xf0); break; + } + put_dest (dc, a); + + /** 0111 1100 00hl srcx MOVdir src,R0L */ + + if (srcx == 0 || srcx == 4 || srcx == 5) + UNSUPPORTED(); + sc = decode_srcdest4 (srcx, 0); + a = get_reg (r0l); + b = get_src (sc); + switch (hl) + { + case 0: a = (a & 0xf0) | (b & 0x0f); break; + case 1: a = (a & 0xf0) | ((b>>4) & 0x0f); break; + case 2: a = (a & 0x0f) | ((b & 0x0f)<<4); break; + case 3: a = (a & 0x0f) | (b & 0xf0); break; + } + put_reg (r0l, a); + + /** 0111 110w 0101 dest MUL.size #IMM,dest */ + + UNARY_SOP; + imm = sign_ext (IMM(w), w?16:8); + tprintf("%d * %d = %d\n", v, imm, v*imm); + v *= imm; + dc = widen_sd (dc); + put_dest (dc, v); + + /** 0111 100w srcx dest MUL.size src,dest */ + + BINARY_SOP; + v = a * b; + tprintf("%d * %d = %d\n", a, b, v); + dc = widen_sd (dc); + put_dest (dc, v); + + /** 0111 110w 0100 dest MULU.size #IMM,dest */ + + UNARY_UOP; + imm = IMM(w); + tprintf("%u * %u = %u\n", v, imm, v*imm); + v *= imm; + dc = widen_sd (dc); + put_dest (dc, v); + + /** 0111 000w srcx dest MULU.size src,dest */ + + BINARY_UOP; + v = a * b; + tprintf("%u * %u = %u\n", a, b, v); + dc = widen_sd (dc); + put_dest (dc, v); + + /** 0111 010w 0101 dest NEG.size dest */ + + UNARY_SOP; + tprintf("%d * -1 = %d\n", v, -v); + v = -v; + set_oszc (v, w+1, v == 0); + put_dest (dc, v); + + /** 0000 0100 NOP */ + + tprintf("nop\n"); + + /** 0111 010w 0111 dest NOT.size:G */ + + UNARY_UOP; + tprintf("~ %x = %x\n", v, ~v); + v = ~v; + set_sz (v, w+1); + put_dest (dc, v); + + /** 1011 1dst NOT.B:S dest */ + + dc = decode_dest3 (dst, 0); + v = get_src (dc); + tprintf("~ %x = %x\n", v, ~v); + v = ~v; + set_sz (v, 1); + put_dest (dc, v); + + /** 0111 011w 0011 dest OR.size:G #IMM,dest */ + + UNARY_UOP; + imm = IMM(w); + tprintf ("%x | %x = %x\n", v, imm, v | imm); + v |= imm; + set_sz (v, w+1); + put_dest (dc, v); + + /** 1001 1dst OR.B:S #IMM8,dest */ + + imm = IMM(0); + dc = decode_dest3 (dst, 0); + v = get_src (dc); + tprintf("%x | %x = %x\n", v, imm, v|imm); + v |= imm; + set_sz (v, 1); + put_dest (dc, v); + + /** 1001 100w srcx dest OR.size:G src,dest */ + + BINARY_UOP; + tprintf ("%x | %x = %x\n", a, b, a | b); + v = a | b; + set_sz (v, w+1); + put_dest (dc, v); + + /** 0001 1d sr OR.B:S src,R0L/R0H */ + + sc = decode_src2 (sr, 0, d); + dc = decode_dest1 (d, 0); + a = get_src (sc); + b = get_src (dc); + v = a | b; + tprintf("%x | %x = %x\n", a, b, v); + set_sz (v, 1); + put_dest (dc, v); + + /** 0111 010w 1101 dest POP.size:G dest */ + + dc = decode_srcdest4 (dest, w); + if (w) + { + v = mem_get_hi (get_reg (sp)); + put_reg (sp, get_reg (sp) + 2); + tprintf("pophi: %x\n", v); + } + else + { + v = mem_get_qi (get_reg (sp)); + put_reg (sp, get_reg (sp) + 1); + tprintf("popqi: %x\n", v); + } + put_dest (dc, v); + + /** 1001 d010 POP.B:S dest */ + + v = mem_get_qi (get_reg (sp)); + put_reg (d ? r0h : r0l, v); + put_reg (sp, get_reg (sp) + 1); + tprintf("popqi: %x\n", v); + + /** 1101 d010 POP.W:S dest */ + + v = mem_get_hi (get_reg (sp)); + put_reg (d ? a1 : a0, v); + put_reg (sp, get_reg (sp) + 2); + tprintf("pophi: %x\n", v); + + /** 1110 1011 0reg 0011 POPC dest */ + + dc = decode_cr (reg); + v = mem_get_hi (get_reg (sp)); + put_dest (dc, v); + put_reg (sp, get_reg (sp) + 2); + tprintf("popc: %x\n", v); + + /** 1110 1101 POPM dest */ + + static int map[] = { r0, r1, r2, r3, a0, a1, sb, fb }; + imm = IMM(0); + tprintf("popm: %x\n", imm); + for (a=0; a<8; a++) + if (imm & (1<= 0); + + /** 1011 100w srcx dest SBB.size src,dest */ + + sc = decode_srcdest4(srcx, w); + dc = decode_srcdest4(dest, w); + b = get_src (sc); + MATH_OP (dc, b, !carry, -, >= 0); + + /** 1111 000w immm dest SHA.size #IMM, dest */ + + dc = decode_srcdest4(dest, w); + shift_op (dc, 1, IMM4()); + + /** 0111 010w 1111 dest SHA.size R1H,dest */ + + dc = decode_srcdest4(dest, w); + a = sign_ext (get_reg (r1h), 8); + shift_op (dc, 1, a); + + /** 1110 1011 101d immm SHA.L #IMM, dest */ + + dc = reg_sd (d ? r3r1 : r2r0); + shift_op (dc, 1, IMM4()); + + /** 1110 1011 001d 0001 SHA.L R1H,dest */ + + dc = reg_sd (d ? r3r1 : r2r0); + a = sign_ext (get_reg (r1h), 8); + shift_op (dc, 1, a); + + /** 1110 100w immm dest SHL.size #IMM, dest */ + + dc = decode_srcdest4(dest, w); + shift_op (dc, 0, IMM4()); + + /** 0111 010w 1110 dest SHL.size R1H,dest */ + + dc = decode_srcdest4(dest, w); + a = sign_ext (get_reg (r1h), 8); + shift_op (dc, 0, a); + + /** 1110 1011 100d immm SHL.L #IMM,dest */ + + dc = reg_sd (d ? r3r1 : r2r0); + shift_op (dc, 0, IMM4()); + + /** 1110 1011 000d 0001 SHL.L R1H,dest */ + + dc = reg_sd (d ? r3r1 : r2r0); + a = sign_ext (get_reg (r1h), 8); + shift_op (dc, 0, a); + + /** 0111 110w 1110 100b SMOVB.size */ + + int count = get_reg (r3); + int s1 = get_reg (a0) + (get_reg (r1h) << 16); + int s2 = get_reg (a1); + int inc = (w ? 2 : 1) * (b ? -1 : 1); + + while (count) + { + if (w) + { + v = mem_get_hi (s1); + mem_put_hi (s2, v); + } + else + { + v = mem_get_qi (s1); + mem_put_qi (s2, v); + } + s1 += inc; + s2 += inc; + count --; + } + put_reg (r3, count); + put_reg (a0, s1 & 0xffff); + put_reg (a1, s2); + put_reg (r1h, s1 >> 16); + + /** 0111 110w 1110 1010 SSTR.size */ + + int count = get_reg (r3); + int s1 = get_reg (a1); + v = get_reg (w ? r0 : r0l); + + while (count) + { + if (w) + { + mem_put_hi (s1, v); + s1 += 2; + } + else + { + mem_put_qi (s1, v); + s1 += 1; + } + count --; + } + put_reg (r3, count); + put_reg (a1, s1); + + /** 0111 1011 1src dest STC src,dest */ + + dc = decode_srcdest4 (dest, 1); + sc = decode_cr (src); + put_dest (dc, get_src(sc)); + + /** 0111 1100 1100 dest STC PC,dest */ + + dc = decode_srcdest4 (dest, 1); + dc.bytes = 3; + put_dest (dc, orig_pc); + + /** 0111 1101 1111 0000 STCTX abs16,abs20 */ + + NOTYET(); + + /** 0111 010w 0000 srcx STE.size src,abs20 */ + + sc = decode_srcdest4 (srcx, w); + a = IMM(2); + v = get_src (sc); + if (w) + mem_put_hi (a, v); + else + mem_put_qi (a, v); + if (srcx == 4 || srcx == 5) + { + v = get_reg (sc.u.reg); + set_sz (v, 2); + } + else + set_sz (v, w+1); + + /** 0111 010w 0001 srcx STE.size src,disp20[a0] */ + + sc = decode_srcdest4 (srcx, w); + a = get_reg(a0) + IMM(2); + v = get_src (sc); + if (w) + mem_put_hi (a, v); + else + mem_put_qi (a, v); + if (srcx == 4 || srcx == 5) + { + v = get_reg (sc.u.reg); + set_sz (v, 2); + } + else + set_sz (v, w+1); + + /** 0111 010w 0010 srcx STE.size src,[a1a0] */ + + sc = decode_srcdest4 (srcx, w); + a = get_reg(a1a0); + v = get_src (sc); + if (w) + mem_put_hi (a, v); + else + mem_put_qi (a, v); + if (srcx == 4 || srcx == 5) + { + v = get_reg (sc.u.reg); + set_sz (v, 2); + } + else + set_sz (v, w+1); + + /** 1101 0dst STNZ #IMM8,dest */ + + imm = IMM(0); + dc = decode_dest3(dst, 0); + if (!FLAG_Z) + put_dest (dc, imm); + + /** 1100 1dst STZ #IMM8,dest */ + + imm = IMM(0); + dc = decode_dest3(dst, 0); + if (FLAG_Z) + put_dest (dc, imm); + + /** 1101 1dst STZX #IMM81,#IMM82,dest */ + + a = IMM(0); + dc = decode_dest3(dst, 0); + b = IMM(0); + if (FLAG_Z) + put_dest (dc, a); + else + put_dest (dc, b); + + /** 0111 011w 0101 dest SUB.size:G #IMM,dest */ + + dc = decode_srcdest4 (dest, w); + imm = IMM(w); + MATH_OP (dc, imm, 0, -, >= 0); + + /** 1000 1dst SUB.B:S #IMM8,dest */ + + imm = IMM(0); + dc = decode_dest3 (dst, 0); + MATH_OP (dc, imm, 0, -, >= 0); + + /** 1010 100w srcx dest SUB.size:G src,dest */ + + sc = decode_srcdest4(srcx, w); + dc = decode_srcdest4(dest, w); + b = get_src (sc); + MATH_OP (dc, b, 0, -, >= 0); + + /** 0010 1d sr SUB.B:S src,R0L/R0H */ + + sc = decode_src2 (sr, 0, d); + dc = decode_dest1 (d, 0); + b = get_src (sc); + MATH_OP (dc, b, 0, -, >= 0); + + /** 0111 011w 0000 dest TST.size #IMM, dest */ + + UNARY_UOP; + imm = IMM(w); + tprintf ("%x & %x = %x\n", v, imm, v & imm); + v &= imm; + set_sz (v, w+1); + + /** 1000 000w srcx dest TST.size src,dest */ + + BINARY_UOP; + tprintf ("%x & %x = %x\n", a, b, a & b); + v = a & b; + set_sz (v, w+1); + + /** 1111 1111 UND */ + + trigger_fixed_interrupt (0xffdc); + + /** 0111 1101 1111 0011 WAIT */ + + tprintf("waiting...\n"); + + /** 0111 101w 00sr dest XCHG.size src,dest */ + + sc = decode_srcdest4 (sr, w); + dc = decode_srcdest4 (dest, w); + a = get_src (sc); + b = get_src (dc); + put_dest (dc, a); + put_dest (sc, b); + + /** 0111 011w 0001 dest XOR.size #IMM,dest */ + + UNARY_UOP; + imm = IMM(w); + tprintf ("%x ^ %x = %x\n", v, imm, v ^ imm); + v ^= imm; + set_sz (v, w+1); + put_dest (dc, v); + + /** 1000 100w srcx dest XOR.size src,dest */ + + BINARY_UOP; + tprintf ("%x ^ %x = %x\n", a, b, a ^ b); + v = a ^ b; + set_sz (v, w+1); + put_dest (dc, v); + + /** OP */ +/** */ + + return step_result; +} Index: misc.c =================================================================== --- misc.c (nonexistent) +++ misc.c (revision 842) @@ -0,0 +1,77 @@ +/* misc.c --- miscellaneous utility functions for M32C simulator. + +Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Contributed by Red Hat, Inc. + +This file is part of the GNU simulators. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + + +#include + +#include "cpu.h" +#include "misc.h" + +int +bcd2int (int bcd, int w) +{ + int v = 0, m = 1, i; + for (i = 0; i < (w ? 4 : 2); i++) + { + v += (bcd % 16) * m; + m *= 10; + bcd /= 16; + } + return v; +} + +int +int2bcd (int v, int w) +{ + int bcd = 0, m = 1, i; + for (i = 0; i < (w ? 4 : 2); i++) + { + bcd += (v % 10) * m; + m *= 16; + v /= 10; + } + return bcd; +} + +char * +comma (unsigned int u) +{ + static char buf[5][20]; + static int bi = 0; + int comma = 0; + char *bp; + + bi = (bi + 1) % 5; + bp = buf[bi] + 19; + *--bp = 0; + do + { + if (comma == 3) + { + *--bp = ','; + comma = 0; + } + comma++; + *--bp = '0' + (u % 10); + u /= 10; + } + while (u); + return bp; +}
misc.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.