Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ build-packages/
package/
packages/
cscope.*
lib-tzcode/libtz.a
target/
output/
38 changes: 31 additions & 7 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
LIBRARIES= kit
DLLIBRARIES = libkit
MAKE_DEBS = 1

DST.lib+= $(DST.dir)/libkit$(EXT.lib)

libsources = $(wildcard $(1)/*.c) $(subst $(OS_class)/,,$(wildcard $(1)/$(OS_class)/*.c))
libobjects = $(foreach SOURCE,$(call libsources,$(1)),$(patsubst $(1)/%.c,$(1)/$(DST.dir)/%$(EXT.obj),$(SOURCE)))
DST.obj = $(foreach PACKAGE,$(ALL_LIBRARIES),$(call libobjects,$(COM.dir)/lib-$(PACKAGE)))
DST.obj = $(foreach PACKAGE,$(filter-out tzcode,$(ALL_LIBRARIES)),$(call libobjects,$(COM.dir)/lib-$(PACKAGE)))
TZCODE.dir = $(COM.dir)/lib-tzcode
DST.obj += $(TZCODE.dir)/asctime.o $(TZCODE.dir)/difftime.o $(TZCODE.dir)/localtime.o $(TZCODE.dir)/strftime.o

libheaders= $(wildcard $(1)/*.h) $(wildcard $(1)/$(DST.dir)/*.h) $(wildcard $(1)/$(OS_class)/*.h)
SRC.inc.lib= $(filter-out %-private.h,$(foreach PACKAGE,$(ALL_LIBRARIES),$(call libheaders,$(COM.dir)/lib-$(PACKAGE))))
DST.inc.lib= $(filter-out %-private.h,$(foreach PACKAGE,$(ALL_LIBRARIES),$(subst /$(OS_class),,$(subst ./lib-$(PACKAGE),$(DST.dir)/include,$(call libheaders,$(COM.dir)/lib-$(PACKAGE))))))
SRC.inc.lib= $(filter-out %/private.h %-private.h,$(foreach PACKAGE,$(ALL_LIBRARIES),$(call libheaders,$(COM.dir)/lib-$(PACKAGE))))
DST.inc.lib= $(filter-out %/private.h %-private.h,$(foreach PACKAGE,$(ALL_LIBRARIES),$(subst /$(OS_class),,$(subst ./lib-$(PACKAGE),$(DST.dir)/include,$(call libheaders,$(COM.dir)/lib-$(PACKAGE))))))
SRC.inc= $(SRC.inc.lib)
DST.inc= $(DST.inc.lib)

DEB_BUILD_NUMBER= $(shell echo -$${BUILD_NUMBER-dev})

include dependencies.mak

ifdef MAKE_DEBUG
Expand All @@ -21,9 +26,28 @@ endif
include:
@$(MAKE_PERL_ECHO_BOLD) "make[$(MAKELEVEL)]: updating: $(DST.dir)/include"
-$(MAKE_RUN)$(MKDIR) $(call OSPATH,$(DST.dir)/include) $(TO_NUL) $(FAKE_PASS)
$(MAKE_RUN) $(COPYFILES2DIR) $(SRC.inc.lib) $(DST.dir)/include
$(COPYFILES2DIR) $(SRC.inc.lib) $(DST.dir)/include

ifeq ($(filter remote,$(MAKECMDGOALS)),)
clean:: $(DEP.dirs)
rm -rf target
rm -rf output

realclean:: $(DEP.dirs)
endif
rm -rf target
rm -rf output

package:
if [ ! -e build-linux-64-release/libkit.a ]; then $(MAKE) release; fi
mkdir -p target/include
cp -rp build-linux-64-release/include/*.h target/include
cp build-linux-64-release/libkit.a target
cp build-linux-64-release/libkit.so.$(DEB.ver) target
cp -p bin/kit-alloc-analyze target
ln -sf libkit.so.$(DEB.ver) target/libkit.so.$(DEB.ver.maj)
ln -sf libkit.so.$(DEB.ver.maj) target/libkit.so
cp -rp debian target
@err=$$(dpkg-parsechangelog -l target/debian/changelog 2>&1 >/dev/null); [ -z "$$err" ] || { echo "$$err"; false; }
perl -nale '$$_ =~ s/libkit \(([0-9.-]+)\) (\w+); urgency=(\w+)/libkit ($$1$(DEB_BUILD_NUMBER)) $$2; urgency=$$3/g;print' <debian/changelog >target/debian/changelog
cd target && dpkg-buildpackage -b -rfakeroot -uc -us
mkdir -p output
mv libkit_*_amd64.deb libkit-dev_*_amd64.deb libkit_*_amd64.changes libkit_*_amd64.buildinfo output
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ libkit
This library contains useful standalone routines, supplying a basic
"kit" for developing C code.

The library contains tensor mathematical operations in kit-tensor.c
that implement operations similar to those in PyTorch. For documentation
see: pytorch.org.

The build depends on the mak, libsxe and libjemalloc submodules which
must be checked out alongside libkit.
4 changes: 2 additions & 2 deletions bin/kit-alloc-analyze
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ for (my $line_number = 1; my $line = <>; $line_number++) {
}
}

if ($line =~ m{- ([^: ]+): (?:\d+): 0x([\da-f]+) = kit_((?:m|c|re)alloc|strdup)\((?:0x([\da-f]+)|\(nil\))?(?:, |\[)?(\d+)}) {
if ($line =~ m{- ([^: ]+): (?:\d+): 0x([\da-f]+) = kit_((?:m|c|re)alloc|memalign|strn?dup)\((?:0x([\da-f]+)|\(nil\))?(?:, |\[)?(\d+)}) {
# This is an alloc, realloc, or strdup, lines look like this:
# 20210407 222641.037 T 26795 ------ 6 - conf.c: 119: 0x7f8b69c17180 = kit_realloc((nil), 88)
# 20210407 222641.037 T 26795 ------ 6 - conf.c: 670: 0x7f8b69c17180 = kit_realloc(0x7f8b69c17180, 88)
Expand Down Expand Up @@ -120,4 +120,4 @@ foreach my $address (sort {$mem{$a}{line_number} cmp $mem{$b}{line_number}} keys
print " " . ($opts{'n'} ? "$mem{$address}{line_number}:" : "") . " $mem{$address}{line}";
}

print "kit_alloc debug logging may not be enabled\n" if not %filestats;
print "kit_alloc debug logging may not be enabled\n" if not %filestats;
159 changes: 159 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
libkit (2.11) stable; urgency=low
* DPT-3563 - SonarQube 'bug's reported in 2.10 release
* DPT-3592 - Need sxe-cdb.h module in libkit

-- Jim Belton <jabelton@cisco.com> Thu, 32 Jul 2025 15:35:42 +0000

libkit (2.10) stable; urgency=low
* DPT-3518 - Handle invalid timezones passed into kit_timezone_time_to_localtime

-- Sean Mooney <seamoone@cisco.com> Mon, 14 Jul 2025 05:39:18 +0000

libkit (2.9) stable; urgency=low
* DPT-3064 - Support concatenated arrays

-- Jim Belton <jabelton@cisco.com> Wed, 18 Jun 2025 14:54:42 +0000

libkit (2.8) stable; urgency=low
* DPT-3415 - Handle cached timezones with no tzdata

-- Brian Somers <brsomers@cisco.com> Tue, 6 May 2025 21:11:42 +0000

libkit (2.7) stable; urgency=low
* DPT-3261 - sxe_jitson_stack_push_string_reversed
* DPT-1364 - Added new guid, deviceid and strto utility functions
* DPT-3307 - Support the SXE_JITSON_TYPE_REVERSED flag

-- Jim Belton <jabelton@cisco.com> Mon, 24 Mar 2025 15:21:42 +0000

libkit (2.6) stable; urgency=low
* DPT-3232 - Support Intersect operator in WHERE

-- Jim Belton <jabelton@cisco.com> Thu, 20 Feb 2025 14:50:42 +0000

libkit (2.5) stable; urgency=low
* DPT-3141 - sxe-jitson: yet another unicode bug

-- Jim Belton <jabelton@cisco.com> Wed, 8 Jan 2025 12:22:42 +0000

libkit (2.4) stable; urgency=low
* DPT-3052 - Further fix to unicode parsing
* DPT-3072 - Reduce lock contentions during sxe-jitson object/array indexing

-- Jim Belton <jabelton@cisco.com> Tue, 03 Dec 2024 01:03:42 +0000

libkit (2.3) stable; urgency=low
* DPT-2866 - Make object indexing thread safe
* DPT-2771 - Deprecate support for Debian-10
* DPT-3052 - Don't overallocate UTF-8 strings

-- Jim Belton <jabelton@cisco.com> Tue, 12 Nov 2024 12:21:42 +0000

libkit (2.2) stable; urgency=low
* DPT-2828 - Add a build-number suffix to package names
* DPT-2930 - Optimize tensor calculations
* DPT-2866 - Try to make indexing thread safe

-- Brian Somers <brsomers@cisco.com> Sat, 7 Sep 2024 00:29:42 +0000

libkit (2.1) stable; urgency=low
* DPT-2823 - SXE_TIME values are not Y2038 safe
* DPT-2833 - Review security hotspots in sonarqube for libkit
* DPT-2909 - Dereference operator arguments
* THR-4904 - Remove memory allocations from kit_tensor_matmul

-- Jim Belton <jabelton@cisco.com> Wed, 18 Jul 2024 17:16:42 +0000

libkit (2.00) stable; urgency=low
* DPT-2718 - Combine nonevent-driven libsxe modules into libkit
* DPT-2719 - Create a libkit-2.0 debian package build
* DPT-2739 - Integrate libkit-2.0 dpkg into opendnscache
* DPT-2745 - Core Dump in sxe_jitson_is_reference
* DPT-2787 - libkit should build on ubuntu 22.04 and debian 12
* DPT-2793 - Build .deb packages that aptly 1.3 supports
* DPT-2742 - Changes to allow external casts to use jitson string functions
* DPT-2817 - Silence libkit sonarQube noise

-- Jim Belton <jabelton@cisco.com> Wed, 03 Jul 2024 01:38:17 +0000

libkit (1.20) stable; urgency=low
* DPT-2716 - Clean up code smells

-- Brian Somers <brsomers@cisco.com> Thu, 14 Sep 2023 22:10:42 +0000

libkit (1.19) stable; urgency=low
* DPT-2479 - Add tensor math operations code into libkit

-- Dejan Donin <ddonin@cisco.com> Wed, 8 May 2024 13:40:42 +0000

libkit (1.17) stable; urgency=low
* Added iana.org/time-zones tzcode (version 2023c)
* DPT-2183 - Build tzcode and a kit-timezone wrapper
* DPT-2501 - Add a graphite-thread-started callback

-- Jim Belton <jabelton@cisco.com> Mon, 19 Feb 2024 18:36:42 +0000

libkit (1.16) stable; urgency=low
* DPT-2266 - New MOCKERROR macro

-- Sean Mooney <seamoone@cisco.com> Tue, 19 Dec 2023 22:23:00 +0000

libkit (1.14) stable; urgency=low
* DPT-2262 - Allow graphitelog frequency to be changed quickly
* DPT-1574 - Graphite log write timeout set to log_timeout_ms

-- Jim Belton <jabelton@cisco.com> Tue, 17 Oct 2023 00:14:01 +0000

libkit (1.12) stable; urgency=low
* DPT-2245 - Report graphite statistics relative to wall time

-- Brian Somers <brsomers@cisco.com> Thu, 14 Sep 2023 22:10:42 +0000

libkit (1.11) stable; urgency=low
* DPT-2096 - Make malloc guard bytes work with libssl3

-- Jim Belton <jabelton@cisco.com> Tue, 8 Aug 2023 10:35:42 +0000

libkit (1.8) stable; urgency=low
* DPT-2004 - Correct an encoding error
* DPT-2052 - Introduce ASAN - the address sanitizer
* DPT-2046 - kit_memory should support guard words
* DPT-2036 - Add additional checks in opendnscache code
* DPT-2046 - Disable memory guard words in the debug build

-- Brian Somers <brsomers@cisco.com> Fri, 23 Jun 2023 05:08:42 +0000

libkit (1.7) stable; urgency=low
* DPT-1946 - Make kit_stub_resolve() more robust

-- Brian Somers <brsomers@cisco.com> Tue, 9 May 2023 23:37:42 +0000

libkit (1.6) stable; urgency=low
* DPT-1699 - Add kit_bool_from_str()

-- Brian Somers <brsomers@cisco.com> Mon, 24 Apr 2023 17:21:42 +0000

libkit (1.5) stable; urgency=low
* DPT-1854 - Remove ZEUS artifacts

-- Brian Somers <brsomers@cisco.com> Tue, 4 Apr 2023 19:06:42 +0000

libkit (1.4) stable; urgency=low
* DPT-1769 - Add support for Ubuntu-22.04

-- Prashanth Suvarna <psuvarna@cisco.com> Tue, 28 Mar 2023 03:17:42 +0000

libkit (1.3) stable; urgency=low
* DPT-1812 - ok to call kit_memory_allocations before kit_counters_initialize

-- Jim Belton <jabelton@cisco.com> Mon, 20 Mar 2023 16:20:42 +0000

libkit (1.2) stable; urgency=low
* DPT-1632 - SCR0: Handle hardcoded references to opendns.com

-- Jake Zhang <jakezhan@cisco.com> Wed, 1 Mar 2023 22:14:42 +0000

libkit (1.1) stable; urgency=low
* DPT-1771 - Fix policy server memory instability in kit-counters

-- Jim Belton <jabelton@cisco.com> Fri, 24 Feb 2023 19:39:42 +0000
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
18 changes: 18 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Source: libkit
Maintainer: cie-eng.dns-platform@cisco.com
Section: devel
Priority: optional
Build-Depends: debhelper (>= 9)
Standards-Version: 4.7.0.0

Package: libkit-dev
Section: libdevel
Architecture: any
Depends: libkit (= ${binary:Version}), ${misc:Depends}
Description: Cisco C toolkit library headers

Package: libkit
Section: libs
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Cisco C toolkit shared library
4 changes: 4 additions & 0 deletions debian/libkit-dev.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
libkit.a usr/lib
include/*.h usr/include/kit
libkit.so usr/lib/x86_64-linux-gnu
kit-alloc-analyze usr/bin
1 change: 1 addition & 0 deletions debian/libkit.install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libkit.so.* usr/lib/x86_64-linux-gnu
20 changes: 20 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

%:
dh $@

override_dh_auto_test:
dh_auto_test --no-parallel

# Required until aptly is upgrade to 1.5 or above
override_dh_builddeb:
dh_builddeb -- -Zxz

override_dh_installchangelogs:
dh_installchangelogs -XChangeLog

override_dh_strip:
@sync
18 changes: 14 additions & 4 deletions dependencies.mak
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@ TOP.dir = $(COM.dir)/..
# This is used by both the package GNUmakefiles and the top level GNUmakefile
#
remove_to = $(if $(filter $(1),$(2)),$(call remove_to,$(1),$(wordlist 2,$(words $(2)),$(2))),$(2))
ALL_LIBRARIES = kit
ALL_LIBRARIES = sxe-jitson kit sxe-dict sxe-cdb sxe-hash sxe-pool sxe-thread sxe-mmap sxe-list kit-alloc sxe-md5 sxe-util \
sxe-log kit-mock sxe-test tzcode
LIB_DEPENDENCIES = $(call remove_to,$(LIBRARIES),$(ALL_LIBRARIES))

MAK_VERSION ?= 2 # By default, use the libtap package; set this to 1 to use libtap built in to libsxe
CONVENTION_OPTOUT_LIST = lib-kit/kit-queue.h
MAKE_ALLOW_LOWERCASE_TYPEDEF = 1
MAKE_ALLOW_LOWERCASE_TYPEDEF = 1
MAKE_ALLOW_LOWERCASE_HASH_DEFINE = 1
MAKE_ALLOW_SPACE_AFTER_ASTERISK = 1

COVERAGE_OPTOUT_LIST = lib-tzcode

include $(TOP.dir)/mak/mak-common.mak

ifneq ($(MAK_VERSION),1) # Versions of mak > 1 use an external tap libary
LINK_FLAGS += -ltap
CFLAGS += -D_GNU_SOURCE=1 -D_FORTIFY_SOURCE=2 -pthread
LINK_DLLS += -lxxhash -lresolv -lrt -rdynamic -pthread -ldl
LINK_FLAGS += -pie -z noexecstack

ifeq ($(OS_name), linux)
LINK_DLLS += -lbsd -ljemalloc
endif
30 changes: 30 additions & 0 deletions dev-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

# This script should be run with sudo to add the dev packages required to build libkit

set -e

case $(uname -o) in
FreeBSD)
# jemalloc is the default memory allocator in FreeBSD
# PATH=/sbin:$PATH

# for pkg in xxhash; do
# if ! pkg info -q $pkg ; then
# pkg install -y $pkg
# fi
# done
;;

GNU/Linux)
export DEBIAN_FRONTEND=noninteractive
apt-get -y install debhelper libbsd-dev libjemalloc-dev libxxhash-dev
;;

*)
echo "I don't know what I'm doing" >&2
exit 1
;;
esac

exit 0
4 changes: 4 additions & 0 deletions lib-kit-alloc/GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
LIBRARIES = kit-alloc

include ../dependencies.mak

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@

#include "kit-alloc.h"

extern void kit_memory_init_internal(bool hard);
void kit_memory_initialize_counters(void);

#endif
Loading