Let autoconf determine if host is big endian or not

This commit is contained in:
Michael Meissner 1995-11-30 11:13:08 +00:00
parent 9d5aef8075
commit 1f1e5dd85f
4 changed files with 630 additions and 84 deletions

View File

@ -1,11 +1,18 @@
Tue Nov 28 13:38:26 1995 Michael Meissner <meissner@tiktok.cygnus.com> Tue Nov 28 13:38:26 1995 Michael Meissner <meissner@tiktok.cygnus.com>
* sim-endian.h: Look at WORDS_BIGENDIAN to determine if the host
is big endian or little endian. For SWAP_n, use htonl/htons if
host is little endian, not big endian and if WITH_NTOH is defined.
* configure{,.in} (--enable-sim-model-issue): Instead of defining * configure{,.in} (--enable-sim-model-issue): Instead of defining
0/1, define it to be MODEL_ISSUE_{PROCESS,IGNORE}. 0/1, define it to be MODEL_ISSUE_{PROCESS,IGNORE}. Add
AC_C_BIGENDIAN to determine if the host is big endian or not.
* config.in: Regenerate.
* std-config.h (WITH_MODEL_ISSUE): Default to 0. * std-config.h (WITH_MODEL_ISSUE): Default to 0.
(CURRENT_MODEL_ISSUE): Reference WITH_MODEL_ISSUE, and if that is (CURRENT_MODEL_ISSUE): Reference WITH_MODEL_ISSUE, and if that is
0, use current_model_issue. 0, use current_model_issue.
(MODEL_ISSUE_{PROCESS,IGNORE}): Define as -1/1.
* psim.c (current_model_issue): New global variable. * psim.c (current_model_issue): New global variable.

387
sim/ppc/configure vendored
View File

