jdk/make/java/nio/genBuffer.sh
author amenkov
Tue, 14 Sep 2010 12:38:49 +0400
changeset 6505 b1faae5e44a3
parent 5506 202f599c92aa
permissions -rw-r--r--
6944033: RFE: add PCM_FLOAT support Reviewed-by: dav
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
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4502
diff changeset
     4
# Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
2
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4502
diff changeset
     9
# published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
# particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4502
diff changeset
    11
# by Oracle in the LICENSE file that accompanied this code.
2
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
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4502
diff changeset
    23
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4502
diff changeset
    24
# or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4502
diff changeset
    25
# questions.
2
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;;
4502
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 4115
diff changeset
    47
  int)   fulltype=integer;;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
  *)     fulltype=$type;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
case $type in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
  byte)           LBPV=0;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
  char | short)   LBPV=1;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
  int | float)    LBPV=2;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
  long | double)  LBPV=3;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
4502
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 4115
diff changeset
    58
case $type in 
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 4115
diff changeset
    59
  float|double) floatingPointOrIntegralType=floatingPointType;;
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 4115
diff changeset
    60
  *)            floatingPointOrIntegralType=integralType;;
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 4115
diff changeset
    61
esac
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 4115
diff changeset
    62
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
typesAndBits() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
  type="$1"; BO="$2"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
  memtype=$type; swaptype=$type; frombits=; tobits=
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
  case $type in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    float)   memtype=int
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
             if [ x$BO != xU ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
	       swaptype=int
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
	       fromBits=Float.intBitsToFloat
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
	       toBits=Float.floatToRawIntBits
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
	     fi;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    double)  memtype=long
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
             if [ x$BO != xU ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
	       swaptype=long
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
	       fromBits=Double.longBitsToDouble
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
	       toBits=Double.doubleToRawLongBits
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
	     fi;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
  esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
  echo memtype=$memtype swaptype=$swaptype fromBits=$fromBits toBits=$toBits
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
  echo $type $fulltype $memtype $swaptype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
  | $NAWK '{ type = $1; fulltype = $2; memtype = $3; swaptype = $4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
	     x = substr(type, 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
	     Type = toupper(x) substr(type, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
	     Fulltype = toupper(x) substr(fulltype, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
	     Memtype = toupper(substr(memtype, 1, 1)) substr(memtype, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
	     Swaptype = toupper(substr(swaptype, 1, 1)) substr(swaptype, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
	     printf("Type=%s x=%s Fulltype=%s Memtype=%s Swaptype=%s ",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
		    Type, x, Fulltype, Memtype, Swaptype); }'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
  echo "swap=`if [ x$BO = xS ]; then echo Bits.swap; fi`"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
eval `typesAndBits $type $BO`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
a=`if [ $type = int ]; then echo an; else echo a; fi`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
A=`if [ $type = int ]; then echo An; else echo A; fi`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
if [ "x$rw" = xR ]; then rwkey=ro; else rwkey=rw; fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
set -e
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
$SPP <$SRC >$DST \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
  -K$type \
4502
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 4115
diff changeset
   110
  -K$floatingPointOrIntegralType \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
  -Dtype=$type \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
  -DType=$Type \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
  -Dfulltype=$fulltype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
  -DFulltype=$Fulltype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
  -Dx=$x \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
  -Dmemtype=$memtype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
  -DMemtype=$Memtype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
  -DSwaptype=$Swaptype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
  -DfromBits=$fromBits \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
  -DtoBits=$toBits \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
  -DLG_BYTES_PER_VALUE=$LBPV \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
  -DBYTES_PER_VALUE="(1 << $LBPV)" \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
  -DBO=$BO \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
  -Dswap=$swap \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
  -DRW=$rw \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
  -K$rwkey \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
  -Da=$a \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
  -DA=$A \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
  -Kbo$BO
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
if [ $BIN ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
  genBinOps() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    type="$1"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    Type=`echo $1 | $NAWK '{ print toupper(substr($1, 1, 1)) substr($1, 2) }'`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    fulltype="$2"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    LBPV="$3"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    nbytes="$4"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    nbytesButOne="$5"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    a=`if [ $type = int ]; then echo an; else echo a; fi`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    src=$6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    eval `typesAndBits $type`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    $SPP <$src \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
      -Dtype=$type \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
      -DType=$Type \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
      -Dfulltype=$fulltype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
      -Dmemtype=$memtype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
      -DMemtype=$Memtype \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
      -DfromBits=$fromBits \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
      -DtoBits=$toBits \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
      -DLG_BYTES_PER_VALUE=$LBPV \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
      -DBYTES_PER_VALUE="(1 << $LBPV)" \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
      -Dnbytes=$nbytes \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
      -DnbytesButOne=$nbytesButOne \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
      -DRW=$rw \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
      -K$rwkey \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
      -Da=$a \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
      -be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
  mv $DST $DST.tmp
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
  sed -e '/#BIN/,$d' <$DST.tmp >$DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
  rm -f $DST.tmp
4115
e09be02771b6 6888701: Change all template java source files to a .java-template file suffix
ohair
parents: 2
diff changeset
   164
  binops=`dirname $SRC`/`basename $SRC .java.template`-bin.java.template
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
  genBinOps char character 1 two one $binops >>$DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
  genBinOps short short 1 two one $binops >>$DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
  genBinOps int integer 2 four three $binops >>$DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
  genBinOps long long 3 eight seven $binops >>$DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
  genBinOps float float 2 four three $binops >>$DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
  genBinOps double double 3 eight seven $binops >>$DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
  echo '}' >>$DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
fi