Skip to content

Commit

Permalink
Merge pull request #8715 from pshipton/j9sock
Browse files Browse the repository at this point in the history
Remove obsolete j9sock functions
  • Loading branch information
keithc-ca committed Mar 5, 2020
2 parents 51d9fc6 + 15b2812 commit b2cfada
Show file tree
Hide file tree
Showing 17 changed files with 190 additions and 10,226 deletions.
3 changes: 1 addition & 2 deletions runtime/bcutil/dynload.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2019 IBM Corp. and others
* Copyright (c) 1991, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -29,7 +29,6 @@
#include "cfr.h"
#include "cfreader.h"
#include "j2sever.h"
#include "j9socket.h"
#include "j9protos.h"
#include "j9consts.h"
#include "jimage.h"
Expand Down
3 changes: 1 addition & 2 deletions runtime/exelib/common/libhlp.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2017 IBM Corp. and others
* Copyright (c) 1991, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -26,7 +26,6 @@
#include "jni.h"
#include "j9user.h"
#include "j9port.h"
#include "j9socket.h"
#include "cfr.h"
#include "j9.h"
#include "j9protos.h"
Expand Down
191 changes: 1 addition & 190 deletions runtime/oti/j9port_generated.h

Large diffs are not rendered by default.

50 changes: 2 additions & 48 deletions runtime/oti/j9socket.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1998, 2014 IBM Corp. and others
* Copyright (c) 1998, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -30,12 +30,8 @@
#include "j9porterror.h"

/* Socket types, stream & datagram */
#define J9SOCK_STREAM 0
#define J9SOCK_DGRAM 1
#define J9SOCK_AFINET 2
#define J9SOCK_ANY 3
#define J9SOCK_DEFPROTOCOL 0
#define J9SOCK_INADDR_ANY (uint32_t)0
#define J9SOCK_INADDR_ANY (uint32_t)0
#define J9SOCK_NOFLAGS (uint32_t)0 /* The default flag argument value, as in a recv */
#define J9SOCK_INADDR_LEN 4 /* The length in bytes of a binary IPv4 internet address */
#define J9SOCK_INADDR6_LEN 16 /* The length in bytes of a binary IPv6 internet address */
Expand All @@ -58,52 +54,10 @@
#define J9PROTOCOL_FAMILY_INET4 J9ADDR_FAMILY_AFINET4 /* IPv6 */
#define J9PROTOCOL_FAMILY_INET6 J9ADDR_FAMILY_AFINET6 /* IPv6 */

/* Portable defines for socket levels */
#define J9_SOL_SOCKET 1
#define J9_IPPROTO_TCP 2
#define J9_IPPROTO_IP 3
#define J9_IPPROTO_IPV6 4

/* Portable defines for socket options */
#define J9_SO_LINGER 1
#define J9_SO_KEEPALIVE 2
#define J9_TCP_NODELAY 3
#define J9_MCAST_TTL 4
#define J9_MCAST_ADD_MEMBERSHIP 5
#define J9_MCAST_DROP_MEMBERSHIP 6
#define J9_MCAST_INTERFACE 7
#define J9_SO_REUSEADDR 8
#define J9_SO_REUSEPORT 9

#define J9_SO_SNDBUF 11
#define J9_SO_RCVBUF 12
#define J9_SO_BROADCAST 13 /*[PR1FLSKTU] Support datagram broadcasts */
#define J9_SO_OOBINLINE 14
#define J9_IP_MULTICAST_LOOP 15
#define J9_IP_TOS 16
#define J9_MCAST_INTERFACE_2 17
#define J9_IPV6_ADD_MEMBERSHIP 18
#define J9_IPV6_DROP_MEMBERSHIP 19

/* Portable defines for socket read/write options */
#define J9SOCK_MSG_PEEK 1
#define J9SOCK_MSG_OOB 2

/* Platform Constants */
typedef struct j9socket_struct *j9socket_t;
typedef struct j9sockaddr_struct *j9sockaddr_t;
typedef struct j9hostent_struct *j9hostent_t;
typedef struct j9fdset_struct *j9fdset_t;
typedef struct j9timeval_struct *j9timeval_t;
typedef struct j9linger_struct *j9linger_t;
typedef struct j9ipmreq_struct *j9ipmreq_t;
typedef struct j9addrinfo_struct *j9addrinfo_t; /* IPv6 */
typedef struct j9ipv6_mreq_struct *j9ipv6_mreq_t; /* IPv6 */

