Mac build fixes

pull/3322/head^2
Craig Tiller 9 years ago
parent 6b8046375e
commit ebc7ef268c
  1. 1
      include/grpc/support/port_platform.h
  2. 3
      src/core/iomgr/pollset_multipoller_with_poll_posix.c
  3. 10
      src/core/iomgr/tcp_posix.c
  4. 8
      src/core/support/cpu_posix.c
  5. 2
      src/core/support/log_posix.c
  6. 4
      src/core/support/time_posix.c

@ -179,6 +179,7 @@
#ifndef _BSD_SOURCE #ifndef _BSD_SOURCE
#define _BSD_SOURCE #define _BSD_SOURCE
#endif #endif
#define GPR_MSG_IOVLEN_TYPE int
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
#define GPR_PLATFORM_STRING "ios" #define GPR_PLATFORM_STRING "ios"
#define GPR_CPU_IPHONE 1 #define GPR_CPU_IPHONE 1

@ -101,7 +101,8 @@ static void multipoll_with_poll_pollset_maybe_work(
gpr_timespec now, int allow_synchronous_callback) { gpr_timespec now, int allow_synchronous_callback) {
int timeout; int timeout;
int r; int r;
size_t i, j, pfd_count, fd_count; size_t i, j, fd_count;
nfds_t pfd_count;
pollset_hdr *h; pollset_hdr *h;
/* TODO(ctiller): inline some elements to avoid an allocation */ /* TODO(ctiller): inline some elements to avoid an allocation */
grpc_fd_watcher *watchers; grpc_fd_watcher *watchers;

@ -61,6 +61,12 @@
#define SENDMSG_FLAGS 0 #define SENDMSG_FLAGS 0
#endif #endif
#ifdef GPR_MSG_IOVLEN_TYPE
typedef GPR_MSG_IOVLEN_TYPE msg_iovlen_type;
#else
typedef size_t msg_iovlen_type;
#endif
int grpc_tcp_trace = 0; int grpc_tcp_trace = 0;
typedef struct { typedef struct {
@ -68,7 +74,7 @@ typedef struct {
grpc_fd *em_fd; grpc_fd *em_fd;
int fd; int fd;
int finished_edge; int finished_edge;
size_t iov_size; /* Number of slices to allocate per read attempt */ msg_iovlen_type iov_size; /* Number of slices to allocate per read attempt */
size_t slice_size; size_t slice_size;
gpr_refcount refcount; gpr_refcount refcount;
@ -265,7 +271,7 @@ static grpc_endpoint_op_status tcp_read(grpc_endpoint *ep,
static grpc_endpoint_op_status tcp_flush(grpc_tcp *tcp) { static grpc_endpoint_op_status tcp_flush(grpc_tcp *tcp) {
struct msghdr msg; struct msghdr msg;
struct iovec iov[MAX_WRITE_IOVEC]; struct iovec iov[MAX_WRITE_IOVEC];
size_t iov_size; msg_iovlen_type iov_size;
ssize_t sent_length; ssize_t sent_length;
size_t sending_length; size_t sending_length;
size_t trailing; size_t trailing;

@ -44,11 +44,11 @@
static __thread char magic_thread_local; static __thread char magic_thread_local;
static int ncpus = 0; static long ncpus = 0;
static void init_ncpus() { static void init_ncpus() {
ncpus = sysconf(_SC_NPROCESSORS_ONLN); ncpus = sysconf(_SC_NPROCESSORS_ONLN);
if (ncpus < 1) { if (ncpus < 1 || ncpus > GPR_UINT32_MAX) {
gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1"); gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1");
ncpus = 1; ncpus = 1;
} }
@ -57,7 +57,7 @@ static void init_ncpus() {
unsigned gpr_cpu_num_cores(void) { unsigned gpr_cpu_num_cores(void) {
static gpr_once once = GPR_ONCE_INIT; static gpr_once once = GPR_ONCE_INIT;
gpr_once_init(&once, init_ncpus); gpr_once_init(&once, init_ncpus);
return ncpus; return (unsigned)ncpus;
} }
/* This is a cheap, but good enough, pointer hash for sharding things: */ /* This is a cheap, but good enough, pointer hash for sharding things: */
@ -71,7 +71,7 @@ unsigned gpr_cpu_current_cpu(void) {
most code that's using this is using it to shard across work queues though, most code that's using this is using it to shard across work queues though,
so here we use thread identity instead to achieve a similar though not so here we use thread identity instead to achieve a similar though not
identical effect */ identical effect */
return shard_ptr(&magic_thread_local); return (unsigned)shard_ptr(&magic_thread_local);
} }
#endif /* GPR_CPU_POSIX */ #endif /* GPR_CPU_POSIX */

@ -62,7 +62,7 @@ void gpr_log(const char *file, int line, gpr_log_severity severity,
} else if ((size_t)ret <= sizeof(buf) - 1) { } else if ((size_t)ret <= sizeof(buf) - 1) {
message = buf; message = buf;
} else { } else {
message = allocated = gpr_malloc(ret + 1); message = allocated = gpr_malloc((size_t)ret + 1);
va_start(args, format); va_start(args, format);
vsnprintf(message, ret + 1, format, args); vsnprintf(message, ret + 1, format, args);
va_end(args); va_end(args);

@ -108,8 +108,8 @@ gpr_timespec gpr_now(gpr_clock_type clock) {
break; break;
case GPR_CLOCK_MONOTONIC: case GPR_CLOCK_MONOTONIC:
now_dbl = (mach_absolute_time() - g_time_start) * g_time_scale; now_dbl = (mach_absolute_time() - g_time_start) * g_time_scale;
now.tv_sec = now_dbl * 1e-9; now.tv_sec = (time_t)(now_dbl * 1e-9);
now.tv_nsec = now_dbl - now.tv_sec * 1e9; now.tv_nsec = (int)(now_dbl - ((double)now.tv_sec) * 1e9);
break; break;
case GPR_CLOCK_PRECISE: case GPR_CLOCK_PRECISE:
gpr_precise_clock_now(&now); gpr_precise_clock_now(&now);

Loading…
Cancel
Save