Skip to content

Commit

Permalink
Created Function Prototypes for OMRSocketAPI
Browse files Browse the repository at this point in the history
Created Unimplemented Function Prototypes in omrsock.c

-Modified omr files to be able to see and compile omrsock code
-Added new omrsock.c file for common for all operating systems, this
includes function prototypes proposed by the Socket API proprosal
-Added omrsock variables needed by the function prototypes. They are
created in omrportsock.h

Issue: eclipse-omr#4102

Co-authored-by: Babneet Singh <sbabneet@ca.ibm.com>

Signed-off-by: Haley Cao <haleycao88@hotmail.com>
  • Loading branch information
Haley Cao authored and AidanHa committed Nov 4, 2019
1 parent 70bc681 commit 9673db4
Show file tree
Hide file tree
Showing 7 changed files with 510 additions and 0 deletions.
52 changes: 52 additions & 0 deletions include_core/omrport.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "omrthread.h"
#include "omrmemcategories.h"
#include "omrporterror.h"
#include "omrportsock.h"
#if defined(OMR_OPT_CUDA)
#include "omrcuda.h"
#endif /* OMR_OPT_CUDA */
Expand Down Expand Up @@ -1684,6 +1685,40 @@ typedef struct OMRPortLibrary {
uintptr_t (*heap_query_size)(struct OMRPortLibrary *portLibrary, struct J9Heap *heap, void *address) ;
/** see @ref omrheap.c::omrheap_grow "omrheap_grow"*/
BOOLEAN (*heap_grow)(struct OMRPortLibrary *portLibrary, struct J9Heap *heap, uintptr_t growAmount) ;
/** see @ref omrsock.c::omrsock_getaddrinfo_create_hints "omrsock_getaddrinfo_create_hints"*/
int32_t (*sock_getaddrinfo_create_hints)(struct OMRPortLibrary *portLibrary, omrsock_addrinfo_t *hints, int32_t family, int32_t socktype, int32_t protocol, int32_t flags) ;
/** see @ref omrsock.c::omrsock_getaddrinfo "omrsock_getaddrinfo"*/
int32_t (*sock_getaddrinfo)(struct OMRPortLibrary *portLibrary, char *node, char *service, omrsock_addrinfo_t hints, omrsock_addrinfo_t result) ;
/** see @ref omrsock.c::omrsock_getaddrinfo_length "omrsock_getaddrinfo_length"*/
int32_t (*sock_getaddrinfo_length)(struct OMRPortLibrary *portLibrary, omrsock_addrinfo_t hints, uint32_t *length) ;
/** see @ref omrsock.c::omrsock_getaddrinfo_family "omrsock_getaddrinfo_family"*/
int32_t (*sock_getaddrinfo_family)(struct OMRPortLibrary *portLibrary, omrsock_addrinfo_t *handle, int32_t *family, int32_t index ) ;
/** see @ref omrsock.c::omrsock_getaddrinfo_socktype "omrsock_getaddrinfo_socktype"*/
int32_t (*sock_getaddrinfo_socktype)(struct OMRPortLibrary *portLibrary, omrsock_addrinfo_t handle, int32_t *socktype, int32_t index) ;
/** see @ref omrsock.c::omrsock_getaddrinfo_protocol "omrsock_getaddrinfo_protocol"*/
int32_t (*sock_getaddrinfo_protocol)(struct OMRPortLibrary *portLibrary, omrsock_addrinfo_t handle, int32_t *protocol, int32_t index) ;
/** see @ref omrsock.c::omrsock_freeaddrinfo "omrsock_freeaddrinfo"*/
int32_t (*sock_freeaddrinfo)(struct OMRPortLibrary *portLibrary, omrsock_addrinfo_t handle) ;
/** see @ref omrsock.c::omrsock_socket "omrsock_socket"*/
int32_t (*sock_socket)(struct OMRPortLibrary *portLibrary, omrsock_socket_t sock, int32_t family, int32_t socktype, int32_t protocol) ;
/** see @ref omrsock.c::omrsock_bind "omrsock_bind"*/
int32_t (*sock_bind)(struct OMRPortLibrary *portLibrary, omrsock_socket_t sock, omrsock_sockaddr_t addr) ;
/** see @ref omrsock.c::omrsock_listen "omrsock_listen"*/
int32_t (*sock_listen)(struct OMRPortLibrary *portLibrary, omrsock_socket_t sock, int32_t backlog) ;
/** see @ref omrsock.c::omrsock_connect "omrsock_connect"*/
int32_t (*sock_connect)(struct OMRPortLibrary *portLibrary, omrsock_socket_t sock, omrsock_sockaddr_t addr) ;
/** see @ref omrsock.c::omrsock_accept "omrsock_accept"*/
int32_t (*sock_accept)(struct OMRPortLibrary *portLibrary, omrsock_socket_t serverSock, omrsock_sockaddr_t addrHandle, omrsock_socket_t *sockHandle) ;
/** see @ref omrsock.c::omrsock_send "omrsock_send"*/
int32_t (*sock_send)(struct OMRPortLibrary *portLibrary, omrsock_socket_t sock, uint8_t *buf, int32_t nbyte, int32_t flags) ;
/** see @ref omrsock.c::omrsock_sendto "omrsock_sendto"*/
int32_t (*sock_sendto)(struct OMRPortLibrary *portLibrary, omrsock_socket_t sock, uint8_t *buf, int32_t nbyte, int32_t flags, omrsock_sockaddr_t addrHandle) ;
/** see @ref omrsock.c::omrsock_recv "omrsock_recv"*/
int32_t (*sock_recv)(struct OMRPortLibrary *portLibrary, omrsock_socket_t sock, uint8_t *buf, int32_t nbyte, int32_t flags) ;
/** see @ref omrsock.c::omrsock_recvfrom "omrsock_recvfrom"*/
int32_t (*sock_recvfrom)(struct OMRPortLibrary *portLibrary, omrsock_socket_t sock, uint8_t *buf, int32_t nbyte, int32_t flags, omrsock_sockaddr_t addrHandle) ;
/** see @ref omrsock.c::omrsock_close "omrsock_close"*/
int32_t (*sock_close)(struct OMRPortLibrary *portLibrary, omrsock_socket_t sock) ;
#if defined(OMR_OPT_CUDA)
/** CUDA configuration data */
J9CudaConfig *cuda_configData;
Expand Down Expand Up @@ -2124,6 +2159,23 @@ extern J9_CFUNC int32_t omrport_getVersion(struct OMRPortLibrary *portLibrary);
#define omrmem_categories_decrement_counters(param1,param2) privateOmrPortLibrary->mem_categories_decrement_counters((param1), (param2))
#define omrheap_query_size(param1,param2) privateOmrPortLibrary->heap_query_size(privateOmrPortLibrary, (param1), (param2))
#define omrheap_grow(param1,param2) privateOmrPortLibrary->heap_grow(privateOmrPortLibrary, (param1), (param2))
#define omrsock_getaddrinfo_create_hints(param1,param2,param3,param4,param5) privateOmrPortLibrary->sock_getaddrinfo_create_hints(privateOmrPortLibrary, (param1), (param2), (param3), (param4), (param5))
#define omrsock_getaddrinfo(param1,param2,param3,param4) privateOmrPortLibrary->sock_getaddrinfo(privateOmrPortLibrary, (param1), (param2), (param3), (param4))
#define omrsock_getaddrinfo_length(param1,param2) privateOmrPortLibrary->sock_getaddrinfo_length(privateOmrPortLibrary, (param1), (param2))
#define omrsock_getaddrinfo_family(param1,param2,param3) privateOmrPortLibrary->sock_getaddrinfo_family(privateOmrPortLibrary, (param1), (param2), (param3))
#define omrsock_getaddrinfo_socktype(param1,param2,param3) privateOmrPortLibrary->sock_getaddrinfo_socktype(privateOmrPortLibrary, (param1), (param2), (param3))
#define omrsock_getaddrinfo_protocol(param1,param2,param3) privateOmrPortLibrary->sock_getaddrinfo_protocol(privateOmrPortLibrary, (param1), (param2), (param3))
#define omrsock_freeaddrinfo(param1) privateOmrPortLibrary->sock_freeaddrinfo(privateOmrPortLibrary, (param1))
#define omrsock_socket(param1, param2, param3, param4) privateOmrPortLibrary->sock_socket(privateOmrPortLibrary, (param1), (param2), (param3), (param4))
#define omrsock_bind(param1,param2) privateOmrPortLibrary->sock_bind(privateOmrPortLibrary, (param1), (param2))
#define omrsock_listen(param1,param2) privateOmrPortLibrary->sock_listen(privateOmrPortLibrary, (param1), (param2))
#define omrsock_connect(param1,param2) privateOmrPortLibrary->sock_connect(privateOmrPortLibrary, (param1), (param2))
#define omrsock_accept(param1,param2,param3) privateOmrPortLibrary->sock_accept(privateOmrPortLibrary, (param1), (param2), (param3))
#define omrsock_send(param1,param2,param3,param4) privateOmrPortLibrary->sock_send(privateOmrPortLibrary, (param1), (param2), (param3), (param4))
#define omrsock_sendto(param1,param2,param3,param4,param5) privateOmrPortLibrary->sock_sendto(privateOmrPortLibrary, (param1), (param2), (param3), (param4), (param5))
#define omrsock_recv(param1,param2,param3,param4) privateOmrPortLibrary->sock_recv(privateOmrPortLibrary, (param1), (param2), (param3), (param4))
#define omrsock_recvfrom(param1,param2,param3,param4,param5) privateOmrPortLibrary->sock_recvfrom(privateOmrPortLibrary, (param1), (param2), (param3), (param4), (param5))
#define omrsock_close(param1) privateOmrPortLibrary->sock_close(privateOmrPortLibrary, (param1))

#if defined(OMR_OPT_CUDA)
#define omrcuda_startup() \
Expand Down
35 changes: 35 additions & 0 deletions include_core/omrportsock.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*******************************************************************************
* Copyright (c) 2019, 2019 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
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

#if !defined(OMRPORTSOCK_H_)
#define OMRPORTSOCK_H_

/* Pointer to OMRAddInfoNode, a struct that contains addrinfo information. */
typedef struct OMRAddrInfoNode *omrsock_addrinfo_t;

/* Pointer to ip address. It has enough space for Ipv4 or IPv6 addresses. */
typedef struct OMRSockAddrStorage *omrsock_sockaddr_t;

/* Pointer to a socket descriptor */
typedef struct OMRSocket *omrsock_socket_t;

#endif /* !defined(OMRPORTSOCK_H_) */
1 change: 1 addition & 0 deletions port/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ list(APPEND OBJECTS
omrmemcategories.c
omrport.c
omrmmap.c
omrsock.c
j9nls.c
j9nlshelpers.c
omrosbacktrace.c
Expand Down
17 changes: 17 additions & 0 deletions port/common/omrport.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,23 @@ static OMRPortLibrary MasterPortLibraryTable = {
omrmem_categories_decrement_counters, /* mem_categories_decrement_counters */
omrheap_query_size, /* heap_query_size */
omrheap_grow, /* heap_grow*/
omrsock_getaddrinfo_create_hints, /* sock_getaddrinfo_create_hints */
omrsock_getaddrinfo, /* sock_getaddrinfo */
omrsock_getaddrinfo_length, /* sock_getaddrinfo_length */
omrsock_getaddrinfo_family, /* sock_getaddrinfo_family */
omrsock_getaddrinfo_socktype, /* sock_getaddrinfo_socktype */
omrsock_getaddrinfo_protocol, /* sock_getaddrinfo_protocol */
omrsock_freeaddrinfo, /* sock_freeaddrinfo */
omrsock_socket, /* sock_socket */
omrsock_bind, /* sock_bind */
omrsock_listen, /* sock_listen */
omrsock_connect, /* sock_connect */
omrsock_accept, /* sock_accept */
omrsock_send, /* sock_send */
omrsock_sendto, /* sock_sendto */
omrsock_recv, /* sock_recv */
omrsock_recvfrom, /* sock_recvfrom */
omrsock_close, /* sock_close */
#if defined(OMR_OPT_CUDA)
NULL, /* cuda_configData */
omrcuda_startup, /* cuda_startup */
Expand Down
Loading

0 comments on commit 9673db4

Please sign in to comment.