Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
024099d
clang-tidy fixes; more to go
fromage17 Sep 20, 2020
4fdde63
clang-tidy fixes; more to go
fromage17 Sep 20, 2020
1efbe65
clang-tidy fixes -- 2nd bunch
fromage17 Sep 20, 2020
820eef6
.clang-tidy
fromage17 Sep 21, 2020
bf88764
fixing errs/warns found during compilation of test_suite.cpp
fromage17 Sep 21, 2020
cf385fc
compiler-fixes for test_suite.cpp; also changed /dev/null to /dev/std…
fromage17 Sep 21, 2020
049d80f
clean-up the nan/inf code in printf.c; supplem tests for nan/inf in …
fromage17 Sep 22, 2020
9d4589a
include printf.cpp instead of printf.c
fromage17 Sep 23, 2020
e61fe74
printf.cpp: start c++-izing casts
fromage17 Sep 23, 2020
5746f12
cvt all c-style casts to c++
fromage17 Sep 23, 2020
8fdf30f
cvt most c-style #defines to const
fromage17 Sep 23, 2020
f6fcdb4
FLAGS_FOO() as constexpr functions
fromage17 Sep 24, 2020
37fec1a
FLAGS_FOO as constexpr variables
fromage17 Sep 24, 2020
e90c30f
rm printf.c -- printf.cpp is the new incarnation
fromage17 Sep 24, 2020
c6b1dc6
copy printf.{cpp,h} back to printf repo after testing in Ventilator repo
fromage17 Sep 26, 2020
f2fe158
test::_putchar,printf_idx,printf_buffer,_out_fct
fromage17 Sep 26, 2020
21f8642
use same printf.* for internal and external repo
fromage17 Sep 26, 2020
5d75dbf
mv <cstdio> are others -> inside _putchar()
fromage17 Sep 26, 2020
2800811
printf.cpp printf.h: working
fromage17 Sep 28, 2020
f78c665
printf.cpp printf.h pre-commit
fromage17 Sep 29, 2020
10288df
fixed clang-tidy errs in test/test_suite.cpp
fromage17 Sep 29, 2020
2442efc
cppcheck fixes
fromage17 Sep 29, 2020
2a48877
test_suite, clang-tidy, cppcheck : all pass.
fromage17 Sep 29, 2020
a969fb5
fixing 9.99e-to-10.00e bug; also Makefile improvements
fromage17 Oct 7, 2020
e0fab1e
Makefile
fromage17 Oct 10, 2020
1467b25
frac == 0U out, mv 'rescale' up, oob values tests unified for eEgG
fromage17 Oct 10, 2020
1b02858
oob values tests mv'd to eEgG and fF cases in big switch
fromage17 Oct 11, 2020
35e707e
mistaken rounding-test; excess_prec
fromage17 Oct 11, 2020
a1fb4ef
test_suite.cpp: new TCs for prec>exp10 test; printf.cpp: rm old comm-…
fromage17 Oct 12, 2020
be2489d
test_suite: prec vs exp10 TCs
fromage17 Oct 12, 2020
72d1c9f
printf.cpp: prec -= exp10
fromage17 Oct 12, 2020
a7efe5e
test_suite.cpp: %g cases
fromage17 Oct 13, 2020
c2f4022
printf.cpp: implem proper defn of %g ; streamline test-case printing
fromage17 Oct 14, 2020
d9981a9
test_suite.cpp: more %g cases
fromage17 Oct 14, 2020
540b180
test_suite.cpp: refine diagnostic cout msg
fromage17 Oct 14, 2020
8257676
test_suite.cpp: use proper c++ casts, numeric_limits<>
fromage17 Oct 14, 2020
f095f29
exp10-deriving constants
fromage17 Oct 14, 2020
0b81f0a
printf.cpp: better constexpr names; test_suite.cpp: organize the floa…
fromage17 Oct 14, 2020
da4a9ba
printf.cpp
fromage17 Oct 14, 2020
2ab933f
test_suite.cpp: added %g-to-e tests
fromage17 Oct 15, 2020
c49d3e7
test_suite.cpp: refining %g-to-e test cases
fromage17 Oct 15, 2020
2a6dea2
calc_frac,calc_exp10,fill_mant: basic calls, don't replace _etoa's ca…
fromage17 Oct 17, 2020
6ea4586
printf.cpp: calc_frac(),calc_exp10,fill_mantissa() basic calls: TC's …
fromage17 Oct 17, 2020
75f88c8
printf.cpp: calc_frac(),calc_exp10,fill_mantissa(): all calls from _…
fromage17 Oct 18, 2020
fb484c2
9.9-to-10.0 rollover bug fixed!
fromage17 Oct 19, 2020
431c75e
printf.cpp, test_suite.cpp: cleanup after fixing rollover-to-exp10 bug
fromage17 Oct 20, 2020
bb1dd52
dbging adjust_sigfigs()
fromage17 Oct 20, 2020
dca7779
test_suite.cpp & adjust_sigfigs(): ALL TC's pass!
fromage17 Oct 21, 2020
36831bf
adjust_sigfigs(): misc chgs
fromage17 Oct 21, 2020
c1a563f
printf.cpp: calc_*() pass ptrs not refs; constexprs must not depend o…
fromage17 Oct 22, 2020
f3c56a8
testing, clang-tidy, cppcheck fixes
fromage17 Oct 22, 2020
f2ce05a
using CaseSpec alias
fromage17 Oct 28, 2020
e26d696
using CaseSpec alias, pt 2
fromage17 Oct 29, 2020
9557403
Test Cases: using struct alias to specify CaseSpec; also Catch2's CHE…
fromage17 Oct 30, 2020
9563e19
Test Cases: refine use of CHECK(); cleanups
fromage17 Oct 30, 2020
230ed13
Test Cases: cleanups
fromage17 Oct 30, 2020
ce2e5a3
Makefile: flexible targets - yay
fromage17 Oct 31, 2020
5c93b9a
Makefile: targ 'run' runs test_suite; test_suite.cpp: prefer CHECK() …
fromage17 Oct 31, 2020
afea1cd
Makefile: 'make checks' will build printf/test_suite and run all test…
fromage17 Nov 1, 2020
e8778fe
make_for_all_stds, Makefile: cleanups; printf.cpp: finish constexprs
fromage17 Nov 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
# TODO(jkff): Re-enable google-readability-casting: it can be annoying, but it
# can catch some nasty bugs. E.g. C-style casts happily cast a pointer to the
# wrong type.
Checks: >
*,
-*-magic-numbers,
-hicpp-*,
-cppcoreguidelines-*,
-fuchsia-*,
-clion-*,
-cert-*,
-readability-named-parameter,
-llvm-header-guard,
-google-readability-todo,
-misc-unused-parameters,
-*-braces-around-statements,
-google-readability-casting,
-readability-else-after-return,
-modernize-use-auto,
-modernize-use-trailing-return-type,
-modernize-deprecated-headers,
-llvm-include-order,
-modernize-avoid-c-arrays,
-readability-uppercase-literal-suffix,
-bugprone-narrowing-conversions,
-readability-isolate-declaration,
-readability-convert-member-functions-to-static,
-modernize-use-default-member-init,
-misc-non-private-member-variables-in-classes,
-readability-implicit-bool-conversion,
-modernize-use-using,
-modernize-use-nodiscard,
-readability-non-const-parameter,
-google-runtime-int,
-clang-analyzer-security.FloatLoopCounter

