From eaa713e93b6aadf08fda33238670cd3577a7db52 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 6 Jul 2016 16:02:38 +0200 Subject: [PATCH] geohash.c and geohash_helper.c are part of Redis. They were under /deps since they originate from a different source tree, however at this point they are very modified and we took ownership of both the files making changes, fixing bugs, so there is no upgrade path from the original code tree. Given that, better to move the code under /src with proper dependencies and with a more simpler editing experience. --- deps/Makefile | 7 ------- deps/geohash-int/Makefile | 23 ---------------------- src/Makefile | 11 +++++------ {deps/geohash-int => src}/geohash.c | 6 +++--- {deps/geohash-int => src}/geohash.h | 0 {deps/geohash-int => src}/geohash_helper.c | 8 ++++---- {deps/geohash-int => src}/geohash_helper.h | 0 7 files changed, 12 insertions(+), 43 deletions(-) delete mode 100644 deps/geohash-int/Makefile rename {deps/geohash-int => src}/geohash.c (98%) rename {deps/geohash-int => src}/geohash.h (100%) rename {deps/geohash-int => src}/geohash_helper.c (98%) rename {deps/geohash-int => src}/geohash_helper.h (100%) diff --git a/deps/Makefile b/deps/Makefile index 1c10bce9e..e148a331c 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -36,7 +36,6 @@ distclean: -(cd hiredis && $(MAKE) clean) > /dev/null || true -(cd linenoise && $(MAKE) clean) > /dev/null || true -(cd lua && $(MAKE) clean) > /dev/null || true - -(cd geohash-int && $(MAKE) clean) > /dev/null || true -(cd jemalloc && [ -f Makefile ] && $(MAKE) distclean) > /dev/null || true -(rm -f .make-*) @@ -82,9 +81,3 @@ jemalloc: .make-prerequisites cd jemalloc && $(MAKE) CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" lib/libjemalloc.a .PHONY: jemalloc - -geohash-int: .make-prerequisites - @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) - cd geohash-int && $(MAKE) - -.PHONY: geohash-int diff --git a/deps/geohash-int/Makefile b/deps/geohash-int/Makefile deleted file mode 100644 index b7c259577..000000000 --- a/deps/geohash-int/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -STD= -WARN= -Wall -OPT= -O2 - -R_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) -R_LDFLAGS= $(LDFLAGS) -DEBUG= -g - -R_CC=$(CC) $(R_CFLAGS) -R_LD=$(CC) $(R_LDFLAGS) - -all: geohash.o geohash_helper.o - -.PHONY: all - -geohash.o: geohash.h geohash.c -geohash_helper.o: geohash.h geohash_helper.h geohash_helper.c - -.c.o: - $(R_CC) -c $< - -clean: - rm -f *.o diff --git a/src/Makefile b/src/Makefile index 2ee01a463..325402ec2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -15,12 +15,12 @@ release_hdr := $(shell sh -c './mkreleasehdr.sh') uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') OPTIMIZATION?=-O2 -DEPENDENCY_TARGETS=hiredis linenoise lua geohash-int +DEPENDENCY_TARGETS=hiredis linenoise lua NODEPS:=clean distclean # Default settings STD=-std=c99 -pedantic -DREDIS_STATIC='' -WARN=-Wall -W +WARN=-Wall -W -Wno-missing-field-initializers OPT=$(OPTIMIZATION) PREFIX?=/usr/local @@ -54,7 +54,7 @@ endif # Override default settings if possible -include .make-settings -FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS) -I../deps/geohash-int +FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS) FINAL_LDFLAGS=$(LDFLAGS) $(REDIS_LDFLAGS) $(DEBUG) FINAL_LIBS=-lm DEBUG=-g -ggdb @@ -128,8 +128,7 @@ endif REDIS_SERVER_NAME=redis-server REDIS_SENTINEL_NAME=redis-sentinel -REDIS_SERVER_OBJ=adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o geo.o lazyfree.o module.o evict.o expire.o -REDIS_GEOHASH_OBJ=../deps/geohash-int/geohash.o ../deps/geohash-int/geohash_helper.o +REDIS_SERVER_OBJ=adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o REDIS_CLI_NAME=redis-cli REDIS_CLI_OBJ=anet.o adlist.o redis-cli.o zmalloc.o release.o anet.o ae.o crc64.o REDIS_BENCHMARK_NAME=redis-benchmark @@ -182,7 +181,7 @@ endif # redis-server $(REDIS_SERVER_NAME): $(REDIS_SERVER_OBJ) - $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/lua/src/liblua.a $(REDIS_GEOHASH_OBJ) $(FINAL_LIBS) + $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/lua/src/liblua.a $(FINAL_LIBS) # redis-sentinel $(REDIS_SENTINEL_NAME): $(REDIS_SERVER_NAME) diff --git a/deps/geohash-int/geohash.c b/src/geohash.c similarity index 98% rename from deps/geohash-int/geohash.c rename to src/geohash.c index d3bc7de25..a5e1dffbf 100644 --- a/deps/geohash-int/geohash.c +++ b/src/geohash.c @@ -151,7 +151,7 @@ int geohashEncode(GeoHashRange *long_range, GeoHashRange *lat_range, } int geohashEncodeType(double longitude, double latitude, uint8_t step, GeoHashBits *hash) { - GeoHashRange r[2] = { { 0 } }; + GeoHashRange r[2] = {{0}}; geohashGetCoordRange(&r[0], &r[1]); return geohashEncode(&r[0], &r[1], longitude, latitude, step, hash); } @@ -194,7 +194,7 @@ int geohashDecode(const GeoHashRange long_range, const GeoHashRange lat_range, } int geohashDecodeType(const GeoHashBits hash, GeoHashArea *area) { - GeoHashRange r[2] = { { 0 } }; + GeoHashRange r[2] = {{0}}; geohashGetCoordRange(&r[0], &r[1]); return geohashDecode(r[0], r[1], hash, area); } @@ -211,7 +211,7 @@ int geohashDecodeAreaToLongLat(const GeoHashArea *area, double *xy) { } int geohashDecodeToLongLatType(const GeoHashBits hash, double *xy) { - GeoHashArea area = { { 0 } }; + GeoHashArea area = {{0}}; if (!xy || !geohashDecodeType(hash, &area)) return 0; return geohashDecodeAreaToLongLat(&area, xy); diff --git a/deps/geohash-int/geohash.h b/src/geohash.h similarity index 100% rename from deps/geohash-int/geohash.h rename to src/geohash.h diff --git a/deps/geohash-int/geohash_helper.c b/src/geohash_helper.c similarity index 98% rename from deps/geohash-int/geohash_helper.c rename to src/geohash_helper.c index 4b8894676..da8833fa8 100644 --- a/deps/geohash-int/geohash_helper.c +++ b/src/geohash_helper.c @@ -110,10 +110,10 @@ int geohashBoundingBox(double longitude, double latitude, double radius_meters, GeoHashRadius geohashGetAreasByRadius(double longitude, double latitude, double radius_meters) { GeoHashRange long_range, lat_range; - GeoHashRadius radius = { { 0 } }; - GeoHashBits hash = { 0 }; - GeoHashNeighbors neighbors = { { 0 } }; - GeoHashArea area = { { 0 } }; + GeoHashRadius radius = {{0}}; + GeoHashBits hash = {0,0}; + GeoHashNeighbors neighbors = {{0}}; + GeoHashArea area = {{0}}; double min_lon, max_lon, min_lat, max_lat; double bounds[4]; int steps; diff --git a/deps/geohash-int/geohash_helper.h b/src/geohash_helper.h similarity index 100% rename from deps/geohash-int/geohash_helper.h rename to src/geohash_helper.h