jdk/make/java/nio/genBuffer.sh
author ohair
Tue, 04 Mar 2008 09:51:25 -0800
changeset 29 b8bedccd805d
parent 2 90ce3da70b43
child 4115 e09be02771b6
permissions -rw-r--r--
6638060: Build failed with GNU make 3.81 (part of latest Solaris 'gmake') Summary: Changes to the way GNU make 3.81 deals with the env variable SHELL Reviewed-by: xdono
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
#! /bin/sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
# Copyright 2000-2005 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
# published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
# particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
# by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
# This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
# version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
# accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
# You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
# 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
# CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
# have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
# Generate concrete buffer classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
# Required environment variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#   NAWK SED SPP    To invoke tools
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#   TYPE            Primitive type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#   SRC             Source file
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#   DST             Destination file
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
# Optional environment variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#   RW              Mutability: R(ead only), W(ritable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#   BO              Byte order: B(ig), L(ittle), S(wapped), U(nswapped)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#   BIN             Defined => generate binary-data access methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
type=$TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
rw=$RW
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
rwkey=XX
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
case $type in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
  char)  fulltype=character;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
  *)     fulltype=$type;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
case $type in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
  byte)           LBPV=0;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
  char | short)   LBPV=1;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
  int | float)    LBPV=2;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
  long | double)  LBPV=3;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
typesAndBits() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
  type="$1"; BO="$2"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
  memtype=$type; swaptype=$type; frombits=; tobits=
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
  case $type in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    float)   memtype=int
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
             if [ x$BO != xU ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
	       swaptype=int
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
	       fromBits=Float.intBitsToFloat
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
	       toBits=Float.floatToRawIntBits
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
	     fi;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    double)  memtype=long
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
             if [ x$BO != xU ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
	       swaptype=long
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
	       fromBits=Double.longBitsToDouble
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
	       toBits=Double.doubleToRawLongBits
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
	     fi;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
  esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
  echo memtype=$memtype swaptype=$swaptype fromBits=$fromBits toBits=$toBits
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
  echo $type $fulltype $memtype $swaptype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
  | $NAWK '{ type = $1; fulltype = $2; memtype = $3; swaptype = $4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
	     x = substr(type, 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
	     Type = toupper(x) substr(type, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
	     Fulltype = toupper(x) substr(fulltype, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
	     Memtype = toupper(substr(memtype, 1, 1)) substr(memtype, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
	     Swaptype = toupper(substr(swaptype, 1, 1)) substr(swaptype, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
	     printf("Type=%s x=%s Fulltype=%s Memtype=%s Swaptype=%s ",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
		    Type, x, Fulltype, Memtype, Swaptype); }'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
  echo "swap=`if [ x$BO = xS ]; then echo Bits.swap; fi`"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
eval `typesAndBits $type $BO`
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
a=`if [ $type = int ]; then echo an; else echo a; fi`
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
A=`if [ $type = int ]; then echo An; else echo A; fi`
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
if [ "x$rw" = xR ]; then rwkey=ro; else rwkey=rw; fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
set -e
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
$SPP <$SRC >$DST \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
  -K$type \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
  -Dtype=$type \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
  -DType=$Type \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
  -Dfulltype=$fulltype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
  -DFulltype=$Fulltype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
  -Dx=$x \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
  -Dmemtype=$memtype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
  -DMemtype=$Memtype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
  -DSwaptype=$Swaptype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
  -DfromBits=$fromBits \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
  -DtoBits=$toBits \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
  -DLG_BYTES_PER_VALUE=$LBPV \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
  -DBYTES_PER_VALUE="(1 << $LBPV)" \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
  -DBO=$BO \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
  -Dswap=$swap \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
  -DRW=$rw \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
  -K$rwkey \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
  -Da=$a \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
  -DA=$A \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
  -Kbo$BO
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
if [ $BIN ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
  genBinOps() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    type="$1"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    Type=`echo $1 | $NAWK '{ print toupper(substr($1, 1, 1)) substr($1, 2) }'`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    fulltype="$2"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    LBPV="$3"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    nbytes="$4"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    nbytesButOne="$5"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    a=`if [ $type = int ]; then echo an; else echo a; fi`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    src=$6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    eval `typesAndBits $type`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    $SPP <$src \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
      -Dtype=$type \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
      -DType=$Type \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
      -Dfulltype=$fulltype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
      -Dmemtype=$memtype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
      -DMemtype=$Memtype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
      -DfromBits=$fromBits \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
      -DtoBits=$toBits \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
      -DLG_BYTES_PER_VALUE=$LBPV \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
      -DBYTES_PER_VALUE="(1 << $LBPV)" \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
      -Dnbytes=$nbytes \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
      -DnbytesButOne=$nbytesButOne \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
      -DRW=$rw \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
      -K$rwkey \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
      -Da=$a \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
      -be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
  mv $DST $DST.tmp
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
  sed -e '/#BIN/,$d' <$DST.tmp >$DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
  rm -f $DST.tmp
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
  binops=`dirname $SRC`/`basename $SRC .java`-bin.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
  genBinOps char character 1 two one $binops >>$DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
  genBinOps short short 1 two one $binops >>$DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
  genBinOps int integer 2 four three $binops >>$DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
  genBinOps long long 3 eight seven $binops >>$DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
  genBinOps float float 2 four three $binops >>$DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
  genBinOps double double 3 eight seven $binops >>$DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
  echo '}' >>$DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
fi