WarningsAsErrors: '*'

# TODO: Add naming style checks (readability-identifier-naming).
...
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
129 changes: 92 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# ------------------------------------------------------------------------------
#
#
# Generic Makefile
#
# Copyright Marco Paland 2007 - 2017
# Distributed under the MIT License
#
# ------------------------------------------------------------------------------

SHELL := /bin/bash

# ------------------------------------------------------------------------------
# Paths
# ------------------------------------------------------------------------------
PATH_TOOLS_CC = /usr/bin/
PATH_TOOLS_CC_LIB = /usr/lib/
PATH_TOOLS_UTIL =
PATH_TOOLS_UTIL =

PATH_BIN = bin
PATH_TMP = tmp
PATH_NUL = /dev/null
PATH_NUL = /dev/stderr
PATH_OBJ = $(PATH_TMP)/obj
PATH_LST = $(PATH_TMP)/lst
PATH_ERR = $(PATH_TMP)/err
Expand Down Expand Up @@ -50,10 +52,13 @@ FILES_PRJ = test/test_suite
# -Iinclude_path3 \
# ------------------------------------------------------------------------------

C_INCLUDES =
C_INCLUDES =

C_DEFINES =
C_DEFINES =

ifndef $(CC_STD)
CC_STD = -std=c++14
endif

