Merge branch 'bitsetmacros' into compression-accept-encoding

pull/2533/head
David Garcia Quintas 10 years ago
commit 9b768a5fe9
  1. 32
      Makefile
  2. 9
      include/grpc/support/useful.h
  3. 56
      templates/Makefile.template
  4. 7
      test/core/support/useful_test.c

@ -339,10 +339,10 @@ CACHE_MK =
HAS_PKG_CONFIG ?= $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false) HAS_PKG_CONFIG ?= $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false)
ifeq ($(HAS_PKG_CONFIG), true) ifeq ($(HAS_PKG_CONFIG), true)
CACHE_MK += HAS_PKG_CONFIG = true\n CACHE_MK += HAS_PKG_CONFIG = true,
endif endif
PC_TEMPLATE = prefix=$(prefix)\nexec_prefix=\$${prefix}\nincludedir=\$${prefix}/include\nlibdir=\$${exec_prefix}/lib\n\nName: $(PC_NAME)\nDescription: $(PC_DESCRIPTION)\nVersion: $(VERSION)\nCflags: -I\$${includedir} $(PC_CFLAGS)\nRequires.private: $(PC_REQUIRES_PRIVATE)\nLibs: -L\$${libdir} $(PC_LIB)\nLibs.private: $(PC_LIBS_PRIVATE) PC_TEMPLATE = prefix=$(prefix),exec_prefix=\$${prefix},includedir=\$${prefix}/include,libdir=\$${exec_prefix}/lib,,Name: $(PC_NAME),Description: $(PC_DESCRIPTION),Version: $(VERSION),Cflags: -I\$${includedir} $(PC_CFLAGS),Requires.private: $(PC_REQUIRES_PRIVATE),Libs: -L\$${libdir} $(PC_LIB),Libs.private: $(PC_LIBS_PRIVATE)
# gpr .pc file # gpr .pc file
PC_NAME = gRPC Portable Runtime PC_NAME = gRPC Portable Runtime
@ -417,7 +417,7 @@ HAS_SYSTEM_PERFTOOLS ?= $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true
ifeq ($(HAS_SYSTEM_PERFTOOLS),true) ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
DEFINES += GRPC_HAVE_PERFTOOLS DEFINES += GRPC_HAVE_PERFTOOLS
LIBS += profiler LIBS += profiler
CACHE_MK += HAS_SYSTEM_PERFTOOLS = true\n CACHE_MK += HAS_SYSTEM_PERFTOOLS = true,
endif endif
endif endif
@ -426,20 +426,20 @@ ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false) HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true) ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
HAS_SYSTEM_OPENSSL_NPN = true HAS_SYSTEM_OPENSSL_NPN = true
CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true\n CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true,
else else
HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false) HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
endif endif
ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true) ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true\n CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true,
endif endif
HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false) HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
ifeq ($(HAS_SYSTEM_ZLIB),true) ifeq ($(HAS_SYSTEM_ZLIB),true)
CACHE_MK += HAS_SYSTEM_ZLIB = true\n CACHE_MK += HAS_SYSTEM_ZLIB = true,
endif endif
HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY) HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY)
ifeq ($(HAS_SYSTEM_PROTOBUF),true) ifeq ($(HAS_SYSTEM_PROTOBUF),true)
CACHE_MK += HAS_SYSTEM_PROTOBUF = true\n CACHE_MK += HAS_SYSTEM_PROTOBUF = true,
endif endif
else else
# override system libraries if the config requires a custom compiled library # override system libraries if the config requires a custom compiled library
@ -451,10 +451,10 @@ endif
HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false) HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
ifeq ($(HAS_PROTOC),true) ifeq ($(HAS_PROTOC),true)
CACHE_MK += HAS_PROTOC = true\n CACHE_MK += HAS_PROTOC = true,
HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false) HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false)
ifeq ($(HAS_VALID_PROTOC),true) ifeq ($(HAS_VALID_PROTOC),true)
CACHE_MK += HAS_VALID_PROTOC = true\n CACHE_MK += HAS_VALID_PROTOC = true,
endif endif
else else
HAS_VALID_PROTOC = false HAS_VALID_PROTOC = false
@ -475,7 +475,7 @@ endif
endif endif
ifeq ($(HAS_SYSTEMTAP),true) ifeq ($(HAS_SYSTEMTAP),true)
CACHE_MK += HAS_SYSTEMTAP = true\n CACHE_MK += HAS_SYSTEMTAP = true,
endif endif
# Note that for testing purposes, one can do: # Note that for testing purposes, one can do:
@ -2905,32 +2905,32 @@ endif
cache.mk:: cache.mk::
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) echo -e "$(CACHE_MK)" >$@ $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@
$(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc: $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc:
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) mkdir -p $(@D) $(Q) mkdir -p $(@D)
$(Q) echo -e "$(GPR_PC_FILE)" >$@ $(Q) echo "$(GPR_PC_FILE)" | tr , '\n' >$@
$(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc:
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) mkdir -p $(@D) $(Q) mkdir -p $(@D)
$(Q) echo -e "$(GRPC_PC_FILE)" >$@ $(Q) echo "$(GRPC_PC_FILE)" | tr , '\n' >$@
$(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc:
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) mkdir -p $(@D) $(Q) mkdir -p $(@D)
$(Q) echo -e "$(GRPC_UNSECURE_PC_FILE)" >$@ $(Q) echo "$(GRPC_UNSECURE_PC_FILE)" | tr , '\n' >$@
$(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc:
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) mkdir -p $(@D) $(Q) mkdir -p $(@D)
$(Q) echo -e "$(GRPCXX_PC_FILE)" >$@ $(Q) echo "$(GRPCXX_PC_FILE)" | tr , '\n' >$@
$(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc:
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) mkdir -p $(@D) $(Q) mkdir -p $(@D)
$(Q) echo -e "$(GRPCXX_UNSECURE_PC_FILE)" >$@ $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@
ifeq ($(NO_PROTOC),true) ifeq ($(NO_PROTOC),true)
$(GENDIR)/examples/pubsub/empty.pb.cc: protoc_dep_error $(GENDIR)/examples/pubsub/empty.pb.cc: protoc_dep_error

