Mercurial > hg > icedtea8-forest > jdk
changeset 11526:14a4b0a9a0b7 jdk8u65-b17
8034179: Clean up nio genConstants
Reviewed-by: alanb, ihse, dholmes
author | erikj |
---|---|
date | Fri, 21 Aug 2015 11:34:13 +0200 |
parents | 25a3ef813ea0 |
children | b3ce30db46ab |
files | make/CompileJavaClasses.gmk make/gensrc/GensrcMisc.gmk make/src/native/genconstants/ch/genSocketOptionRegistry.c make/src/native/genconstants/fs/genSolarisConstants.c make/src/native/genconstants/fs/genUnixConstants.c src/share/native/sun/nio/ch/genSocketOptionRegistry.c src/solaris/native/sun/nio/fs/genSolarisConstants.c src/solaris/native/sun/nio/fs/genUnixConstants.c |
diffstat | 8 files changed, 389 insertions(+), 398 deletions(-) [+] |
line wrap: on
line diff
--- a/make/CompileJavaClasses.gmk Thu Oct 01 11:16:16 2015 -0700 +++ b/make/CompileJavaClasses.gmk Fri Aug 21 11:34:13 2015 +0200 @@ -238,11 +238,6 @@ EXFILES += sun/nio/fs/PollingWatchService.java endif -# TODO: Fix when converting NIO -# Exclude *-linux-arm.java and *-linux-ppc.java from closed. -EXFILES += -linux-arm.java \ - -linux-ppc.java - ifeq ($(OPENJDK_TARGET_OS), windows) EXFILES += sun/nio/ch/AbstractPollSelectorImpl.java \ sun/nio/ch/PollSelectorProvider.java \
--- a/make/gensrc/GensrcMisc.gmk Thu Oct 01 11:16:16 2015 -0700 +++ b/make/gensrc/GensrcMisc.gmk Fri Aug 21 11:34:13 2015 +0200 @@ -64,9 +64,9 @@ GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc/sun/nio/ch/SocketOptionRegistry.java -GENSRC_SOR_SRC := $(JDK_TOPDIR)/src/share/native/sun/nio/ch +GENSRC_SOR_SRC := $(JDK_TOPDIR)/make/src/native/genconstants/ch GENSRC_SOR_SRC_FILE := genSocketOptionRegistry.c -GENSRC_SOR_BIN := $(JDK_OUTPUTDIR)/gensrc/genSocketOptionRegistry +GENSRC_SOR_BIN := $(JDK_OUTPUTDIR)/btnative/genSocketOptionRegistry SOR_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSRC_SOR_SRC)/$(GENSRC_SOR_SRC_FILE) | \ $(NAWK) '/^.*Copyright.*Oracle/ { printf "%s %s",$$4,$$5 }') @@ -81,11 +81,9 @@ OUTPUT_DIR := $(GENSRC_SOR_BIN), \ PROGRAM := genSocketOptionRegistry)) -ifneq ($(wildcard $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/ch/SocketOptionRegistry-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java), ) - HAS_SOCKET_OPTION_REGISTRY := true -endif +SOR_PREGEN_FILE := $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/ch/SocketOptionRegistry-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java.template -ifneq ($(HAS_SOCKET_OPTION_REGISTRY), true) +ifeq ($(wildcard $(SOR_PREGEN_FILE)), ) $(JDK_OUTPUTDIR)/gensrc/sun/nio/ch/SocketOptionRegistry.java: $(BUILD_GENSRC_SOR_EXE) $(MKDIR) -p $(@D) $(RM) $@ $@.tmp @@ -93,7 +91,7 @@ $(BUILD_GENSRC_SOR_EXE) >> $@.tmp $(MV) $@.tmp $@ else - $(JDK_OUTPUTDIR)/gensrc/sun/nio/ch/SocketOptionRegistry.java: $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/ch/SocketOptionRegistry-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java + $(JDK_OUTPUTDIR)/gensrc/sun/nio/ch/SocketOptionRegistry.java: $(SOR_PREGEN_FILE) $(call install-file) endif @@ -103,9 +101,9 @@ GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc/sun/nio/fs/UnixConstants.java - GENSRC_UC_SRC := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/nio/fs + GENSRC_UC_SRC := $(JDK_TOPDIR)/make/src/native/genconstants/fs GENSRC_UC_SRC_FILE := genUnixConstants.c - GENSRC_UC_BIN := $(JDK_OUTPUTDIR)/gensrc/genUnixConstants + GENSRC_UC_BIN := $(JDK_OUTPUTDIR)/btnative/genUnixConstants UC_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSRC_UC_SRC)/$(GENSRC_UC_SRC_FILE) | \ $(NAWK) '/^.*Copyright.*Oracle/ { printf "%s %s",$$4,$$5 }') @@ -121,11 +119,9 @@ OUTPUT_DIR := $(GENSRC_UC_BIN), \ PROGRAM := genUnixConstants)) - ifneq ($(wildcard $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/fs/UnixConstants-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java), ) - HAS_UNIX_CONSTANTS := true - endif + UC_PREGEN_FILE := $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/fs/UnixConstants-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java.template - ifneq ($(HAS_UNIX_CONSTANTS), true) + ifeq ($(wildcard $(UC_PREGEN_FILE)), ) $(JDK_OUTPUTDIR)/gensrc/sun/nio/fs/UnixConstants.java: $(BUILD_GENSRC_UC_EXE) $(MKDIR) -p $(@D) $(RM) $@ $@.tmp @@ -133,7 +129,7 @@ $(BUILD_GENSRC_UC_EXE) >> $@.tmp $(MV) $@.tmp $@ else - $(JDK_OUTPUTDIR)/gensrc/sun/nio/fs/UnixConstants.java: $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/fs/UnixConstants-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java + $(JDK_OUTPUTDIR)/gensrc/sun/nio/fs/UnixConstants.java: $(UC_PREGEN_FILE) $(call install-file) endif @@ -145,9 +141,9 @@ GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc/sun/nio/fs/SolarisConstants.java - GENSRC_SOL_SRC := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/nio/fs + GENSRC_SOL_SRC := $(JDK_TOPDIR)/make/src/native/genconstants/fs GENSRC_SOL_SRC_FILE := genSolarisConstants.c - GENSRC_SOL_BIN := $(JDK_OUTPUTDIR)/gensrc/genSolarisConstants + GENSRC_SOL_BIN := $(JDK_OUTPUTDIR)/btnative/genSolarisConstants SOL_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSRC_SOL_SRC)/$(GENSRC_SOL_SRC_FILE) | \ $(NAWK) '/^.*Copyright.*Oracle/ { printf "%s %s",$$4,$$5 }')
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/src/native/genconstants/ch/genSocketOptionRegistry.c Fri Aug 21 11:34:13 2015 +0200 @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code 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 + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include <stdio.h> +#ifdef _WIN32 +#include <winsock2.h> +#include <ws2tcpip.h> +#else +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <netinet/tcp.h> +#endif + +/** + * Generates sun.nio.ch.SocketOptionRegistry, a class that maps Java-level + * socket options to the platform specific level and option. + */ + +static void out(char* s) { + printf("%s\n", s); +} + +static void emit(const char *name, char * family, int level, int optname) { + printf(" map.put(new RegistryKey(%s, %s),", name, family); + printf(" new OptionKey(%d, %d));\n", level, optname); +} + +static void emit_unspec(const char *name, int level, int optname) { + emit(name, "Net.UNSPEC", level, optname); +} + +static void emit_inet(const char *name, int level, int optname) { + emit(name, "StandardProtocolFamily.INET", level, optname); +} + +static void emit_inet6(const char *name, int level, int optname) { + emit(name, "StandardProtocolFamily.INET6", level, optname); +} + +int main(int argc, const char* argv[]) { + out("// AUTOMATICALLY GENERATED FILE - DO NOT EDIT "); + out("package sun.nio.ch; "); + out("import java.net.SocketOption; "); + out("import java.net.StandardSocketOptions; "); + out("import java.net.ProtocolFamily; "); + out("import java.net.StandardProtocolFamily; "); + out("import java.util.Map; "); + out("import java.util.HashMap; "); + out("class SocketOptionRegistry { "); + out(" private SocketOptionRegistry() { } "); + out(" private static class RegistryKey { "); + out(" private final SocketOption<?> name; "); + out(" private final ProtocolFamily family; "); + out(" RegistryKey(SocketOption<?> name, ProtocolFamily family) { "); + out(" this.name = name; "); + out(" this.family = family; "); + out(" } "); + out(" public int hashCode() { "); + out(" return name.hashCode() + family.hashCode(); "); + out(" } "); + out(" public boolean equals(Object ob) { "); + out(" if (ob == null) return false; "); + out(" if (!(ob instanceof RegistryKey)) return false; "); + out(" RegistryKey other = (RegistryKey)ob; "); + out(" if (this.name != other.name) return false; "); + out(" if (this.family != other.family) return false; "); + out(" return true; "); + out(" } "); + out(" } "); + out(" private static class LazyInitialization { "); + out(" static final Map<RegistryKey,OptionKey> options = options(); "); + out(" private static Map<RegistryKey,OptionKey> options() { "); + out(" Map<RegistryKey,OptionKey> map = "); + out(" new HashMap<RegistryKey,OptionKey>(); "); + + emit_unspec("StandardSocketOptions.SO_BROADCAST", SOL_SOCKET, SO_BROADCAST); + emit_unspec("StandardSocketOptions.SO_KEEPALIVE", SOL_SOCKET, SO_KEEPALIVE); + emit_unspec("StandardSocketOptions.SO_LINGER", SOL_SOCKET, SO_LINGER); + emit_unspec("StandardSocketOptions.SO_SNDBUF", SOL_SOCKET, SO_SNDBUF); + emit_unspec("StandardSocketOptions.SO_RCVBUF", SOL_SOCKET, SO_RCVBUF); + emit_unspec("StandardSocketOptions.SO_REUSEADDR", SOL_SOCKET, SO_REUSEADDR); + emit_unspec("StandardSocketOptions.TCP_NODELAY", IPPROTO_TCP, TCP_NODELAY); + + emit_inet("StandardSocketOptions.IP_TOS", IPPROTO_IP, IP_TOS); + emit_inet("StandardSocketOptions.IP_MULTICAST_IF", IPPROTO_IP, IP_MULTICAST_IF); + emit_inet("StandardSocketOptions.IP_MULTICAST_TTL", IPPROTO_IP, IP_MULTICAST_TTL); + emit_inet("StandardSocketOptions.IP_MULTICAST_LOOP", IPPROTO_IP, IP_MULTICAST_LOOP); + +#ifdef AF_INET6 + emit_inet6("StandardSocketOptions.IP_TOS", IPPROTO_IPV6, IPV6_TCLASS); + emit_inet6("StandardSocketOptions.IP_MULTICAST_IF", IPPROTO_IPV6, IPV6_MULTICAST_IF); + emit_inet6("StandardSocketOptions.IP_MULTICAST_TTL", IPPROTO_IPV6, IPV6_MULTICAST_HOPS); + emit_inet6("StandardSocketOptions.IP_MULTICAST_LOOP", IPPROTO_IPV6, IPV6_MULTICAST_LOOP); +#endif + + emit_unspec("ExtendedSocketOption.SO_OOBINLINE", SOL_SOCKET, SO_OOBINLINE); + + out(" return map; "); + out(" } "); + out(" } "); + out(" public static OptionKey findOption(SocketOption<?> name, ProtocolFamily family) { "); + out(" RegistryKey key = new RegistryKey(name, family); "); + out(" return LazyInitialization.options.get(key); "); + out(" } "); + out("} "); + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/src/native/genconstants/fs/genSolarisConstants.c Fri Aug 21 11:34:13 2015 +0200 @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code 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 + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include <stdio.h> +#include <errno.h> +#include <unistd.h> +#include <sys/acl.h> +#include <fcntl.h> +#include <sys/stat.h> + +/** + * Generates sun.nio.fs.SolarisConstants + */ + +static void out(char* s) { + printf("%s\n", s); +} + +static void emit(char* name, int value) { + printf(" static final int %s = %d;\n", name, value); +} + +static void emitX(char* name, int value) { + printf(" static final int %s = 0x%x;\n", name, value); +} + +#define DEF(X) emit(#X, X); +#define DEFX(X) emitX(#X, X); + +int main(int argc, const char* argv[]) { + out("// AUTOMATICALLY GENERATED FILE - DO NOT EDIT "); + out("package sun.nio.fs; "); + out("class SolarisConstants { "); + out(" private SolarisConstants() { } "); + + // extended attributes + DEFX(O_XATTR); + DEF(_PC_XATTR_ENABLED); + + // ACL configuration + DEF(_PC_ACL_ENABLED); + DEFX(_ACL_ACE_ENABLED); + + // ACL commands + DEFX(ACE_GETACL); + DEFX(ACE_SETACL); + + // ACL mask/flags/types + emitX("ACE_ACCESS_ALLOWED_ACE_TYPE", 0x0000); + emitX("ACE_ACCESS_DENIED_ACE_TYPE", 0x0001); + emitX("ACE_SYSTEM_AUDIT_ACE_TYPE", 0x0002); + emitX("ACE_SYSTEM_ALARM_ACE_TYPE", 0x0003); + emitX("ACE_READ_DATA", 0x00000001); + emitX("ACE_LIST_DIRECTORY", 0x00000001); + emitX("ACE_WRITE_DATA", 0x00000002); + emitX("ACE_ADD_FILE", 0x00000002); + emitX("ACE_APPEND_DATA", 0x00000004); + emitX("ACE_ADD_SUBDIRECTORY", 0x00000004); + emitX("ACE_READ_NAMED_ATTRS", 0x00000008); + emitX("ACE_WRITE_NAMED_ATTRS", 0x00000010); + emitX("ACE_EXECUTE", 0x00000020); + emitX("ACE_DELETE_CHILD", 0x00000040); + emitX("ACE_READ_ATTRIBUTES", 0x00000080); + emitX("ACE_WRITE_ATTRIBUTES", 0x00000100); + emitX("ACE_DELETE", 0x00010000); + emitX("ACE_READ_ACL", 0x00020000); + emitX("ACE_WRITE_ACL", 0x00040000); + emitX("ACE_WRITE_OWNER", 0x00080000); + emitX("ACE_SYNCHRONIZE", 0x00100000); + emitX("ACE_FILE_INHERIT_ACE", 0x0001); + emitX("ACE_DIRECTORY_INHERIT_ACE", 0x0002); + emitX("ACE_NO_PROPAGATE_INHERIT_ACE", 0x0004); + emitX("ACE_INHERIT_ONLY_ACE", 0x0008); + emitX("ACE_SUCCESSFUL_ACCESS_ACE_FLAG", 0x0010); + emitX("ACE_FAILED_ACCESS_ACE_FLAG", 0x0020); + emitX("ACE_IDENTIFIER_GROUP", 0x0040); + emitX("ACE_OWNER", 0x1000); + emitX("ACE_GROUP", 0x2000); + emitX("ACE_EVERYONE", 0x4000); + + out("} "); + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/src/native/genconstants/fs/genUnixConstants.c Fri Aug 21 11:34:13 2015 +0200 @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code 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 + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include <stdio.h> +#include <errno.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/stat.h> + +/** + * Generates sun.nio.fs.UnixConstants + */ + +static void out(char* s) { + printf("%s\n", s); +} + +static void emit(char* name, int value) { + printf(" static final int %s = %d;\n", name, value); +} + +static void emitX(char* name, int value) { + printf(" static final int %s = 0x%x;\n", name, value); +} + +#define DEF(X) emit(#X, X); +#define DEFX(X) emitX(#X, X); + +int main(int argc, const char* argv[]) { + out("// AUTOMATICALLY GENERATED FILE - DO NOT EDIT "); + out("package sun.nio.fs; "); + out("class UnixConstants { "); + out(" private UnixConstants() { } "); + + // open flags + DEF(O_RDONLY); + DEF(O_WRONLY); + DEF(O_RDWR); + DEFX(O_APPEND); + DEFX(O_CREAT); + DEFX(O_EXCL); + DEFX(O_TRUNC); + DEFX(O_SYNC); +#ifndef O_DSYNC + // At least FreeBSD doesn't define O_DSYNC + emit("O_DSYNC", O_SYNC); +#else + DEFX(O_DSYNC); +#endif +#ifdef O_NOFOLLOW + DEFX(O_NOFOLLOW); +#else + // not supported (dummy values will not be used at runtime). + emitX("O_NOFOLLOW", 0x0); +#endif + + // mode masks + emitX("S_IAMB", + (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH)); + DEF(S_IRUSR); + DEF(S_IWUSR); + DEF(S_IXUSR); + DEF(S_IRGRP); + DEF(S_IWGRP); + DEF(S_IXGRP); + DEF(S_IROTH); + DEF(S_IWOTH); + DEF(S_IXOTH); + DEFX(S_IFMT); + DEFX(S_IFREG); + DEFX(S_IFDIR); + DEFX(S_IFLNK); + DEFX(S_IFCHR); + DEFX(S_IFBLK); + DEFX(S_IFIFO); + + // access modes + DEF(R_OK); + DEF(W_OK); + DEF(X_OK); + DEF(F_OK); + + // errors + DEF(ENOENT); + DEF(EACCES); + DEF(EEXIST); + DEF(ENOTDIR); + DEF(EINVAL); + DEF(EXDEV); + DEF(EISDIR); + DEF(ENOTEMPTY); + DEF(ENOSPC); + DEF(EAGAIN); + DEF(ENOSYS); + DEF(ELOOP); + DEF(EROFS); +#ifndef ENODATA + // Only used in Linux java source, provide any value so it compiles + emit("ENODATA", ELAST); +#else + DEF(ENODATA); +#endif + DEF(ERANGE); + DEF(EMFILE); + + // flags used with openat/unlinkat/etc. +#if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_REMOVEDIR) + DEFX(AT_SYMLINK_NOFOLLOW) + DEFX(AT_REMOVEDIR); +#else + // not supported (dummy values will not be used at runtime). + emitX("AT_SYMLINK_NOFOLLOW", 0x0); + emitX("AT_REMOVEDIR", 0x0); +#endif + + out("} "); + + return 0; +}
--- a/src/share/native/sun/nio/ch/genSocketOptionRegistry.c Thu Oct 01 11:16:16 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include <stdio.h> -#ifdef _WIN32 -#include <winsock2.h> -#include <ws2tcpip.h> -#else -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <netinet/tcp.h> -#endif - -/** - * Generates sun.nio.ch.SocketOptionRegistry, a class that maps Java-level - * socket options to the platform specific level and option. - */ - -static void out(char* s) { - printf("%s\n", s); -} - -static void emit(const char *name, char * family, int level, int optname) { - printf(" map.put(new RegistryKey(%s, %s),", name, family); - printf(" new OptionKey(%d, %d));\n", level, optname); -} - -static void emit_unspec(const char *name, int level, int optname) { - emit(name, "Net.UNSPEC", level, optname); -} - -static void emit_inet(const char *name, int level, int optname) { - emit(name, "StandardProtocolFamily.INET", level, optname); -} - -static void emit_inet6(const char *name, int level, int optname) { - emit(name, "StandardProtocolFamily.INET6", level, optname); -} - -int main(int argc, const char* argv[]) { - out("// AUTOMATICALLY GENERATED FILE - DO NOT EDIT "); - out("package sun.nio.ch; "); - out("import java.net.SocketOption; "); - out("import java.net.StandardSocketOptions; "); - out("import java.net.ProtocolFamily; "); - out("import java.net.StandardProtocolFamily; "); - out("import java.util.Map; "); - out("import java.util.HashMap; "); - out("class SocketOptionRegistry { "); - out(" private SocketOptionRegistry() { } "); - out(" private static class RegistryKey { "); - out(" private final SocketOption<?> name; "); - out(" private final ProtocolFamily family; "); - out(" RegistryKey(SocketOption<?> name, ProtocolFamily family) { "); - out(" this.name = name; "); - out(" this.family = family; "); - out(" } "); - out(" public int hashCode() { "); - out(" return name.hashCode() + family.hashCode(); "); - out(" } "); - out(" public boolean equals(Object ob) { "); - out(" if (ob == null) return false; "); - out(" if (!(ob instanceof RegistryKey)) return false; "); - out(" RegistryKey other = (RegistryKey)ob; "); - out(" if (this.name != other.name) return false; "); - out(" if (this.family != other.family) return false; "); - out(" return true; "); - out(" } "); - out(" } "); - out(" private static class LazyInitialization { "); - out(" static final Map<RegistryKey,OptionKey> options = options(); "); - out(" private static Map<RegistryKey,OptionKey> options() { "); - out(" Map<RegistryKey,OptionKey> map = "); - out(" new HashMap<RegistryKey,OptionKey>(); "); - - emit_unspec("StandardSocketOptions.SO_BROADCAST", SOL_SOCKET, SO_BROADCAST); - emit_unspec("StandardSocketOptions.SO_KEEPALIVE", SOL_SOCKET, SO_KEEPALIVE); - emit_unspec("StandardSocketOptions.SO_LINGER", SOL_SOCKET, SO_LINGER); - emit_unspec("StandardSocketOptions.SO_SNDBUF", SOL_SOCKET, SO_SNDBUF); - emit_unspec("StandardSocketOptions.SO_RCVBUF", SOL_SOCKET, SO_RCVBUF); - emit_unspec("StandardSocketOptions.SO_REUSEADDR", SOL_SOCKET, SO_REUSEADDR); - emit_unspec("StandardSocketOptions.TCP_NODELAY", IPPROTO_TCP, TCP_NODELAY); - - emit_inet("StandardSocketOptions.IP_TOS", IPPROTO_IP, IP_TOS); - emit_inet("StandardSocketOptions.IP_MULTICAST_IF", IPPROTO_IP, IP_MULTICAST_IF); - emit_inet("StandardSocketOptions.IP_MULTICAST_TTL", IPPROTO_IP, IP_MULTICAST_TTL); - emit_inet("StandardSocketOptions.IP_MULTICAST_LOOP", IPPROTO_IP, IP_MULTICAST_LOOP); - -#ifdef AF_INET6 - emit_inet6("StandardSocketOptions.IP_TOS", IPPROTO_IPV6, IPV6_TCLASS); - emit_inet6("StandardSocketOptions.IP_MULTICAST_IF", IPPROTO_IPV6, IPV6_MULTICAST_IF); - emit_inet6("StandardSocketOptions.IP_MULTICAST_TTL", IPPROTO_IPV6, IPV6_MULTICAST_HOPS); - emit_inet6("StandardSocketOptions.IP_MULTICAST_LOOP", IPPROTO_IPV6, IPV6_MULTICAST_LOOP); -#endif - - emit_unspec("ExtendedSocketOption.SO_OOBINLINE", SOL_SOCKET, SO_OOBINLINE); - - out(" return map; "); - out(" } "); - out(" } "); - out(" public static OptionKey findOption(SocketOption<?> name, ProtocolFamily family) { "); - out(" RegistryKey key = new RegistryKey(name, family); "); - out(" return LazyInitialization.options.get(key); "); - out(" } "); - out("} "); - - return 0; -}
--- a/src/solaris/native/sun/nio/fs/genSolarisConstants.c Thu Oct 01 11:16:16 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include <stdio.h> -#include <errno.h> -#include <unistd.h> -#include <sys/acl.h> -#include <fcntl.h> -#include <sys/stat.h> - -/** - * Generates sun.nio.fs.SolarisConstants - */ - -static void out(char* s) { - printf("%s\n", s); -} - -static void emit(char* name, int value) { - printf(" static final int %s = %d;\n", name, value); -} - -static void emitX(char* name, int value) { - printf(" static final int %s = 0x%x;\n", name, value); -} - -#define DEF(X) emit(#X, X); -#define DEFX(X) emitX(#X, X); - -int main(int argc, const char* argv[]) { - out("// AUTOMATICALLY GENERATED FILE - DO NOT EDIT "); - out("package sun.nio.fs; "); - out("class SolarisConstants { "); - out(" private SolarisConstants() { } "); - - // extended attributes - DEFX(O_XATTR); - DEF(_PC_XATTR_ENABLED); - - // ACL configuration - DEF(_PC_ACL_ENABLED); - DEFX(_ACL_ACE_ENABLED); - - // ACL commands - DEFX(ACE_GETACL); - DEFX(ACE_SETACL); - - // ACL mask/flags/types - emitX("ACE_ACCESS_ALLOWED_ACE_TYPE", 0x0000); - emitX("ACE_ACCESS_DENIED_ACE_TYPE", 0x0001); - emitX("ACE_SYSTEM_AUDIT_ACE_TYPE", 0x0002); - emitX("ACE_SYSTEM_ALARM_ACE_TYPE", 0x0003); - emitX("ACE_READ_DATA", 0x00000001); - emitX("ACE_LIST_DIRECTORY", 0x00000001); - emitX("ACE_WRITE_DATA", 0x00000002); - emitX("ACE_ADD_FILE", 0x00000002); - emitX("ACE_APPEND_DATA", 0x00000004); - emitX("ACE_ADD_SUBDIRECTORY", 0x00000004); - emitX("ACE_READ_NAMED_ATTRS", 0x00000008); - emitX("ACE_WRITE_NAMED_ATTRS", 0x00000010); - emitX("ACE_EXECUTE", 0x00000020); - emitX("ACE_DELETE_CHILD", 0x00000040); - emitX("ACE_READ_ATTRIBUTES", 0x00000080); - emitX("ACE_WRITE_ATTRIBUTES", 0x00000100); - emitX("ACE_DELETE", 0x00010000); - emitX("ACE_READ_ACL", 0x00020000); - emitX("ACE_WRITE_ACL", 0x00040000); - emitX("ACE_WRITE_OWNER", 0x00080000); - emitX("ACE_SYNCHRONIZE", 0x00100000); - emitX("ACE_FILE_INHERIT_ACE", 0x0001); - emitX("ACE_DIRECTORY_INHERIT_ACE", 0x0002); - emitX("ACE_NO_PROPAGATE_INHERIT_ACE", 0x0004); - emitX("ACE_INHERIT_ONLY_ACE", 0x0008); - emitX("ACE_SUCCESSFUL_ACCESS_ACE_FLAG", 0x0010); - emitX("ACE_FAILED_ACCESS_ACE_FLAG", 0x0020); - emitX("ACE_IDENTIFIER_GROUP", 0x0040); - emitX("ACE_OWNER", 0x1000); - emitX("ACE_GROUP", 0x2000); - emitX("ACE_EVERYONE", 0x4000); - - out("} "); - return 0; -}
--- a/src/solaris/native/sun/nio/fs/genUnixConstants.c Thu Oct 01 11:16:16 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include <stdio.h> -#include <errno.h> -#include <unistd.h> -#include <fcntl.h> -#include <sys/stat.h> - -/** - * Generates sun.nio.fs.UnixConstants - */ - -static void out(char* s) { - printf("%s\n", s); -} - -static void emit(char* name, int value) { - printf(" static final int %s = %d;\n", name, value); -} - -static void emitX(char* name, int value) { - printf(" static final int %s = 0x%x;\n", name, value); -} - -#define DEF(X) emit(#X, X); -#define DEFX(X) emitX(#X, X); - -int main(int argc, const char* argv[]) { - out("// AUTOMATICALLY GENERATED FILE - DO NOT EDIT "); - out("package sun.nio.fs; "); - out("class UnixConstants { "); - out(" private UnixConstants() { } "); - - // open flags - DEF(O_RDONLY); - DEF(O_WRONLY); - DEF(O_RDWR); - DEFX(O_APPEND); - DEFX(O_CREAT); - DEFX(O_EXCL); - DEFX(O_TRUNC); - DEFX(O_SYNC); -#ifndef O_DSYNC - // At least FreeBSD doesn't define O_DSYNC - emit("O_DSYNC", O_SYNC); -#else - DEFX(O_DSYNC); -#endif -#ifdef O_NOFOLLOW - DEFX(O_NOFOLLOW); -#else - // not supported (dummy values will not be used at runtime). - emitX("O_NOFOLLOW", 0x0); -#endif - - // mode masks - emitX("S_IAMB", - (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH)); - DEF(S_IRUSR); - DEF(S_IWUSR); - DEF(S_IXUSR); - DEF(S_IRGRP); - DEF(S_IWGRP); - DEF(S_IXGRP); - DEF(S_IROTH); - DEF(S_IWOTH); - DEF(S_IXOTH); - DEFX(S_IFMT); - DEFX(S_IFREG); - DEFX(S_IFDIR); - DEFX(S_IFLNK); - DEFX(S_IFCHR); - DEFX(S_IFBLK); - DEFX(S_IFIFO); - - // access modes - DEF(R_OK); - DEF(W_OK); - DEF(X_OK); - DEF(F_OK); - - // errors - DEF(ENOENT); - DEF(EACCES); - DEF(EEXIST); - DEF(ENOTDIR); - DEF(EINVAL); - DEF(EXDEV); - DEF(EISDIR); - DEF(ENOTEMPTY); - DEF(ENOSPC); - DEF(EAGAIN); - DEF(ENOSYS); - DEF(ELOOP); - DEF(EROFS); -#ifndef ENODATA - // Only used in Linux java source, provide any value so it compiles - emit("ENODATA", ELAST); -#else - DEF(ENODATA); -#endif - DEF(ERANGE); - DEF(EMFILE); - - // flags used with openat/unlinkat/etc. -#if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_REMOVEDIR) - DEFX(AT_SYMLINK_NOFOLLOW) - DEFX(AT_REMOVEDIR); -#else - // not supported (dummy values will not be used at runtime). - emitX("AT_SYMLINK_NOFOLLOW", 0x0); - emitX("AT_REMOVEDIR", 0x0); -#endif - - out("} "); - - return 0; -}