/* constants for calling multi-call functions */
#define J9_PORT_SOCKET_STEP_START 10
#define J9_PORT_SOCKET_STEP_CHECK 20
#define J9_PORT_SOCKET_STEP_DONE 30

#endif /* j9socket_h */

Expand Down
121 changes: 1 addition & 120 deletions runtime/oti/portsock.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1998, 2017 IBM Corp. and others
* Copyright (c) 1998, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -26,13 +26,6 @@
#ifndef portsock_h
#define portsock_h

#if defined(LINUX) || defined(AIXPPC) || defined(OSX)
/* needed to pull in "struct timeval" */
#include <sys/select.h>
#elif defined(J9ZOS390)
#include <sys/time.h>
#endif

/* This file did redirect to the port socket header but that sort of reaching back into a private module is very unsafe and breaks with vpath since the header will no longer be in the root of port */
/* As a temporary solution, the structures we were looking for will be stored here. Eventually, this file should be merged into the port_api.h */

Expand All @@ -41,7 +34,6 @@
#define UDATA UDATA_win32_
#include <windows.h>
#undef UDATA /* this is safe because our UDATA is a typedef, not a macro */
#define SOCKET_USE_IPV4_MASK '\x4' /* 00000100 - this tells which one to pick when doing an operation */

/* Undefine the winsockapi because winsock2 defines it. Removes warnings. */
#if defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)
Expand All @@ -57,8 +49,6 @@

#include "j9comp.h"

#define J9SOCK_BADSOCKET -1

#ifdef NI_MAXHOST
#define OSNIMAXHOST NI_MAXHOST
#define OSNIMAXSERV NI_MAXSERV
Expand All @@ -82,126 +72,17 @@ typedef struct j9addrinfo_struct {
} j9addrinfo_struct;

typedef struct hostent OSHOSTENT;
typedef struct ip_mreq OSIPMREQ;
typedef struct ipv6_mreq OSIPMREQ6;

typedef struct linger OSLINGER;

#if defined(WIN32)
typedef SOCKET OSSOCKET; /* as returned by socket() */
typedef SOCKADDR_IN OSSOCKADDR; /* as used by bind() and friends */
typedef struct sockaddr_storage OSSOCKADDR_STORAGE; /* IPv6 */
#else /* !WIN32 */
typedef int OSSOCKET; /* as returned by socket() */
typedef struct sockaddr_in OSSOCKADDR; /* as used by bind() and friends */
#if !defined(J9ZTPF) /* z/TPF doesn't have IPv6 */
typedef struct sockaddr_storage OSSOCKADDR_STORAGE; /* IPv6 */
#endif /* !defined(J9ZTPF) */
#endif /* !WIN32 */

#if defined(LINUX) || defined(AIXPPC) || defined(J9ZOS390) || defined(OSX)
#define SOCKET_CAST(x) ((struct j9socket_struct*) x)->sock
#else /* defined(LINUX) || defined(AIXPPC) || defined(J9ZOS390) || defined(OSX) */
/* all the non-unix ports use this variant */
/* The sockets returned as a j9socket_t (j9socket_struct*) are not actual structs, we just pretend that the pointer is a struct and never dereference it.
*/
#ifdef NO_LVALUE_CASTING
#define SOCKET_CAST(x) (*((OSSOCKET *) &(x)))
#else /* NO_LVALUE_CASTING */
#define SOCKET_CAST(x) ((OSSOCKET)x)
#endif /* !NO_LVALUE_CASTING */
#endif /* defined(LINUX) || defined(AIXPPC) || defined(J9ZOS390) || defined(OSX) */


typedef struct j9sockaddr_struct {
#if defined(IPv6_FUNCTION_SUPPORT) || (defined(WIN32))
OSSOCKADDR_STORAGE addr;
#else
OSSOCKADDR addr;
#endif
} j9sockaddr_struct;