@ -52,4 +52,13 @@
b = x; \ b = x; \
} while (0) } while (0)
/** Set the \a n-th bit of \a i */
#define GPR_BITSET(i, n) (i |= (1u << n))
/** Clear the \a n-th bit of \a i */
#define GPR_BITCLEAR(i, n) (i &= ~(1u << n))
/** Get the \a n-th bit of \a i */
#define GPR_BITGET(i, n) ((i & (1u << n)) != 0)
#endif /* GRPC_SUPPORT_USEFUL_H */ #endif /* GRPC_SUPPORT_USEFUL_H */

@ -353,20 +353,20 @@ CACHE_MK =
HAS_PKG_CONFIG ?= $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false) HAS_PKG_CONFIG ?= $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false)
ifeq ($(HAS_PKG_CONFIG), true) ifeq ($(HAS_PKG_CONFIG), true)
CACHE_MK += HAS_PKG_CONFIG = true\n CACHE_MK += HAS_PKG_CONFIG = true,
endif endif
PC_TEMPLATE = prefix=$(prefix)\n\ PC_TEMPLATE = prefix=$(prefix),\
exec_prefix=${'\$${prefix}'}\n\ exec_prefix=${'\$${prefix}'},\
includedir=${'\$${prefix}'}/include\n\ includedir=${'\$${prefix}'}/include,\
libdir=${'\$${exec_prefix}'}/lib\n\ libdir=${'\$${exec_prefix}'}/lib,\
\n\ ,\
Name: $(PC_NAME)\n\ Name: $(PC_NAME),\
Description: $(PC_DESCRIPTION)\n\ Description: $(PC_DESCRIPTION),\
Version: $(VERSION)\n\ Version: $(VERSION),\
Cflags: -I${'\$${includedir}'} $(PC_CFLAGS)\n\ Cflags: -I${'\$${includedir}'} $(PC_CFLAGS),\
Requires.private: $(PC_REQUIRES_PRIVATE)\n\ Requires.private: $(PC_REQUIRES_PRIVATE),\
Libs: -L${'\$${libdir}'} $(PC_LIB)\n\ Libs: -L${'\$${libdir}'} $(PC_LIB),\
Libs.private: $(PC_LIBS_PRIVATE) Libs.private: $(PC_LIBS_PRIVATE)
# gpr .pc file # gpr .pc file
@ -442,7 +442,7 @@ HAS_SYSTEM_PERFTOOLS ?= $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true
ifeq ($(HAS_SYSTEM_PERFTOOLS),true) ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
DEFINES += GRPC_HAVE_PERFTOOLS DEFINES += GRPC_HAVE_PERFTOOLS
LIBS += profiler LIBS += profiler
CACHE_MK += HAS_SYSTEM_PERFTOOLS = true\n CACHE_MK += HAS_SYSTEM_PERFTOOLS = true,
endif endif
endif endif
@ -451,20 +451,20 @@ ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false) HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true) ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
HAS_SYSTEM_OPENSSL_NPN = true HAS_SYSTEM_OPENSSL_NPN = true
CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true\n CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true,
else else
HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false) HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
endif endif
ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true) ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true\n CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true,
endif endif
HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false) HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
ifeq ($(HAS_SYSTEM_ZLIB),true) ifeq ($(HAS_SYSTEM_ZLIB),true)
CACHE_MK += HAS_SYSTEM_ZLIB = true\n CACHE_MK += HAS_SYSTEM_ZLIB = true,
endif endif
HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY) HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY)
ifeq ($(HAS_SYSTEM_PROTOBUF),true) ifeq ($(HAS_SYSTEM_PROTOBUF),true)
CACHE_MK += HAS_SYSTEM_PROTOBUF = true\n CACHE_MK += HAS_SYSTEM_PROTOBUF = true,
endif endif
else else
# override system libraries if the config requires a custom compiled library # override system libraries if the config requires a custom compiled library
@ -476,10 +476,10 @@ endif
HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false) HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
ifeq ($(HAS_PROTOC),true) ifeq ($(HAS_PROTOC),true)
CACHE_MK += HAS_PROTOC = true\n CACHE_MK += HAS_PROTOC = true,
HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false) HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false)
ifeq ($(HAS_VALID_PROTOC),true) ifeq ($(HAS_VALID_PROTOC),true)
CACHE_MK += HAS_VALID_PROTOC = true\n CACHE_MK += HAS_VALID_PROTOC = true,
endif endif
else else
HAS_VALID_PROTOC = false HAS_VALID_PROTOC = false
@ -500,7 +500,7 @@ endif
endif endif
ifeq ($(HAS_SYSTEMTAP),true) ifeq ($(HAS_SYSTEMTAP),true)
CACHE_MK += HAS_SYSTEMTAP = true\n CACHE_MK += HAS_SYSTEMTAP = true,
endif endif
# Note that for testing purposes, one can do: # Note that for testing purposes, one can do:
@ -1108,32 +1108,32 @@ endif
cache.mk:: cache.mk::
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) echo -e "$(CACHE_MK)" >$@ $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@
$(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc: $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc:
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) mkdir -p $(@D) $(Q) mkdir -p $(@D)
$(Q) echo -e "$(GPR_PC_FILE)" >$@ $(Q) echo "$(GPR_PC_FILE)" | tr , '\n' >$@
$(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc:
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) mkdir -p $(@D) $(Q) mkdir -p $(@D)
$(Q) echo -e "$(GRPC_PC_FILE)" >$@ $(Q) echo "$(GRPC_PC_FILE)" | tr , '\n' >$@
$(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc:
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) mkdir -p $(@D) $(Q) mkdir -p $(@D)
$(Q) echo -e "$(GRPC_UNSECURE_PC_FILE)" >$@ $(Q) echo "$(GRPC_UNSECURE_PC_FILE)" | tr , '\n' >$@
$(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc:
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) mkdir -p $(@D) $(Q) mkdir -p $(@D)
$(Q) echo -e "$(GRPCXX_PC_FILE)" >$@ $(Q) echo "$(GRPCXX_PC_FILE)" | tr , '\n' >$@
$(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc:
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) mkdir -p $(@D) $(Q) mkdir -p $(@D)
$(Q) echo -e "$(GRPCXX_UNSECURE_PC_FILE)" >$@ $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@
% for p in protos: % for p in protos:
ifeq ($(NO_PROTOC),true) ifeq ($(NO_PROTOC),true)

@ -39,6 +39,7 @@
int main(int argc, char **argv) { int main(int argc, char **argv) {
int four[4]; int four[4];
int five[5]; int five[5];
gpr_uint32 bitset = 0;
grpc_test_init(argc, argv); grpc_test_init(argc, argv);
GPR_ASSERT(GPR_MIN(1, 2) == 1); GPR_ASSERT(GPR_MIN(1, 2) == 1);
@ -55,5 +56,11 @@ int main(int argc, char **argv) {
GPR_ASSERT(GPR_ARRAY_SIZE(four) == 4); GPR_ASSERT(GPR_ARRAY_SIZE(four) == 4);
GPR_ASSERT(GPR_ARRAY_SIZE(five) == 5); GPR_ASSERT(GPR_ARRAY_SIZE(five) == 5);
GPR_ASSERT(GPR_BITSET(bitset, 3) == 8);
GPR_ASSERT(GPR_BITGET(bitset, 3) == 1);
GPR_ASSERT(GPR_BITSET(bitset, 1) == 10);
GPR_ASSERT(GPR_BITCLEAR(bitset, 3) == 2);
GPR_ASSERT(GPR_BITGET(bitset, 3) == 0);
return 0; return 0;
} }

Loading…
Cancel
Save