Skip to content

Commit

Permalink
Use C header-only and improve documentation (#6)
Browse files Browse the repository at this point in the history
* Convert C code to header-only

* Add comment for all C functions and macros.

* Use C17 fo testing

* Remove deprecated entries from Doxyfile

* Add Go examples

* Update PR template
  • Loading branch information
nicolaasuni committed Feb 26, 2024
1 parent 956b18b commit 8e37e71
Show file tree
Hide file tree
Showing 19 changed files with 3,569 additions and 1,855 deletions.
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Please include a summary of the change and include relevant motivation and conte
- [ ] Any new code follows the style guidelines of this project.
- [ ] The code changes have been self-reviewed.
- [ ] Corresponding changes to the documentation have been made.
- [ ] The version has been updated in the VERSION and examples/service/go.mod files.
- [ ] The version has been updated in the VERSION file.

## Type of change:

- [ ] MInor non-breaking change → The patch number in the VERSION file has been increased.
- [ ] Minor non-breaking change → The patch number in the VERSION file has been increased.
- [ ] New feature (non-breaking change which adds functionality) → The minor number in the VERSION file has been increased.
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) → This requires a major version release.
- [ ] Automation.
Expand Down
6 changes: 5 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
The code in this project is a C99 translation of the Fingerprint64
The code in this project is a C port of the Fingerprint64
(farmhashna::Hash64) code from Google's FarmHash
(https://github.com/google/farmhash).

This code has been ported/translated by Nicola Asuni to header-only C code.

The original code is released under the MIT License:

Copyright (c) 2014 Google, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# FarmHash64

*Provides farmhash64, a portable C99 64-bit hash function*
*Provides farmhash64, a portable C 64-bit hash function*

[![Donate via PayPal](https://img.shields.io/badge/donate-paypal-87ceeb.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&currency_code=GBP&[email protected]&item_name=donation%20for%20farmhash64%20project)
*Please consider supporting this project by making a donation via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&currency_code=GBP&[email protected]&item_name=donation%20for%20farmhash64%20project)*
Expand All @@ -19,7 +19,7 @@

FarmHash is a family of hash functions.

This is a C99 translation of the Fingerprint64 (farmhashna::Hash64) code from Google's FarmHash
This is a C translation of the Fingerprint64 (farmhashna::Hash64) code from Google's FarmHash
(https://github.com/google/farmhash).

FarmHash64 provides a portable 64-bit hash function for strings (byte array).
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
1.4.0
5 changes: 2 additions & 3 deletions c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ doc:
.PHONY: format
format:
astyle --style=allman --recursive --suffix=none 'src/*.h'
astyle --style=allman --recursive --suffix=none 'src/*.c'
astyle --style=allman --recursive --suffix=none 'test/*.c'

# Build and run the unit tests
Expand Down Expand Up @@ -122,12 +121,12 @@ endif
# Test C code compatibility with C++
.PHONY: testcpp
testcpp:
find ./src -type f -name '*.c' -exec gcc -c -pedantic -Werror -Wall -Wextra -Wcast-align -Wundef -Wformat-security -std=c++17 -x c++ -o /dev/null {} \;
find ./src -type f -name '*.h' -exec gcc -c -pedantic -Werror -Wall -Wextra -Wcast-align -Wundef -Wformat-security -std=c++17 -x c++ -o /dev/null {} \;

# use clang-tidy
.PHONY: tidy
tidy:
clang-tidy -checks='*,-llvm-header-guard,-llvm-include-order,-android-cloexec-open,-hicpp-no-assembler,-hicpp-signed-bitwise,-clang-analyzer-alpha.*' -header-filter=.* -p . src/*.c
clang-tidy -checks='*,-llvm-header-guard,-llvm-include-order,-android-cloexec-open,-hicpp-no-assembler,-hicpp-signed-bitwise,-clang-analyzer-alpha.*' -header-filter=.* -p . src/*.h

# Remove all installed files (excluding configuration files)
.PHONY: uninstall
Expand Down
2,704 changes: 1,756 additions & 948 deletions c/doc/Doxyfile

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion c/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
link_directories( ${CMAKE_CURRENT_BINARY_DIR} )
include_directories (${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_BINARY_DIR}/src )

add_library (farmhash64 farmhash64.c farmhash64.h)
add_library (farmhash64 farmhash64.h)
target_include_directories (farmhash64 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(farmhash64 PROPERTIES LINKER_LANGUAGE "C")

# Required to link the math library
target_link_libraries(farmhash64)
Loading

0 comments on commit 8e37e71

Please sign in to comment.