typedef struct j9fdset_struct {
#if defined(LINUX) || defined(OSX)
intptr_t fd; /* fd == -1 indicates the j9fdset is "empty" fd. */
#else
fd_set handle;
#endif /* defined(LINUX) || defined(OSX) */
} j9fdset_struct;

typedef struct j9timeval_struct {
struct timeval time;
} j9timeval_struct;

/*
* Socket structure on windows requires 2 sockets due to the fact that microsoft does not
* handle ipv6-mapped ipv6 addresses. Therefore we need to listen to sockets on both
* the ipv6 and ipv4 stacks, when in a mode where we support ipv6.
*/
typedef struct j9socket_struct {
#if defined(WIN32)
OSSOCKET ipv4;
OSSOCKET ipv6;
uint8_t flags;
#else /* WIN32 */
OSSOCKET sock;
uint16_t family;
#endif /* !WIN32 */
} j9socket_struct;

typedef struct j9linger_struct {
OSLINGER linger;
} j9linger_struct;

typedef struct j9hostent_struct {
OSHOSTENT *entity;
} j9hostent_struct;

typedef struct j9ipmreq_struct {
OSIPMREQ addrpair;
} j9ipmreq_struct;

/** new structure for IPv6 mulitcast requests */
typedef struct j9ipv6_mreq_struct {
#if defined(IPv6_FUNCTION_SUPPORT) || ((defined(WIN32)))
OSIPMREQ6 mreq;
#else
int dummy;
#endif
} j9ipv6_mreq_struct;

/* structure for returning either and IPV4 or IPV6 ip address */
typedef struct j9ipAddress_struct {
union {
#if defined(IPv6_FUNCTION_SUPPORT) || ((defined(WIN32)))
uint8_t bytes[sizeof(struct in6_addr)];
#else
uint8_t bytes[sizeof(struct in_addr)];
#endif
struct in_addr inAddr;
#if defined(IPv6_FUNCTION_SUPPORT) || ((defined(WIN32)))
struct in6_addr in6Addr;
#endif
} addr;
uint32_t length;
uint32_t scope;
} j9ipAddress_struct;

/* structure for returning network interface information */
typedef struct j9NetworkInterface_struct{
char *name;
char *displayName;
uint32_t numberAddresses;
uint32_t index;
struct j9ipAddress_struct *addresses;
} j9NetworkInterface_struct ;

/* array of network interface structures */
typedef struct j9NetworkInterfaceArray_struct {
uint32_t length;
struct j9NetworkInterface_struct* elements;
} j9NetworkInterfaceArray_struct;

#endif /* portsock_h */