@ -1,7 +1,7 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated automatically using autoconf version 2.4 # Generated automatically using autoconf version 2.7
# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. # Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
# #
# This configure script is free software; the Free Software Foundation # This configure script is free software; the Free Software Foundation
@ -87,9 +87,22 @@ target=NONE
verbose= verbose=
x_includes=NONE x_includes=NONE
x_libraries=NONE x_libraries=NONE
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datadir='${prefix}/share'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
libdir='${exec_prefix}/lib'
includedir='${prefix}/include'
oldincludedir='/usr/include'
infodir='${prefix}/info'
mandir='${prefix}/man'
# Initialize some other variables. # Initialize some other variables.
subdirs= subdirs=
MFLAGS= MAKEFLAGS=
ac_prev= ac_prev=
for ac_option for ac_option
@ -111,9 +124,14 @@ do
case "$ac_option" in case "$ac_option" in
-build | --build | --buil | --bui | --bu | --b) -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 ;; ac_prev=build ;;
-build=* | --build=* | --buil=* | --bui=* | --bu=* | --b=*) -build=* | --build=* | --buil=* | --bui=* | --bu=*)
build="$ac_optarg" ;; build="$ac_optarg" ;;
-cache-file | --cache-file | --cache-fil | --cache-fi \ -cache-file | --cache-file | --cache-fil | --cache-fi \
@ -123,6 +141,12 @@ do
| --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
cache_file="$ac_optarg" ;; cache_file="$ac_optarg" ;;
-datadir | --datadir | --datadi | --datad | --data | --dat | --da)
ac_prev=datadir ;;
-datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
| --da=*)
datadir="$ac_optarg" ;;
-disable-* | --disable-*) -disable-* | --disable-*)
ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
# Reject names that are not valid shell variable names. # Reject names that are not valid shell variable names.
@ -173,12 +197,29 @@ Configuration:
Directory and file names: Directory and file names:
--prefix=PREFIX install architecture-independent files in PREFIX --prefix=PREFIX install architecture-independent files in PREFIX
[$ac_default_prefix] [$ac_default_prefix]
--exec-prefix=PREFIX install architecture-dependent files in PREFIX --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[same as prefix] [same as prefix]
--bindir=DIR user executables in DIR [EPREFIX/bin]
--sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
--libexecdir=DIR program executables in DIR [EPREFIX/libexec]
--datadir=DIR read-only architecture-independent data in DIR
[PREFIX/share]
--sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data in DIR
[PREFIX/com]
--localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
--libdir=DIR object code libraries in DIR [EPREFIX/lib]
--includedir=DIR C header files in DIR [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
--infodir=DIR info documentation in DIR [PREFIX/info]
--mandir=DIR man documentation in DIR [PREFIX/man]
--srcdir=DIR find the sources in DIR [configure dir or ..] --srcdir=DIR find the sources in DIR [configure dir or ..]
--program-prefix=PREFIX prepend PREFIX to installed program names --program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM run sed PROGRAM on installed program names --program-transform-name=PROGRAM
run sed PROGRAM on installed program names
EOF
cat << EOF
Host type: Host type:
--build=BUILD configure for building on BUILD [BUILD=HOST] --build=BUILD configure for building on BUILD [BUILD=HOST]
--host=HOST configure for HOST [guessed] --host=HOST configure for HOST [guessed]
@ -190,8 +231,10 @@ Features and packages:
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--x-includes=DIR X include files are in DIR --x-includes=DIR X include files are in DIR
--x-libraries=DIR X library files are in DIR --x-libraries=DIR X library files are in DIR
--enable and --with options recognized:$ac_help
EOF EOF
if test -n "$ac_help"; then
echo "--enable and --with options recognized:$ac_help"
fi
exit 0 ;; exit 0 ;;
-host | --host | --hos | --ho) -host | --host | --hos | --ho)
@ -199,6 +242,44 @@ EOF
-host=* | --host=* | --hos=* | --ho=*) -host=* | --host=* | --hos=* | --ho=*)
host="$ac_optarg" ;; host="$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" ;;
-localstatedir | --localstatedir | --localstatedi | --localstated \
| --localstate | --localstat | --localsta | --localst \
| --locals | --local | --loca | --loc | --lo)
ac_prev=localstatedir ;;
-localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
| --localstate=* | --localstat=* | --localsta=* | --localst=* \
| --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
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) -nfp | --nfp | --nf)
# Obsolete; use --without-fp. # Obsolete; use --without-fp.
with_fp=no ;; with_fp=no ;;
@ -211,6 +292,15 @@ EOF
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
no_recursion=yes ;; 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) -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
ac_prev=prefix ;; ac_prev=prefix ;;
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
@ -251,6 +341,23 @@ EOF
| -silent | --silent | --silen | --sile | --sil) | -silent | --silent | --silen | --sile | --sil)
silent=yes ;; 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) -site | --site | --sit)
ac_prev=site ;; ac_prev=site ;;
-site=* | --site=* | --sit=*) -site=* | --site=* | --sit=*)
@ -261,6 +368,13 @@ EOF
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
srcdir="$ac_optarg" ;; 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) -target | --target | --targe | --targ | --tar | --ta | --t)
ac_prev=target ;; ac_prev=target ;;
-target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
@ -270,7 +384,7 @@ EOF
verbose=yes ;; verbose=yes ;;
-version | --version | --versio | --versi | --vers) -version | --version | --versio | --versi | --vers)
echo "configure generated by autoconf version 2.4" echo "configure generated by autoconf version 2.7"
exit 0 ;; exit 0 ;;
-with-* | --with-*) -with-* | --with-*)
@ -316,7 +430,7 @@ EOF
-*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
;; ;;
*) *)
if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
echo "configure: warning: $ac_option: invalid host type" 1>&2 echo "configure: warning: $ac_option: invalid host type" 1>&2
fi fi
@ -435,9 +549,12 @@ fi
ac_ext=c ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS' ac_cpp='echo $CPP $CPPFLAGS 1>&5;
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5 2>&5' $CPP $CPPFLAGS'
ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5 2>&5' ac_compile='echo ${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5;
${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5 2>&5'
ac_link='echo ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5;
${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5 2>&5'
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
# Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
@ -454,8 +571,8 @@ fi
# Check whether --enable-sim-cflags or --disable-sim-cflags was given. # Check whether --enable-sim-cflags or --disable-sim-cflags was given.
enableval="$enable_sim_cflags" if test "${enable_sim_cflags+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_cflags"
case "${enableval}" in case "${enableval}" in
yes) sim_cflags="-O2 -fomit-frame-pointer";; yes) sim_cflags="-O2 -fomit-frame-pointer";;
no) sim_cflags="";; no) sim_cflags="";;
@ -469,8 +586,8 @@ else
fi fi
# Check whether --enable-sim-warnings or --disable-sim-warnings was given. # Check whether --enable-sim-warnings or --disable-sim-warnings was given.
enableval="$enable_sim_warnings" if test "${enable_sim_warnings+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_warnings"
case "${enableval}" in case "${enableval}" in
yes) sim_warnings="-Werror -Wall -Wpointer-arith -Wmissing-prototypes";; yes) sim_warnings="-Werror -Wall -Wpointer-arith -Wmissing-prototypes";;
no) sim_warnings="-w";; no) sim_warnings="-w";;
@ -484,8 +601,8 @@ else
fi fi
# Check whether --enable-sim-config or --disable-sim-config was given. # Check whether --enable-sim-config or --disable-sim-config was given.
enableval="$enable_sim_config" if test "${enable_sim_config+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_config"
case "${enableval}" in case "${enableval}" in
yes|no) { echo "configure: error: "No value supplied for --enable-sim-config=file"" 1>&2; exit 1; };; yes|no) { echo "configure: error: "No value supplied for --enable-sim-config=file"" 1>&2; exit 1; };;
*) if test -f "${srcdir}/${enableval}"; then *) if test -f "${srcdir}/${enableval}"; then
@ -508,8 +625,8 @@ fi
fi fi
# Check whether --enable-sim-opcode or --disable-sim-opcode was given. # Check whether --enable-sim-opcode or --disable-sim-opcode was given.
enableval="$enable_sim_opcode" if test "${enable_sim_opcode+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_opcode"
case "${enableval}" in case "${enableval}" in
yes|no) { echo "configure: error: "No value supplied for --enable-sim-opcode=file"" 1>&2; exit 1; };; yes|no) { echo "configure: error: "No value supplied for --enable-sim-opcode=file"" 1>&2; exit 1; };;
*) if test -f "${srcdir}/${enableval}"; then *) if test -f "${srcdir}/${enableval}"; then
@ -532,8 +649,8 @@ fi
fi fi
# Check whether --enable-sim-switch or --disable-sim-switch was given. # Check whether --enable-sim-switch or --disable-sim-switch was given.
enableval="$enable_sim_switch" if test "${enable_sim_switch+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_switch"
case "${enableval}" in case "${enableval}" in
yes) sim_switch="-s";; yes) sim_switch="-s";;
no) sim_switch="";; no) sim_switch="";;
@ -550,8 +667,8 @@ fi
fi fi
# Check whether --enable-sim-duplicate or --disable-sim-duplicate was given. # Check whether --enable-sim-duplicate or --disable-sim-duplicate was given.
enableval="$enable_sim_duplicate" if test "${enable_sim_duplicate+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_duplicate"
case "${enableval}" in case "${enableval}" in
yes) sim_dup="-e";; yes) sim_dup="-e";;
no) sim_dup="";; no) sim_dup="";;
@ -568,8 +685,8 @@ fi
fi fi
# Check whether --enable-sim-filter or --disable-sim-filter was given. # Check whether --enable-sim-filter or --disable-sim-filter was given.
enableval="$enable_sim_filter" if test "${enable_sim_filter+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_filter"
case "${enableval}" in case "${enableval}" in
yes) { echo "configure: error: "--enable-sim-filter must be specified with a rule to filter or no"" 1>&2; exit 1; }; sim_filter="";; yes) { echo "configure: error: "--enable-sim-filter must be specified with a rule to filter or no"" 1>&2; exit 1; }; sim_filter="";;
no) sim_filter="";; no) sim_filter="";;
@ -586,8 +703,8 @@ fi
fi fi
# Check whether --enable-sim-icache or --disable-sim-icache was given. # Check whether --enable-sim-icache or --disable-sim-icache was given.
enableval="$enable_sim_icache" if test "${enable_sim_icache+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_icache"
icache="" icache=""
case "${enableval}" in case "${enableval}" in
yes) sim_icache="-r 1024"; icache="1024";; yes) sim_icache="-r 1024"; icache="1024";;
@ -606,8 +723,8 @@ fi
fi fi
# Check whether --enable-sim-inline or --disable-sim-inline was given. # Check whether --enable-sim-inline or --disable-sim-inline was given.
enableval="$enable_sim_inline" if test "${enable_sim_inline+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_inline"
sim_inline="" sim_inline=""
case "$enableval" in case "$enableval" in
no) sim_inline="-DDEFAULT_INLINE=0 -DINLINE=";; no) sim_inline="-DDEFAULT_INLINE=0 -DINLINE=";;
@ -644,8 +761,8 @@ fi
fi fi
# Check whether --enable-sim-bswap or --disable-sim-bswap was given. # Check whether --enable-sim-bswap or --disable-sim-bswap was given.
enableval="$enable_sim_bswap" if test "${enable_sim_bswap+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_bswap"
case "${enableval}" in case "${enableval}" in
yes) sim_bswap="-DWITH_BSWAP=1";; yes) sim_bswap="-DWITH_BSWAP=1";;
no) sim_bswap="-DWITH_BSWAP=0";; no) sim_bswap="-DWITH_BSWAP=0";;
@ -659,8 +776,8 @@ else
fi fi
# Check whether --enable-sim-endian or --disable-sim-endian was given. # Check whether --enable-sim-endian or --disable-sim-endian was given.
enableval="$enable_sim_endian" if test "${enable_sim_endian+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_endian"
case "${enableval}" in case "${enableval}" in
yes) case "$target" in yes) case "$target" in
*powerpc-*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";; *powerpc-*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
@ -680,8 +797,8 @@ else
fi fi
# Check whether --enable-sim-hostendian or --disable-sim-hostendian was given. # Check whether --enable-sim-hostendian or --disable-sim-hostendian was given.
enableval="$enable_sim_hostendian" if test "${enable_sim_hostendian+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_hostendian"
case "${enableval}" in case "${enableval}" in
no) sim_hostendian="-DWITH_HOST_BYTE_ORDER=0";; no) sim_hostendian="-DWITH_HOST_BYTE_ORDER=0";;
b*|B*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN";; b*|B*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN";;
@ -696,8 +813,8 @@ else
fi fi
# Check whether --enable-sim-smp or --disable-sim-smp was given. # Check whether --enable-sim-smp or --disable-sim-smp was given.
enableval="$enable_sim_smp" if test "${enable_sim_smp+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_smp"
case "${enableval}" in case "${enableval}" in
yes) sim_smp="-DWITH_SMP=5";; yes) sim_smp="-DWITH_SMP=5";;
no) sim_smp="-DWITH_SMP=0";; no) sim_smp="-DWITH_SMP=0";;
@ -714,8 +831,8 @@ fi
fi fi
# Check whether --enable-sim-xor-endian or --disable-sim-xor-endian was given. # Check whether --enable-sim-xor-endian or --disable-sim-xor-endian was given.
enableval="$enable_sim_xor_endian" if test "${enable_sim_xor_endian+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_xor_endian"
case "${enableval}" in case "${enableval}" in
yes) sim_xor_endian="-DWITH_XOR_ENDIAN=8";; yes) sim_xor_endian="-DWITH_XOR_ENDIAN=8";;
no) sim_xor_endian="-DWITH_XOR_ENDIAN=0";; no) sim_xor_endian="-DWITH_XOR_ENDIAN=0";;
@ -726,8 +843,8 @@ else
fi fi
# Check whether --enable-sim-bitsize or --disable-sim-bitsize was given. # Check whether --enable-sim-bitsize or --disable-sim-bitsize was given.
enableval="$enable_sim_bitsize" if test "${enable_sim_bitsize+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_bitsize"
case "${enableval}" in case "${enableval}" in
32|64) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=$enableval";; 32|64) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=$enableval";;
*) { echo "configure: error: "--enable-sim-bitsize was given $enableval" 1>&2; exit 1; }; sim_bitsize="";; *) { echo "configure: error: "--enable-sim-bitsize was given $enableval" 1>&2; exit 1; }; sim_bitsize="";;
@ -740,8 +857,8 @@ else
fi fi
# Check whether --enable-sim-hostbitsize or --disable-sim-hostbitsize was given. # Check whether --enable-sim-hostbitsize or --disable-sim-hostbitsize was given.
enableval="$enable_sim_hostbitsize" if test "${enable_sim_hostbitsize+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_hostbitsize"
case "${enableval}" in case "${enableval}" in
32|64) sim_hostbitsize="-DWITH_HOST_WORD_BITSIZE=$enableval";; 32|64) sim_hostbitsize="-DWITH_HOST_WORD_BITSIZE=$enableval";;
*) { echo "configure: error: "--enable-sim-hostbitsize was given $enableval" 1>&2; exit 1; }; sim_hostbitsize="";; *) { echo "configure: error: "--enable-sim-hostbitsize was given $enableval" 1>&2; exit 1; }; sim_hostbitsize="";;
@ -754,8 +871,8 @@ else
fi fi
# Check whether --enable-sim-env or --disable-sim-env was given. # Check whether --enable-sim-env or --disable-sim-env was given.
enableval="$enable_sim_env" if test "${enable_sim_env+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_env"
case "${enableval}" in case "${enableval}" in
operating | os | oea) sim_env="-DWITH_ENVIRONMENT=OPERATING_ENVIRONMENT";; operating | os | oea) sim_env="-DWITH_ENVIRONMENT=OPERATING_ENVIRONMENT";;
virtual | vea) sim_env="-DWITH_ENVIRONMENT=VIRTUAL_ENVIRONMENT";; virtual | vea) sim_env="-DWITH_ENVIRONMENT=VIRTUAL_ENVIRONMENT";;
@ -771,8 +888,8 @@ else
fi fi
# Check whether --enable-sim-timebase or --disable-sim-timebase was given. # Check whether --enable-sim-timebase or --disable-sim-timebase was given.
enableval="$enable_sim_timebase" if test "${enable_sim_timebase+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_timebase"
case "${enableval}" in case "${enableval}" in
yes) sim_timebase="-DWITH_TIME_BASE=1";; yes) sim_timebase="-DWITH_TIME_BASE=1";;
no) sim_timebase="-DWITH_TIME_BASE=0";; no) sim_timebase="-DWITH_TIME_BASE=0";;
@ -786,8 +903,8 @@ else
fi fi
# Check whether --enable-sim-alignment or --disable-sim-alignment was given. # Check whether --enable-sim-alignment or --disable-sim-alignment was given.
enableval="$enable_sim_alignment" if test "${enable_sim_alignment+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_alignment"
case "${enableval}" in case "${enableval}" in
yes | strict | STRICT) sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";; yes | strict | STRICT) sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";;
no | nonstrict | NONSTRICT) sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";; no | nonstrict | NONSTRICT) sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";;
@ -801,8 +918,8 @@ else
fi fi
# Check whether --enable-sim-trace or --disable-sim-trace was given. # Check whether --enable-sim-trace or --disable-sim-trace was given.
enableval="$enable_sim_trace" if test "${enable_sim_trace+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_trace"
case "${enableval}" in case "${enableval}" in
yes) sim_trace="-DWITH_TRACE=1";; yes) sim_trace="-DWITH_TRACE=1";;
no) sim_trace="-DWITH_TRACE=0";; no) sim_trace="-DWITH_TRACE=0";;
@ -816,8 +933,8 @@ else
fi fi
# Check whether --enable-sim-assert or --disable-sim-assert was given. # Check whether --enable-sim-assert or --disable-sim-assert was given.
enableval="$enable_sim_assert" if test "${enable_sim_assert+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_assert"
case "${enableval}" in case "${enableval}" in
yes) sim_assert="-DWITH_ASSERT=1";; yes) sim_assert="-DWITH_ASSERT=1";;
no) sim_assert="-DWITH_ASSERT=0";; no) sim_assert="-DWITH_ASSERT=0";;
@ -831,8 +948,8 @@ else
fi fi
# Check whether --enable-sim-reserved-bits or --disable-sim-reserved-bits was given. # Check whether --enable-sim-reserved-bits or --disable-sim-reserved-bits was given.
enableval="$enable_sim_reserved_bits" if test "${enable_sim_reserved_bits+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_reserved_bits"
case "${enableval}" in case "${enableval}" in
yes) sim_reserved="-DWITH_RESERVED_BITS=1";; yes) sim_reserved="-DWITH_RESERVED_BITS=1";;
no) sim_reserved="-DWITH_RESERVED_BITS=0";; no) sim_reserved="-DWITH_RESERVED_BITS=0";;
@ -846,8 +963,8 @@ else
fi fi
# Check whether --enable-sim-float or --disable-sim-float was given. # Check whether --enable-sim-float or --disable-sim-float was given.
enableval="$enable_sim_float" if test "${enable_sim_float+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_float"
case "${enableval}" in case "${enableval}" in
yes | hard) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT";; yes | hard) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT";;
no | soft) sim_float="-DWITH_FLOATING_POINT=SOFT_FLOATING_POINT";; no | soft) sim_float="-DWITH_FLOATING_POINT=SOFT_FLOATING_POINT";;
@ -861,8 +978,8 @@ else
fi fi
# Check whether --enable-sim-monitor or --disable-sim-monitor was given. # Check whether --enable-sim-monitor or --disable-sim-monitor was given.
enableval="$enable_sim_monitor" if test "${enable_sim_monitor+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_monitor"
case "${enableval}" in case "${enableval}" in
yes) sim_mon="-DWITH_MON='MONITOR_INSTRUCTION_ISSUE | MONITOR_LOAD_STORE_UNIT'";; yes) sim_mon="-DWITH_MON='MONITOR_INSTRUCTION_ISSUE | MONITOR_LOAD_STORE_UNIT'";;
no) sim_mon="-DWITH_MON=0";; no) sim_mon="-DWITH_MON=0";;
@ -878,8 +995,8 @@ else
fi fi
# Check whether --enable-sim-model or --disable-sim-model was given. # Check whether --enable-sim-model or --disable-sim-model was given.
enableval="$enable_sim_model" if test "${enable_sim_model+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_model"
case "${enableval}" in case "${enableval}" in
yes|no) { echo "configure: error: "No value supplied for --enable-sim-model=model"" 1>&2; exit 1; };; yes|no) { echo "configure: error: "No value supplied for --enable-sim-model=model"" 1>&2; exit 1; };;
*) sim_model="-DWITH_MODEL=${enableval}";; *) sim_model="-DWITH_MODEL=${enableval}";;
@ -892,8 +1009,8 @@ else
fi fi
# Check whether --enable-sim-default-model or --disable-sim-default-model was given. # Check whether --enable-sim-default-model or --disable-sim-default-model was given.
enableval="$enable_sim_default_model" if test "${enable_sim_default_model+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_default_model"
case "${enableval}" in case "${enableval}" in
yes|no) { echo "configure: error: "No value supplied for --enable-sim-default-model=model"" 1>&2; exit 1; };; yes|no) { echo "configure: error: "No value supplied for --enable-sim-default-model=model"" 1>&2; exit 1; };;
*) sim_default_model="-DWITH_DEFAULT_MODEL=${enableval}";; *) sim_default_model="-DWITH_DEFAULT_MODEL=${enableval}";;
@ -906,8 +1023,8 @@ else
fi fi
# Check whether --enable-sim-model-issue or --disable-sim-model-issue was given. # Check whether --enable-sim-model-issue or --disable-sim-model-issue was given.
enableval="$enable_sim_model_issue" if test "${enable_sim_model_issue+set}" = set; then
if test -n "$enableval"; then enableval="$enable_sim_model_issue"
case "${enableval}" in case "${enableval}" in
yes) sim_model_issue="-DWITH_MODEL_ISSUE=MODEL_ISSUE_PROCESS";; yes) sim_model_issue="-DWITH_MODEL_ISSUE=MODEL_ISSUE_PROCESS";;
no) sim_model_issue="-DWITH_MODEL_ISSUE=MODEL_ISSUE_IGNORE";; no) sim_model_issue="-DWITH_MODEL_ISSUE=MODEL_ISSUE_IGNORE";;
@ -946,7 +1063,7 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
# #
# The rules are: # The rules are:
# 1. You are not allowed to specify --host, --target, and nonopt at the # 1. You are not allowed to specify --host, --target, and nonopt at the
# same time. # same time.
# 2. Host defaults to nonopt. # 2. Host defaults to nonopt.
# 3. If nonopt is not specified, then host defaults to the current host, # 3. If nonopt is not specified, then host defaults to the current host,
# as determined by config.guess. # as determined by config.guess.
@ -1028,8 +1145,10 @@ test "$host_alias" != "$target_alias" &&
if test "$program_transform_name" = s,x,x,; then if test "$program_transform_name" = s,x,x,; then
program_transform_name= program_transform_name=
else else
# Double any \ or $. # Double any \ or $. echo might interpret backslashes.
echo 's,\\,\\\\,g; s,\$,$$,g' > conftestsed cat <<\EOF_SED > conftestsed
s,\\,\\\\,g; s,\$,$$,g
EOF_SED
program_transform_name="`echo $program_transform_name|sed -f conftestsed`" program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
rm -f conftestsed rm -f conftestsed
fi fi
@ -1091,6 +1210,7 @@ else
ac_cv_prog_gcc=no ac_cv_prog_gcc=no
fi fi
fi fi
echo "$ac_t""$ac_cv_prog_gcc" 1>&6 echo "$ac_t""$ac_cv_prog_gcc" 1>&6
if test $ac_cv_prog_gcc = yes; then if test $ac_cv_prog_gcc = yes; then
GCC=yes GCC=yes
@ -1108,7 +1228,8 @@ fi
rm -f conftest* rm -f conftest*
fi fi
echo "$ac_t""$ac_cv_prog_gcc_g" 1>&6
echo "$ac_t""$ac_cv_prog_gcc_g" 1>&6
if test $ac_cv_prog_gcc_g = yes; then if test $ac_cv_prog_gcc_g = yes; then
CFLAGS="-g -O" CFLAGS="-g -O"
else else
@ -1187,13 +1308,13 @@ if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1191 "configure" #line 1312 "configure"
#include "confdefs.h" #include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes, /* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */ which can conflict with char $ac_func(); below. */
#include <assert.h> #include <assert.h>
/* Override any gcc2 internal prototype to avoid an error. */ /* Override any gcc2 internal prototype to avoid an error. */
char $ac_func(); char $ac_func();
int main() { return 0; } int main() { return 0; }
int t() { int t() {
@ -1221,7 +1342,7 @@ rm -f conftest*
fi fi
if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
echo "$ac_t""yes" 1>&6 echo "$ac_t""yes" 1>&6
ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'` ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
cat >> confdefs.h <<EOF cat >> confdefs.h <<EOF
#define $ac_tr_func 1 #define $ac_tr_func 1
EOF EOF
@ -1242,7 +1363,7 @@ else
ac_cv_c_cross=yes ac_cv_c_cross=yes
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1246 "configure" #line 1367 "configure"
#include "confdefs.h" #include "confdefs.h"
main(){return(0);} main(){return(0);}
EOF EOF
@ -1255,14 +1376,100 @@ fi
fi fi
rm -fr conftest* rm -fr conftest*
fi fi
cross_compiling=$ac_cv_c_cross
echo "$ac_t""$ac_cv_c_cross" 1>&6 echo "$ac_t""$ac_cv_c_cross" 1>&6
cross_compiling=$ac_cv_c_cross
if test "x$cross_compiling" = "xno"; then if test "x$cross_compiling" = "xno"; then
CC_FOR_BUILD='$(CC)' CC_FOR_BUILD='$(CC)'
else else
CC_FOR_BUILD=gcc CC_FOR_BUILD=gcc
fi fi
echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_bigendian=unknown
# See if sys/param.h defines the BYTE_ORDER macro.
cat > conftest.$ac_ext <<EOF
#line 1396 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
int main() { return 0; }
int t() {
#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
bogus endian macros
#endif
; return 0; }
EOF
if eval $ac_compile; then
rm -rf conftest*
# It does; now see whether it defined to BIG_ENDIAN or not.
cat > conftest.$ac_ext <<EOF
#line 1412 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
int main() { return 0; }
int t() {
#if BYTE_ORDER != BIG_ENDIAN
not big endian
#endif
; return 0; }
EOF
if eval $ac_compile; then
rm -rf conftest*
ac_cv_c_bigendian=yes
else
rm -rf conftest*
ac_cv_c_bigendian=no
fi
rm -f conftest*
fi
rm -f conftest*
if test $ac_cv_c_bigendian = unknown; then
if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
#line 1441 "configure"
#include "confdefs.h"
main () {
/* Are we little or big endian? From Harbison&Steele. */
union
{
long l;
char c[sizeof (long)];
} u;
u.l = 1;
exit (u.c[sizeof (long) - 1] == 1);
}
EOF
eval $ac_link
if test -s conftest && (./conftest; exit) 2>/dev/null; then
ac_cv_c_bigendian=no
else
ac_cv_c_bigendian=yes
fi
fi
rm -fr conftest*
fi
fi
echo "$ac_t""$ac_cv_c_bigendian" 1>&6
if test $ac_cv_c_bigendian = yes; then
cat >> confdefs.h <<\EOF
#define WORDS_BIGENDIAN 1
EOF
fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
@ -1280,7 +1487,7 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser, # On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. # not just through cpp.
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1284 "configure" #line 1491 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <assert.h> #include <assert.h>
Syntax Error Syntax Error
@ -1294,7 +1501,7 @@ else
rm -rf conftest* rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp" CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1298 "configure" #line 1505 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <assert.h> #include <assert.h>
Syntax Error Syntax Error
@ -1327,7 +1534,7 @@ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1331 "configure" #line 1538 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <$ac_hdr> #include <$ac_hdr>
EOF EOF
@ -1345,7 +1552,7 @@ rm -f conftest*
fi fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6 echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./\055' '[A-Z]___'` ac_tr_hdr=HAVE_`echo $ac_hdr | tr 'abcdefghijklmnopqrstuvwxyz./\055' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___'`
cat >> confdefs.h <<EOF cat >> confdefs.h <<EOF
#define $ac_tr_hdr 1 #define $ac_tr_hdr 1
EOF EOF
@ -1432,7 +1639,7 @@ do
echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
-version | --version | --versio | --versi | --vers | --ver | --ve | --v) -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
echo "$CONFIG_STATUS generated by autoconf version 2.4" echo "$CONFIG_STATUS generated by autoconf version 2.7"
exit 0 ;; exit 0 ;;
-help | --help | --hel | --he | --h) -help | --help | --hel | --he | --h)
echo "\$ac_cs_usage"; exit 0 ;; echo "\$ac_cs_usage"; exit 0 ;;
@ -1443,10 +1650,12 @@ done
ac_given_srcdir=$srcdir ac_given_srcdir=$srcdir
trap 'rm -fr `echo "Makefile config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 trap 'rm -fr `echo "Makefile config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
cat >> $CONFIG_STATUS <<EOF
# Protect against being on the right side of a sed subst in config.status. # Protect against being on the right side of a sed subst in config.status.
sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\\\&%]/\\\\&/g; sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
$ac_vpsub $ac_vpsub
$extrasub $extrasub
s%@CFLAGS@%$CFLAGS%g s%@CFLAGS@%$CFLAGS%g
@ -1458,6 +1667,18 @@ s%@LIBS@%$LIBS%g
s%@exec_prefix@%$exec_prefix%g s%@exec_prefix@%$exec_prefix%g
s%@prefix@%$prefix%g s%@prefix@%$prefix%g
s%@program_transform_name@%$program_transform_name%g s%@program_transform_name@%$program_transform_name%g
s%@bindir@%$bindir%g
s%@sbindir@%$sbindir%g
s%@libexecdir@%$libexecdir%g
s%@datadir@%$datadir%g
s%@sysconfdir@%$sysconfdir%g
s%@sharedstatedir@%$sharedstatedir%g
s%@localstatedir@%$localstatedir%g
s%@libdir@%$libdir%g
s%@includedir@%$includedir%g
s%@oldincludedir@%$oldincludedir%g
s%@infodir@%$infodir%g
s%@mandir@%$mandir%g
s%@host@%$host%g s%@host@%$host%g
s%@host_alias@%$host_alias%g s%@host_alias@%$host_alias%g
s%@host_cpu@%$host_cpu%g s%@host_cpu@%$host_cpu%g
@ -1599,7 +1820,7 @@ EOF
# Transform confdefs.h into a sed script conftest.vals that substitutes # Transform confdefs.h into a sed script conftest.vals that substitutes
# the proper values into config.h.in to produce config.h. And first: # the proper values into config.h.in to produce config.h. And first:
# Protect against being on the right side of a sed subst in config.status. # Protect against being on the right side of a sed subst in config.status.
# Protect against being in an unquoted here document in config.status. # Protect against being in an unquoted here document in config.status.
rm -f conftest.vals rm -f conftest.vals
cat > conftest.hdr <<\EOF cat > conftest.hdr <<\EOF

View File

@ -414,6 +414,9 @@ else
fi fi
AC_SUBST(CC_FOR_BUILD) AC_SUBST(CC_FOR_BUILD)
AC_C_BIGENDIAN
AC_SUBST(WORDS_BIGENDIAN)
AC_CHECK_HEADERS(string.h strings.h stdlib.h time.h sys/types.h sys/time.h sys/times.h unistd.h sys/resource.h) AC_CHECK_HEADERS(string.h strings.h stdlib.h time.h sys/types.h sys/time.h sys/times.h unistd.h sys/resource.h)
AC_OUTPUT(Makefile, AC_OUTPUT(Makefile,

315
sim/ppc/sim-endian.h Normal file
View File

@ -0,0 +1,315 @@
/* This file is part of the program psim.
Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
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 2 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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SIM_ENDIAN_H_
#define _SIM_ENDIAN_H_
#ifndef INLINE_SIM_ENDIAN
#define INLINE_SIM_ENDIAN
#endif
/* C byte conversion functions */
INLINE_SIM_ENDIAN unsigned_1 endian_h2t_1(unsigned_1 x);
INLINE_SIM_ENDIAN unsigned_2 endian_h2t_2(unsigned_2 x);
INLINE_SIM_ENDIAN unsigned_4 endian_h2t_4(unsigned_4 x);
INLINE_SIM_ENDIAN unsigned_8 endian_h2t_8(unsigned_8 x);
INLINE_SIM_ENDIAN unsigned_1 endian_t2h_1(unsigned_1 x);
INLINE_SIM_ENDIAN unsigned_2 endian_t2h_2(unsigned_2 x);
INLINE_SIM_ENDIAN unsigned_4 endian_t2h_4(unsigned_4 x);
INLINE_SIM_ENDIAN unsigned_8 endian_t2h_8(unsigned_8 x);
INLINE_SIM_ENDIAN unsigned_1 swap_1(unsigned_1 x);
INLINE_SIM_ENDIAN unsigned_2 swap_2(unsigned_2 x);
INLINE_SIM_ENDIAN unsigned_4 swap_4(unsigned_4 x);
INLINE_SIM_ENDIAN unsigned_8 swap_8(unsigned_8 x);
/* Host dependant:
The CPP below defines information about the compilation host. In
particular it defines the macro's:
WITH_HOST_BYTE_ORDER The byte order of the host. Could
be any of LITTLE_ENDIAN, BIG_ENDIAN
or 0 (unknown). Those macro's also
need to be defined.
WITH_NTOH Network byte order macros defined.
Possible value is 32 or (maybe one
day 64 because some 64bit network
byte order macro is defined.
*/
/* NetBSD:
NetBSD is easy, everything you could ever want is in a header file
(well almost :-) */
#if defined(__NetBSD__)
# include <machine/endian.h>
# define WITH_NTOH 32 /* what about alpha? */
# if (WITH_HOST_BYTE_ORDER == 0)
# undef WITH_HOST_BYTE_ORDER
# define WITH_HOST_BYTE_ORDER BYTE_ORDER
# endif
# if (BYTE_ORDER != WITH_HOST_BYTE_ORDER)
# error "host endian incorrectly configured, check config.h"
# endif
#endif
/* Linux is similarly easy. */
#if defined(__linux__)
# include <endian.h>
# include <asm/byteorder.h>
# if defined(__LITTLE_ENDIAN) && !defined(LITTLE_ENDIAN)
# define LITTLE_ENDIAN __LITTLE_ENDIAN
# endif
# if defined(__BIG_ENDIAN) && !defined(BIG_ENDIAN)
# define BIG_ENDIAN __BIG_ENDIAN
# endif
# if defined(__BYTE_ORDER) && !defined(BYTE_ORDER)
# define BYTE_ORDER __BYTE_ORDER
# endif
# if !defined(__alpha__)
# define WITH_NTOH 32 /* what about alpha? */
# endif
# if (WITH_HOST_BYTE_ORDER == 0)
# undef WITH_HOST_BYTE_ORDER
# define WITH_HOST_BYTE_ORDER BYTE_ORDER
# endif
# if (BYTE_ORDER != WITH_HOST_BYTE_ORDER)
# error "host endian incorrectly configured, check config.h"
# endif
#endif
/* INSERT HERE - hosts that have available LITTLE_ENDIAN and
BIG_ENDIAN macro's */
/* Some hosts don't define LITTLE_ENDIAN or BIG_ENDIAN, help them out */
#ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN 1234
#endif
#ifndef BIG_ENDIAN
#define BIG_ENDIAN 4321
#endif
/* SunOS on SPARC:
Big endian last time I looked */
#if defined(sparc) || defined(__sparc__)
# if (WITH_HOST_BYTE_ORDER == 0)
# undef WITH_HOST_BYTE_ORDER
# define WITH_HOST_BYTE_ORDER BIG_ENDIAN
# endif
# if (WITH_HOST_BYTE_ORDER != BIG_ENDIAN)
# error "sun was big endian last time I looked ..."
# endif
#endif
/* Random x86
Little endian last time I looked */
#if defined(i386) || defined(i486) || defined(i586) || defined(__i386__) || defined(__i486__) || defined(__i586__)
# if (WITH_HOST_BYTE_ORDER == 0)
# undef WITH_HOST_BYTE_ORDER
# define WITH_HOST_BYTE_ORDER LITTLE_ENDIAN
# endif
# if (WITH_HOST_BYTE_ORDER != LITTLE_ENDIAN)
# error "x86 was little endian last time I looked ..."
# endif
#endif
#if (defined (__i486__) || defined (__i586__)) && defined(__GNUC__) && WITH_BSWAP && WITH_NTOH
#undef htonl
#undef ntohl
#define htonl(IN) __extension__ ({ int _out; __asm__ ("bswap %0" : "=r" (_out) : "0" (IN)); _out; })
#define ntohl(IN) __extension__ ({ int _out; __asm__ ("bswap %0" : "=r" (_out) : "0" (IN)); _out; })
#endif
/* Configure defines WORDS_BIGENDIAN if the host is big endian. */
#if (WITH_HOST_BYTE_ORDER == 0)
# undef WITH_HOST_BYTE_ORDER
# ifdef WORDS_BIGENDIAN
# define WITH_HOST_BYTE_ORDER BIG_ENDIAN
# else
# define WITH_HOST_BYTE_ORDER LITTLE_ENDIAN
# endif
#endif
/* SWAP:
Some times a swap must always be performed, select the most
effecient method to swap a collection of bytes.
HOST BE sw
HOST LE sw/ntoh
HOST ?? sw
*/
#if (WITH_HOST_BYTE_ORDER \
&& WITH_NTOH \
&& WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN)
#define SWAP_1(X) (X)
#define SWAP_2(X) ntohs(X)
#define SWAP_4(X) ntohl(X)
#define SWAP_8(X) swap_8(X)
#else
#define SWAP_1(X) (X)
#define SWAP_2(X) swap_2(X)
#define SWAP_4(X) swap_4(X)
#define SWAP_8(X) swap_8(X)
#endif
/* CONVERSION:
Convert between host and target byte orders by the most efficient
method known (if needed at all)
TARG BE TARG LE TARG ??
HOST BE ok swap swap
HOST LE htohl ok ok|ntohl
HOST ?? ntohl swap swap
*/
/* FUNCTIONS:
Returns the value swapped according to the host/target byte order */
/* no need to swap */
#if (WITH_HOST_BYTE_ORDER \
&& WITH_TARGET_BYTE_ORDER \
&& WITH_HOST_BYTE_ORDER == WITH_TARGET_BYTE_ORDER )
#define H2T_1(X) (X)
#define H2T_2(X) (X)
#define H2T_4(X) (X)
#define H2T_8(X) (X)
#define T2H_1(X) (X)
#define T2H_2(X) (X)
#define T2H_4(X) (X)
#define T2H_8(X) (X)
#endif
/* have ntoh and big endian target */
#if (WITH_TARGET_BYTE_ORDER == BIG_ENDIAN \
&& WITH_HOST_BYTE_ORDER != BIG_ENDIAN \
&& WITH_NTOH)
#define H2T_8(X) endian_h2t_8(X)
#define H2T_4(X) htonl(X)
#define H2T_2(X) htons(X)
#define H2T_1(X) (X)
#define T2H_8(X) endian_t2h_8(X)
#define T2H_4(X) htonl(X)
#define T2H_2(X) htons(X)
#define T2H_1(X) (X)
#endif
/* have ntoh, little host and unknown target */
#if (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN \
&& WITH_TARGET_BYTE_ORDER == 0 \
&& WITH_NTOH)
#define H2T_8(X) (CURRENT_TARGET_BYTE_ORDER == CURRENT_HOST_BYTE_ORDER \
? (X) : endian_h2t_8(X))
#define H2T_4(X) (CURRENT_TARGET_BYTE_ORDER == CURRENT_HOST_BYTE_ORDER \
? (X) : htonl(X))
#define H2T_2(X) (CURRENT_TARGET_BYTE_ORDER == CURRENT_HOST_BYTE_ORDER \
? (X) : htons(X))
#define H2T_1(X) (CURRENT_TARGET_BYTE_ORDER == CURRENT_HOST_BYTE_ORDER \
? (X) : (X))
#define T2H_8(X) (CURRENT_TARGET_BYTE_ORDER == CURRENT_HOST_BYTE_ORDER \
? (X) : endian_t2h_8(X))
#define T2H_4(X) (CURRENT_TARGET_BYTE_ORDER == CURRENT_HOST_BYTE_ORDER \
? (X) : htonl(X))
#define T2H_2(X) (CURRENT_TARGET_BYTE_ORDER == CURRENT_HOST_BYTE_ORDER \
? (X) : htons(X))
#define T2H_1(X) (CURRENT_TARGET_BYTE_ORDER == CURRENT_HOST_BYTE_ORDER \
? (X) : (X))
#endif
/* if all else fails use software */
#ifndef H2T_1
#define H2T_1(X) (X)
#define H2T_2(X) endian_h2t_2(X)
#define H2T_4(X) endian_h2t_4(X)
#define H2T_8(X) endian_h2t_8(X)
#define T2H_1(X) (X)
#define T2H_2(X) endian_t2h_2(X)
#define T2H_4(X) endian_t2h_4(X)
#define T2H_8(X) endian_t2h_8(X)
#endif
/* CONVERT IN PLACE:
These macros, given an argument of unknown size, swap its value in
place if a host/target conversion is required. */
#define H2T(VARIABLE) \
do { \
switch (sizeof(VARIABLE)) { \
case 1: VARIABLE = H2T_1(VARIABLE); break; \
case 2: VARIABLE = H2T_2(VARIABLE); break; \
case 4: VARIABLE = H2T_4(VARIABLE); break; \
case 8: VARIABLE = H2T_8(VARIABLE); break; \
} \
} while (0)
#define T2H(VARIABLE) \
do { \
switch (sizeof(VARIABLE)) { \
case 1: VARIABLE = T2H_1(VARIABLE); break; \
case 2: VARIABLE = T2H_2(VARIABLE); break; \
case 4: VARIABLE = T2H_4(VARIABLE); break; \
case 8: VARIABLE = T2H_8(VARIABLE); break; \
} \
} while (0)
/* TARGET WORD:
Byte swap a quantity the size of the targets word */
#if (WITH_TARGET_WORD_BITSIZE == 64)
#define H2T_word(X) H2T_8(X)
#define T2H_word(X) T2H_8(X)
#endif
#if (WITH_TARGET_WORD_BITSIZE == 32)
#define H2T_word(X) H2T_4(X)
#define T2H_word(X) T2H_4(X)
#endif
#endif /* _SIM_ENDIAN_H_ */