Add platform ifdefs, fix up some MSVC warnings

pull/153/head
Craig Tiller 10 years ago
parent dedbae744a
commit 0c0b60c322
  1. 6
      src/core/iomgr/resolve_address.h
  2. 6
      src/core/iomgr/socket_utils_common_posix.c
  3. 6
      src/core/iomgr/tcp_client_posix.c
  4. 6
      src/core/iomgr/tcp_posix.c
  5. 3
      src/core/iomgr/tcp_server.h
  6. 6
      src/core/iomgr/tcp_server_posix.c
  7. 2
      src/core/transport/chttp2/frame_data.c
  8. 2
      src/core/transport/chttp2/hpack_parser.c
  9. 2
      src/core/transport/chttp2_transport.c
  10. 2
      src/core/transport/stream_op.c
  11. 5
      test/core/transport/transport_end2end_tests.c
  12. 2
      test/core/util/test_config.c

@ -34,10 +34,12 @@
#ifndef __GRPC_INTERNAL_IOMGR_RESOLVE_ADDRESS_H__
#define __GRPC_INTERNAL_IOMGR_RESOLVE_ADDRESS_H__
#include <sys/socket.h>
#include <stddef.h>
#define GRPC_MAX_SOCKADDR_SIZE 128
typedef struct {
struct sockaddr_storage addr;
char addr[GRPC_MAX_SOCKADDR_SIZE];
int len;
} grpc_resolved_address;

@ -31,6 +31,10 @@
*
*/
#include <grpc/support/port_platform.h>
#ifdef GPR_POSIX_SOCKET
#include "src/core/iomgr/socket_utils_posix.h"
#include <arpa/inet.h>
@ -187,3 +191,5 @@ int grpc_create_dualstack_socket(const struct sockaddr *addr, int type,
*dsmode = family == AF_INET ? GRPC_DSMODE_IPV4 : GRPC_DSMODE_NONE;
return socket(family, type, protocol);
}
#endif

@ -31,6 +31,10 @@
*
*/
#include <grpc/support/port_platform.h>
#ifdef GPR_POSIX_SOCKET
#include "src/core/iomgr/tcp_client.h"
#include <errno.h>
@ -229,3 +233,5 @@ void grpc_tcp_client_connect(void (*cb)(void *arg, grpc_endpoint *ep),
grpc_alarm_init(&ac->alarm, deadline, on_alarm, ac, gpr_now());
grpc_fd_notify_on_write(ac->fd, on_writable, ac);
}
#endif

@ -31,6 +31,10 @@
*
*/
#include <grpc/support/port_platform.h>
#ifdef GPR_POSIX_SOCKET
#include "src/core/iomgr/tcp_posix.h"
#include <errno.h>
@ -539,3 +543,5 @@ grpc_endpoint *grpc_tcp_create(grpc_fd *em_fd, size_t slice_size) {
tcp->em_fd = em_fd;
return &tcp->base;
}
#endif

@ -34,9 +34,6 @@
#ifndef __GRPC_INTERNAL_IOMGR_TCP_SERVER_H__
#define __GRPC_INTERNAL_IOMGR_TCP_SERVER_H__
#include <sys/types.h>
#include <sys/socket.h>
#include "src/core/iomgr/endpoint.h"
/* Forward decl of grpc_tcp_server */

@ -31,6 +31,10 @@
*
*/
#include <grpc/support/port_platform.h>
#ifdef GRPC_POSIX_SOCKET
#define _GNU_SOURCE
#include "src/core/iomgr/tcp_server.h"
@ -364,3 +368,5 @@ void grpc_tcp_server_start(grpc_tcp_server *s, grpc_pollset *pollset,
}
gpr_mu_unlock(&s->mu);
}
#endif

@ -141,7 +141,7 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
gpr_slice_sub(slice, cur - beg, end - beg));
p->state = GRPC_CHTTP2_DATA_FH_0;
return GRPC_CHTTP2_PARSE_OK;
} else if (end - cur > p->frame_size) {
} else if ((gpr_uint32)(end - cur) > p->frame_size) {
state->need_flush_reads = 1;
grpc_sopb_add_slice(
&p->incoming_sopb,

@ -1212,7 +1212,7 @@ static int huff_nibble(grpc_chttp2_hpack_parser *p, gpr_uint8 nibble) {
gpr_int16 next = next_sub_tbl[16 * next_tbl[p->huff_state] + nibble];
if (emit != -1) {
if (emit >= 0 && emit < 256) {
gpr_uint8 c = emit;
gpr_uint8 c = (gpr_uint8) emit;
if (!append_string(p, &c, (&c) + 1)) return 0;
} else {
assert(emit == 256);

@ -1611,7 +1611,7 @@ static int process_read(transport *t, gpr_slice slice) {
}
t->deframe_state = DTS_FH_0;
return 1;
} else if (end - cur > t->incoming_frame_size) {
} else if ((gpr_uint32)(end - cur) > t->incoming_frame_size) {
if (!parse_frame_slice(
t, gpr_slice_sub_no_ref(slice, cur - beg,
cur + t->incoming_frame_size - beg),

@ -63,7 +63,7 @@ void grpc_sopb_reset(grpc_stream_op_buffer *sopb) {
}
void grpc_stream_ops_unref_owned_objects(grpc_stream_op *ops, size_t nops) {
int i;
size_t i;
for (i = 0; i < nops; i++) {
switch (ops[i].type) {
case GRPC_OP_SLICE:

@ -129,7 +129,8 @@ static void expect_metadata(test_stream *s, int from_client, const char *key,
/* Convert some number of seconds into a gpr_timespec that many seconds in the
future */
static gpr_timespec deadline_from_seconds(double deadline_seconds) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(deadline_seconds * 1e6));
return gpr_time_add(gpr_now(),
gpr_time_from_micros((long)(deadline_seconds * 1e6)));
}
/* Init a test_user_data instance */
@ -573,7 +574,7 @@ static grpc_transport_setup_result setup_client_transport(
name - the name of this test */
static void begin_test(test_fixture *f, grpc_transport_test_config *config,
const char *name) {
gpr_timespec timeout = gpr_time_add(gpr_now(), gpr_time_from_micros(100e6));
gpr_timespec timeout = gpr_time_add(gpr_now(), gpr_time_from_seconds(100));
gpr_log(GPR_INFO, "BEGIN: %s/%s", name, config->name);

@ -48,8 +48,10 @@ static int seed(void) { return _getpid(); }
#endif
void grpc_test_init(int argc, char **argv) {
#ifndef GPR_WIN32
/* disable SIGPIPE */
signal(SIGPIPE, SIG_IGN);
#endif
/* seed rng with pid, so we don't end up with the same random numbers as a
concurrently running test binary */
srand(seed());

Loading…
Cancel
Save