65 changes: 1 addition & 64 deletions runtime/port/common/j9port.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2019 IBM Corp. and others
* Copyright (c) 1991, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -52,19 +52,8 @@ static J9PortLibrary MasterPortLibraryTable = {
j9sysinfo_get_cache_info, /* sysinfo_get_cache_info */
j9sock_startup, /* sock_startup */
j9sock_shutdown, /* sock_shutdown */
j9sock_htons, /* sock_htons */
j9sock_write, /* sock_write */
j9sock_sockaddr, /* sock_sockaddr */
j9sock_read, /* sock_read */
j9sock_socket, /* sock_socket */
j9sock_close, /* sock_close */
j9sock_connect, /* sock_connect */
j9sock_inetaddr, /* sock_inetaddr */
j9sock_gethostbyname, /* sock_gethostbyname */
j9sock_hostent_addrlist, /* sock_hostent_addrlist */
j9sock_sockaddr_init, /* sock_sockaddr_init */
j9sock_linger_init, /* sock_linger_init */
j9sock_setopt_linger, /* sock_setopt_linger */
j9gp_startup, /* gp_startup */
j9gp_shutdown, /* gp_shutdown */
j9gp_protect, /* gp_protect */
Expand All @@ -80,67 +69,15 @@ static J9PortLibrary MasterPortLibraryTable = {
j9sysinfo_DLPAR_enabled, /* sysinfo_DLPAR_enabled */
j9sysinfo_DLPAR_max_CPUs, /* sysinfo_DLPAR_max_CPUs */
j9sysinfo_weak_memory_consistency, /* sysinfo_weak_memory_consistency */
j9sock_htonl, /* sock_htonl */
j9sock_bind, /* sock_bind */
j9sock_accept, /* sock_accept */
j9sock_shutdown_input, /* sock_shutdown_input */
j9sock_shutdown_output, /* sock_shutdown_output */
j9sock_listen, /* sock_listen */
j9sock_ntohl, /* sock_ntohl */
j9sock_ntohs, /* sock_ntohs */
j9sock_getpeername, /* sock_getpeername */
j9sock_getsockname, /* sock_getsockname */
j9sock_readfrom, /* sock_readfrom */
j9sock_select, /* sock_select */
j9sock_writeto, /* sock_writeto */
j9sock_inetntoa, /* sock_inetntoa */
j9sock_gethostbyaddr, /* sock_gethostbyaddr */
j9sock_gethostname, /* sock_gethostname */
j9sock_hostent_aliaslist, /* sock_hostent_aliaslist */
j9sock_hostent_hostname, /* sock_hostent_hostname */
j9sock_sockaddr_port, /* sock_sockaddr_port */
j9sock_sockaddr_address, /* sock_sockaddr_address */
j9sock_fdset_init, /* sock_fdset_init */
j9sock_fdset_size, /* sock_fdset_size */
j9sock_timeval_init, /* sock_timeval_init */
j9sock_getopt_int, /* sock_getopt_int */
j9sock_setopt_int, /* sock_setopt_int */
j9sock_getopt_bool, /* sock_getopt_bool */
j9sock_setopt_bool, /* sock_setopt_bool */
j9sock_getopt_byte, /* sock_getopt_byte */
j9sock_setopt_byte, /* sock_setopt_byte */
j9sock_getopt_linger, /* sock_getopt_linger */
j9sock_getopt_sockaddr, /* sock_getopt_sockaddr */
j9sock_setopt_sockaddr, /* sock_setopt_sockaddr */
j9sock_setopt_ipmreq, /* sock_setopt_ipmreq */
j9sock_linger_enabled, /* sock_linger_enabled */
j9sock_linger_linger, /* sock_linger_linger */
j9sock_ipmreq_init, /* sock_ipmreq_init */
j9sock_setflag, /* sock_setflag */
j9sock_freeaddrinfo, /* sock_freeaddrinfo */
j9sock_getaddrinfo, /* sock_getaddrinfo */
j9sock_getaddrinfo_address, /* sock_getaddrinfo_address */
j9sock_getaddrinfo_create_hints, /* sock_getaddrinfo_create_hints */
j9sock_getaddrinfo_family, /* sock_getaddrinfo_family */
j9sock_getaddrinfo_length, /* sock_getaddrinfo_length */
j9sock_getaddrinfo_name, /* sock_getaddrinfo_name */
j9sock_getnameinfo, /* sock_getnameinfo */
j9sock_ipv6_mreq_init, /* sock_ipv6_mreq_init */
j9sock_setopt_ipv6_mreq, /* sock_setopt_ipv6_mreq */
j9sock_sockaddr_address6, /* sock_sockaddr_address6 */
j9sock_sockaddr_family, /* sock_sockaddr_family */
j9sock_sockaddr_init6, /* sock_sockaddr_init6 */
j9sock_socketIsValid, /* sock_socketIsValid */
j9sock_select_read, /* sock_select_read */
j9sock_set_nonblocking, /* sock_set_nonblocking */
j9sock_error_message, /* sock_error_message */
j9sock_get_network_interfaces, /* sock_get_network_interfaces */
j9sock_free_network_interface_struct, /* sock_free_network_interface_struct */
j9sock_connect_with_timeout, /* sock_connect_with_timeout */
j9sock_fdset_zero, /* sock_fdset_zero */
j9sock_fdset_set, /* sock_fdset_set */
j9sock_fdset_clr, /* sock_fdset_clr */
j9sock_fdset_isset, /* sock_fdset_isset */
j9shsem_params_init, /* shsem_parameters_init */
j9shsem_startup, /* shsem_startup */
j9shsem_shutdown, /* shsem_shutdown */
Expand Down

0 comments on commit b2cfada

Please sign in to comment.