# ------------------------------------------------------------------------------
# The target name and location
Expand Down Expand Up @@ -107,7 +112,7 @@ SED = $(PATH_TOOLS_UTIL)sed

GCCFLAGS = $(C_INCLUDES) \
$(C_DEFINES) \
-std=c++11 \
$(CC_STD) \
-g \
-Wall \
-pedantic \
Expand Down Expand Up @@ -166,7 +171,7 @@ LFLAGS = $(GCCFLAGS) \
# Main-Dependencies (app: all)
# ------------------------------------------------------------------------------
.PHONY: all
all: clean_prj $(TRG) $(TRG)_nm.txt
all: clean_prj $(TRG) $(TRG)_nm.txt diagnostics checks cov_app


# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -223,49 +228,99 @@ version:
# ------------------------------------------------------------------------------

# ------------------------------------------------------------------------------
# Link/locate application
# tests and lint-like checkers
# ------------------------------------------------------------------------------
$(TRG) : $(FILES_O)
@-$(ECHO) +++ linkink application to generate: $(TRG)
@-$(CL) $(LFLAGS) -L. -lc $(PATH_OBJ)/*.o -Wl,-Map,$(TRG).map -o $(TRG)
# profiling
@-$(CL) $(LFLAGS) -L. -lc $(PATH_COV)/*.o --coverage -o $(PATH_COV)/$(APP)
.PHONY: most
most : $(TRG) tests lints

.PHONY: lints
lints : cppcheck tidy

.PHONY: cppcheck
cppcheck : printf.cppcheck.out

.PHONY: tidy
tidy : test/test_suite.tidy.out

.PHONY: tests
tests : $(TRG)
$(TRG) -r compact

.PHONY: tests_verbose
tests_verbose : $(TRG)
$(TRG) -r compact -s

%.cppcheck.out: %.cpp
cppcheck --enable=warning,style --inline-suppr $< > $@ 2>&1

test/%.tidy.out: test/%.cpp
clang-tidy $< > $@ 2>&1

# ------------------------------------------------------------------------------
# parse the object files to obtain symbol information, and create a size summary
# ------------------------------------------------------------------------------
$(TRG)_nm.txt : $(TRG)
@-$(ECHO) +++ parsing symbols with nm to generate: $(TRG)_nm.txt
@-$(NM) --numeric-sort --print-size $(TRG) > $(TRG)_nm.txt
$(NM) --numeric-sort --print-size $(TRG) > $(TRG)_nm.txt
@-$(ECHO) +++ demangling symbols with c++filt to generate: $(TRG)_cppfilt.txt
@-$(NM) --numeric-sort --print-size $(TRG) | $(CPPFILT) > $(TRG)_cppfilt.txt
$(NM) --numeric-sort --print-size $(TRG) | $(CPPFILT) > $(TRG)_cppfilt.txt
@-$(ECHO) +++ creating size summary table with size to generate: $(TRG)_size.txt
@-$(SIZE) -A -t $(TRG) > $(TRG)_size.txt
$(SIZE) -A -t $(TRG) > $(TRG)_size.txt

# ------------------------------------------------------------------------------
# compiling/assembling/linking/locating: normal executable target
# ------------------------------------------------------------------------------
.PHONY: bin_app
bin_app : $(TRG)

.PHONY: diagnostics
diagnostics: obj_d obj_lst pre_pre

.PHONY: obj_o
obj_o : $(PATH_OBJ)/*.o

.PHONY: obj_d
obj_d : $(PATH_OBJ)/*.d

.PHONY: obj_lst
obj_lst : $(PATH_OBJ)/*.lst

.PHONY: pre_pre
pre_pre : $(PATH_PRE)/*.pre

%.o : %.cpp
@$(ECHO) +++ compile: $<
$(TRG) : $(PATH_OBJ)/*.o
@-$(ECHO) +++ linkink application to generate: $(TRG)
$(CL) $(LFLAGS) -L. -lc $(PATH_OBJ)/*.o -Wl,-Map,$(TRG).map -o $(TRG)

$(PATH_OBJ)/%.o : test/%.cpp
# Compile the source file
$(CL) $(CPPFLAGS) $< -c -o $(PATH_OBJ)/$(basename $(@F)).o 2> $(PATH_ERR)/$(basename $(@F)).err
# ...and Reformat (using sed) any possible error/warning messages for the VisualStudio(R) output window
# ...and Create an assembly listing using objdump
$(SED) -e 's|.h:\([0-9]*\),|.h(\1) :|' -e 's|:\([0-9]*\):|(\1) :|' $(PATH_ERR)/$(basename $(@F)).err

$(PATH_PRE)/%.pre : test/%.cpp
$(CL) $(CPPFLAGS) $< -E -o $(PATH_PRE)/$(basename $(@F)).pre

$(PATH_OBJ)/%.d : test/%.cpp
# ...and Generate a dependency file (using the -MM flag)
@-$(CL) $(CPPFLAGS) $< -E -o $(PATH_PRE)/$(basename $(@F)).pre
@-$(CL) $(CPPFLAGS) $< -c -o $(PATH_OBJ)/$(basename $(@F)).o 2> $(PATH_ERR)/$(basename $(@F)).err
@-$(SED) -e 's|.h:\([0-9]*\),|.h(\1) :|' -e 's|:\([0-9]*\):|(\1) :|' $(PATH_ERR)/$(basename $(@F)).err
@-$(OBJDUMP) --disassemble --line-numbers -S $(PATH_OBJ)/$(basename $(@F)).o > $(PATH_LST)/$(basename $(@F)).lst
@-$(CL) $(CPPFLAGS) $< -MM > $(PATH_OBJ)/$(basename $(@F)).d
# profiling
@-$(CL) $(CPPFLAGS) -O0 --coverage $< -c -o $(PATH_COV)/$(basename $(@F)).o 2> $(PATH_NUL)

%.o : %.c
@$(ECHO) +++ compile: $<
# Compile the source file
# ...and Reformat (using sed) any possible error/warning messages for the VisualStudio(R) output window
$(CL) $(CPPFLAGS) $< -MM > $(PATH_OBJ)/$(basename $(@F)).d

$(PATH_OBJ)/%.lst : $(PATH_OBJ)/%.o
# ...and Create an assembly listing using objdump
# ...and Generate a dependency file (using the -MM flag)
@-$(CL) $(CFLAGS) $< -E -o $(PATH_PRE)/$(basename $(@F)).pre
@-$(CC) $(CFLAGS) $< -c -o $(PATH_OBJ)/$(basename $(@F)).o 2> $(PATH_ERR)/$(basename $(@F)).err
@-$(SED) -e 's|.h:\([0-9]*\),|.h(\1) :|' -e 's|:\([0-9]*\):|(\1) :|' $(PATH_ERR)/$(basename $(@F)).err
@-$(OBJDUMP) -S $(PATH_OBJ)/$(basename $(@F)).o > $(PATH_LST)/$(basename $(@F)).lst
@-$(CC) $(CFLAGS) $< -MM > $(PATH_OBJ)/$(basename $(@F)).d
$(OBJDUMP) --disassemble --line-numbers -S $(PATH_OBJ)/$(basename $(@F)).o > $(PATH_LST)/$(basename $(@F)).lst

# ------------------------------------------------------------------------------
# compiling/assembling/linking/locating: profiling target
# ------------------------------------------------------------------------------
.PHONY: cov_app
cov_app : $(PATH_COV)/$(APP)

.PHONY: cov_o
cov_o : $(PATH_COV)/*.o

$(PATH_COV)/$(APP) : $(PATH_COV)/*.o
@-$(ECHO) +++ linking application to generate: $(PATH_COV)/$(APP)
$(CL) $(LFLAGS) -L. -lc $(PATH_COV)/*.o --coverage -o $(PATH_COV)/$(APP)

$(PATH_COV)/%.o : test/%.cpp
$(CL) $(CPPFLAGS) -O0 --coverage $< -c -o $(PATH_COV)/$(basename $(@F)).o 2> $(PATH_ERR)/$(basename $(@F)).coverr
8 changes: 8 additions & 0 deletions make_for_all_stds
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -o xtrace
for v in "-std=c++11" "-std=c++14" "-std=c++17"
do
echo building for $v
touch test/test_suite.cpp printf.cpp
make most CC_STD=$v
done
Loading