2
# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
# This code is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation. Oracle designates this
8
# particular file as subject to the "Classpath" exception as provided
9
# by Oracle in the LICENSE file that accompanied this code.
11
# This code is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
# version 2 for more details (a copy is included in the LICENSE file that
15
# accompanied this code).
17
# You should have received a copy of the GNU General Public License version
18
# 2 along with this work; if not, write to the Free Software Foundation,
19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
# or visit www.oracle.com if you need additional information or have any
28
GENSRC_BUFFER_DST := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/nio
30
GENSRC_BUFFER_SRC := $(MODULE_SRC)/share/classes/java/nio
34
$(GENSRC_BUFFER_DST)/_the.buffer.dir:
35
$(call LogInfo, Generating buffer classes)
36
$(call MakeDir, $(@D))
61
$1_category := integralType
68
$1_fulltype := character
69
$1_Fulltype := Character
70
$1_category := integralType
71
$1_streams := streamableType
82
$1_category := integralType
91
$1_fulltype := integer
92
$1_Fulltype := Integer
93
$1_category := integralType
102
$1_category := integralType
111
$1_category := floatingPointType
118
$1_fulltype := double
119
$1_Fulltype := Double
120
$1_category := floatingPointType
124
$1_Swaptype := $$($1_Type)
126
$1_Memtype := $$($1_Type)
133
$1_fromBits := Float.intBitsToFloat
134
$1_toBits := Float.floatToRawIntBits
143
$1_fromBits := Double.longBitsToDouble
144
$1_toBits := Double.doubleToRawLongBits
159
# param 6 nbytesButOne
160
$(call typesAndBits,$1,$2,$3)
163
$1_nbytesButOne := $6
164
$1_CMD := $(TOOL_SPP) \
167
-Dfulltype=$$($1_fulltype) \
168
-Dmemtype=$$($1_memtype) \
169
-DMemtype=$$($1_Memtype) \
170
-DfromBits=$$($1_fromBits) \
171
-DtoBits=$$($1_toBits) \
172
-DLG_BYTES_PER_VALUE=$$($1_LBPV) \
173
-DBYTES_PER_VALUE="(1 << $$($1_LBPV))" \
174
-Dnbytes=$$($1_nbytes) \
175
-DnbytesButOne=$$($1_nbytesButOne) \
183
# param 1 is for output file
184
# param 2 is template dependency
185
# param 3-9 are named args.
188
# RW := Mutability (R)ead-only (W)ritable
189
# BO := (U)nswapped/(S)wapped/(L)ittle/(B)ig
191
$(if $3,$1_$(strip $3))
192
$(if $4,$1_$(strip $4))
193
$(if $5,$1_$(strip $5))
194
$(if $6,$1_$(strip $6))
195
$(if $7,$1_$(strip $7))
196
$(if $8,$1_$(strip $8))
197
$(if $9,$1_$(strip $9))
198
$(if $(10),$1_$(strip $(10)))
199
$(if $(11),$1_$(strip $(11)))
200
$(if $(12),$1_$(strip $(12)))
201
$(if $(13),$1_$(strip $(13)))
202
$(if $(14),$1_$(strip $(14)))
203
$(foreach i,3 4 5 6 7 8 9 10 11 12 13 14 15,$(if $($i),$1_$(strip $($i)))$(NEWLINE))
204
$(call LogSetupMacroEntry,SetupGenBuffer($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))
205
$(if $(16),$(error Internal makefile error: Too many arguments to SetupGenBuffer, please update GensrcBuffer.gmk))
207
$(call fixRw,$1,$$($1_RW))
208
$(call typesAndBits,$1,$$($1_type),$$($1_BO))
210
$1_DST := $(GENSRC_BUFFER_DST)/$1.java
211
$1_SRC := $(GENSRC_BUFFER_SRC)/$(strip $2).java.template
212
$1_SRC_BIN := $(GENSRC_BUFFER_SRC)/$(strip $2)-bin.java.template
215
ifneq ($$($1_BIN), 1)
219
$1_DEP += $$($1_SRC) $$($1_SRC_BIN)
220
$1_OUT := $(GENSRC_BUFFER_DST)/$1.binop.0.java
224
$(call genBinOps,$1_char,char,$$($1_BO),$$($1_RW),two,one)
225
$(call genBinOps,$1_short,short,$$($1_BO),$$($1_RW),two,one)
226
$(call genBinOps,$1_int,int,$$($1_BO),$$($1_RW),four,three)
227
$(call genBinOps,$1_long,long,$$($1_BO),$$($1_RW),eight,seven)
228
$(call genBinOps,$1_float,float,$$($1_BO),$$($1_RW),four,three)
229
$(call genBinOps,$1_double,double,$$($1_BO),$$($1_RW),eight,seven)
232
$$($1_DST): $$($1_DEP) $(GENSRC_BUFFER_DST)/_the.buffer.dir
234
$(TOOL_SPP) -i$$($1_SRC) -o$$($1_OUT).tmp \
240
-Dfulltype=$$($1_fulltype) \
241
-DFulltype=$$($1_Fulltype) \
242
-Dstreamtype=$$($1_streamtype) \
243
-DStreamtype=$$($1_Streamtype) \
245
-Dmemtype=$$($1_memtype) \
246
-DMemtype=$$($1_Memtype) \
247
-DSwaptype=$$($1_Swaptype) \
248
-DfromBits=$$($1_fromBits) \
249
-DtoBits=$$($1_toBits) \
250
-DLG_BYTES_PER_VALUE=$$($1_LBPV) \
251
-DBYTES_PER_VALUE="(1 << $$($1_LBPV))" \
259
$(MV) $$($1_OUT).tmp $$($1_OUT)
260
# Do the extra bin thing
262
$(SED) -e '/#BIN/,$$$$d' < $$($1_OUT) > $$($1_DST).tmp
264
$$($1_char_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp
265
$$($1_short_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp
266
$$($1_int_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp
267
$$($1_long_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp
268
$$($1_float_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp
269
$$($1_double_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp
270
$(PRINTF) "}\n" >> $$($1_DST).tmp
271
mv $$($1_DST).tmp $$($1_DST)
274
GENSRC_BUFFER += $$($1_DST)
282
$(eval $(call SetupGenBuffer,ByteBuffer, $(X_BUF), type:=byte, BIN:=1))
283
$(eval $(call SetupGenBuffer,CharBuffer, $(X_BUF), type:=char))
284
$(eval $(call SetupGenBuffer,ShortBuffer, $(X_BUF), type:=short))
285
$(eval $(call SetupGenBuffer,IntBuffer, $(X_BUF), type:=int))
286
$(eval $(call SetupGenBuffer,LongBuffer, $(X_BUF), type:=long))
287
$(eval $(call SetupGenBuffer,FloatBuffer, $(X_BUF), type:=float))
288
$(eval $(call SetupGenBuffer,DoubleBuffer,$(X_BUF), type:=double))
290
# Buffers whose contents are heap-allocated
292
HEAP_X_BUF := Heap-X-Buffer
294
$(eval $(call SetupGenBuffer,HeapByteBuffer, $(HEAP_X_BUF), type:=byte))
295
$(eval $(call SetupGenBuffer,HeapByteBufferR, $(HEAP_X_BUF), type:=byte, RW:=R))
296
$(eval $(call SetupGenBuffer,HeapCharBuffer, $(HEAP_X_BUF), type:=char))
297
$(eval $(call SetupGenBuffer,HeapCharBufferR, $(HEAP_X_BUF), type:=char, RW:=R))
298
$(eval $(call SetupGenBuffer,HeapShortBuffer, $(HEAP_X_BUF), type:=short))
299
$(eval $(call SetupGenBuffer,HeapShortBufferR, $(HEAP_X_BUF), type:=short, RW:=R))
300
$(eval $(call SetupGenBuffer,HeapIntBuffer, $(HEAP_X_BUF), type:=int))
301
$(eval $(call SetupGenBuffer,HeapIntBufferR, $(HEAP_X_BUF), type:=int, RW:=R))
302
$(eval $(call SetupGenBuffer,HeapLongBuffer, $(HEAP_X_BUF), type:=long))
303
$(eval $(call SetupGenBuffer,HeapLongBufferR, $(HEAP_X_BUF), type:=long, RW:=R))
304
$(eval $(call SetupGenBuffer,HeapFloatBuffer, $(HEAP_X_BUF), type:=float))
305
$(eval $(call SetupGenBuffer,HeapFloatBufferR, $(HEAP_X_BUF), type:=float, RW:=R))
306
$(eval $(call SetupGenBuffer,HeapDoubleBuffer, $(HEAP_X_BUF), type:=double))
307
$(eval $(call SetupGenBuffer,HeapDoubleBufferR,$(HEAP_X_BUF), type:=double, RW:=R))
311
DIRECT_X_BUF := Direct-X-Buffer
313
$(eval $(call SetupGenBuffer,DirectByteBuffer, $(DIRECT_X_BUF), type:=byte, BIN:=1))
314
$(eval $(call SetupGenBuffer,DirectByteBufferR,$(DIRECT_X_BUF), type:=byte, BIN:=1, RW:=R))
316
# Unswapped views of direct byte buffers
318
$(eval $(call SetupGenBuffer,DirectCharBufferU, $(DIRECT_X_BUF), type:=char, BO:=U))
319
$(eval $(call SetupGenBuffer,DirectCharBufferRU, $(DIRECT_X_BUF), type:=char, RW:=R, BO:=U))
320
$(eval $(call SetupGenBuffer,DirectShortBufferU, $(DIRECT_X_BUF), type:=short, BO:=U))
321
$(eval $(call SetupGenBuffer,DirectShortBufferRU, $(DIRECT_X_BUF), type:=short, RW:=R, BO:=U))
322
$(eval $(call SetupGenBuffer,DirectIntBufferU, $(DIRECT_X_BUF), type:=int, BO:=U))
323
$(eval $(call SetupGenBuffer,DirectIntBufferRU, $(DIRECT_X_BUF), type:=int, RW:=R, BO:=U))
324
$(eval $(call SetupGenBuffer,DirectLongBufferU, $(DIRECT_X_BUF), type:=long, BO:=U))
325
$(eval $(call SetupGenBuffer,DirectLongBufferRU, $(DIRECT_X_BUF), type:=long, RW:=R, BO:=U))
326
$(eval $(call SetupGenBuffer,DirectFloatBufferU, $(DIRECT_X_BUF), type:=float, BO:=U))
327
$(eval $(call SetupGenBuffer,DirectFloatBufferRU, $(DIRECT_X_BUF), type:=float, RW:=R, BO:=U))
328
$(eval $(call SetupGenBuffer,DirectDoubleBufferU, $(DIRECT_X_BUF), type:=double, BO:=U))
329
$(eval $(call SetupGenBuffer,DirectDoubleBufferRU,$(DIRECT_X_BUF), type:=double, RW:=R, BO:=U))
331
# Swapped views of direct byte buffers
333
$(eval $(call SetupGenBuffer,DirectCharBufferS, $(DIRECT_X_BUF), type:=char, BO:=S))
334
$(eval $(call SetupGenBuffer,DirectCharBufferRS, $(DIRECT_X_BUF), type:=char, RW:=R, BO:=S))
335
$(eval $(call SetupGenBuffer,DirectShortBufferS, $(DIRECT_X_BUF), type:=short, BO:=S))
336
$(eval $(call SetupGenBuffer,DirectShortBufferRS, $(DIRECT_X_BUF), type:=short, RW:=R, BO:=S))
337
$(eval $(call SetupGenBuffer,DirectIntBufferS, $(DIRECT_X_BUF), type:=int, BO:=S))
338
$(eval $(call SetupGenBuffer,DirectIntBufferRS, $(DIRECT_X_BUF), type:=int, RW:=R, BO:=S))
339
$(eval $(call SetupGenBuffer,DirectLongBufferS, $(DIRECT_X_BUF), type:=long, BO:=S))
340
$(eval $(call SetupGenBuffer,DirectLongBufferRS, $(DIRECT_X_BUF), type:=long, RW:=R, BO:=S))
341
$(eval $(call SetupGenBuffer,DirectFloatBufferS, $(DIRECT_X_BUF), type:=float, BO:=S))
342
$(eval $(call SetupGenBuffer,DirectFloatBufferRS, $(DIRECT_X_BUF), type:=float, RW:=R, BO:=S))
343
$(eval $(call SetupGenBuffer,DirectDoubleBufferS, $(DIRECT_X_BUF), type:=double, BO:=S))
344
$(eval $(call SetupGenBuffer,DirectDoubleBufferRS,$(DIRECT_X_BUF), type:=double, RW:=R, BO:=S))
346
# Big-endian views of byte buffers
348
BYTE_X_BUF := ByteBufferAs-X-Buffer
350
$(eval $(call SetupGenBuffer,ByteBufferAsCharBufferB, $(BYTE_X_BUF), type:=char, BO:=B))
351
$(eval $(call SetupGenBuffer,ByteBufferAsCharBufferRB, $(BYTE_X_BUF), type:=char, RW:=R, BO:=B))
352
$(eval $(call SetupGenBuffer,ByteBufferAsShortBufferB, $(BYTE_X_BUF), type:=short, BO:=B))
353
$(eval $(call SetupGenBuffer,ByteBufferAsShortBufferRB, $(BYTE_X_BUF), type:=short, RW:=R, BO:=B))
354
$(eval $(call SetupGenBuffer,ByteBufferAsIntBufferB, $(BYTE_X_BUF), type:=int, BO:=B))
355
$(eval $(call SetupGenBuffer,ByteBufferAsIntBufferRB, $(BYTE_X_BUF), type:=int, RW:=R, BO:=B))
356
$(eval $(call SetupGenBuffer,ByteBufferAsLongBufferB, $(BYTE_X_BUF), type:=long, BO:=B))
357
$(eval $(call SetupGenBuffer,ByteBufferAsLongBufferRB, $(BYTE_X_BUF), type:=long, RW:=R, BO:=B))
358
$(eval $(call SetupGenBuffer,ByteBufferAsFloatBufferB, $(BYTE_X_BUF), type:=float, BO:=B))
359
$(eval $(call SetupGenBuffer,ByteBufferAsFloatBufferRB, $(BYTE_X_BUF), type:=float, RW:=R, BO:=B))
360
$(eval $(call SetupGenBuffer,ByteBufferAsDoubleBufferB, $(BYTE_X_BUF), type:=double, BO:=B))
361
$(eval $(call SetupGenBuffer,ByteBufferAsDoubleBufferRB,$(BYTE_X_BUF), type:=double, RW:=R, BO:=B))
363
# Little-endian views of byte buffers
365
$(eval $(call SetupGenBuffer,ByteBufferAsCharBufferL, $(BYTE_X_BUF), type:=char, BO:=L))
366
$(eval $(call SetupGenBuffer,ByteBufferAsCharBufferRL, $(BYTE_X_BUF), type:=char, RW:=R, BO:=L))
367
$(eval $(call SetupGenBuffer,ByteBufferAsShortBufferL, $(BYTE_X_BUF), type:=short, BO:=L))
368
$(eval $(call SetupGenBuffer,ByteBufferAsShortBufferRL, $(BYTE_X_BUF), type:=short, RW:=R, BO:=L))
369
$(eval $(call SetupGenBuffer,ByteBufferAsIntBufferL, $(BYTE_X_BUF), type:=int, BO:=L))
370
$(eval $(call SetupGenBuffer,ByteBufferAsIntBufferRL, $(BYTE_X_BUF), type:=int, RW:=R, BO:=L))
371
$(eval $(call SetupGenBuffer,ByteBufferAsLongBufferL, $(BYTE_X_BUF), type:=long, BO:=L))
372
$(eval $(call SetupGenBuffer,ByteBufferAsLongBufferRL, $(BYTE_X_BUF), type:=long, RW:=R, BO:=L))
373
$(eval $(call SetupGenBuffer,ByteBufferAsFloatBufferL, $(BYTE_X_BUF), type:=float, BO:=L))
374
$(eval $(call SetupGenBuffer,ByteBufferAsFloatBufferRL, $(BYTE_X_BUF), type:=float, RW:=R, BO:=L))
375
$(eval $(call SetupGenBuffer,ByteBufferAsDoubleBufferL, $(BYTE_X_BUF), type:=double, BO:=L))
376
$(eval $(call SetupGenBuffer,ByteBufferAsDoubleBufferRL,$(BYTE_X_BUF), type:=double, RW:=R, BO:=L))
380
$(GENSRC_BUFFER): $(BUILD_TOOLS_JDK)
382
TARGETS += $(GENSRC_BUFFER)