[-]
[+]
|
Changed |
_service:tar_git:libglibutil.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil.spec
^
|
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/.gitignore
^
|
@@ -1,17 +1,12 @@
*~
-test/libglibutil_test.ncb
-test/libglibutil_test.opt
test/coverage/full.gcov
test/coverage/libglibutil.gcov
test/coverage/results
-debian/.debhelper
debian/files
debian/libglibutil-dev.debhelper.log
-debian/libglibutil-dev.install
debian/libglibutil-dev.substvars
debian/libglibutil-dev
debian/libglibutil.debhelper.log
-debian/libglibutil.install
debian/libglibutil.postinst.debhelper
debian/libglibutil.postrm.debhelper
debian/libglibutil.substvars
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/Makefile
^
|
@@ -1,12 +1,12 @@
# -*- Mode: makefile-gmake -*-
-.PHONY: clean all debug release coverage pkgconfig install install-dev test
-.PHONY: print_debug_lib print_release_lib print_coverage_lib
+.PHONY: clean all debug release
+
#
# Required packages
#
-PKGS = glib-2.0 gobject-2.0
+PKGS = glib-2.0
#
# Default target
@@ -15,29 +15,15 @@
all: debug release pkgconfig
#
-# Directories
-#
-
-SRC_DIR = src
-INCLUDE_DIR = include
-BUILD_DIR = build
-DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
-RELEASE_BUILD_DIR = $(BUILD_DIR)/release
-COVERAGE_BUILD_DIR = $(BUILD_DIR)/coverage
-
-#
# Library version
#
-VERSION_FILE = $(INCLUDE_DIR)/gutil_version.h
-get_version = $(shell grep -E '^ *\#define +GUTIL_VERSION_$1 +[0-9]+$$' $(VERSION_FILE) | sed 's/ */ /g' | cut -d ' ' -f 3)
-
-VERSION_MAJOR := $(call get_version,MAJOR)
-VERSION_MINOR := $(call get_version,MINOR)
-VERSION_MICRO := $(call get_version,MICRO)
+VERSION_MAJOR = 1
+VERSION_MINOR = 0
+VERSION_RELEASE = 3
# Version for pkg-config
-PCVERSION := $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_MICRO)
+PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
#
# Library name
@@ -49,53 +35,59 @@
LIB_SYMLINK1 = $(LIB_DEV_SYMLINK).$(VERSION_MAJOR)
LIB_SYMLINK2 = $(LIB_SYMLINK1).$(VERSION_MINOR)
LIB_SONAME = $(LIB_SYMLINK1)
-LIB = $(LIB_SONAME).$(VERSION_MINOR).$(VERSION_MICRO)
-STATIC_LIB = $(LIB_NAME).a
+LIB = $(LIB_SONAME).$(VERSION_MINOR).$(VERSION_RELEASE)
#
# Sources
#
SRC = \
- gutil_datapack.c \
- gutil_history.c \
- gutil_idlepool.c \
- gutil_idlequeue.c \
- gutil_inotify.c \
- gutil_intarray.c \
- gutil_ints.c \
gutil_log.c \
- gutil_misc.c \
- gutil_ring.c \
- gutil_strv.c \
- gutil_timenotify.c \
- gutil_objv.c \
- gutil_version.c \
- gutil_weakref.c
+ gutil_strv.c
+
+#
+# Directories
+#
+
+SRC_DIR = src
+INCLUDE_DIR = include
+BUILD_DIR = build
+DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
+RELEASE_BUILD_DIR = $(BUILD_DIR)/release
+
+#
+# Code coverage
+#
+
+ifndef GCOV
+GCOV = 0
+endif
+
+ifneq ($(GCOV),0)
+CFLAGS += --coverage
+LDFLAGS += --coverage
+endif
#
# Tools and flags
#
-PKG_CONFIG ?= pkg-config
-CC ?= $(CROSS_COMPILE)gcc
-STRIP ?= strip
+CC = $(CROSS_COMPILE)gcc
LD = $(CC)
-WARNINGS ?= -Wall -Wsign-compare
+WARNINGS = -Wall
INCLUDES = -I$(INCLUDE_DIR)
BASE_FLAGS = -fPIC
FULL_CFLAGS = $(BASE_FLAGS) $(CFLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) \
- -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32 \
- -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_MAX_ALLOWED \
- -MMD -MP $(shell $(PKG_CONFIG) --cflags $(PKGS))
+ -MMD -MP $(shell pkg-config --cflags $(PKGS))
FULL_LDFLAGS = $(BASE_FLAGS) $(LDFLAGS) -shared -Wl,-soname,$(LIB_SONAME) \
- -Wl,--version-script=$(LIB_NAME).ver
-LIBS := $(shell $(PKG_CONFIG) --libs $(PKGS))
+ $(shell pkg-config --libs $(PKGS))
DEBUG_FLAGS = -g
RELEASE_FLAGS =
-COVERAGE_FLAGS = -g
-KEEP_SYMBOLS ?= 0
+ifndef KEEP_SYMBOLS
+KEEP_SYMBOLS = 0
+endif
+
ifneq ($(KEEP_SYMBOLS),0)
RELEASE_FLAGS += -g
endif
@@ -104,7 +96,6 @@
RELEASE_LDFLAGS = $(FULL_LDFLAGS) $(RELEASE_FLAGS)
DEBUG_CFLAGS = $(FULL_CFLAGS) $(DEBUG_FLAGS) -DDEBUG
RELEASE_CFLAGS = $(FULL_CFLAGS) $(RELEASE_FLAGS) -O2
-COVERAGE_CFLAGS = $(FULL_CFLAGS) $(COVERAGE_FLAGS) -O0 --coverage
#
# Files
@@ -113,69 +104,62 @@
PKGCONFIG = $(BUILD_DIR)/$(LIB_NAME).pc
DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
-COVERAGE_OBJS = $(SRC:%.c=$(COVERAGE_BUILD_DIR)/%.o)
-
-DEBUG_LIB = $(DEBUG_BUILD_DIR)/$(LIB)
-RELEASE_LIB = $(RELEASE_BUILD_DIR)/$(LIB)
-DEBUG_LINK = $(DEBUG_BUILD_DIR)/$(LIB_SYMLINK1)
-RELEASE_LINK = $(RELEASE_BUILD_DIR)/$(LIB_SYMLINK1)
-DEBUG_DEV_LINK = $(DEBUG_BUILD_DIR)/$(LIB_DEV_SYMLINK)
-RELEASE_DEV_LINK = $(RELEASE_BUILD_DIR)/$(LIB_DEV_SYMLINK)
-DEBUG_STATIC_LIB = $(DEBUG_BUILD_DIR)/$(STATIC_LIB)
-RELEASE_STATIC_LIB = $(RELEASE_BUILD_DIR)/$(STATIC_LIB)
-COVERAGE_STATIC_LIB = $(COVERAGE_BUILD_DIR)/$(STATIC_LIB)
#
# Dependencies
#
-DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d) $(COVERAGE_OBJS:%.o=%.d)
+DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(DEPS)),)
-include $(DEPS)
endif
endif
-$(PKGCONFIG): | $(BUILD_DIR)
-$(DEBUG_OBJS) $(DEBUG_LIB) $(DEBUG_STATIC_LIB): | $(DEBUG_BUILD_DIR)
-$(RELEASE_OBJS) $(RELEASE_LIB) $(RELEASE_STATIC_LIB): | $(RELEASE_BUILD_DIR)
-$(COVERAGE_OBJS) $(COVERAGE_STATIC_LIB): | $(COVERAGE_BUILD_DIR)
+$(DEBUG_OBJS) $(DEBUG_LIB): | $(DEBUG_BUILD_DIR)
+$(RELEASE_OBJS) $(RELEASE_LIB): | $(RELEASE_BUILD_DIR)
#
# Rules
#
-debug: $(DEBUG_STATIC_LIB) $(DEBUG_DEV_LINK)
+DEBUG_LIB = $(DEBUG_BUILD_DIR)/$(LIB)
+RELEASE_LIB = $(RELEASE_BUILD_DIR)/$(LIB)
+DEBUG_LINK = $(DEBUG_BUILD_DIR)/$(LIB_SYMLINK1)
+RELEASE_LINK = $(RELEASE_BUILD_DIR)/$(LIB_SYMLINK1)
-release: $(RELEASE_STATIC_LIB) $(RELEASE_DEV_LINK)
+debug: $(DEBUG_LIB) $(DEBUG_LINK)
-coverage: $(COVERAGE_STATIC_LIB)
+release: $(RELEASE_LIB) $(RELEASE_LINK)
pkgconfig: $(PKGCONFIG)
print_debug_lib:
- @echo $(DEBUG_STATIC_LIB)
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/debian/changelog
^
|
@@ -1,518 +1,3 @@
-libglibutil (1.0.79) unstable; urgency=low
-
- * Exported gutil_source_remove() and Added gutil_source_clear()
-
- -- Slava Monich <slava@monich.com> Thu, 02 May 2024 17:40:30 +0300
-
-libglibutil (1.0.78) unstable; urgency=low
-
- * Added gutil_source_remove()
- * Added gutil_source_clear()
-
- -- Slava Monich <slava@monich.com> Thu, 02 May 2024 04:43:18 +0300
-
-libglibutil (1.0.77) unstable; urgency=low
-
- * Eliminate defects found by Coverity
-
- -- Slava Monich <slava@monich.com> Wed, 10 Apr 2024 04:13:16 +0300
-
-libglibutil (1.0.76) unstable; urgency=low
-
- * Added gutil_idle_pool_get_default()
- * Return the value pushed to the idle pool
- * Interpret NULL as the default pool when appropriate
-
- -- Slava Monich <slava@monich.com> Sun, 28 Jan 2024 02:36:16 +0200
-
-libglibutil (1.0.75) unstable; urgency=low
-
- * Cross-compilation tweaks
- * Compatibility with clang -fsanitize=cfi
- * Export all and only required symbols
-
- -- Slava Monich <slava@monich.com> Fri, 01 Dec 2023 02:01:34 +0200
-
-libglibutil (1.0.74) unstable; urgency=low
-
- * Added Added gutil_data_copy_as_variant()
-
- -- Slava Monich <slava@monich.com> Sun, 10 Sep 2023 04:11:17 +0300
-
-libglibutil (1.0.73) unstable; urgency=low
-
- * Define and use MAKE var instead of explicitly calling make
- * Added gutil_log_set_timestamp_format()
-
- -- Slava Monich <slava@monich.com> Tue, 05 Sep 2023 15:53:55 +0300
-
-libglibutil (1.0.72) unstable; urgency=low
-
- * Don't export gutil_time_notify_get_type()
- * Added gutil_data_new()
- * Added gutil_data_copy()
- * Added gutil_objv_new()
-
- -- Slava Monich <slava@monich.com> Sun, 20 Aug 2023 02:05:13 +0300
-
-libglibutil (1.0.71) unstable; urgency=low
-
- * Added gutil_object_ref()
- * Added gutil_object_unref()
- * Added gutil_objv_append()
- * Added gutil_objv_insert()
- * Added gutil_ptrv_is_empty()
- * Added gutil_bin2hex()
- * Added gutil_data2hex()
-
- -- Slava Monich <slava@monich.com> Sun, 18 Jun 2023 14:24:13 +0300
-
-libglibutil (1.0.70) unstable; urgency=low
-
- * Added gutil_objv module
-
- -- Slava Monich <slava@monich.com> Mon, 29 May 2023 01:35:08 +0300
-
-libglibutil (1.0.69) unstable; urgency=low
-
- * Runtime and compile time version detection
- * Added gutil_datapack module
- * Require glib 2.32
-
- -- Slava Monich <slava@monich.com> Thu, 06 Apr 2023 02:13:48 +0300
-
-libglibutil (1.0.68) unstable; urgency=low
-
- * Added gutil_weakref module
- * Fixed a few compilation warnings
- * Packaging tweaks
-
- -- Slava Monich <slava@monich.com> Sat, 04 Feb 2023 04:26:45 +0200
-
-libglibutil (1.0.67) unstable; urgency=low
-
- * Added gutil_log_dump_bytes()
-
- -- Slava Monich <slava.monich@jolla.com> Fri, 15 Jul 2022 03:02:33 +0300
-
-libglibutil (1.0.66) unstable; urgency=low
-
- * Bumped debhelper compat level to 7
-
- -- Slava Monich <slava.monich@jolla.com> Fri, 15 Jul 2022 03:02:33 +0300
-
-libglibutil (1.0.65) unstable; urgency=low
-
- * Fixed a Musl compatibility issue
-
- -- Slava Monich <slava.monich@jolla.com> Thu, 16 Jun 2022 02:12:22 +0300
-
-libglibutil (1.0.64) unstable; urgency=low
-
- * Resolved a mysterious parallel build issue
-
- -- Slava Monich <slava.monich@jolla.com> Tue, 17 May 2022 03:56:50 +0300
-
-libglibutil (1.0.63) unstable; urgency=low
-
- * Added gutil_bytes_has_prefix()
- * Added gutil_bytes_has_suffix()
-
- -- Slava Monich <slava.monich@jolla.com> Sat, 23 Apr 2022 21:24:25 +0300
-
-libglibutil (1.0.62) unstable; urgency=low
-
- * Added gutil_strlen0()
- * Added gutil_strv_find_last()
- * Added gutil_strv_remove_dups()
-
- -- Slava Monich <slava.monich@jolla.com> Sun, 13 Mar 2022 21:59:26 +0200
-
-libglibutil (1.0.61) unstable; urgency=low
-
- * Added gutil_strv_remove()
-
- -- Slava Monich <slava.monich@jolla.com> Thu, 25 Nov 2021 18:31:18 +0200
-
-libglibutil (1.0.60) unstable; urgency=low
-
- * Housekeeping release
-
- -- Slava Monich <slava.monich@jolla.com> Mon, 22 Nov 2021 23:37:14 +0200
-
-libglibutil (1.0.58) unstable; urgency=low
-
- * Don't check upper bound when setting log level from the envvironment
-
- -- Slava Monich <slava.monich@jolla.com> Wed, 17 Nov 2021 13:17:45 +0200
-
-libglibutil (1.0.57) unstable; urgency=low
-
- * Fixed unit tests for older 32-bit systems
-
- -- Slava Monich <slava.monich@jolla.com> Mon, 08 Nov 2021 02:28:37 +0200
-
-libglibutil (1.0.56) unstable; urgency=low
-
- * Added gutil_parse_int64()
- * Added gutil_parse_uint64()
-
- -- Slava Monich <slava.monich@jolla.com> Sun, 03 Oct 2021 20:18:15 +0300
-
-libglibutil (1.0.55) unstable; urgency=low
-
- * Added gutil_log_dump()
- * Added gutil_range_init_with_bytes()
- * Added gutil_range_has_prefix()
- * Added gutil_range_skip_prefix()
-
- -- Slava Monich <slava.monich@jolla.com> Sun, 23 May 2021 03:33:58 +0300
-
-libglibutil (1.0.54) unstable; urgency=low
-
- * Added GUtilRange type
- * Tweaked interpretation of environment variables
-
- -- Slava Monich <slava.monich@jolla.com> Mon, 17 May 2021 16:06:25 +0300
-
-libglibutil (1.0.53) unstable; urgency=low
-
- * Optimized gutil_parse_int()
- * Added gutil_parse_uint()
-
- -- Slava Monich <slava.monich@jolla.com> Wed, 05 May 2021 15:30:57 +0300
-
-libglibutil (1.0.52) unstable; urgency=low
-
- * Added gutil_memdup()
-
- -- Slava Monich <slava.monich@jolla.com> Sun, 18 Apr 2021 17:40:41 +0300
-
-libglibutil (1.0.51) unstable; urgency=low
-
- * Initialize default log settings from the environment
- * Disable timestamps by default
- * Added gutil_log_tid option
- * Added gutil_ptrv_free()
-
- -- Slava Monich <slava.monich@jolla.com> Thu, 25 Feb 2021 19:36:05 +0200
-
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/debian/compat
^
|
@@ -1 +1 @@
-7
+5
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/debian/control
^
|
@@ -2,7 +2,7 @@
Section: libs
Priority: optional
Maintainer: Slava Monich <slava.monich@jolla.com>
-Build-Depends: debhelper (>= 8.1.3), libglib2.0-dev (>= 2.32)
+Build-Depends: debhelper (>= 7), libglib2.0-dev (>= 2.0)
Standards-Version: 3.8.4
Package: libglibutil
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/debian/copyright
^
|
@@ -1,5 +1,7 @@
-Copyright (C) 2023-2024 Slava Monich <slava@monich.com>
-Copyright (C) 2014-2022 Jolla Ltd.
+Copyright (C) 2014-2015 Jolla Ltd.
+Contact: Slava Monich <slava.monich@jolla.com>
+
+You may use this file under the terms of BSD license as follows:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -10,9 +12,9 @@
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- 3. Neither the names of the copyright holders nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
+ 3. Neither the name of the Jolla Ltd nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
[-]
[+]
|
Added |
_service:tar_git:libglibutil-1.0.3.tar.bz2/debian/libglibutil-dev.install
^
|
@@ -0,0 +1,3 @@
+debian/tmp/usr/lib/libglibutil.so usr/lib
+include/*.h usr/include/gutil
+build/libglibutil.pc usr/lib/pkgconfig
|
[-]
[+]
|
Added |
_service:tar_git:libglibutil-1.0.3.tar.bz2/debian/libglibutil.install
^
|
@@ -0,0 +1 @@
+debian/tmp/usr/lib/libglibutil.so.* usr/lib
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/debian/rules
^
|
@@ -4,13 +4,8 @@
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
-LIBDIR=usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
-
-override_dh_auto_build:
- dh_auto_build -- LIBDIR=$(LIBDIR) release pkgconfig debian/libglibutil.install debian/libglibutil-dev.install
-
override_dh_auto_install:
- dh_auto_install -- LIBDIR=$(LIBDIR) install-dev
+ dh_auto_install -- install-dev
%:
dh $@
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/include/gutil_log.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2023 Slava Monich <slava@monich.com>
- * Copyright (C) 2014-2022 Jolla Ltd.
+ * Copyright (C) 2014-2015 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
+ * 3. Neither the name of the Jolla Ltd nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -75,28 +75,17 @@
# endif
#endif
-/* Logging function prototypes */
-#define GUTIL_DEFINE_LOG_FN(fn) void fn(const char* name, int level, \
- const char* format, va_list va)
-#define GUTIL_DEFINE_LOG_FN2(fn) void fn(const GLogModule* module, \
- int level, const char* format, va_list va)
-typedef GUTIL_DEFINE_LOG_FN((*GLogProc));
-typedef GUTIL_DEFINE_LOG_FN2((*GLogProc2));
-
/* Log module */
struct glog_module {
const char* name; /* Name (used as prefix) */
const GLogModule* parent; /* Parent log module (optional) */
- GLogProc2 log_proc; /* Per-module logging function (1.0.43) */
+ void* reserved; /* Reserved for future expansion */
const int max_level; /* Maximum level defined at compile time */
int level; /* Current log level */
- int flags; /* Flags (see below) */
+ int flags; /* Flags (should be zero) */
int reserved2; /* Reserved for future expansion */
};
-#define GLOG_FLAG_HIDE_NAME (0x01) /* Don't print the module name */
-#define GLOG_FLAG_DISABLE (0x02) /* Don't print this log */
-
/* Command line parsing helper. Option format is [module]:level
* where level can be either a number or log level name ("none", err etc.) */
gboolean
@@ -145,25 +134,6 @@
const GLogModule* module,
int level);
-void
-gutil_log_dump(
- const GLogModule* module,
- int level,
- const char* prefix,
- const void* data,
- gsize size); /* Since 1.0.55 */
-
-void
-gutil_log_dump_bytes(
- const GLogModule* module,
- int level,
- const char* prefix,
- GBytes* bytes); /* Since 1.0.67 */
-
-void
-gutil_log_set_timestamp_format(
- const char* f /* see strftime(3) */ ); /* Since 1.0.73 */
-
/* Known log types */
extern const char GLOG_TYPE_STDOUT[];
extern const char GLOG_TYPE_STDERR[];
@@ -172,21 +142,19 @@
extern const char GLOG_TYPE_SYSLOG[];
/* Available log handlers */
+#define GUTIL_DEFINE_LOG_FN(fn) void fn(const char* name, int level, \
+ const char* format, va_list va)
GUTIL_DEFINE_LOG_FN(gutil_log_stdout);
GUTIL_DEFINE_LOG_FN(gutil_log_stderr);
GUTIL_DEFINE_LOG_FN(gutil_log_glib);
GUTIL_DEFINE_LOG_FN(gutil_log_syslog);
-GUTIL_DEFINE_LOG_FN2(gutil_log_stdout2); /* Since 1.0.43 */
-GUTIL_DEFINE_LOG_FN2(gutil_log_stderr2); /* Since 1.0.43 */
-GUTIL_DEFINE_LOG_FN2(gutil_log_glib2); /* Since 1.0.43 */
-GUTIL_DEFINE_LOG_FN2(gutil_log_syslog2); /* Since 1.0.43 */
/* Log configuration */
+#define GLOG_MODULE_DECL(m) extern GLogModule m;
GLOG_MODULE_DECL(gutil_log_default)
+typedef GUTIL_DEFINE_LOG_FN((*GLogProc));
extern GLogProc gutil_log_func;
-extern GLogProc2 gutil_log_func2;
extern gboolean gutil_log_timestamp; /* Only affects stdout and stderr */
-extern gboolean gutil_log_tid; /* Since 1.0.51 */
/* Log module (optional) */
#define GLOG_MODULE_DEFINE_(var,name) \
@@ -218,12 +186,8 @@
#endif
#ifndef GLOG_VARARGS
-# define GLOG_VA_FN(x) _gutil_log_##x
-# define GLOG_VA_NONE(x) G_INLINE_FUNC \
- void GLOG_VA_FN(x)(const char* f, ...) {}
-# define GLOG_VA(x) GLOG_VA_(GLOG_VA_FN(x),x)
-# define GLOG_VA_(fn,x) G_INLINE_FUNC \
- void fn(const char* f, ...) { \
+# define GLOG_VA_NONE(x) static inline void GUTIL_##x(const char* f, ...) {}
+# define GLOG_VA(x) static inline void GUTIL_##x(const char* f, ...) { \
if (f && f[0]) { \
va_list va; va_start(va,f); \
gutil_logv(GLOG_MODULE_CURRENT, GLOG_LEVEL_##x, f, va); \
@@ -283,7 +247,6 @@
# endif /* GUTIL_LOG_ERR */
#else
# define GERR_ GERR
-# define GERR GLOG_VA_FN(ERR)
# if GUTIL_LOG_ERR
GLOG_VA(ERR)
# else
@@ -303,7 +266,6 @@
# endif /* GUTIL_LOGL_WARN */
#else
# define GWARN_ GWARN
-# define GWARN GLOG_VA_FN(WARN)
# if GUTIL_LOG_WARN
GLOG_VA(WARN)
# else
@@ -323,7 +285,6 @@
# endif /* GUTIL_LOG_INFO */
#else
# define GINFO_ GINFO
-# define GINFO GLOG_VA_FN(INFO)
# if GUTIL_LOG_INFO
GLOG_VA(INFO)
# else
@@ -337,23 +298,16 @@
GLOG_LEVEL_DEBUG, f, ##args)
# define GDEBUG_(f,args...) gutil_log(GLOG_MODULE_CURRENT, \
GLOG_LEVEL_DEBUG, "%s() " f, __FUNCTION__, ##args)
-# define GDEBUG_DUMP(buf,n) gutil_log_dump(GLOG_MODULE_CURRENT, \
- GLOG_LEVEL_DEBUG, NULL, buf, n) /* Since 1.0.55 */
-# define GDEBUG_DUMP_BYTES(b) gutil_log_dump_bytes(GLOG_MODULE_CURRENT, \
- GLOG_LEVEL_DEBUG, NULL, b) /* Since 1.0.67 */
# else
# define GDEBUG(f,args...) GLOG_NOTHING
# define GDEBUG_(f,args...) GLOG_NOTHING
-# define GDEBUG_DUMP(buf,n) GLOG_NOTHING /* Since 1.0.55 */
-# define GDEBUG_DUMP_BYTES(b) GLOG_NOTHING /* Since 1.0.67 */
# endif /* GUTIL_LOG_DEBUG */
#else
# define GDEBUG_ GDEBUG
-# define GDEBUG GLOG_VA_FN(debug)
# if GUTIL_LOG_DEBUG
- GLOG_VA_(GDEBUG,DEBUG)
+ GLOG_VA(DEBUG)
# else
- GLOG_VA_NONE_(GDEBUG,DEBUG)
+ GLOG_VA_NONE(DEBUG)
# endif /* GUTIL_LOG_DEBUG */
#endif /* GLOG_VARARGS */
@@ -369,7 +323,6 @@
# endif /* GUTIL_LOG_VERBOSE */
#else
# define GVERBOSE_ GVERBOSE
-# define GVERBOSE GLOG_VA_FN(VERBOSE)
# if GUTIL_LOG_VERBOSE
GLOG_VA(VERBOSE)
# else
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/include/gutil_macros.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2020 Jolla Ltd.
- * Copyright (C) 2014-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2014-2015 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
+ * 3. Neither the name of the Jolla Ltd nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -48,8 +48,6 @@
# define G_PACKED
#endif
-#define gutil_slice_free(x) g_slice_free1(sizeof(*(x)), x) /* Since 1.0.49 */
-
#endif /* GUTIL_MACROS_H */
/*
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/include/gutil_strv.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2022 Jolla Ltd.
- * Copyright (C) 2014-2022 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2014-2016 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
+ * 3. Neither the name of the Jolla Ltd nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -53,13 +53,6 @@
guint i);
/**
- * Returns the last string in the array, NULL if there's nothing there.
- */
-const char*
-gutil_strv_last(
- const GStrV* sv); /* Since 1.0.35 */
-
-/**
* Returns index of the specified string in the string array,
* or -1 if the string is not found.
*/
@@ -69,15 +62,6 @@
const char* s);
/**
- * Returns index of the last occurrence of specified string in the string
- * array, or -1 if the string is not found.
- */
-int
-gutil_strv_find_last(
- const GStrV* sv,
- const char* s); /* Since 1.0.62 */
-
-/**
* Checks if string array contains the specified string.
*/
gboolean
@@ -91,42 +75,7 @@
GStrV*
gutil_strv_add(
GStrV* sv,
- const char* s)
- G_GNUC_WARN_UNUSED_RESULT;
-
-/**
- * Appends new string(s) to the array.
- */
-GStrV*
-gutil_strv_addv(
- GStrV* sv,
- const char* s,
- ...) /* Since 1.0.47 */
- G_GNUC_WARN_UNUSED_RESULT
- G_GNUC_NULL_TERMINATED;
-
-/**
- * Removes the string from the specified position in the array.
- */
-GStrV*
-gutil_strv_remove_at(
- GStrV* sv,
- int pos,
- gboolean free_string)
- G_GNUC_WARN_UNUSED_RESULT;
-
-/**
- * Removes one or all matching strings from the array and frees them.
- */
-GStrV*
-gutil_strv_remove(
- GStrV* sv,
- const char* s,
- gboolean remove_all) /* Since 1.0.61 */
- G_GNUC_WARN_UNUSED_RESULT;
-
-#define gutil_strv_remove_one(sv, s) gutil_strv_remove(sv, s, FALSE)
-#define gutil_strv_remove_all(sv, s) gutil_strv_remove(sv, s, TRUE)
+ const char* s);
/**
* Checks two string arrays for equality.
@@ -136,41 +85,6 @@
const GStrV* sv1,
const GStrV* sv2);
-/**
- * Removes all duplicates from the string array.
- */
-GStrV*
-gutil_strv_remove_dups(
- GStrV* sv); /* Since 1.0.62 */
-
-/**
- * Sorts the string array
- */
-GStrV*
-gutil_strv_sort(
- GStrV* sv,
- gboolean ascending);
-
-/**
- * Binary search in the sorted string array. Returns index of the
- * specified string in the string array, or -1 if the string is not
- * found. It's basically a version of gutil_strv_find optimized for
- * sorted arrays. The string array must be sorted by gutil_strv_sort
- * with the same 'ascending' argument.
- */
-int
-gutil_strv_bsearch(
- GStrV* sv,
- const char* s,
- gboolean ascending); /* Since 1.0.40 */
-
-/**
- * Removes leading and trailing whitespaces from all strings in the vector.
- */
-GStrV*
-gutil_strv_strip(
- GStrV* sv);
-
G_END_DECLS
#endif /* GUTIL_STRV_H */
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/include/gutil_types.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2021 Jolla Ltd.
- * Copyright (C) 2023 Slava Monich <slava@monich.com>
+ * Copyright (C) 2014-2016 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
+ * 3. Neither the name of the Jolla Ltd nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -34,36 +34,12 @@
#define GUTIL_TYPES_H
#include <glib.h>
+#include <glib-object.h>
#include <string.h>
#include <stdio.h>
-G_BEGIN_DECLS
-
-typedef char* GStrV;
-typedef struct gutil_idle_pool GUtilIdlePool;
-typedef struct gutil_idle_queue GUtilIdleQueue;
-typedef struct gutil_ints GUtilInts;
-typedef struct gutil_int_array GUtilIntArray;
-typedef struct gutil_int_history GUtilIntHistory;
-typedef struct gutil_inotify_watch GUtilInotifyWatch;
-typedef struct gutil_ring GUtilRing;
-typedef struct gutil_time_notify GUtilTimeNotify;
-typedef struct gutil_weakref GUtilWeakRef; /* Since 1.0.68 */
-
-typedef struct gutil_data {
- const guint8* bytes;
- gsize size;
-} GUtilData;
-
-typedef struct gutil_range {
- const guint8* ptr;
- const guint8* end;
-} GUtilRange; /* Since 1.0.54 */
-
-#define GLOG_MODULE_DECL(m) extern GLogModule m;
typedef struct glog_module GLogModule;
-
-G_END_DECLS
+typedef char* GStrV;
#endif /* GUTIL_TYPES_H */
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/libglibutil.pc.in
^
|
@@ -1,10 +1,10 @@
name=glibutil
-libdir=@libdir@
+libdir=/usr/lib
includedir=/usr/include
Name: libglibutil
Description: Library of glib utilities
-Version: @version@
-Requires.private: glib-2.0
+Version: [version]
+Requires: glib-2.0
Libs: -L${libdir} -l${name}
Cflags: -I${includedir} -I${includedir}/gutil
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/src/gutil_log.c
^
|
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2014-2023 Slava Monich <slava@monich.com>
- * Copyright (C) 2014-2022 Jolla Ltd.
+ * Copyright (C) 2014-2015 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.com>
*
- * You may use this file under the terms of the BSD license as follows:
+ * You may use this file under the terms of BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -13,9 +13,9 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
+ * 3. Neither the name of the Jolla Ltd nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -31,21 +31,9 @@
*/
#include "gutil_log.h"
-#include "gutil_misc.h"
-#include <stdlib.h>
-
-#if __GNUC__ >= 4
-#pragma GCC visibility push(default)
-#endif
-
-#ifdef unix
-# include <unistd.h>
-# include <sys/syscall.h>
-# define gettid() ((int)syscall(SYS_gettid))
-#elif defined(_WIN32)
+#if defined(DEBUG) && defined(_WIN32)
# include <windows.h>
-# define gettid() ((int)GetCurrentThreadId())
#endif
#ifndef GLOG_SYSLOG
@@ -61,26 +49,17 @@
#endif /* GLOG_GLIB */
/* Allows timestamps in stdout log */
-gboolean gutil_log_timestamp = FALSE;
-static const char gutil_log_ftime_default[] = "%Y-%m-%d %H:%M:%S ";
-static const char* gutil_log_ftime = gutil_log_ftime_default;
-static char* gutil_log_ftime_custom = NULL;
-
-/* Adds thread id prefix */
-gboolean gutil_log_tid = FALSE; /* Since 1.0.51 */
+gboolean gutil_log_timestamp = TRUE;
/* Log configuration */
-static GUTIL_DEFINE_LOG_FN2(gutil_log_default_proc);
GLogProc gutil_log_func = gutil_log_stdout;
-GLogProc2 gutil_log_func2 = gutil_log_default_proc;
GLogModule gutil_log_default = {
NULL, /* name */
NULL, /* parent */
- NULL, /* log_proc */
+ NULL, /* reserved */
GLOG_LEVEL_MAX, /* max_level */
GLOG_LEVEL_DEFAULT, /* level */
- 0, /* flags */
- 0 /* reserved2 */
+ 0 /* flags */
};
/* Log level descriptions */
@@ -126,7 +105,6 @@
{
int size, nchars = -1;
char* buffer;
-
if (buf) {
size = bufsize;
buffer = buf;
@@ -134,11 +112,10 @@
size = MAX(100,bufsize);
buffer = g_malloc(size);
}
-
while (buffer) {
+
/* Try to print in the allocated space. */
va_list va2;
-
G_VA_COPY(va2, va);
nchars = g_vsnprintf(buffer, size, format, va2);
va_end(va2);
@@ -171,27 +148,13 @@
char buf[512];
const char* prefix = "";
char* msg;
-
- /* gutil_log_ftime is never NULL but can be empty */
- if (gutil_log_timestamp && gutil_log_ftime[0]) {
+ if (gutil_log_timestamp) {
time_t now;
-#ifndef _WIN32
- struct tm tm_;
-#define localtime(t) localtime_r(t, &tm_)
-#endif
-
time(&now);
- strftime(t, sizeof(t), gutil_log_ftime, localtime(&now));
-#undef localtime
+ strftime(t, sizeof(t), "%Y-%m-%d %H:%M:%S ", localtime(&now));
} else {
t[0] = 0;
}
-
- /* Empty name is treated the same way as NULL */
- if (name && !name[0]) {
- name = NULL;
- }
-
switch (level) {
case GLOG_LEVEL_WARN: prefix = "WARNING: "; break;
case GLOG_LEVEL_ERR: prefix = "ERROR: "; break;
@@ -210,18 +173,8 @@
}
#endif
if (name) {
-#ifdef gettid
- if (gutil_log_tid)
- fprintf(out, "[%d] %s[%s] %s%s\n", gettid(), t, name, prefix, msg);
- else
-#endif
fprintf(out, "%s[%s] %s%s\n", t, name, prefix, msg);
} else {
-#ifdef gettid
- if (gutil_log_tid)
- fprintf(out, "[%d] %s%s%s\n", gettid(), t, prefix, msg);
- else
-#endif
fprintf(out, "%s%s%s\n", t, prefix, msg);
}
if (msg != buf) g_free(msg);
@@ -247,26 +200,6 @@
gutil_log_stdio(stderr, name, level, format, va);
}
-void
-gutil_log_stdout2(
- const GLogModule* module,
- int level,
- const char* format,
- va_list va) /* Since 1.0.43 */
-{
- gutil_log_stdout(module ? module->name : NULL, level, format, va);
-}
-
-void
-gutil_log_stderr2(
- const GLogModule* module,
- int level,
- const char* format,
- va_list va) /* Since 1.0.43 */
-{
- gutil_log_stderr(module ? module->name : NULL, level, format, va);
-}
-
/* Formards output to syslog */
#if GLOG_SYSLOG
#include <syslog.h>
@@ -279,7 +212,6 @@
{
int priority;
const char* prefix = NULL;
-
switch (level) {
default:
case GLOG_LEVEL_INFO:
@@ -300,53 +232,19 @@
prefix = "ERROR! ";
break;
}
-
- if (name) {
- /* We don't want to see default name twice in the log */
- if (!name[0] || name == gutil_log_default.name ||
- !g_strcmp0(name, gutil_log_default.name)) {
- name = NULL;
- }
- }
-
- if (name || prefix
-#ifdef gettid
- || gutil_log_tid
-#endif
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/src/gutil_strv.c
^
|
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2014-2023 Slava Monich <slava@monich.com>
- * Copyright (C) 2014-2022 Jolla Ltd.
+ * Copyright (C) 2014-2016 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.com>
*
- * You may use this file under the terms of the BSD license as follows:
+ * You may use this file under the terms of BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -13,9 +13,9 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
+ * 3. Neither the name of the Jolla Ltd nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -31,13 +31,6 @@
*/
#include "gutil_strv.h"
-#include "gutil_misc.h"
-
-#include <stdlib.h>
-
-#if __GNUC__ >= 4
-#pragma GCC visibility push(default)
-#endif
/**
* NULL-tolerant version of g_strv_length
@@ -46,7 +39,13 @@
gutil_strv_length(
const GStrV* sv)
{
- return (guint) gutil_ptrv_length(sv);
+ if (G_LIKELY(sv)) {
+ guint i = 0;
+ while (sv[i]) i++;
+ return i;
+ } else {
+ return 0;
+ }
}
/**
@@ -59,7 +58,6 @@
{
if (G_LIKELY(sv)) {
guint k = 0;
-
while (sv[k] && k < i) k++;
if (k == i) {
/* We also end up here if i == len but that's OK */
@@ -70,22 +68,6 @@
}
/**
- * Returns the last string in the array, NULL if there's nothing there.
- */
-const char*
-gutil_strv_last(
- const GStrV* sv) /* Since 1.0.35 */
-{
- if (G_LIKELY(sv) && G_LIKELY(sv[0])) {
- guint k = 0;
-
- while (sv[k + 1]) k++;
- return sv[k];
- }
- return NULL;
-}
-
-/**
* Returns index of the specified string in the string array,
* or -1 if the string is not found.
*/
@@ -94,10 +76,9 @@
const GStrV* sv,
const char* s)
{
- if (G_LIKELY(sv) && G_LIKELY(s)) {
+ if (sv && s) {
int i = 0;
const GStrV* ptr;
-
for (ptr = sv; *ptr; ptr++, i++) {
if (!strcmp(*ptr, s)) {
return i;
@@ -107,36 +88,6 @@
return -1;
}
-/* Helper for gutil_strv_find_last and friends */
-static
-int
-gutil_strv_find_last_impl(
- const GStrV* sv,
- const char* s,
- int i /* exclisive */)
-{
- while (i > 0) {
- if (!strcmp(sv[--i], s)) {
- return i;
- }
- }
- return -1;
-}
-
-/**
- * Returns index of the last occurrence of specified string in the string
- * array, or -1 if the string is not found.
- */
-int
-gutil_strv_find_last(
- const GStrV* sv,
- const char* s) /* Since 1.0.62 */
-{
- /* NULL sv is handled by gutil_strv_length() */
- return G_LIKELY(s) ? gutil_strv_find_last_impl(sv, s,
- gutil_strv_length(sv)) : -1;
-}
-
/**
* Checks if string array contains the specified string.
*/
@@ -157,249 +108,36 @@
const char* s)
{
if (s) {
- guint len = gutil_strv_length(sv);
-
- sv = g_renew(char*, sv, len + 2);
- sv[len++] = g_strdup(s);
- sv[len] = NULL;
- }
- return sv;
-}
-
-/**
- * Appends new strings to the array.
- */
-GStrV*
-gutil_strv_addv(
- GStrV* sv,
- const char* s,
- ...)
-{
- if (s) {
- va_list va;
- const char* s1;
- guint len, i, n;
-
- va_start(va, s);
- for (n = 1; (s1 = va_arg(va, char*)) != NULL; n++);
- va_end(va);
-
- len = gutil_strv_length(sv);
- sv = g_renew(gchar*, sv, len + n + 1);
- sv[len++] = g_strdup(s);
- va_start(va, s);
- for (i = 1; i < n; i++) sv[len++] = g_strdup(va_arg(va, char*));
- va_end(va);
- sv[len] = NULL;
- }
- return sv;
-}
-
-/* Internal helper for removal functions */
-static
-GStrV*
-gutil_strv_remove_impl(
- GStrV* sv,
- guint pos,
- guint len,
- gboolean free_string)
-{
- if (free_string) {
- g_free(sv[pos]);
- }
- memmove(sv + pos, sv + pos + 1, sizeof(char*)*(len - pos));
- return g_realloc(sv, sizeof(char*)*len);
-}
-
-/**
- * Removes the string from the specified position in the array.
- */
-GStrV*
-gutil_strv_remove_at(
- GStrV* sv,
- int pos,
- gboolean free_string)
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/test/Makefile
^
|
@@ -2,16 +2,4 @@
all:
%:
- @$(MAKE) -C test_datapack $*
- @$(MAKE) -C test_history $*
- @$(MAKE) -C test_idlepool $*
- @$(MAKE) -C test_idlequeue $*
- @$(MAKE) -C test_inotify $*
- @$(MAKE) -C test_intarray $*
- @$(MAKE) -C test_ints $*
- @$(MAKE) -C test_log $*
- @$(MAKE) -C test_misc $*
- @$(MAKE) -C test_objv $*
- @$(MAKE) -C test_ring $*
@$(MAKE) -C test_strv $*
- @$(MAKE) -C test_weakref $*
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/test/common/Makefile
^
|
@@ -1,6 +1,6 @@
# -*- Mode: makefile-gmake -*-
-.PHONY: clean all debug release coverage debug_lib release_lib coverage_lib
+.PHONY: clean all debug release libglibutil-release libglibutil-debug
#
# Real test makefile defines EXE (and possibly SRC) and includes this one.
@@ -10,14 +10,15 @@
${error EXE not defined}
endif
-SRC ?= $(EXE).c
-COMMON_SRC ?= test_main.c test_object.c
+ifndef SRC
+SRC = $(EXE).c
+endif
#
# Required packages
#
-PKGS += gobject-2.0 glib-2.0
+PKGS = glib-2.0
#
# Default target
@@ -35,14 +36,26 @@
BUILD_DIR = build
DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
RELEASE_BUILD_DIR = $(BUILD_DIR)/release
-COVERAGE_BUILD_DIR = $(BUILD_DIR)/coverage
+
+#
+# Code coverage
+#
+
+ifndef GCOV
+GCOV = 0
+endif
+
+ifneq ($(GCOV),0)
+CFLAGS += --coverage
+LDFLAGS += --coverage
+SUBMAKE_OPTS += GCOV=1
+endif
#
# Tools and flags
#
-PKG_CONFIG ?= pkg-config
-CC ?= $(CROSS_COMPILE)gcc
+CC = $(CROSS_COMPILE)gcc
LD = $(CC)
WARNINGS = -Wall
INCLUDES = -I$(LIB_DIR)/include -I$(LIB_DIR)/src -I$(COMMON_DIR)
@@ -50,17 +63,17 @@
BASE_LDFLAGS = $(BASE_FLAGS) $(LDFLAGS)
BASE_CFLAGS = $(BASE_FLAGS) $(CFLAGS)
FULL_CFLAGS = $(BASE_CFLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
- -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32 \
- -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_MAX_ALLOWED \
- $(shell $(PKG_CONFIG) --cflags $(PKGS))
+ $(shell pkg-config --cflags $(PKGS))
FULL_LDFLAGS = $(BASE_LDFLAGS)
-LIBS = $(shell $(PKG_CONFIG) --libs $(PKGS))
-QUIET_MAKE = $(MAKE) --no-print-directory
+LIBS = $(shell pkg-config --libs $(PKGS))
+QUIET_MAKE = make --no-print-directory
DEBUG_FLAGS = -g
RELEASE_FLAGS =
-COVERAGE_FLAGS = -g
-KEEP_SYMBOLS ?= 0
+ifndef KEEP_SYMBOLS
+KEEP_SYMBOLS = 0
+endif
+
ifneq ($(KEEP_SYMBOLS),0)
RELEASE_FLAGS += -g
SUBMAKE_OPTS += KEEP_SYMBOLS=1
@@ -68,52 +81,39 @@
DEBUG_LDFLAGS = $(FULL_LDFLAGS) $(DEBUG_FLAGS)
RELEASE_LDFLAGS = $(FULL_LDFLAGS) $(RELEASE_FLAGS)
-COVERAGE_LDFLAGS = $(FULL_LDFLAGS) $(COVERAGE_FLAGS) --coverage
-
DEBUG_CFLAGS = $(FULL_CFLAGS) $(DEBUG_FLAGS) -DDEBUG
RELEASE_CFLAGS = $(FULL_CFLAGS) $(RELEASE_FLAGS) -O2
-COVERAGE_CFLAGS = $(FULL_CFLAGS) $(COVERAGE_FLAGS) --coverage
#
# Files
#
DEBUG_OBJS = \
- $(COMMON_SRC:%.c=$(DEBUG_BUILD_DIR)/common_%.o) \
+ $(COMMON_SRC:%.c=$(DEBUG_BUILD_DIR)/%.o) \
$(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
RELEASE_OBJS = \
- $(COMMON_SRC:%.c=$(RELEASE_BUILD_DIR)/common_%.o) \
+ $(COMMON_SRC:%.c=$(RELEASE_BUILD_DIR)/%.o) \
$(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
-COVERAGE_OBJS = \
- $(COMMON_SRC:%.c=$(COVERAGE_BUILD_DIR)/common_%.o) \
- $(SRC:%.c=$(COVERAGE_BUILD_DIR)/%.o)
DEBUG_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_lib)
RELEASE_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_lib)
-COVERAGE_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_coverage_lib)
-
+DEBUG_LIB_PATH := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_path)
DEBUG_LIB := $(LIB_DIR)/$(DEBUG_LIB_FILE)
RELEASE_LIB := $(LIB_DIR)/$(RELEASE_LIB_FILE)
-COVERAGE_LIB := $(LIB_DIR)/$(COVERAGE_LIB_FILE)
#
# Dependencies
#
-DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d) $(COVERAGE_OBJS:%.o=%.d)
+DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(DEPS)),)
-include $(DEPS)
endif
endif
-$(DEBUG_LIB): | debug_lib
-$(RELEASE_LIB): | release_lib
-$(COVERAGE_LIB): | coverage_lib
-
$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
-$(COVERAGE_OBJS): | $(COVERAGE_BUILD_DIR)
#
# Rules
@@ -121,29 +121,23 @@
DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
-COVERAGE_EXE = $(COVERAGE_BUILD_DIR)/$(EXE)
-
-debug: debug_lib $(DEBUG_EXE)
-release: release_lib $(RELEASE_EXE)
+debug: libglibutil-debug $(DEBUG_EXE)
-coverage: coverage_lib $(COVERAGE_EXE)
+release: libglibutil-release $(RELEASE_EXE)
clean:
rm -f *~
rm -fr $(BUILD_DIR)
cleaner: clean
- @$(MAKE) -C $(LIB_DIR) clean
+ @make -C $(LIB_DIR) clean
test_banner:
@echo "===========" $(EXE) "=========== "
test: test_banner debug
- @$(DEBUG_EXE)
-
-valgrind: test_banner debug
- @G_DEBUG=gc-friendly G_SLICE=always-malloc valgrind --tool=memcheck --leak-check=full --show-possibly-lost=no $(DEBUG_EXE)
+ @LD_LIBRARY_PATH="$(LIB_DIR)/$(DEBUG_LIB_PATH)" $(DEBUG_EXE)
$(DEBUG_BUILD_DIR):
mkdir -p $@
@@ -151,27 +145,18 @@
$(RELEASE_BUILD_DIR):
mkdir -p $@
-$(COVERAGE_BUILD_DIR):
- mkdir -p $@
-
$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
$(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
$(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(COVERAGE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(DEBUG_BUILD_DIR)/common_%.o : $(COMMON_DIR)/%.c
+$(DEBUG_BUILD_DIR)/%.o : $(COMMON_DIR)/%.c
$(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(RELEASE_BUILD_DIR)/common_%.o : $(COMMON_DIR)/%.c
+$(RELEASE_BUILD_DIR)/%.o : $(COMMON_DIR)/%.c
$(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(COVERAGE_BUILD_DIR)/common_%.o : $(COMMON_DIR)/%.c
- $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/test/coverage/run
^
|
@@ -3,22 +3,8 @@
# This script requires lcov to be installed
#
-TESTS="\
-test_datapack \
-test_history \
-test_idlepool \
-test_idlequeue \
-test_inotify \
-test_intarray \
-test_ints \
-test_log \
-test_misc \
-test_objv \
-test_ring \
-test_strv \
-test_weakref"
-
-FLAVOR="coverage"
+TESTS="test_strv"
+FLAVOR="release"
pushd `dirname $0` > /dev/null
COV_DIR="$PWD"
@@ -35,7 +21,7 @@
make GCOV=1 -C "$BASE_DIR" clean $FLAVOR
for t in $TESTS ; do
pushd "$TEST_DIR/$t"
- make -C "$TEST_DIR/$t" clean $FLAVOR || exit 1
+ make GCOV=1 -C "$TEST_DIR/$t" clean $FLAVOR || exit 1
build/$FLAVOR/$t || exit 1
popd
done
@@ -49,4 +35,4 @@
rm -f "$FULL_COV" "$GLIBUTIL_COV"
lcov $LCOV_OPT -c -d "$LD_LIBRARY_PATH" -b "$BASE_DIR" -o "$FULL_COV" || exit 1
lcov $LCOV_OPT -e "$FULL_COV" "$BASE_DIR/src/*" -o "$GLIBUTIL_COV" || exit 1
-genhtml $GENHTML_OPT -t libglibutil "$GLIBUTIL_COV" --output-directory "$COV_DIR/results" || exit 1
+genhtml $GENHTML_OPT "$GLIBUTIL_COV" --output-directory "$COV_DIR/results" || exit 1
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.3.tar.bz2/test/test_strv/test_strv.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2022 Jolla Ltd.
- * Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
+ * 3. Neither the name of the Jolla Ltd nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -30,86 +30,40 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "test_common.h"
-
#include "gutil_strv.h"
#include "gutil_log.h"
-static TestOpt test_opt;
+#define RET_OK (0)
+#define RET_ERR (1)
+
+typedef struct test_desc {
+ const char* name;
+ int (*run)();
+} TestDesc;
/*==========================================================================*
* Basic
*==========================================================================*/
static
-void
-test_basic(
- void)
+int
+test_basic()
{
+ int ret = RET_ERR;
char** sv = g_strsplit("a,b", ",", 0);
- g_assert(gutil_strv_length(NULL) == 0);
- g_assert(gutil_strv_length(sv) == 2);
- g_assert(!g_strcmp0(gutil_strv_at(sv, 0), "a"));
- g_assert(!g_strcmp0(gutil_strv_at(sv, 1), "b"));
- g_assert(!gutil_strv_at(sv, 2));
- g_assert(!gutil_strv_at(sv, 3));
- g_assert(!gutil_strv_at(NULL, 0));
- g_assert(!gutil_strv_strip(NULL));
+ if (gutil_strv_length(NULL) == 0 &&
+ gutil_strv_length(sv) == 2 &&
+ !g_strcmp0(gutil_strv_at(sv, 0), "a") &&
+ !g_strcmp0(gutil_strv_at(sv, 1), "b") &&
+ !gutil_strv_at(sv, 2) &&
+ !gutil_strv_at(sv, 3) &&
+ !gutil_strv_at(NULL, 0)) {
+ ret = RET_OK;
+ }
g_strfreev(sv);
-}
-
-/*==========================================================================*
- * Last
- *==========================================================================*/
-
-static
-void
-test_last(
- void)
-{
- char** empty = g_new0(char*, 1);
- char** a = g_strsplit("a", ",", 0);
- char** ab = g_strsplit("a,b", ",", 0);
-
- g_assert(!gutil_strv_last(NULL));
- g_assert(!gutil_strv_last(empty));
- g_assert(!g_strcmp0(gutil_strv_last(a), "a"));
- g_assert(!g_strcmp0(gutil_strv_last(ab), "b"));
-
- g_strfreev(empty);
- g_strfreev(a);
- g_strfreev(ab);
-}
-
-/*==========================================================================*
- * Add
- *==========================================================================*/
-
-static
-void
-test_addv(
- void)
-{
- char** sv1;
- char** sv2;
-
- g_assert(!gutil_strv_add(NULL, NULL));
- g_assert(!gutil_strv_addv(NULL, NULL, NULL));
-
- sv1 = gutil_strv_add(NULL, "a");
- g_assert(gutil_strv_addv(sv1, NULL, NULL) == sv1);
- sv2 = gutil_strv_addv(NULL, "a", NULL);
- g_assert(gutil_strv_equal(sv1, sv2));
-
- g_strfreev(sv1);
- sv1 = g_strsplit("a,bb,ccc", ",", 0);
- sv2 = gutil_strv_addv(sv2, "bb", "ccc", NULL);
- g_assert(gutil_strv_equal(sv1, sv2));
-
- g_strfreev(sv1);
- g_strfreev(sv2);
+ return ret;
}
/*==========================================================================*
@@ -117,35 +71,36 @@
*==========================================================================*/
static
-void
-test_equal(
- void)
+int
+test_equal()
{
- char** sv1 = gutil_strv_addv(NULL, "a", "b", "c", " ", "", NULL);
+ int ret = RET_OK;
+ /* gutil_strv_add(NULL, NULL) is a nop */
+ char** sv1 = gutil_strv_add(gutil_strv_add(gutil_strv_add(gutil_strv_add(
+ gutil_strv_add(gutil_strv_add(NULL, NULL), "a"), "b"), "c"), " "), "");
char** sv2 = g_strsplit("a,b,c, ,", ",", 0);
char** sv3 = g_strsplit("a,a,a, ,", ",", 0);
char** sv4 = g_strsplit("a,b,c,,", ",", 0);
char** sv5 = g_strsplit("a,b,c,", ",", 0);
- char* empty = NULL;
- g_assert(!gutil_strv_add(NULL, NULL));
- g_assert(gutil_strv_equal(NULL, NULL));
- g_assert(gutil_strv_equal(NULL, &empty));
- g_assert(gutil_strv_equal(&empty, NULL));
- g_assert(!gutil_strv_equal(sv1, NULL));
- g_assert(!gutil_strv_equal(NULL, sv2));
- g_assert(gutil_strv_equal(sv1, sv1));
- g_assert(gutil_strv_equal(sv1, sv2));
- g_assert(!gutil_strv_equal(sv1, sv3));
- g_assert(!gutil_strv_equal(sv1, sv4));
- g_assert(!gutil_strv_equal(sv1, sv5));
- g_assert(!gutil_strv_equal(sv5, sv1));
+ GASSERT(gutil_strv_equal(sv1, sv2));
+ if (!gutil_strv_equal(sv1, sv2)) ret = RET_ERR;
+
+ GASSERT(!gutil_strv_equal(sv1, sv3));
+ if (gutil_strv_equal(sv1, sv3)) ret = RET_ERR;
+
+ GASSERT(!gutil_strv_equal(sv1, sv4));
+ if (gutil_strv_equal(sv1, sv4)) ret = RET_ERR;
+
+ GASSERT(!gutil_strv_equal(sv1, sv5));
+ if (gutil_strv_equal(sv1, sv5)) ret = RET_ERR;
g_strfreev(sv1);
g_strfreev(sv2);
g_strfreev(sv3);
g_strfreev(sv4);
g_strfreev(sv5);
+ return ret;
}
/*==========================================================================*
@@ -153,197 +108,105 @@
*==========================================================================*/
static
-void
-test_find(
- void)
+int
+test_find()
{
+ int ret = RET_OK;
char** sv = g_strsplit("a,b,b,c", ",", 0);
- g_assert(gutil_strv_contains(sv, "a"));
- g_assert(gutil_strv_contains(sv, "b"));
- g_assert(gutil_strv_contains(sv, "c"));
- g_assert(!gutil_strv_contains(sv, "d"));
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/LICENSE
^
|
@@ -1,27 +0,0 @@
-Copyright (C) 2023-2024 Slava Monich <slava@monich.com>
-Copyright (C) 2014-2022 Jolla Ltd.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. Neither the names of the copyright holders nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGE.
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/debian/libglibutil-dev.install.in
^
|
@@ -1,3 +0,0 @@
-debian/tmp/@LIBDIR@/libglibutil.so @LIBDIR@
-debian/tmp/@LIBDIR@/pkgconfig/libglibutil.pc @LIBDIR@/pkgconfig
-debian/tmp/usr/include/* usr/include/
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/debian/libglibutil.install.in
^
|
@@ -1 +0,0 @@
-debian/tmp/@LIBDIR@/libglibutil.so.* @LIBDIR@
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/debian/source/format
^
|
@@ -1 +0,0 @@
-3.0 (native)
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/include/gutil_datapack.h
^
|
@@ -1,190 +0,0 @@
-/*
- * Copyright (C) 2023 Slava Monich <slava@monich.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUTIL_DATAPACK_H
-#define GUTIL_DATAPACK_H
-
-#include "gutil_types.h"
-
-/*
- * Utilities for packing and unpacking simple data types and structures.
- *
- * Since 1.0.69
- */
-
-G_BEGIN_DECLS
-
-/*
- * Compact 7 bits per byte representation of a signed integer with
- * redundant sign bits removed. Most significant bit is the continuation
- * flag. Bit 0x40 in the first (most significant) byte is the sign bit.
- * Unused bits in the most significant chunk must be filled with the
- * sign bit.
- *
- * For positive numbers it's slightly less efficient than encoding unsigned
- * numbers because of one extra sign bit (e.g. unsigned number 65 can be
- * squeezed into a single byte but the signed one takes 2 bytes).
- *
- * Examples:
- *
- * 33 (0x0000000000000021) => 00100001 (0x21)
- * -33 (0xffffffffffffffdf) => 01011111 (0x5f)
- * 65 (0x0000000000000041) => 10000000 01000001 (0x80 0x41)
- * -65 (0xffffffffffffff3f) => 11111111 00111111 (0xff 0x3f)
- * 129 (0x0000000000000081) => 10000001 00000001 (0x81 0x01)
- * -129 (0xffffffffffffff7f) => 11111110 01111110 (0xfe 0x7f)
- */
-
-guint
-gutil_signed_mbn_size(
- gint64 value);
-
-guint
-gutil_signed_mbn_encode(
- gpointer buf,
- gint64 value);
-
-guint
-gutil_signed_mbn_encode2(
- gpointer buf,
- gint64 value,
- guint value_size);
-
-gboolean
-gutil_signed_mbn_decode(
- GUtilRange* in,
- gint64* out);
-
-gboolean
-gutil_signed_mbn_decode2(
- const GUtilData* in,
- gint64* out);
-
-/*
- * Compact 7 bits per byte representation of an unsigned integer with
- * redundant zero bits removed. Most significant bit is the continuation
- * flag. Unused bits in the first byte (most significant chunk) must be
- * filled with zeros.
- *
- * Examples:
- *
- * 33 (0x0000000000000021) => 00100001 (0x21)
- * 65 (0x0000000000000041) => 01000001 (0x41)
- * 129 (0x0000000000000081) => 10000001 00000001 (0x81 0x01)
- */
-
-guint
-gutil_unsigned_mbn_size(
- guint64 value);
-
-guint
-gutil_unsigned_mbn_encode(
- gpointer buf,
- guint64 value);
-
-guint
-gutil_unsigned_mbn_encode2(
- gpointer buf,
- guint64 value,
- guint value_size);
-
-gboolean
-gutil_unsigned_mbn_decode(
- GUtilRange* in,
- guint64* out);
-
-gboolean
-gutil_unsigned_mbn_decode2(
- const GUtilData* in,
- guint64* out);
-
-/*
- * TLV is a convenient and extendible way to pack various kinds of data
- * into a single memory block. Each entry gets encoded as follows:
- *
- * +---
- * | T (unsigned MBN) : tag (non-zero)
- * +---
- * | L (unsigned MBN) : length (zero if there's no data)
- * +---
- * | V (L bytes) : tag specific data (optional)
- * +---
- *
- * To make API even more convenient, these utilities restrict the tag
- * value to INT_MAX which should be enough in most real life situations.
- * Also, these utilities assume that tags are non-zero. gutil_tlv_decode()
- * returns zero ifno TLV can be pulled out of the input data, and the
- * tags array passed to gutil_tlvs_decode() is zero terminated.
- */
-
-typedef enum gutil_tlvs_decode_flags {
- GUTIL_TLVS_DECODE_NO_FLAGS = 0,
- GUTIL_TLVS_DECODE_FLAG_SKIP_UNKNOWN_TAGS = 0x1
-} GUTIL_TLVS_DECODE_FLAGS;
-
-guint
-gutil_tlv_size(
- guint tag,
- gsize len);
-
-gsize
-gutil_tlv_encode(
- gpointer buf,
- guint tag,
- const GUtilData* val);
-
-guint
-gutil_tlv_decode(
- GUtilRange* in,
- GUtilData* val);
-
-#define GUTIL_TLVS_DECODE_ERROR (-1)
-#define GUTIL_TLVS_DECODE_DUPLICATE_TAG (-2)
-#define GUTIL_TLVS_DECODE_UNKNOWN_TAG (-3)
-
-int
-gutil_tlvs_decode(
- const GUtilData* in,
- const guint* tags,
- GUtilData* vals,
- GUTIL_TLVS_DECODE_FLAGS flags);
-
-G_END_DECLS
-
-#endif /* GUTIL_DATAPACK_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/include/gutil_history.h
^
|
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Jolla Ltd nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUTIL_HISTORY_H
-#define GUTIL_HISTORY_H
-
-#include "gutil_types.h"
-
-G_BEGIN_DECLS
-
-/*
- * A history of values. Keeps track of no more than last X values submitted
- * within the last Y microseconds. Microsecond precision may sound like a bit
- * of an overkill but that's what glib functions like g_get_monotonic_time
- * return.
- *
- * Currently it's only useful for calculating the median but the API could
- * be extended to provide access to the individual samples, if anyone ever
- * needs that.
- *
- * Also, it's calculating median rather than the average taking into account
- * that samples are not necessarily added to the history at uniform intervals.
- * If someone needs the straight average, it's easy enough to add API for that
- * too.
- *
- * When you call gutil_int_history_add but the time hasn't changed since the
- * last gutil_int_history_add call, the last value is replaced (as opposed to
- * adding a new entry).
- */
-
-#define GUTIL_HISTORY_SEC ((gint64)(G_USEC_PER_SEC))
-typedef gint64 (*GUtilHistoryTimeFunc)(void);
-
-GUtilIntHistory*
-gutil_int_history_new(
- int max_size,
- gint64 max_interval);
-
-GUtilIntHistory*
-gutil_int_history_new_full(
- int max_size,
- gint64 max_interval,
- GUtilHistoryTimeFunc time_fn);
-
-GUtilIntHistory*
-gutil_int_history_ref(
- GUtilIntHistory* history);
-
-void
-gutil_int_history_unref(
- GUtilIntHistory* history);
-
-guint
-gutil_int_history_size(
- GUtilIntHistory* history);
-
-gint64
-gutil_int_history_interval(
- GUtilIntHistory* history);
-
-void
-gutil_int_history_clear(
- GUtilIntHistory* history);
-
-int
-gutil_int_history_add(
- GUtilIntHistory* history,
- int value);
-
-int
-gutil_int_history_median(
- GUtilIntHistory* history,
- int default_value);
-
-G_END_DECLS
-
-#endif /* GUTIL_HISTORY_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/include/gutil_idlepool.h
^
|
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2016-2024 Slava Monich <slava@monich.com>
- * Copyright (C) 2016-2018 Jolla Ltd.
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUTIL_IDLEPOOL_H
-#define GUTIL_IDLEPOOL_H
-
-#include "gutil_types.h"
-
-G_BEGIN_DECLS
-
-/*
- * This is a glib equivalent of NSAutoreleasePool. Its purpose is to
- * temporarily hold a reference, until the next idle callback or until
- * the pool is drained manually with gutil_idle_pool_drain().
- *
- * Note that the following functions don't add references, they hold
- * the references which you have created:
- *
- * gutil_idle_pool_add_object()
- * gutil_idle_pool_add_variant()
- * gutil_idle_pool_add_ptr_array()
- * gutil_idle_pool_add_bytes()
- *
- * The following functions, however, do add the reference and hold it
- * until the pool is drained:
- *
- * gutil_idle_pool_add_object_ref()
- * gutil_idle_pool_add_variant_ref()
- * gutil_idle_pool_add_ptr_array_ref()
- * gutil_idle_pool_add_bytes_ref()
- */
-
-GUtilIdlePool*
-gutil_idle_pool_new(
- void);
-
-GUtilIdlePool*
-gutil_idle_pool_get(
- GUtilIdlePool** shared);
-
-GUtilIdlePool*
-gutil_idle_pool_get_default(
- void); /* Since 1.0.76 */
-
-GUtilIdlePool*
-gutil_idle_pool_ref(
- GUtilIdlePool* pool);
-
-void
-gutil_idle_pool_unref(
- GUtilIdlePool* pool);
-
-void
-gutil_idle_pool_destroy(
- GUtilIdlePool* pool); /* Since 1.0.34 */
-
-void
-gutil_idle_pool_drain(
- GUtilIdlePool* pool);
-
-gpointer /* Since 1.0.76 */
-gutil_idle_pool_add(
- GUtilIdlePool* pool,
- gpointer pointer,
- GDestroyNotify destroy);
-
-char** /* Since 1.0.76 */
-gutil_idle_pool_add_strv(
- GUtilIdlePool* pool,
- char** strv); /* Since 1.0.32 */
-
-gpointer /* Since 1.0.76 */
-gutil_idle_pool_add_object(
- GUtilIdlePool* pool,
- gpointer object);
-
-GVariant* /* Since 1.0.76 */
-gutil_idle_pool_add_variant(
- GUtilIdlePool* pool,
- GVariant* variant);
-
-GPtrArray* /* Since 1.0.76 */
-gutil_idle_pool_add_ptr_array(
- GUtilIdlePool* pool,
- GPtrArray* array);
-
-GBytes* /* Since 1.0.76 */
-gutil_idle_pool_add_bytes(
- GUtilIdlePool* pool,
- GBytes* bytes); /* Since 1.0.34 */
-
-gpointer /* Since 1.0.76 */
-gutil_idle_pool_add_object_ref(
- GUtilIdlePool* pool,
- gpointer object);
-
-GVariant* /* Since 1.0.76 */
-gutil_idle_pool_add_variant_ref(
- GUtilIdlePool* pool,
- GVariant* variant);
-
-GPtrArray* /* Since 1.0.76 */
-gutil_idle_pool_add_ptr_array_ref(
- GUtilIdlePool* pool,
- GPtrArray* array);
-
-GBytes* /* Since 1.0.76 */
-gutil_idle_pool_add_bytes_ref(
- GUtilIdlePool* pool,
- GBytes* bytes); /* Since 1.0.34 */
-
-G_END_DECLS
-
-#endif /* GUTIL_IDLEPOOL_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/include/gutil_idlequeue.h
^
|
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Jolla Ltd nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUTIL_IDLEQUEUE_H
-#define GUTIL_IDLEQUEUE_H
-
-#include "gutil_types.h"
-
-G_BEGIN_DECLS
-
-/*
- * GUtilIdleQueue allows to queue idle callbacks, tag them, cancel
- * individual callbacks or all of them.
- */
-
-typedef gsize GUtilIdleQueueTag;
-
-typedef
-void
-(*GUtilIdleFunc)(
- gpointer data);
-
-GUtilIdleQueue*
-gutil_idle_queue_new(void);
-
-void
-gutil_idle_queue_free(
- GUtilIdleQueue* queue);
-
-GUtilIdleQueue*
-gutil_idle_queue_ref(
- GUtilIdleQueue* queue);
-
-void
-gutil_idle_queue_unref(
- GUtilIdleQueue* queue);
-
-void
-gutil_idle_queue_add(
- GUtilIdleQueue* queue,
- GUtilIdleFunc run,
- gpointer data);
-
-void
-gutil_idle_queue_add_full(
- GUtilIdleQueue* queue,
- GUtilIdleFunc run,
- gpointer data,
- GFreeFunc free);
-
-void
-gutil_idle_queue_add_tag(
- GUtilIdleQueue* queue,
- GUtilIdleQueueTag tag,
- GUtilIdleFunc run,
- gpointer data);
-
-void
-gutil_idle_queue_add_tag_full(
- GUtilIdleQueue* queue,
- GUtilIdleQueueTag tag,
- GUtilIdleFunc run,
- gpointer data,
- GFreeFunc free);
-
-gboolean
-gutil_idle_queue_contains_tag(
- GUtilIdleQueue* queue,
- GUtilIdleQueueTag tag);
-
-gboolean
-gutil_idle_queue_cancel_tag(
- GUtilIdleQueue* queue,
- GUtilIdleQueueTag tag);
-
-void
-gutil_idle_queue_cancel_all(
- GUtilIdleQueue* queue);
-
-G_END_DECLS
-
-#endif /* GUTIL_IDLEQUEUE_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/include/gutil_inotify.h
^
|
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2014-2018 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Jolla Ltd nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUTIL_INOTIFY_H
-#define GUTIL_INOTIFY_H
-
-#include "gutil_types.h"
-
-G_BEGIN_DECLS
-
-typedef struct gutil_inotify_watch_callback GUtilInotifyWatchCallback;
-
-typedef void
-(*GUtilInotifyWatchFunc)(
- GUtilInotifyWatch* watch,
- guint mask,
- guint cookie,
- const char* name,
- void* arg);
-
-GUtilInotifyWatch*
-gutil_inotify_watch_new(
- const char* path,
- guint32 mask);
-
-GUtilInotifyWatch*
-gutil_inotify_watch_ref(
- GUtilInotifyWatch* watch);
-
-void
-gutil_inotify_watch_unref(
- GUtilInotifyWatch* watch);
-
-void
-gutil_inotify_watch_destroy(
- GUtilInotifyWatch* watch);
-
-gulong
-gutil_inotify_watch_add_handler(
- GUtilInotifyWatch* watch,
- GUtilInotifyWatchFunc fn,
- void* arg);
-
-void
-gutil_inotify_watch_remove_handler(
- GUtilInotifyWatch* watch,
- gulong id);
-
-GUtilInotifyWatchCallback*
-gutil_inotify_watch_callback_new(
- const char* path,
- guint32 mask,
- GUtilInotifyWatchFunc fn,
- void* arg);
-
-void
-gutil_inotify_watch_callback_free(
- GUtilInotifyWatchCallback* cb);
-
-G_END_DECLS
-
-#endif /* GUTIL_INOTIFY_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/include/gutil_intarray.h
^
|
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Jolla Ltd nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUTIL_INTARRAY_H
-#define GUTIL_INTARRAY_H
-
-#include "gutil_types.h"
-
-G_BEGIN_DECLS
-
-/*
- * This is basically a GArray providing better type safety at compile time.
- */
-struct gutil_int_array {
- int* data;
- guint count;
-};
-
-GUtilIntArray*
-gutil_int_array_new(
- void);
-
-GUtilIntArray*
-gutil_int_array_sized_new(
- guint reserved_count);
-
-GUtilIntArray*
-gutil_int_array_new_from_vals(
- const int* vals,
- guint count);
-
-GUtilIntArray*
-gutil_int_array_new_from_value(
- int value);
-
-int*
-gutil_int_array_free(
- GUtilIntArray* array,
- gboolean free_data);
-
-GUtilInts*
-gutil_int_array_free_to_ints(
- GUtilIntArray* array);
-
-GUtilIntArray*
-gutil_int_array_ref(
- GUtilIntArray* array);
-
-void
-gutil_int_array_unref(
- GUtilIntArray* array);
-
-GUtilIntArray*
-gutil_int_array_append(
- GUtilIntArray* array,
- int val);
-
-GUtilIntArray*
-gutil_int_array_append_vals(
- GUtilIntArray* array,
- const int* vals,
- guint count);
-
-GUtilIntArray*
-gutil_int_array_prepend(
- GUtilIntArray* array,
- int val);
-
-GUtilIntArray*
-gutil_int_array_prepend_vals(
- GUtilIntArray* array,
- const int* vals,
- guint count);
-
-GUtilIntArray*
-gutil_int_array_insert(
- GUtilIntArray* array,
- guint pos,
- int val);
-
-GUtilIntArray*
-gutil_int_array_insert_vals(
- GUtilIntArray* array,
- guint pos,
- const int* vals,
- guint count);
-
-GUtilIntArray*
-gutil_int_array_set_count(
- GUtilIntArray* array,
- guint count);
-
-int
-gutil_int_array_find(
- GUtilIntArray* array,
- int value);
-
-gboolean
-gutil_int_array_contains(
- GUtilIntArray* array,
- int value);
-
-gboolean
-gutil_int_array_remove(
- GUtilIntArray* array,
- int value);
-
-gboolean
-gutil_int_array_remove_fast(
- GUtilIntArray* array,
- int value);
-
-guint
-gutil_int_array_remove_all(
- GUtilIntArray* array,
- int value);
-
-guint
-gutil_int_array_remove_all_fast(
- GUtilIntArray* array,
- int value);
-
-GUtilIntArray*
-gutil_int_array_remove_index(
- GUtilIntArray* array,
- guint pos);
-
-GUtilIntArray*
-gutil_int_array_remove_index_fast(
- GUtilIntArray* array,
- guint pos);
-
-GUtilIntArray*
-gutil_int_array_remove_range(
- GUtilIntArray* array,
- guint pos,
- guint count);
-
-void
-gutil_int_array_sort_ascending(
- GUtilIntArray* array);
-
-void
-gutil_int_array_sort_descending(
- GUtilIntArray* array);
-
-G_END_DECLS
-
-#endif /* GUTIL_INTARRAY_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/include/gutil_ints.h
^
|
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Jolla Ltd nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUTIL_INTS_H
-#define GUTIL_INTS_H
-
-#include "gutil_types.h"
-
-G_BEGIN_DECLS
-
-/*
- * A read-only non-empty array of ints. NULL is the empty array.
- * If it's not NULL then it's not empty.
- */
-
-GUtilInts*
-gutil_ints_new(
- const int* data,
- guint count);
-
-GUtilInts*
-gutil_ints_new_take(
- int* data,
- guint count);
-
-GUtilInts*
-gutil_ints_new_static(
- const int* data,
- guint count);
-
-GUtilInts*
-gutil_ints_new_with_free_func(
- const int* data,
- guint count,
- GDestroyNotify free_func,
- gpointer user_data);
-
-GUtilInts*
-gutil_ints_new_from_ints(
- GUtilInts* ints,
- guint offset,
- guint count);
-
-GUtilInts*
-gutil_ints_ref(
- GUtilInts* ints);
-
-void
-gutil_ints_unref(
- GUtilInts* ints);
-
-int*
-gutil_ints_unref_to_data(
- GUtilInts* ints,
- guint* count);
-
-const int*
-gutil_ints_get_data(
- GUtilInts* ints,
- guint* count);
-
-guint
-gutil_ints_get_count(
- GUtilInts* ints);
-
-int
-gutil_ints_find(
- GUtilInts* ints,
- int value);
-
-gboolean
-gutil_ints_contains(
- GUtilInts* ints,
- int value);
-
-guint
-gutil_ints_hash(
- gconstpointer ints);
-
-gboolean
-gutil_ints_equal(
- gconstpointer a,
- gconstpointer b);
-
-gint
-gutil_ints_compare(
- gconstpointer a,
- gconstpointer b);
-
-G_END_DECLS
-
-#endif /* GUTIL_INTS_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/include/gutil_misc.h
^
|
@@ -1,241 +0,0 @@
-/*
- * Copyright (C) 2023-2024 Slava Monich <slava@monich.com>
- * Copyright (C) 2016-2022 Jolla Ltd.
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUTIL_MISC_H
-#define GUTIL_MISC_H
-
-#include "gutil_types.h"
-
-G_BEGIN_DECLS
-
-void
-gutil_disconnect_handlers(
- gpointer instance,
- gulong* ids,
- int count);
-
-void*
-gutil_object_ref(
- void* object); /* Since 1.0.71 */
-
-void
-gutil_object_unref(
- void* object); /* Since 1.0.71 */
-
-gboolean
-gutil_source_remove(
- guint id); /* Since 1.0.78 */
-
-gboolean
-gutil_source_clear(
- guint* id); /* Since 1.0.78 */
-
-void*
-gutil_hex2bin(
- const char* str,
- gssize len,
- void* data);
-
-char*
-gutil_bin2hex(
- const void* data,
- gsize len,
- gboolean upper_case) /* Since 1.0.71 */
- G_GNUC_WARN_UNUSED_RESULT;
-
-char*
-gutil_data2hex(
- const GUtilData* data,
- gboolean upper_case) /* Since 1.0.71 */
- G_GNUC_WARN_UNUSED_RESULT;
-
-GBytes*
-gutil_hex2bytes(
- const char* str,
- gssize len);
-
-#define GUTIL_HEXDUMP_BUFSIZE (70)
-#define GUTIL_HEXDUMP_MAXBYTES (16)
-
-guint
-gutil_hexdump(
- char* buf,
- const void* data,
- guint size); /* Since 1.0.29 */
-
-gboolean
-gutil_parse_int(
- const char* str,
- int base,
- int* value); /* Since 1.0.30 */
-
-gboolean
-gutil_parse_uint(
- const char* str,
- int base,
- unsigned int* value); /* Since 1.0.53 */
-
-gboolean
-gutil_parse_int64(
- const char* str,
- int base,
- gint64* value); /* Since 1.0.56 */
-
-gboolean
-gutil_parse_uint64(
- const char* str,
- int base,
- guint64* value); /* Since 1.0.56 */
-
-gboolean
-gutil_data_equal(
- const GUtilData* data1,
- const GUtilData* data2); /* Since 1.0.31 */
-
-gboolean
-gutil_data_has_prefix(
- const GUtilData* data,
- const GUtilData* prefix); /* Since 1.0.38 */
-
-gboolean
-gutil_data_has_suffix(
- const GUtilData* data,
- const GUtilData* suffix); /* Since 1.0.38 */
-
-const GUtilData*
-gutil_data_from_string(
- GUtilData* data,
- const char* str); /* Since 1.0.31 */
-
-const GUtilData*
-gutil_data_from_bytes(
- GUtilData* data,
- GBytes* bytes); /* Since 1.0.31 */
-
-GUtilData*
-gutil_data_new(
- const void* bytes,
- guint len) /* Since 1.0.72 */
- G_GNUC_WARN_UNUSED_RESULT;
-
-GUtilData*
-gutil_data_copy(
- const GUtilData* data) /* Since 1.0.72 */
- G_GNUC_WARN_UNUSED_RESULT;
-
-GVariant*
-gutil_data_copy_as_variant(
- const GUtilData* data) /* Since 1.0.74 */
- G_GNUC_WARN_UNUSED_RESULT;
-
-GBytes*
-gutil_bytes_concat(
- GBytes* bytes,
- ...) /* Since 1.0.37 */
- G_GNUC_WARN_UNUSED_RESULT
- G_GNUC_NULL_TERMINATED;
-
-GBytes*
-gutil_bytes_xor(
- GBytes* bytes1,
- GBytes* bytes2); /* Since 1.0.37 */
-
-gboolean
-gutil_bytes_equal(
- GBytes* bytes,
- const void* data,
- gsize size); /* Since 1.0.41 */
-
-gboolean
-gutil_bytes_equal_data(
- GBytes* bytes,
- const GUtilData* data); /* Since 1.0.41 */
-
-gboolean
-gutil_bytes_has_prefix(
- GBytes* bytes,
- const void* data,
- gsize size); /* Since 1.0.63 */
-
-gboolean
-gutil_bytes_has_suffix(
- GBytes* bytes,
- const void* data,
- gsize size); /* Since 1.0.63 */
-
-gsize
-gutil_ptrv_length(
- const void* ptrv); /* Since 1.0.50 */
-
-gboolean
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/include/gutil_objv.h
^
|
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2023 Slava Monich <slava@monich.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUTIL_OBJV_H
-#define GUTIL_OBJV_H
-
-#include "gutil_types.h"
-
-#include <glib-object.h>
-
-/*
- * Operations on NULL-terminated array of references to GObjects.
- *
- * Since 1.0.70
- */
-
-G_BEGIN_DECLS
-
-GObject**
-gutil_objv_new(
- GObject* obj,
- ...) /* Since 1.0.72 */
- G_GNUC_WARN_UNUSED_RESULT
- G_GNUC_NULL_TERMINATED;
-
-void
-gutil_objv_free(
- GObject** objv);
-
-GObject**
-gutil_objv_copy(
- GObject* const* objv)
- G_GNUC_WARN_UNUSED_RESULT;
-
-GObject**
-gutil_objv_add(
- GObject** objv,
- GObject* obj)
- G_GNUC_WARN_UNUSED_RESULT;
-
-GObject**
-gutil_objv_insert(
- GObject** objv,
- GObject* obj,
- gsize pos) /* Since 1.0.71 */
- G_GNUC_WARN_UNUSED_RESULT;
-
-GObject**
-gutil_objv_append(
- GObject** objv,
- GObject* const* objs) /* Since 1.0.71 */
- G_GNUC_WARN_UNUSED_RESULT;
-
-GObject**
-gutil_objv_remove(
- GObject** objv,
- GObject* obj,
- gboolean all)
- G_GNUC_WARN_UNUSED_RESULT;
-
-GObject**
-gutil_objv_remove_at(
- GObject** objv,
- gsize pos)
- G_GNUC_WARN_UNUSED_RESULT;
-
-GObject*
-gutil_objv_at(
- GObject* const* objv,
- gsize pos);
-
-gboolean
-gutil_objv_equal(
- GObject* const* objv1,
- GObject* const* objv2);
-
-GObject*
-gutil_objv_first(
- GObject* const* objv);
-
-GObject*
-gutil_objv_last(
- GObject* const* objv);
-
-gssize
-gutil_objv_find(
- GObject* const* objv,
- GObject* obj);
-
-gssize
-gutil_objv_find_last(
- GObject* const* objv,
- GObject* obj);
-
-gboolean
-gutil_objv_contains(
- GObject* const* objv,
- GObject* obj);
-
-G_END_DECLS
-
-#endif /* GUTIL_OBJV_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/include/gutil_ring.h
^
|
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2016-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Jolla Ltd nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUTIL_RING_H
-#define GUTIL_RING_H
-
-#include "gutil_types.h"
-
-G_BEGIN_DECLS
-
-/*
- * GLib-style "first in, first out" ring buffer.
- *
- * Note that `get' functions don't invoke the free function on the
- * elements they remove from the ring buffer. The ring buffer only
- * frees the elements it removes internally in gutil_ring_clear,
- * gutil_ring_drop functions and the last gutil_ring_unref.
- */
-
-#define GUTIL_RING_UNLIMITED_SIZE (-1)
-
-GUtilRing*
-gutil_ring_new(void);
-
-GUtilRing*
-gutil_ring_sized_new(
- gint reserved_size,
- gint max_size);
-
-GUtilRing*
-gutil_ring_new_full(
- gint reserved_size,
- gint max_size,
- GDestroyNotify free_func);
-
-GUtilRing*
-gutil_ring_ref(
- GUtilRing* ring);
-
-void
-gutil_ring_unref(
- GUtilRing* ring);
-
-void
-gutil_ring_set_free_func(
- GUtilRing* ring,
- GDestroyNotify free_func);
-
-gint
-gutil_ring_max_size(
- GUtilRing* ring);
-
-void
-gutil_ring_set_max_size(
- GUtilRing* ring,
- gint max_size);
-
-gint
-gutil_ring_size(
- GUtilRing* ring);
-
-void
-gutil_ring_clear(
- GUtilRing* ring);
-
-void
-gutil_ring_compact(
- GUtilRing* ring);
-
-gboolean
-gutil_ring_reserve(
- GUtilRing* ring,
- gint reserved_size);
-
-gboolean
-gutil_ring_can_put(
- GUtilRing* ring,
- gint num_elements);
-
-gboolean
-gutil_ring_put(
- GUtilRing* ring,
- gpointer data);
-
-gboolean
-gutil_ring_put_front(
- GUtilRing* ring,
- gpointer data);
-
-gpointer
-gutil_ring_get(
- GUtilRing* ring);
-
-gpointer
-gutil_ring_get_last(
- GUtilRing* ring);
-
-gint
-gutil_ring_drop(
- GUtilRing* ring,
- gint count);
-
-gint
-gutil_ring_drop_last(
- GUtilRing* ring,
- gint count);
-
-gpointer
-gutil_ring_data_at(
- GUtilRing* ring,
- gint pos);
-
-gpointer*
-gutil_ring_flatten(
- GUtilRing* ring,
- gint* size);
-
-G_END_DECLS
-
-#endif /* GUTIL_RING_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/include/gutil_timenotify.h
^
|
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2016-2018 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Jolla Ltd nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUTIL_TIMENOTIFY_H
-#define GUTIL_TIMENOTIFY_H
-
-#include "gutil_types.h"
-
-G_BEGIN_DECLS
-
-typedef void
-(*GUtilTimeNotifyFunc)(
- GUtilTimeNotify* notify,
- void* arg);
-
-GUtilTimeNotify*
-gutil_time_notify_new(
- void);
-
-GUtilTimeNotify*
-gutil_time_notify_ref(
- GUtilTimeNotify* notify);
-
-void
-gutil_time_notify_unref(
- GUtilTimeNotify* notify);
-
-gulong
-gutil_time_notify_add_handler(
- GUtilTimeNotify* notify,
- GUtilTimeNotifyFunc fn,
- void* arg);
-
-void
-gutil_time_notify_remove_handler(
- GUtilTimeNotify* notify,
- gulong id);
-
-G_END_DECLS
-
-#endif /* GUTIL_TIMENOTIFY_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/include/gutil_version.h
^
|
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2023-2024 Slava Monich <slava@monich.com>
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUTIL_VERSION_H
-#define GUTIL_VERSION_H
-
-#include "gutil_types.h"
-
-/*
- * GUTIL_VERSION_X_Y_Z macros will be added with each release. The fact that
- * such macro is defined means that you're compiling against libgutil version
- * X.Y.Z or greater.
- *
- * Since 1.0.69
- */
-
-G_BEGIN_DECLS
-
-#define GUTIL_VERSION_MAJOR 1
-#define GUTIL_VERSION_MINOR 0
-#define GUTIL_VERSION_MICRO 79
-#define GUTIL_VERSION_STRING "1.0.79"
-
-extern const guint gutil_version_major; /* GUTIL_VERSION_MAJOR */
-extern const guint gutil_version_minor; /* GUTIL_VERSION_MINOR */
-extern const guint gutil_version_micro; /* GUTIL_VERSION_MICRO */
-
-/* Version as a single word */
-#define GUTIL_VERSION_(v1,v2,v3) \
- ((((v1) & 0x7f) << 24) | \
- (((v2) & 0xfff) << 12) | \
- ((v3) & 0xfff))
-
-#define GUTIL_VERSION_MAJOR_(v) (((v) >> 24) & 0x7f)
-#define GUTIL_VERSION_MINOR_(v) (((v) >> 12) & 0xfff)
-#define GUTIL_VERSION_MICRO_(v) (((v) & 0xfff))
-
-/* Current compile time version as a single word */
-#define GUTIL_VERSION GUTIL_VERSION_ \
- (GUTIL_VERSION_MAJOR, GUTIL_VERSION_MINOR, GUTIL_VERSION_MICRO)
-
-/* Runtime version as a single word */
-#define gutil_version() GUTIL_VERSION_ \
- (gutil_version_major, gutil_version_minor, gutil_version_micro)
-
-/* Specific versions */
-#define GUTIL_VERSION_1_0_69 GUTIL_VERSION_(1,0,69)
-#define GUTIL_VERSION_1_0_70 GUTIL_VERSION_(1,0,70)
-#define GUTIL_VERSION_1_0_71 GUTIL_VERSION_(1,0,71)
-#define GUTIL_VERSION_1_0_72 GUTIL_VERSION_(1,0,72)
-#define GUTIL_VERSION_1_0_73 GUTIL_VERSION_(1,0,73)
-#define GUTIL_VERSION_1_0_74 GUTIL_VERSION_(1,0,74)
-#define GUTIL_VERSION_1_0_75 GUTIL_VERSION_(1,0,75))
-#define GUTIL_VERSION_1_0_76 GUTIL_VERSION_(1,0,76))
-#define GUTIL_VERSION_1_0_77 GUTIL_VERSION_(1,0,77))
-#define GUTIL_VERSION_1_0_78 GUTIL_VERSION_(1,0,78))
-#define GUTIL_VERSION_1_0_79 GUTIL_VERSION_(1,0,79))
-
-G_END_DECLS
-
-#endif /* GUTIL_VERSION_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/include/gutil_weakref.h
^
|
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2023 Slava Monich <slava@monich.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUTIL_WEAKREF_H
-#define GUTIL_WEAKREF_H
-
-#include "gutil_types.h"
-
-/*
- * Ref-countable weak reference can be used to avoid calling g_weak_ref_set()
- * too often because it grabs global weak_locations_lock for exclusive access.
- * Note that g_weak_ref_set() is also invoked internally by g_weak_ref_init()
- * and g_weak_ref_clear().
- *
- * g_weak_ref_get() on the other hand only acquires weak_locations_lock
- * for read-only access which is less of a bottleneck in a multi-threaded
- * environment. And it's generally significantly simpler and faster than
- * g_weak_ref_set().
- *
- * Since 1.0.68
- */
-
-G_BEGIN_DECLS
-
-GUtilWeakRef*
-gutil_weakref_new(
- gpointer obj);
-
-GUtilWeakRef*
-gutil_weakref_ref(
- GUtilWeakRef* ref);
-
-void
-gutil_weakref_unref(
- GUtilWeakRef* ref);
-
-gpointer
-gutil_weakref_get(
- GUtilWeakRef* ref);
-
-void
-gutil_weakref_set(
- GUtilWeakRef* ref,
- gpointer obj);
-
-G_END_DECLS
-
-#endif /* GUTIL_WEAKREF_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/libglibutil.ver
^
|
@@ -1,235 +0,0 @@
-{
-global:
- GLOG_TYPE_CUSTOM;
- GLOG_TYPE_GLIB;
- GLOG_TYPE_STDERR;
- GLOG_TYPE_STDOUT;
- GLOG_TYPE_SYSLOG;
- gutil_bin2hex;
- gutil_bytes_concat;
- gutil_bytes_equal;
- gutil_bytes_equal_data;
- gutil_bytes_has_prefix;
- gutil_bytes_has_suffix;
- gutil_bytes_xor;
- gutil_data2hex;
- gutil_data_copy;
- gutil_data_copy_as_variant;
- gutil_data_equal;
- gutil_data_from_bytes;
- gutil_data_from_string;
- gutil_data_has_prefix;
- gutil_data_has_suffix;
- gutil_data_new;
- gutil_disconnect_handlers;
- gutil_hex2bin;
- gutil_hex2bytes;
- gutil_hexdump;
- gutil_idle_pool_add;
- gutil_idle_pool_add_bytes;
- gutil_idle_pool_add_bytes_ref;
- gutil_idle_pool_add_object;
- gutil_idle_pool_add_object_ref;
- gutil_idle_pool_add_ptr_array;
- gutil_idle_pool_add_ptr_array_ref;
- gutil_idle_pool_add_strv;
- gutil_idle_pool_add_variant;
- gutil_idle_pool_add_variant_ref;
- gutil_idle_pool_destroy;
- gutil_idle_pool_drain;
- gutil_idle_pool_get;
- gutil_idle_pool_get_default;
- gutil_idle_pool_new;
- gutil_idle_pool_ref;
- gutil_idle_pool_unref;
- gutil_idle_queue_add;
- gutil_idle_queue_add_full;
- gutil_idle_queue_add_tag;
- gutil_idle_queue_add_tag_full;
- gutil_idle_queue_cancel_all;
- gutil_idle_queue_cancel_tag;
- gutil_idle_queue_contains_tag;
- gutil_idle_queue_free;
- gutil_idle_queue_new;
- gutil_idle_queue_ref;
- gutil_idle_queue_unref;
- gutil_inotify_watch_add_handler;
- gutil_inotify_watch_callback_free;
- gutil_inotify_watch_callback_new;
- gutil_inotify_watch_destroy;
- gutil_inotify_watch_new;
- gutil_inotify_watch_ref;
- gutil_inotify_watch_remove_handler;
- gutil_inotify_watch_unref;
- gutil_int_array_append;
- gutil_int_array_append_vals;
- gutil_int_array_contains;
- gutil_int_array_find;
- gutil_int_array_free;
- gutil_int_array_free_to_ints;
- gutil_int_array_insert;
- gutil_int_array_insert_vals;
- gutil_int_array_new;
- gutil_int_array_new_from_vals;
- gutil_int_array_new_from_value;
- gutil_int_array_prepend;
- gutil_int_array_prepend_vals;
- gutil_int_array_ref;
- gutil_int_array_remove;
- gutil_int_array_remove_all;
- gutil_int_array_remove_all_fast;
- gutil_int_array_remove_fast;
- gutil_int_array_remove_index;
- gutil_int_array_remove_index_fast;
- gutil_int_array_remove_range;
- gutil_int_array_set_count;
- gutil_int_array_sized_new;
- gutil_int_array_sort_ascending;
- gutil_int_array_sort_descending;
- gutil_int_array_unref;
- gutil_int_history_add;
- gutil_int_history_clear;
- gutil_int_history_interval;
- gutil_int_history_median;
- gutil_int_history_new;
- gutil_int_history_new_full;
- gutil_int_history_ref;
- gutil_int_history_size;
- gutil_int_history_unref;
- gutil_ints_compare;
- gutil_ints_contains;
- gutil_ints_equal;
- gutil_ints_find;
- gutil_ints_get_count;
- gutil_ints_get_data;
- gutil_ints_hash;
- gutil_ints_new;
- gutil_ints_new_from_ints;
- gutil_ints_new_static;
- gutil_ints_new_take;
- gutil_ints_new_with_free_func;
- gutil_ints_ref;
- gutil_ints_unref;
- gutil_ints_unref_to_data;
- gutil_log;
- gutil_log_assert;
- gutil_log_default;
- gutil_log_description;
- gutil_log_dump;
- gutil_log_dump_bytes;
- gutil_log_enabled;
- gutil_log_func;
- gutil_log_func2;
- gutil_log_get_type;
- gutil_log_glib;
- gutil_log_glib2;
- gutil_log_parse_option;
- gutil_log_set_timestamp_format;
- gutil_log_set_type;
- gutil_log_stderr;
- gutil_log_stderr2;
- gutil_log_stdio;
- gutil_log_stdout;
- gutil_log_stdout2;
- gutil_log_syslog;
- gutil_log_syslog2;
- gutil_log_tid;
- gutil_log_timestamp;
- gutil_logv;
- gutil_memdup;
- gutil_object_ref;
- gutil_object_unref;
- gutil_objv_add;
- gutil_objv_append;
- gutil_objv_at;
- gutil_objv_contains;
- gutil_objv_copy;
- gutil_objv_equal;
- gutil_objv_find;
- gutil_objv_find_last;
- gutil_objv_first;
- gutil_objv_free;
- gutil_objv_insert;
- gutil_objv_last;
- gutil_objv_new;
- gutil_objv_remove;
- gutil_objv_remove_at;
- gutil_parse_int;
- gutil_parse_int64;
- gutil_parse_uint;
- gutil_parse_uint64;
- gutil_ptrv_free;
- gutil_ptrv_is_empty;
- gutil_ptrv_length;
- gutil_range_has_prefix;
- gutil_range_init_with_bytes;
- gutil_range_skip_prefix;
- gutil_ring_can_put;
- gutil_ring_clear;
- gutil_ring_compact;
- gutil_ring_data_at;
- gutil_ring_drop;
- gutil_ring_drop_last;
- gutil_ring_flatten;
- gutil_ring_get;
- gutil_ring_get_last;
- gutil_ring_max_size;
- gutil_ring_new;
- gutil_ring_new_full;
- gutil_ring_put;
- gutil_ring_put_front;
- gutil_ring_ref;
- gutil_ring_reserve;
- gutil_ring_set_free_func;
- gutil_ring_set_max_size;
- gutil_ring_size;
- gutil_ring_sized_new;
- gutil_ring_unref;
- gutil_signed_mbn_decode;
- gutil_signed_mbn_decode2;
- gutil_signed_mbn_encode;
- gutil_signed_mbn_encode2;
- gutil_signed_mbn_size;
- gutil_source_clear;
- gutil_source_remove;
- gutil_strlen0;
- gutil_strv_add;
- gutil_strv_addv;
- gutil_strv_at;
- gutil_strv_bsearch;
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/src/gutil_datapack.c
^
|
@@ -1,483 +0,0 @@
-/*
- * Copyright (C) 2023-2024 Slava Monich <slava@monich.com>
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gutil_datapack.h"
-
-#if __GNUC__ >= 4
-#pragma GCC visibility push(default)
-#endif
-
-/*
- * Compact 7 bits per byte representation of a signed integer with
- * redundant sign bits removed. Most significant bit is the continuation
- * flag. Bit 0x40 in the first (most significant) byte is the sign bit.
- * Unused bits in the most significant chunk must be filled with the
- * sign bit.
- *
- * For positive numbers it's slightly less efficient than encoding unsigned
- * numbers because of one extra sign bit (e.g. unsigned number 65 can be
- * squeezed into a single byte but the signed one takes 2 bytes).
- *
- * Examples:
- *
- * 33 (0x0000000000000021) => 00100001 (0x21)
- * -33 (0xffffffffffffffdf) => 01011111 (0x5f)
- * 65 (0x0000000000000041) => 10000000 01000001 (0x80 0x41)
- * -65 (0xffffffffffffff3f) => 11111111 00111111 (0xff 0x3f)
- * 129 (0x0000000000000081) => 10000001 00000001 (0x81 0x01)
- * -129 (0xffffffffffffff7f) => 11111110 01111110 (0xfe 0x7f)
- */
-
-guint
-gutil_signed_mbn_size(
- gint64 value)
-{
- guint n = 1, msc = (value & 0x7f); /* Most Significant Chunk */
-
- value >>= 7;
- if (value < 0) {
- while (value != -1) {
- msc = (value & 0x7f);
- value >>= 7;
- n++;
- }
- if (!(msc & 0x40)) {
- n++; /* Sign bit didn't fit */
- }
- } else {
- while (value) {
- msc = (value & 0x7f);
- value >>= 7;
- n++;
- }
- if (msc & 0x40) {
- n++; /* Sign bit didn't fit */
- }
- }
- return n;
-}
-
-guint
-gutil_signed_mbn_encode(
- gpointer buf,
- gint64 value)
-{
- return gutil_signed_mbn_encode2(buf, value,
- gutil_signed_mbn_size(value));
-}
-
-guint
-gutil_signed_mbn_encode2(
- gpointer buf,
- gint64 value,
- guint size)
-{
- guchar* ptr = buf;
-
- /* Zero or too large size must be a programming error. */
- if (size > 0) {
- guint n = size;
-
- ptr[--n] = (guchar)(value & 0x7f);
- value >>= 7;
- while (n) {
- ptr[--n] = (guchar)(value | 0x80);
- value >>= 7;
- }
-
- if (value < 0) {
- const guint maxbits = sizeof(value) * 8;
-
- /* Special treatment of negative numbers */
- if (size * 7 > maxbits) {
- /* Extend the sign bit */
- ptr[0] |= ~((1 << (maxbits - (size - 1) * 7)) - 1);
- }
- }
- }
- return size;
-}
-
-gboolean
-gutil_signed_mbn_decode(
- GUtilRange* in,
- gint64* out)
-{
- if (in->ptr < in->end) {
- guchar last = in->ptr[0];
-
- if (last & 0x80) {
- const int maxbits = sizeof(*out) * 8;
- const guchar msc = last; /* Most Significant Chunk */
- int nbits = 7;
- guint off = 1;
- guint64 value = (last & 0x7f);
-
- while ((in->ptr + off) < in->end &&
- ((last = in->ptr[off++]) & 0x80)) {
- value = (value << 7) | (last & 0x7f);
- if ((nbits + 7) <= maxbits) {
- nbits += 7;
- } else {
- /* Too many bytes */
- return FALSE;
- }
- }
-
- if (!(last & 0x80)) {
- value = (value << 7) | last;
- if (msc & 0x40) {
- /* Negative number */
- if ((nbits + 7) < maxbits) {
- /* Extend the sign bit */
- if (out) {
- *out = value | ~((G_GINT64_CONSTANT(1) <<
- (nbits + 7)) - 1);
- }
- in->ptr += off;
- return TRUE;
- } else {
- /* Unused bits must be set to 1 */
- if ((msc | ((1 << (maxbits - nbits)) - 1)) == 0xff) {
- if (out) {
- *out = value;
- }
- in->ptr += off;
- return TRUE;
- }
- }
- } else {
- /* Positive number, unused bits (if any) must be zeroed */
- /* Unused bits must be zeroed */
- if ((nbits + 7) < maxbits ||
- (msc & ~((1 << (maxbits - nbits)) - 1)) == 0x80) {
- if (out) {
- *out = value;
- }
- in->ptr += off;
- return TRUE;
- }
- }
- }
- /* Broken sequence */
- } else {
- /* Single byte, very common case */
- if (out) {
- if ((*out = *in->ptr++) & 0x40) {
- /* Small negative number */
- *out |= (G_GINT64_CONSTANT(-1) ^ 0x7f);
- }
- } else {
- in->ptr++;
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/src/gutil_history.c
^
|
@@ -1,259 +0,0 @@
-/*
- * Copyright (C) 2017-2023 Slava Monich <slava@monich.com>
- * Copyright (C) 2017 Jolla Ltd.
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gutil_history.h"
-#include "gutil_log.h"
-
-#if __GNUC__ >= 4
-#pragma GCC visibility push(default)
-#endif
-
-#define GUTIL_HISTORY_DEFAULT_TIME_FUNC g_get_monotonic_time
-
-typedef struct gutil_int_history_entry {
- gint64 time;
- int value;
-} GUtilIntHistoryEntry;
-
-struct gutil_int_history {
- gint ref_count;
- GUtilHistoryTimeFunc time;
- gint64 max_interval;
- int first; /* Oldest position (inclusive) */
- int last; /* Latest position (inclusive) */
- int max_size; /* Number of entries */
- GUtilIntHistoryEntry entry[1];
-};
-
-GUtilIntHistory*
-gutil_int_history_new(
- int max_size,
- gint64 max_interval)
-{
- return gutil_int_history_new_full(max_size, max_interval, NULL);
-}
-
-GUtilIntHistory*
-gutil_int_history_new_full(
- int max_size,
- gint64 max_interval,
- GUtilHistoryTimeFunc fn)
-{
- if (max_size > 0 && max_interval > 0) {
- /*
- * We don't allow to dynamically change the maximum history size
- * so we can allocate the whole thing from a single memory block.
- */
- GUtilIntHistory* h = g_malloc0(sizeof(GUtilIntHistory) +
- (max_size - 1) * sizeof(GUtilIntHistoryEntry));
-
- g_atomic_int_set(&h->ref_count, 1);
- h->max_size = max_size;
- h->max_interval = max_interval;
- h->first = h->last = -1;
- h->time = fn ? fn : GUTIL_HISTORY_DEFAULT_TIME_FUNC;
- return h;
- }
- return NULL;
-}
-
-GUtilIntHistory*
-gutil_int_history_ref(
- GUtilIntHistory* h)
-{
- if (G_LIKELY(h)) {
- GASSERT(h->ref_count > 0);
- g_atomic_int_inc(&h->ref_count);
- }
- return h;
-}
-
-void
-gutil_int_history_unref(
- GUtilIntHistory* h)
-{
- if (G_LIKELY(h)) {
- GASSERT(h->ref_count > 0);
- if (g_atomic_int_dec_and_test(&h->ref_count)) {
- g_free(h);
- }
- }
-}
-
-static
-gboolean
-gutil_int_history_flush(
- GUtilIntHistory* h,
- const gint64 now)
-{
- const gint64 cutoff = now - h->max_interval;
-
- if (h->entry[h->last].time >= cutoff) {
- /* At least the last entry is valid */
- while (h->entry[h->first].time < cutoff) {
- h->first = (h->first + 1) % h->max_size;
- }
- return TRUE;
- } else {
- /* The last entry has expired */
- h->last = h->first = -1;
- return FALSE;
- }
-}
-
-guint
-gutil_int_history_size(
- GUtilIntHistory* h)
-{
- if (G_LIKELY(h) && h->last >= 0) {
- if (gutil_int_history_flush(h, h->time())) {
- if (h->first > h->last) {
- return (h->max_size + h->last - h->first + 1);
- } else {
- GASSERT(h->last > h->first);
- return (h->last - h->first + 1);
- }
- }
- }
- return 0;
-}
-
-gint64
-gutil_int_history_interval(
- GUtilIntHistory* h)
-{
- if (G_LIKELY(h) && h->last >= 0) {
- const gint64 now = h->time();
-
- if (gutil_int_history_flush(h, now)) {
- return now - h->entry[h->first].time;
- }
- }
- return 0;
-}
-
-void
-gutil_int_history_clear(
- GUtilIntHistory* h)
-{
- if (G_LIKELY(h)) {
- h->last = h->first = -1;
- }
-}
-
-
-static
-int
-gutil_int_history_median_at(
- GUtilIntHistory* h,
- const gint64 now)
-{
- /* The caller has already checked that the history is not empty */
- if (h->first == h->last) {
- return h->entry[h->last].value;
- } else {
- int pos = h->first;
- int v = h->entry[pos].value;
- gint64 t = h->entry[pos].time;
- gint64 dt = 0;
- gint64 area = 0;
-
- while (pos != h->last) {
- gint64 t1;
- int v1;
-
- pos = (pos + 1) % h->max_size;
- t1 = h->entry[pos].time;
- v1 = h->entry[pos].value;
- dt += t1 - t;
- area += (t1 - t)*(v + v1)/2;
- t = t1;
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/src/gutil_idlepool.c
^
|
@@ -1,390 +0,0 @@
-/*
- * Copyright (C) 2016-2024 Slava Monich <slava@monich.com>
- * Copyright (C) 2016-2020 Jolla Ltd.
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <gutil_idlepool.h>
-#include <gutil_macros.h>
-#include <gutil_log.h>
-
-#include <glib-object.h>
-
-#if __GNUC__ >= 4
-#pragma GCC visibility push(default)
-#endif
-
-typedef struct gutil_idle_pool_item GUtilIdlePoolItem;
-
-struct gutil_idle_pool_item {
- GUtilIdlePoolItem* next;
- gpointer pointer;
- GDestroyNotify destroy;
-};
-
-struct gutil_idle_pool {
- gint ref_count;
- guint idle_id;
- GThread* thread;
- GUtilIdlePoolItem* first;
- GUtilIdlePoolItem* last;
- GUtilIdlePool** shared;
-};
-
-GUtilIdlePool*
-gutil_idle_pool_new()
-{
- GUtilIdlePool* self = g_slice_new0(GUtilIdlePool);
-
- /* No need to take a ref as we never dereference this pointer */
- self->thread = g_thread_self();
- g_atomic_int_set(&self->ref_count, 1);
- return self;
-}
-
-static
-void
-gutil_idle_pool_unref_1(
- gpointer pool)
-{
- gutil_idle_pool_unref(pool);
-}
-
-GUtilIdlePool*
-gutil_idle_pool_get(
- GUtilIdlePool** shared)
-{
- if (shared) {
- if (*shared) {
- /* The object already exists */
- return *shared;
- } else {
- GUtilIdlePool* pool = gutil_idle_pool_new();
-
- pool->shared = shared;
- /* New shared object will destroy itself if the caller
- * doesn't reference it. */
- gutil_idle_pool_add(pool, pool, gutil_idle_pool_unref_1);
- *shared = pool;
- return pool;
- }
- } else {
- return gutil_idle_pool_new();
- }
-}
-
-/*
- * Thread specific GUtilIdlePool gets created on demand and remains alive
- * until the thread exits or gutil_idle_pool_release_default is called. The
- * thread should have a GMainContext or else strange things may happen (see
- * the comments in gutil_idle_pool_idle).
- */
-GUtilIdlePool*
-gutil_idle_pool_get_default() /* Since 1.0.76 */
-{
- static GPrivate thread_pool = G_PRIVATE_INIT(gutil_idle_pool_unref_1);
- GUtilIdlePool* pool = g_private_get(&thread_pool);
-
- if (!pool) {
- pool = gutil_idle_pool_new();
- g_private_set(&thread_pool, pool);
- }
- return pool;
-}
-
-GUtilIdlePool*
-gutil_idle_pool_ref(
- GUtilIdlePool* self)
-{
- if (G_LIKELY(self)) {
- GASSERT(self->ref_count > 0);
- g_atomic_int_inc(&self->ref_count);
- }
- return self;
-}
-
-void
-gutil_idle_pool_unref(
- GUtilIdlePool* self)
-{
- if (G_LIKELY(self)) {
- GASSERT(self->ref_count > 0);
- if (g_atomic_int_dec_and_test(&self->ref_count)) {
- /* Clear pointer to the shared instance */
- if (self->shared) *(self->shared) = NULL;
- gutil_idle_pool_drain(self);
- gutil_slice_free(self);
- }
- }
-}
-
-void
-gutil_idle_pool_destroy(
- GUtilIdlePool* self) /* Since 1.0.34 */
-{
- if (G_LIKELY(self)) {
- gutil_idle_pool_drain(self);
- gutil_idle_pool_unref(self);
- }
-}
-
-void
-gutil_idle_pool_drain(
- GUtilIdlePool* self)
-{
- /* If no pool is specified, use the default one for this thread */
- if (!self) {
- self = gutil_idle_pool_get_default();
- }
- while (self->first) {
- GUtilIdlePoolItem* items = self->first;
- GUtilIdlePoolItem* item = items;
-
- self->first = self->last = NULL;
- while (item) {
- item->destroy(item->pointer);
- item = item->next;
- }
- g_slice_free_chain(GUtilIdlePoolItem, items, next);
- }
- if (self->idle_id) {
- const guint id = self->idle_id;
-
- self->idle_id = 0;
- g_source_remove(id);
- }
-}
-
-static
-gboolean
-gutil_idle_pool_idle(
- gpointer user_data)
-{
- GUtilIdlePool* self = user_data;
-
- self->idle_id = 0;
-
- /*
- * gutil_idle_pool_idle may be invoked on a wrong (main) thread if
- * something is added to a thread specific pool (e.g. the one created
- * by gutil_idle_pool_get_default) before the thread specific GMainContext
- * has been pushed to the context stack. In this case we must not touch
- * the pool because the access to the pool items is not synchronized and
- * we generally want to destroy items on the same thread which has created
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/src/gutil_idlequeue.c
^
|
@@ -1,320 +0,0 @@
-/*
- * Copyright (C) 2017-2024 Slava Monich <slava@monich.com>
- * Copyright (C) 2017-2020 Jolla Ltd.
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gutil_idlequeue.h"
-#include "gutil_macros.h"
-#include "gutil_misc.h"
-#include "gutil_log.h"
-
-#if __GNUC__ >= 4
-#pragma GCC visibility push(default)
-#endif
-
-typedef struct gutil_idle_queue_item GUtilIdleQueueItem;
-
-struct gutil_idle_queue_item {
- GUtilIdleQueueItem* next;
- GUtilIdleQueueTag tag;
- gpointer data;
- GUtilIdleFunc run;
- GFreeFunc destroy;
- gboolean completed;
-};
-
-struct gutil_idle_queue {
- gint ref_count;
- guint source_id;
- GUtilIdleQueueItem* first;
- GUtilIdleQueueItem* last;
-};
-
-static
-void
-gutil_idle_queue_item_destroy(
- GUtilIdleQueueItem* item)
-{
- GASSERT(item->completed);
- if (item->destroy) {
- item->destroy(item->data);
- }
- gutil_slice_free(item);
-}
-
-static
-gboolean
-gutil_idle_queue_run(
- gpointer data)
-{
- GUtilIdleQueue* q = data;
- GUtilIdleQueueItem* item;
- GUtilIdleQueueItem* done = NULL;
-
- /*
- * Mark all currently existing items as as completed. Callbacks
- * that we are about to invoke may add more items, those we are
- * not supposed to run until the next idle loop. Also, note that
- * callbacks may cancel some of the completed items, that's why
- * we can't remove them from the list just yet.
- */
- for (item = q->first; item; item = item->next) {
- item->completed = TRUE;
- }
-
- while ((item = q->first) && item->completed) {
- /* Remove this one from the list */
- q->first = item->next;
- if (!q->first) {
- q->last = NULL;
- }
-
- /* Place it to the "done" list */
- item->next = done;
- done = item;
-
- /* Invoke the callbacks */
- if (item->run) {
- item->run(item->data);
- }
-
- if (item->destroy) {
- item->destroy(item->data);
- }
- }
-
- /* Free the completed items */
- g_slice_free_chain(GUtilIdleQueueItem, done, next);
-
- if (q->first) {
- /* New callbacks have been added */
- return G_SOURCE_CONTINUE;
- } else {
- q->source_id = 0;
- return G_SOURCE_REMOVE;
- }
-}
-
-GUtilIdleQueue*
-gutil_idle_queue_new()
-{
- GUtilIdleQueue* q = g_slice_new0(GUtilIdleQueue);
-
- g_atomic_int_set(&q->ref_count, 1);
- return q;
-}
-
-void
-gutil_idle_queue_free(
- GUtilIdleQueue* q)
-{
- gutil_idle_queue_cancel_all(q);
- gutil_idle_queue_unref(q);
-}
-
-GUtilIdleQueue*
-gutil_idle_queue_ref(
- GUtilIdleQueue* q)
-{
- if (G_LIKELY(q)) {
- GASSERT(q->ref_count > 0);
- g_atomic_int_inc(&q->ref_count);
- }
- return q;
-}
-
-void
-gutil_idle_queue_unref(
- GUtilIdleQueue* q)
-{
- if (G_LIKELY(q)) {
- GASSERT(q->ref_count > 0);
- if (g_atomic_int_dec_and_test(&q->ref_count)) {
- gutil_idle_queue_cancel_all(q);
- gutil_slice_free(q);
- }
- }
-}
-
-void
-gutil_idle_queue_add(
- GUtilIdleQueue* q,
- GUtilIdleFunc run,
- gpointer data)
-{
- gutil_idle_queue_add_tag_full(q, 0, run, data, NULL);
-}
-
-void
-gutil_idle_queue_add_full(
- GUtilIdleQueue* q,
- GUtilIdleFunc run,
- gpointer data,
- GFreeFunc free)
-{
- gutil_idle_queue_add_tag_full(q, 0, run, data, free);
-}
-
-void
-gutil_idle_queue_add_tag(
- GUtilIdleQueue* q,
- GUtilIdleQueueTag tag,
- GUtilIdleFunc run,
- gpointer data)
-{
- gutil_idle_queue_add_tag_full(q, tag, run, data, NULL);
-}
-
-void
-gutil_idle_queue_add_tag_full(
- GUtilIdleQueue* q,
- GUtilIdleQueueTag tag,
- GUtilIdleFunc run,
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/src/gutil_inotify.c
^
|
@@ -1,444 +0,0 @@
-/*
- * Copyright (C) 2014-2023 Slava Monich <slava@monich.com>
- * Copyright (C) 2014-2018 Jolla Ltd.
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <gutil_inotify.h>
-#include <gutil_log.h>
-
-#include <glib-object.h>
-
-#include <sys/inotify.h>
-#include <unistd.h>
-#include <errno.h>
-
-#ifdef __clang__
-#define NO_SANITIZE_CFI __attribute__((no_sanitize("cfi")))
-#else
-#define NO_SANITIZE_CFI
-#endif
-
-#if __GNUC__ >= 4
-#pragma GCC visibility push(default)
-#endif
-
-typedef struct gutil_inotify {
- int ref_count;
- int fd;
- GHashTable* watches;
- GIOChannel* io_channel;
- guint io_watch_id;
- gchar buf[sizeof(struct inotify_event) + NAME_MAX + 1];
-} GUtilInotify;
-
-typedef GObjectClass GUtilInotifyWatchClass;
-typedef GUtilInotifyWatch GUtilInotifyWatch;
-
-struct gutil_inotify_watch {
- GObject object;
- GUtilInotify* inotify;
- GUtilInotifyWatch* parent;
- guint32 mask;
- char* path;
- int wd;
-};
-
-struct gutil_inotify_watch_callback {
- GUtilInotifyWatch* watch;
- gulong id;
-};
-
-enum gutil_inotify_watch_signal {
- SIGNAL_WATCH_EVENT,
- SIGNAL_COUNT
-};
-
-#define SIGNAL_WATCH_EVENT_NAME "gutil-inotify-watch-event"
-
-static guint gutil_inotify_watch_signals[SIGNAL_COUNT] = { 0 };
-
-#define PARENT_TYPE G_TYPE_OBJECT
-#define PARENT_CLASS gutil_inotify_watch_parent_class
-#define THIS_TYPE gutil_inotify_watch_get_type()
-#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, THIS_TYPE, GUtilInotifyWatch)
-
-G_GNUC_INTERNAL GType THIS_TYPE;
-G_DEFINE_TYPE(GUtilInotifyWatch, gutil_inotify_watch, PARENT_TYPE)
-
-/*==========================================================================*
- * GUtilInotify
- *==========================================================================*/
-
-static GUtilInotify* gutil_inotify_instance = NULL;
-
-static
-GUtilInotify*
-gutil_inotify_ref(
- GUtilInotify* self)
-{
- GASSERT(self->ref_count > 0);
- g_atomic_int_inc(&self->ref_count);
- return self;
-}
-
-static
-void
-gutil_inotify_unref(
- GUtilInotify* self)
-{
- GASSERT(self->ref_count > 0);
- if (g_atomic_int_dec_and_test(&self->ref_count)) {
- if (self->io_watch_id) {
- g_source_remove(self->io_watch_id);
- }
- GASSERT(!g_hash_table_size(self->watches));
- g_hash_table_destroy(self->watches);
- g_io_channel_shutdown(self->io_channel, FALSE, NULL);
- g_io_channel_unref(self->io_channel);
- close(self->fd);
- g_free(self);
- if (gutil_inotify_instance == self) {
- gutil_inotify_instance = NULL;
- }
- }
-}
-
-static
-gboolean
-gutil_inotify_read(
- GUtilInotify* self)
-{
- G_GNUC_UNUSED GIOStatus status;
- gsize nbytes = 0;
- GError* error = NULL;
-
- status = g_io_channel_read_chars(self->io_channel, self->buf, sizeof(self->buf),
- &nbytes, &error);
- GASSERT(status == G_IO_STATUS_NORMAL || (status == G_IO_STATUS_ERROR && error));
- if (error) {
- GERR("Inotify read failed: %s", error->message);
- g_error_free(error);
- return FALSE;
- } else {
- const char* next = self->buf;
-
- while (nbytes > 0) {
- const struct inotify_event* event = (void*)next;
- const size_t len = sizeof(struct inotify_event) + event->len;
- const char* path = event->len ? event->name : NULL;
-
- GDEBUG("Inotify event 0x%04x for %s", event->mask, path);
- GASSERT(len <= nbytes);
- if (len > nbytes) {
- break;
- } else {
- GUtilInotifyWatch* watch = g_hash_table_lookup(self->watches,
- GINT_TO_POINTER(event->wd));
-
- if (watch) {
- gutil_inotify_watch_ref(watch);
- g_signal_emit(watch,
- gutil_inotify_watch_signals[SIGNAL_WATCH_EVENT], 0,
- event->mask, event->cookie, path);
- gutil_inotify_watch_unref(watch);
- }
- next += len;
- nbytes -= len;
- }
- }
- return TRUE;
- }
-}
-
-static
-gboolean
-gutil_inotify_callback(
- GIOChannel* channel,
- GIOCondition condition,
- gpointer user_data)
-{
- GUtilInotify* self = user_data;
-
- if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
- self->io_watch_id = 0;
- return G_SOURCE_REMOVE;
- } else {
- gboolean ok;
-
- gutil_inotify_ref(self);
- ok = (condition & G_IO_IN) && gutil_inotify_read(self);
- if (!ok) self->io_watch_id = 0;
- gutil_inotify_unref(self);
- return ok;
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/src/gutil_intarray.c
^
|
@@ -1,362 +0,0 @@
-/*
- * Copyright (C) 2017-2023 Slava Monich <slava@monich.com>
- * Copyright (C) 2017 Jolla Ltd.
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gutil_intarray.h"
-#include "gutil_ints.h"
-
-#if __GNUC__ >= 4
-#pragma GCC visibility push(default)
-#endif
-
-G_STATIC_ASSERT(sizeof(GUtilIntArray) == sizeof(GArray));
-#define ELEMENT_SIZE (sizeof(int))
-
-GUtilIntArray*
-gutil_int_array_new()
-{
- return (GUtilIntArray*)g_array_sized_new(FALSE, FALSE, ELEMENT_SIZE, 0);
-}
-
-GUtilIntArray*
-gutil_int_array_sized_new(
- guint reserved)
-{
- return (GUtilIntArray*)g_array_sized_new(FALSE, FALSE, ELEMENT_SIZE,
- reserved * ELEMENT_SIZE);
-}
-
-GUtilIntArray*
-gutil_int_array_new_from_vals(
- const int* vals,
- guint count)
-{
- GUtilIntArray* array = gutil_int_array_sized_new(count);
-
- gutil_int_array_append_vals(array, vals, count);
- return array;
-}
-
-GUtilIntArray*
-gutil_int_array_new_from_value(
- int value)
-{
- return gutil_int_array_new_from_vals(&value, 1);
-}
-
-int*
-gutil_int_array_free(
- GUtilIntArray* array,
- gboolean free_data)
-{
- if (array) {
- if (array->count) {
- return (int*)g_array_free((GArray*)array, free_data);
- } else {
- return (int*)g_array_free((GArray*)array, TRUE);
- }
- } else {
- return NULL;
- }
-}
-
-GUtilInts*
-gutil_int_array_free_to_ints(
- GUtilIntArray* array)
-{
- if (array) {
- if (array->count) {
- guint count = array->count;
- int* values = gutil_int_array_free(array, FALSE);
-
- return gutil_ints_new_take(values, count);
- } else {
- gutil_int_array_free(array, TRUE);
- }
- }
- return NULL;
-}
-
-GUtilIntArray*
-gutil_int_array_ref(
- GUtilIntArray* array)
-{
- if (array) {
- return (GUtilIntArray*)g_array_ref((GArray*)array);
- }
- return NULL;
-}
-
-void
-gutil_int_array_unref(
- GUtilIntArray* array)
-{
- if (array) {
- g_array_unref((GArray*)array);
- }
-}
-
-GUtilIntArray*
-gutil_int_array_append(
- GUtilIntArray* array,
- int val)
-{
- return gutil_int_array_append_vals(array, &val, 1);
-}
-
-GUtilIntArray*
-gutil_int_array_append_vals(
- GUtilIntArray* array,
- const int* vals,
- guint count)
-{
- if (array) {
- g_array_append_vals((GArray*)array, (void*)vals, count);
- }
- return array;
-}
-
-GUtilIntArray*
-gutil_int_array_prepend(
- GUtilIntArray* array,
- int val)
-{
- return gutil_int_array_prepend_vals(array, &val, 1);
-}
-
-GUtilIntArray*
-gutil_int_array_prepend_vals(
- GUtilIntArray* array,
- const int* vals,
- guint count)
-{
- if (array) {
- g_array_prepend_vals((GArray*)array, (void*)vals, count);
- }
- return array;
-}
-
-GUtilIntArray*
-gutil_int_array_insert(
- GUtilIntArray* array,
- guint pos,
- int val)
-{
- return gutil_int_array_insert_vals(array, pos, &val, 1);
-}
-
-GUtilIntArray*
-gutil_int_array_insert_vals(
- GUtilIntArray* array,
- guint pos,
- const int* vals,
- guint count)
-{
- if (array) {
- g_array_insert_vals((GArray*)array, pos, (void*)vals, count);
- }
- return array;
-}
-
-GUtilIntArray*
-gutil_int_array_set_count(
- GUtilIntArray* array,
- guint count)
-{
- if (array) {
- g_array_set_size((GArray*)array, count);
- }
- return array;
-}
-
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/src/gutil_ints.c
^
|
@@ -1,317 +0,0 @@
-/*
- * Copyright (C) 2017-2023 Slava Monich <slava@monich.com>
- * Copyright (C) 2017-2021 Jolla Ltd.
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gutil_intarray.h"
-#include "gutil_ints.h"
-#include "gutil_misc.h"
-#include "gutil_macros.h"
-
-#if __GNUC__ >= 4
-#pragma GCC visibility push(default)
-#endif
-
-struct gutil_ints {
- const int* data;
- guint count;
- gint ref_count;
- GDestroyNotify free_func;
- gpointer user_data;
-};
-
-GUtilInts*
-gutil_ints_new(
- const int* data,
- guint n)
-{
- if (data && n) {
- return gutil_ints_new_take(gutil_memdup(data, n * sizeof(int)), n);
- } else {
- return NULL;
- }
-}
-
-GUtilInts*
-gutil_ints_new_take(
- int* data,
- guint count)
-{
- return gutil_ints_new_with_free_func(data, count, g_free, data);
-}
-
-GUtilInts*
-gutil_ints_new_static(
- const int* data,
- guint count)
-{
- return gutil_ints_new_with_free_func(data, count, NULL, NULL);
-}
-
-GUtilInts*
-gutil_ints_new_with_free_func(
- const int* data,
- guint count,
- GDestroyNotify free_func,
- gpointer user_data)
-{
- if (data && count) {
- GUtilInts* ints = g_slice_new(GUtilInts);
-
- ints->data = data;
- ints->count = count;
- ints->free_func = free_func;
- ints->user_data = user_data;
- g_atomic_int_set(&ints->ref_count, 1);
- return ints;
- } else {
- return NULL;
- }
-}
-
-static
-void
-gutil_ints_unref1(
- gpointer ints)
-{
- gutil_ints_unref(ints);
-}
-
-GUtilInts*
-gutil_ints_new_from_ints(
- GUtilInts* ints,
- guint offset,
- guint count)
-{
- if (ints && offset < ints->count) {
- guint end = offset + count;
-
- if (end > ints->count) {
- end = ints->count;
- }
- return gutil_ints_new_with_free_func(ints->data + offset, end - offset,
- gutil_ints_unref1, gutil_ints_ref(ints));
- }
- return NULL;
-}
-
-GUtilInts*
-gutil_ints_ref(
- GUtilInts* ints)
-{
- if (ints) {
- g_atomic_int_inc(&ints->ref_count);
- return ints;
- }
- return NULL;
-}
-
-void
-gutil_ints_unref(
- GUtilInts* ints)
-{
- if (ints) {
- if (g_atomic_int_dec_and_test(&ints->ref_count)) {
- if (ints->free_func) {
- ints->free_func(ints->user_data);
- }
- gutil_slice_free(ints);
- }
- }
-}
-
-int*
-gutil_ints_unref_to_data(
- GUtilInts* ints,
- guint* count)
-{
- if (ints) {
- int* result;
-
- if (count) {
- *count = ints->count;
- }
- if (g_atomic_int_dec_and_test(&ints->ref_count)) {
- if (ints->free_func == g_free) {
- /* We can allow the caller to free the data */
- result = (int*)ints->data;
- } else {
- result = gutil_memdup(ints->data, ints->count * sizeof(int));
- ints->free_func(ints->user_data);
- }
- gutil_slice_free(ints);
- } else {
- result = gutil_memdup(ints->data, ints->count * sizeof(int));
- }
- return result;
- } else {
- if (count) {
- *count = 0;
- }
- return NULL;
- }
-}
-
-const int*
-gutil_ints_get_data(
- GUtilInts* ints,
- guint* count)
-{
- if (ints) {
- if (count) {
- *count = ints->count;
- }
- return ints->data;
- } else {
- if (count) {
- *count = 0;
- }
- return NULL;
- }
-}
-
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/src/gutil_misc.c
^
|
@@ -1,808 +0,0 @@
-/*
- * Copyright (C) 2016-2024 Slava Monich <slava@monich.com>
- * Copyright (C) 2016-2022 Jolla Ltd.
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gutil_misc.h"
-
-#include <glib-object.h>
-
-#include <ctype.h>
-#include <errno.h>
-#include <limits.h>
-
-#if __GNUC__ >= 4
-#pragma GCC visibility push(default)
-#endif
-
-void
-gutil_disconnect_handlers(
- gpointer instance,
- gulong *ids,
- int count)
-{
- if (G_LIKELY(instance) && G_LIKELY(ids)) {
- int i;
-
- for (i=0; i<count; i++) {
- if (ids[i]) {
- g_signal_handler_disconnect(instance, ids[i]);
- ids[i] = 0;
- }
- }
- }
-}
-
-void*
-gutil_object_ref(
- void* object) /* Since 1.0.71 */
-{
- /* Just a NULL-tolerant version of g_object_ref() */
- if (object) {
- g_object_ref(object);
- }
- return object;
-}
-
-void
-gutil_object_unref(
- void* object) /* Since 1.0.71 */
-{
- /* Just a NULL-tolerant version of g_object_unref */
- if (object) {
- g_object_unref(object);
- }
-}
-
-gboolean
-gutil_source_remove(
- guint id) /* Since 1.0.78 */
-{
- /* Zero-tolerant version of g_source_remove */
- if (id) {
- g_source_remove(id);
- return TRUE;
- }
- return FALSE;
-}
-
-gboolean
-gutil_source_clear(
- guint* id) /* Since 1.0.78 */
-{
- /* Yet another zero-tolerant version of g_source_remove */
- if (id && *id) {
- g_source_remove(*id);
- *id = 0;
- return TRUE;
- }
- return FALSE;
-
-}
-
-void*
-gutil_hex2bin(
- const char* str,
- gssize len,
- void* data)
-{
- if (str && data && len > 0 && !(len & 1)) {
- gssize i;
- guint8* ptr = data;
-
- for (i=0; i<len; i+=2) {
- static const guint8 hex[] = {
- 0, 1, 2, 3, 4, 5, 6, 7, /* 0x30..0x37 */
- 8, 9, 0, 0, 0, 0, 0, 0, /* 0x3a..0x3f */
- 0,10,11,12,13,14,15, 0, /* 0x40..0x47 */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x4a..0x4f */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40..0x47 */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x5a..0x5f */
- 0,10,11,12,13,14,15 /* 0x60..0x66 */
- };
- const char x1 = str[i];
- const char x2 = str[i+1];
-
- if (g_ascii_isxdigit(x1) && g_ascii_isxdigit(x2)) {
- *ptr++ = (hex[x1-0x30] << 4) + hex[x2-0x30];
- } else {
- return NULL;
- }
- }
- return data;
- }
- return NULL;
-}
-
-char*
-gutil_bin2hex(
- const void* data,
- gsize len,
- gboolean upper_case) /* Since 1.0.71 */
-{
- static const char hex[] = "0123456789abcdef";
- static const char HEX[] = "0123456789ABCDEF";
- const char* map = upper_case ? HEX : hex;
- const guchar* ptr = data;
- const guchar* end = ptr + len;
- char* out = g_malloc(2 * len + 1);
- char* dest = out;
-
- while (ptr < end) {
- const guchar b = *ptr++;
-
- *dest++ = map[(b >> 4) & 0xf];
- *dest++ = map[b & 0xf];
- }
-
- *dest = 0;
- return out;
-}
-
-char*
-gutil_data2hex(
- const GUtilData* data,
- gboolean upper_case) /* Since 1.0.71 */
-{
- return data ? gutil_bin2hex(data->bytes, data->size, upper_case) : NULL;
-}
-
-GBytes*
-gutil_hex2bytes(
- const char* str,
- gssize len)
-{
- if (str) {
- if (len < 0) len = strlen(str);
- if (len > 0 && !(len & 1)) {
- const gsize n = len/2;
- void* data = g_malloc(n);
-
- if (gutil_hex2bin(str, len, data)) {
- return g_bytes_new_take(data, n);
- }
- g_free(data);
- }
- }
- return NULL;
-}
-
-/**
- * The caller makes sure that the destination buffer has at least
- * GUTIL_HEXDUMP_BUFSIZE bytes available. Returns the number of
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/src/gutil_objv.c
^
|
@@ -1,347 +0,0 @@
-/*
- * Copyright (C) 2023 Slava Monich <slava@monich.com>
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gutil_objv.h"
-#include "gutil_misc.h"
-
-#if __GNUC__ >= 4
-#pragma GCC visibility push(default)
-#endif
-
-GObject**
-gutil_objv_new(
- GObject* obj1,
- ...) /* Since 1.0.72 */
-{
- gsize len = 0;
- GObject** objv;
- GObject** ptr;
-
- if (obj1) {
- GObject* obj;
- va_list args;
-
- len++;
- va_start(args, obj1);
- while ((obj = va_arg(args, GObject*)) != NULL) {
- len++;
- }
- va_end(args);
- }
-
- ptr = objv = g_new(GObject*, len + 1);
- if (obj1) {
- GObject* obj;
- va_list args;
-
- g_object_ref(*ptr++ = obj1);
- va_start(args, obj1);
- while ((obj = va_arg(args, GObject*)) != NULL) {
- g_object_ref(*ptr++ = obj);
- }
- va_end(args);
- }
- *ptr = NULL;
- return objv;
-}
-
-void
-gutil_objv_free(
- GObject** objv)
-{
- if (objv) {
- GObject** ptr = objv;
-
- while (*ptr) g_object_unref(*ptr++);
- g_free(objv);
- }
-}
-
-GObject**
-gutil_objv_copy(
- GObject* const* objv)
-{
- if (objv) {
- GObject* const* ptr = objv;
- gsize n = 0;
-
- /* Count the objects and bump references at the same time */
- while (*ptr) {
- g_object_ref(*ptr++);
- n++;
- }
- return gutil_memdup(objv, sizeof(GObject*) * (n + 1));
- }
- return NULL;
-
-}
-
-GObject**
-gutil_objv_add(
- GObject** objv,
- GObject* obj)
-{
- if (obj) {
- gsize len = gutil_ptrv_length(objv);
-
- objv = g_renew(GObject*, objv, len + 2);
- g_object_ref(objv[len++] = obj);
- objv[len] = NULL;
- }
- return objv;
-}
-
-GObject**
-gutil_objv_insert(
- GObject** objv,
- GObject* obj,
- gsize pos) /* Since 1.0.71 */
-{
- if (obj) {
- gsize len = gutil_ptrv_length(objv);
-
- objv = g_renew(GObject*, objv, len + 2);
- if (pos >= len) {
- /* Insert as the last element */
- g_object_ref(objv[len++] = obj);
- objv[len] = NULL;
- } else {
- /* Insert somewhere in the middle (or at the very beginning) */
- memmove(objv + (pos + 1), objv + pos, sizeof(GObject*) *
- (len - pos + 1)); /* Move NULL too */
- g_object_ref(objv[pos] = obj);
- }
- }
- return objv;
-}
-
-GObject**
-gutil_objv_append(
- GObject** objv,
- GObject* const* objs) /* Since 1.0.71 */
-{
- const gsize len2 = gutil_ptrv_length(objs);
-
- if (len2 > 0) {
- const gsize len1 = gutil_ptrv_length(objv);
- GObject* const* src;
- GObject** dest;
-
- objv = g_renew(GObject*, objv, len1 + len2 + 1);
- dest = objv + len1;
- src = objs;
- while (*src) {
- *dest++ = g_object_ref(*src++);
- }
- *dest = NULL;
- }
- return objv;
-}
-
-static
-gssize
-gutil_objv_find_last_impl(
- GObject* const* objv,
- GObject* obj,
- gsize i /* exclisive */)
-{
- while (i > 0) {
- if (objv[--i] == obj) {
- return i;
- }
- }
- return -1;
-}
-
-static
-GObject**
-gutil_objv_remove_impl(
- GObject** objv,
- gsize pos,
- gsize len)
-{
- g_object_unref(objv[pos]);
- memmove(objv + pos, objv + (pos + 1), sizeof(GObject*) * (len - pos));
- return g_realloc(objv, sizeof(GObject*) * len);
-}
-
-GObject**
-gutil_objv_remove(
- GObject** objv,
- GObject* obj,
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/src/gutil_ring.c
^
|
@@ -1,451 +0,0 @@
-/*
- * Copyright (C) 2016-2023 Slava Monich <slava@monich.com>
- * Copyright (C) 2016-2020 Jolla Ltd.
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gutil_ring.h"
-#include "gutil_macros.h"
-#include "gutil_log.h"
-
-#if __GNUC__ >= 4
-#pragma GCC visibility push(default)
-#endif
-
-struct gutil_ring {
- gint ref_count;
- gint alloc;
- gint maxsiz;
- gint start;
- gint end;
- gpointer* data;
- GDestroyNotify free_func;
-};
-
-GUtilRing*
-gutil_ring_new()
-{
- return gutil_ring_sized_new(0, GUTIL_RING_UNLIMITED_SIZE);
-}
-
-GUtilRing*
-gutil_ring_sized_new(
- gint reserved_size,
- gint max_size)
-{
- return gutil_ring_new_full(reserved_size, max_size, NULL);
-}
-
-GUtilRing*
-gutil_ring_new_full(
- gint reserved_size,
- gint max_size,
- GDestroyNotify free_func)
-{
- GUtilRing* r = g_slice_new0(GUtilRing);
-
- g_atomic_int_set(&r->ref_count, 1);
- r->start = r->end = -1;
- r->maxsiz = (max_size < 0) ? GUTIL_RING_UNLIMITED_SIZE : max_size;
- r->free_func = free_func;
- if (reserved_size) {
- r->data = g_new(gpointer, reserved_size);
- r->alloc = reserved_size;
- }
- return r;
-}
-
-GUtilRing*
-gutil_ring_ref(
- GUtilRing* r)
-{
- if (G_LIKELY(r)) {
- GASSERT(r->ref_count > 0);
- g_atomic_int_inc(&r->ref_count);
- }
- return r;
-}
-
-void
-gutil_ring_unref(
- GUtilRing* r)
-{
- if (G_LIKELY(r)) {
- GASSERT(r->ref_count > 0);
- if (g_atomic_int_dec_and_test(&r->ref_count)) {
- if (r->free_func) {
- const gint n = gutil_ring_size(r);
- gint i;
-
- for (i=0; i<n; i++) {
- r->free_func(r->data[(r->start + i) % r->alloc]);
- }
- }
- g_free(r->data);
- gutil_slice_free(r);
- }
- }
-}
-
-void
-gutil_ring_set_free_func(
- GUtilRing* r,
- GDestroyNotify free_func)
-{
- if (G_LIKELY(r)) {
- r->free_func = free_func;
- }
-}
-
-gint
-gutil_ring_max_size(
- GUtilRing* r)
-{
- return G_LIKELY(r) ? r->maxsiz : 0;
-}
-
-void
-gutil_ring_set_max_size(
- GUtilRing* r,
- gint max_size)
-{
- /* Normalize the value */
- if (max_size < 0) max_size = GUTIL_RING_UNLIMITED_SIZE;
- if (G_LIKELY(r) && r->maxsiz != max_size) {
- const gint size = gutil_ring_size(r);
-
- if (max_size >= 0 && size > max_size) {
- gutil_ring_drop(r, size - max_size);
- }
- r->maxsiz = max_size;
- }
-}
-
-gint
-gutil_ring_size(
- GUtilRing* r)
-{
- if (G_LIKELY(r) && r->start >= 0) {
- if (r->start > r->end) {
- return (r->alloc + r->end - r->start);
- } else if (r->end > r->start) {
- return (r->end - r->start);
- } else {
- GASSERT(r->start >= 0 && r->start < r->alloc);
- GASSERT(r->end >= 0 && r->end < r->alloc);
- return r->alloc;
- }
- }
- return 0;
-}
-
-void
-gutil_ring_clear(
- GUtilRing* r)
-{
- if (G_LIKELY(r)) {
- gint n = gutil_ring_size(r);
- if (n > 0) {
- GDestroyNotify free_func = r->free_func;
-
- if (free_func) {
- do {
- free_func(gutil_ring_get(r));
- n--;
- } while (n > 0 && gutil_ring_size(r) > 0);
- } else {
- r->start = r->end = -1;
- }
- }
- }
-}
-
-void
-gutil_ring_compact(
- GUtilRing* r)
-{
- if (G_LIKELY(r)) {
- int n = gutil_ring_size(r);
-
- if (r->alloc > n) {
- if (n > 0) {
- gpointer* buf = g_new(gpointer,n);
-
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/src/gutil_timenotify.c
^
|
@@ -1,235 +0,0 @@
-/*
- * Copyright (C) 2016-2023 Slava Monich <slava@monich.com>
- * Copyright (C) 2016-2019 Jolla Ltd.
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gutil_timenotify.h"
-#include "gutil_misc.h"
-#include "gutil_log.h"
-
-#include <glib-object.h>
-
-#include <time.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/timerfd.h>
-
-#ifdef __clang__
-#define NO_SANITIZE_CFI __attribute__((no_sanitize("cfi")))
-#else
-#define NO_SANITIZE_CFI
-#endif
-
-#if __GNUC__ >= 4
-#pragma GCC visibility push(default)
-#endif
-
-#ifndef TFD_TIMER_CANCEL_ON_SET
-# define TFD_TIMER_CANCEL_ON_SET (1 << 1)
-#endif
-
-#define TIME_T_MAX (time_t)((1UL << ((sizeof(time_t)*8)-1)) - 1)
-
-struct gutil_time_notify {
- GObject object;
- GIOChannel* io_channel;
- guint io_watch_id;
-};
-
-enum gutil_time_notify_signal {
- SIGNAL_TIME_CHANGED,
- SIGNAL_COUNT
-};
-
-#define SIGNAL_TIME_CHANGED_NAME "time-changed"
-
-static guint gutil_time_notify_signals[SIGNAL_COUNT] = { 0 };
-
-#define PARENT_CLASS gutil_time_notify_parent_class
-#define THIS_TYPE gutil_time_notify_get_type()
-#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, THIS_TYPE, GUtilTimeNotify)
-
-GType THIS_TYPE G_GNUC_INTERNAL;
-typedef GObjectClass GUtilTimeNotifyClass;
-G_DEFINE_TYPE(GUtilTimeNotify, gutil_time_notify, G_TYPE_OBJECT)
-
-GUtilTimeNotify*
-gutil_time_notify_new()
-{
- /* There's no need to have more than one instance. */
- static GUtilTimeNotify* gutil_time_notify_instance = NULL;
-
- if (gutil_time_notify_instance) {
- gutil_time_notify_ref(gutil_time_notify_instance);
- } else {
- gutil_time_notify_instance = g_object_new(THIS_TYPE, 0);
- g_object_add_weak_pointer(G_OBJECT(gutil_time_notify_instance),
- (gpointer*)(&gutil_time_notify_instance));
- }
- return gutil_time_notify_instance;
-}
-
-GUtilTimeNotify*
-gutil_time_notify_ref(
- GUtilTimeNotify* self)
-{
- if (G_LIKELY(self)) {
- g_object_ref(THIS(self));
- }
- return self;
-}
-
-void
-gutil_time_notify_unref(
- GUtilTimeNotify* self)
-{
- if (G_LIKELY(self)) {
- g_object_unref(THIS(self));
- }
-}
-
-gulong
-gutil_time_notify_add_handler(
- GUtilTimeNotify* self,
- GUtilTimeNotifyFunc fn,
- void* arg)
-{
- return (G_LIKELY(self) && G_LIKELY(fn)) ? g_signal_connect(self,
- SIGNAL_TIME_CHANGED_NAME, G_CALLBACK(fn), arg) : 0;
-}
-
-void
-gutil_time_notify_remove_handler(
- GUtilTimeNotify* self,
- gulong id)
-{
- if (G_LIKELY(self) && G_LIKELY(id)) {
- g_signal_handler_disconnect(self, id);
- }
-}
-
-static
-gboolean
-gutil_time_notify_callback(
- GIOChannel* channel,
- GIOCondition condition,
- gpointer user_data)
-{
- GUtilTimeNotify* self = THIS(user_data);
-
- if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
- self->io_watch_id = 0;
- return G_SOURCE_REMOVE;
- } else {
- G_GNUC_UNUSED GIOStatus status;
- gsize bytes_read = 0;
- GError* error = NULL;
- guint64 exp;
-
- gutil_time_notify_ref(self);
- status = g_io_channel_read_chars(self->io_channel, (void*)&exp, sizeof(exp),
- &bytes_read, &error);
- GASSERT(status == G_IO_STATUS_ERROR && error);
- if (error) {
- /* ECANCELED is expected */
- GDEBUG("%s", error->message);
- g_error_free(error);
- }
- g_signal_emit(self, gutil_time_notify_signals[SIGNAL_TIME_CHANGED], 0);
- gutil_time_notify_unref(self);
- return G_SOURCE_CONTINUE;
- }
-}
-
-static
-void
-gutil_time_notify_init(
- GUtilTimeNotify* self)
-{
- const int fd = timerfd_create(CLOCK_REALTIME, 0);
-
- if (fd >= 0) {
- struct itimerspec timer;
-
- self->io_channel = g_io_channel_unix_new(fd);
- g_io_channel_set_close_on_unref(self->io_channel, TRUE);
- g_io_channel_set_encoding(self->io_channel, NULL, NULL);
- g_io_channel_set_buffered(self->io_channel, FALSE);
- self->io_watch_id = g_io_add_watch(self->io_channel,
- G_IO_IN | G_IO_HUP | G_IO_NVAL | G_IO_ERR,
- gutil_time_notify_callback, self);
-
- /* Set timeout to the latest possible value */
- memset(&timer, 0, sizeof(timer));
- timer.it_value.tv_sec = TIME_T_MAX;
- timer.it_interval.tv_sec = TIME_T_MAX;
- if (timerfd_settime(fd, TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET,
- &timer, NULL) < 0) {
- GERR("timerfd settime: %s", strerror(errno));
- }
- } else {
- GERR("timerfd open: %s", strerror(errno));
- }
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/src/gutil_version.c
^
|
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2023 Slava Monich <slava@monich.com>
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gutil_version.h"
-
-#if __GNUC__ >= 4
-#pragma GCC visibility push(default)
-#endif
-
-const guint gutil_version_major = GUTIL_VERSION_MAJOR;
-const guint gutil_version_minor = GUTIL_VERSION_MINOR;
-const guint gutil_version_micro = GUTIL_VERSION_MICRO;
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/src/gutil_weakref.c
^
|
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2023 Slava Monich <slava@monich.com>
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gutil_weakref.h"
-#include "gutil_log.h"
-#include "gutil_macros.h"
-
-#include <glib-object.h>
-
-#if __GNUC__ >= 4
-#pragma GCC visibility push(default)
-#endif
-
-/*
- * Ref-countable weak reference can be used to avoid calling g_weak_ref_set()
- * too often because it grabs global weak_locations_lock for exclusive access.
- * Note that g_weak_ref_set() is also invoked internally by g_weak_ref_init()
- * and g_weak_ref_clear().
- *
- * g_weak_ref_get() on the other hand only acquires weak_locations_lock
- * for read-only access which is less of a bottleneck in a multi-threaded
- * environment. And it's generally significantly simpler and faster than
- * g_weak_ref_set().
- *
- * Since 1.0.68
- */
-
-struct gutil_weakref {
- gint ref_count;
- GWeakRef weak_ref;
-};
-
-GUtilWeakRef*
-gutil_weakref_new(
- gpointer obj)
-{
- GUtilWeakRef* self = g_slice_new(GUtilWeakRef);
-
- g_atomic_int_set(&self->ref_count, 1);
- g_weak_ref_init(&self->weak_ref, obj);
- return self;
-}
-
-GUtilWeakRef*
-gutil_weakref_ref(
- GUtilWeakRef* self)
-{
- if (G_LIKELY(self)) {
- GASSERT(self->ref_count > 0);
- g_atomic_int_inc(&self->ref_count);
- }
- return self;
-}
-
-void
-gutil_weakref_unref(
- GUtilWeakRef* self)
-{
- if (G_LIKELY(self)) {
- GASSERT(self->ref_count > 0);
- if (g_atomic_int_dec_and_test(&self->ref_count)) {
- g_weak_ref_clear(&self->weak_ref);
- gutil_slice_free(self);
- }
- }
-}
-
-gpointer
-gutil_weakref_get(
- GUtilWeakRef* self)
-{
- return G_LIKELY(self) ? g_weak_ref_get(&self->weak_ref) : NULL;
-}
-
-void
-gutil_weakref_set(
- GUtilWeakRef* self,
- gpointer obj)
-{
- if (G_LIKELY(self)) {
- g_weak_ref_set(&self->weak_ref, obj);
- }
-}
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/common/test_common.h
^
|
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2016-2022 Jolla Ltd.
- * Copyright (C) 2016-2022 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TEST_COMMON_H
-#define TEST_COMMON_H
-
-#include <gutil_types.h>
-
-#include <glib-object.h>
-
-#define TEST_FLAG_DEBUG (0x01)
-
-typedef struct test_opt {
- int flags;
-} TestOpt;
-
-GType test_object_get_type(void);
-#define TEST_OBJECT_TYPE (test_object_get_type())
-
-extern gint test_object_count;
-
-/* Should be invoked after g_test_init */
-void
-test_init(
- TestOpt* opt,
- int argc,
- char* argv[]);
-
-/* Macros */
-
-#define TEST_INIT_DATA(a,b) ((a).bytes = (void*)(b), (a).size = sizeof(b))
-#define TEST_ARRAY_AND_SIZE(a) (a), sizeof(a)
-
-#endif /* TEST_COMMON_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/common/test_main.c
^
|
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2016 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the Jolla Ltd nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include <gutil_log.h>
-
-void
-test_init(
- TestOpt* opt,
- int argc,
- char* argv[])
-{
- int i;
- memset(opt, 0, sizeof(*opt));
- for (i=1; i<argc; i++) {
- const char* arg = argv[i];
- if (!strcmp(arg, "-d") || !strcmp(arg, "--debug")) {
- opt->flags |= TEST_FLAG_DEBUG;
- } else if (!strcmp(arg, "-v")) {
- GTestConfig* config = (GTestConfig*)g_test_config_vars;
- config->test_verbose = TRUE;
- } else {
- GWARN("Unsupported command line option %s", arg);
- }
- }
-
- /* Setup logging */
- gutil_log_timestamp = FALSE;
- gutil_log_default.level = g_test_verbose() ? GLOG_LEVEL_VERBOSE :
- GLOG_LEVEL_NONE;
-}
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/common/test_object.c
^
|
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2018-2023 Slava Monich <slava@monich.com>
- * Copyright (C) 2018 Jolla Ltd.
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include <gutil_log.h>
-
-typedef GObject TestObject;
-typedef GObjectClass TestObjectClass;
-
-G_DEFINE_TYPE(TestObject, test_object, G_TYPE_OBJECT)
-
-gint test_object_count = 0;
-
-static
-void
-test_object_init(
- TestObject* self)
-{
- g_atomic_int_inc(&test_object_count);
-}
-
-#ifdef __clang__
-__attribute__((no_sanitize("cfi")))
-#endif
-static
-void
-test_object_finalize(
- GObject* object)
-{
- GASSERT(test_object_count > 0);
- g_atomic_int_add(&test_object_count, -1);
- G_OBJECT_CLASS(test_object_parent_class)->finalize(object);
-}
-
-static
-void
-test_object_class_init(
- TestObjectClass* klass)
-{
- klass->finalize = test_object_finalize;
-}
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_datapack/Makefile
^
|
@@ -1,5 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-EXE = test_datapack
-
-include ../common/Makefile
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_datapack/test_datapack.c
^
|
@@ -1,873 +0,0 @@
-/*
- * Copyright (C) 2023 Slava Monich <slava@monich.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include "gutil_datapack.h"
-
-static TestOpt test_opt;
-
-#define TEST_(name) "/datapack/" name
-
-static const guint8 test_unsigned_mbn_data_0[] = { 0x00 };
-static const guint8 test_unsigned_mbn_data_64[] = { 0x40 };
-static const guint8 test_unsigned_mbn_data_127[] = { 0x7f };
-static const guint8 test_unsigned_mbn_data_128[] = { 0x81, 0x00 };
-static const guint8 test_unsigned_mbn_data_257[] = { 0x82, 0x01 };
-static const guint8 test_unsigned_mbn_data_383[] = { 0x82, 0x7f };
-static const guint8 test_unsigned_mbn_data_16383[] = { 0xff, 0x7f };
-static const guint8 test_unsigned_mbn_data_max64[] =
- { 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f };
-
-static const guint8 test_signed_mbn_data_0[] = { 0x00 };
-static const guint8 test_signed_mbn_data_33[] = { 0x21 };
-static const guint8 test_signed_mbn_data_m33[] = { 0x5f };
-static const guint8 test_signed_mbn_data_65[] = { 0x80, 0x41 };
-static const guint8 test_signed_mbn_data_m65[] = { 0xff, 0x3f };
-static const guint8 test_signed_mbn_data_127[] = { 0x80, 0x7f };
-static const guint8 test_signed_mbn_data_128[] = { 0x81, 0x00 };
-static const guint8 test_signed_mbn_data_129[] = { 0x81, 0x01 };
-static const guint8 test_signed_mbn_data_m129[] = { 0xfe, 0x7f };
-static const guint8 test_signed_mbn_data_257[] = { 0x82, 0x01 };
-static const guint8 test_signed_mbn_data_383[] = { 0x82, 0x7f };
-static const guint8 test_signed_mbn_data_16383[] = { 0x80, 0xff, 0x7f };
-static const guint8 test_signed_mbn_data_m16383[] = { 0xff, 0x80, 0x01 };
-static const guint8 test_signed_mbn_data_min64[] = {
- 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x00
-};
-static const guint8 test_signed_mbn_data_max64[] = {
- 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x7f
-};
-
-typedef struct {
- const char* name;
- GUtilData input;
-} TestDecodeFail;
-
-static const guint8 test_mbn_decode_fail_data_short[] = { 0x80 };
-static const guint8 test_mbn_decode_fail_data_too_long[] = {
- 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f
-};
-
-/*==========================================================================*
- * mbn/corner_cases
- *==========================================================================*/
-
-static
-void
-test_mbn_corner_cases()
-{
- guint8 buf[1];
-
- g_assert_cmpuint(gutil_signed_mbn_encode2(buf, 0, 0), == ,0);
- g_assert_cmpuint(gutil_unsigned_mbn_encode2(buf, 0, 0), == ,0);
-}
-
-/*==========================================================================*
- * signed_mbn/size
- *==========================================================================*/
-
-typedef struct {
- const char* name;
- gint64 input;
- guint output;
-} TestSignedMbnSizeData;
-
-/* Use test_mbn_write test data as input */
-static const TestSignedMbnSizeData test_signed_mbn_size_data[] = {
-#define TEST_CASE(x) TEST_("signed_mbn/size/") x
-#define TEST_DATA(x) TEST_CASE(#x), x, sizeof(test_signed_mbn_data_##x)
-#define TEST_DATA_(x) TEST_CASE("-" #x), -x, sizeof(test_signed_mbn_data_m##x)
- { TEST_DATA(0) },
- { TEST_DATA(33) },
- { TEST_DATA_(33) },
- { TEST_DATA(65) },
- { TEST_DATA_(65) },
- { TEST_DATA(127) },
- { TEST_DATA(128) },
- { TEST_DATA(129) },
- { TEST_DATA_(129) },
- { TEST_DATA(257) },
- { TEST_DATA(383) },
- { TEST_DATA(16383) },
- { TEST_DATA_(16383) },
- { TEST_CASE("min64"), G_MININT64, sizeof(test_signed_mbn_data_min64) },
- { TEST_CASE("max64"), G_MAXINT64, sizeof(test_signed_mbn_data_max64) }
-#undef TEST_CASE
-#undef TEST_DATA
-#undef TEST_DATA_
-};
-
-static
-void
-test_signed_mbn_size(
- gconstpointer data)
-{
- const TestSignedMbnSizeData* test = data;
-
- g_assert_cmpuint(gutil_signed_mbn_size(test->input), == ,test->output);
-}
-
-/*==========================================================================*
- * signed_mbn/encode
- *==========================================================================*/
-
-typedef struct {
- const char* name;
- gint64 input;
- GUtilData output;
-} TestSignedMbnEncode;
-
-static const TestSignedMbnEncode test_signed_mbn_encode_data[] = {
-#define TEST_CASE(x) TEST_("signed_mbn/encode/") x
-#define TEST_DATA(x) TEST_CASE(#x), x, \
- { TEST_ARRAY_AND_SIZE(test_signed_mbn_data_##x) }
-#define TEST_DATA_(x) TEST_CASE("-" #x), -x, \
- { TEST_ARRAY_AND_SIZE(test_signed_mbn_data_m##x) }
- { TEST_DATA(0) },
- { TEST_DATA(33) },
- { TEST_DATA_(33) },
- { TEST_DATA(65) },
- { TEST_DATA_(65) },
- { TEST_DATA(127) },
- { TEST_DATA(128) },
- { TEST_DATA(129) },
- { TEST_DATA_(129) },
- { TEST_DATA(257) },
- { TEST_DATA(383) },
- { TEST_DATA(16383) },
- { TEST_DATA_(16383) },
- { TEST_CASE("min64"), G_MININT64,
- { TEST_ARRAY_AND_SIZE(test_signed_mbn_data_min64) } },
- { TEST_CASE("max64"), G_MAXINT64,
- { TEST_ARRAY_AND_SIZE(test_signed_mbn_data_max64) } }
-#undef TEST_CASE
-#undef TEST_DATA
-#undef TEST_DATA_
-};
-
-static
-void
-test_signed_mbn_encode(
- gconstpointer data)
-{
- const TestSignedMbnEncode* test = data;
- guint8* buf = g_malloc(test->output.size);
-
- memset(buf, 0xaa, test->output.size);
- g_assert_cmpuint(gutil_signed_mbn_encode(buf, test->input), == ,
- test->output.size);
- g_assert(!memcmp(buf, test->output.bytes, test->output.size));
-
- g_free(buf);
-}
-
-/*==========================================================================*
- * signed_mbn/decode/ok
- *==========================================================================*/
-
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_history/Makefile
^
|
@@ -1,5 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-EXE = test_history
-
-include ../common/Makefile
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_history/test_history.c
^
|
@@ -1,300 +0,0 @@
-/*
- * Copyright (C) 2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Jolla Ltd nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include "gutil_history.h"
-
-static TestOpt test_opt;
-static gint64 test_history_time;
-
-static
-gint64
-test_history_time_func(void)
-{
- return test_history_time;
-}
-
-/*==========================================================================*
- * NULL tolerance
- *==========================================================================*/
-
-static
-void
-test_history_null(
- void)
-{
- gutil_int_history_unref(NULL);
- gutil_int_history_clear(NULL);
- g_assert(!gutil_int_history_ref(NULL));
- g_assert(!gutil_int_history_size(NULL));
- g_assert(!gutil_int_history_interval(NULL));
- g_assert(!gutil_int_history_add(NULL, 1));
- g_assert(!gutil_int_history_median(NULL, 0));
- g_assert(!gutil_int_history_new(0, 0));
- g_assert(!gutil_int_history_new(1, 0));
- g_assert(!gutil_int_history_new(0, 1));
-}
-
-/*==========================================================================*
- * Basic
- *==========================================================================*/
-
-static
-void
-test_history_basic(
- void)
-{
- /* The default time functon returns real time, not usable for testing */
- GUtilIntHistory* h = gutil_int_history_new(1, 1);
- g_assert(gutil_int_history_size(h) == 0);
- g_assert(gutil_int_history_interval(h) == 0);
- gutil_int_history_unref(gutil_int_history_ref(h));
- gutil_int_history_unref(h);
-}
-
-/*==========================================================================*
- * Clear
- *==========================================================================*/
-
-static
-void
-test_history_clear(
- void)
-{
- GUtilIntHistory* h = gutil_int_history_new_full(2, 2,
- test_history_time_func);
- g_assert(gutil_int_history_median(h, 0) == 0);
- test_history_time = 2;
- g_assert(gutil_int_history_add(h, 1) == 1);
- /* Time hasn't changed, 1 is replaced with 2 */
- g_assert(gutil_int_history_add(h, 2) == 2);
- /* Time goes back, 2 is replaced with 3 */
- test_history_time -=1;
- g_assert(gutil_int_history_add(h, 3) == 3);
- test_history_time += 2;
- g_assert(gutil_int_history_add(h, 5) == 4);
- g_assert(gutil_int_history_size(h) == 2);
- g_assert(gutil_int_history_median(h, 0) == 4);
- g_assert(gutil_int_history_interval(h) == 1);
- gutil_int_history_clear(h);
- g_assert(!gutil_int_history_size(h));
- g_assert(!gutil_int_history_interval(h));
- gutil_int_history_unref(h);
-}
-
-/*==========================================================================*
- * Median
- *==========================================================================*/
-
-static
-void
-test_history_median(
- void)
-{
- GUtilIntHistory* h = gutil_int_history_new_full(2, 2,
- test_history_time_func);
- test_history_time = 1;
- g_assert(gutil_int_history_add(h, 1) == 1);
- test_history_time += 1;
- g_assert(gutil_int_history_add(h, 5) == 3);
- test_history_time += 1;
- /* Still the same, both ends of the interval are inclusive */
- g_assert(gutil_int_history_median(h, 0) == 3);
- test_history_time += 1;
- /* Now one entry expires */
- g_assert(gutil_int_history_median(h, 0) == 5);
- test_history_time += 1;
- /* The last one expires too */
- g_assert(gutil_int_history_median(h, 0) == 0);
- gutil_int_history_unref(h);
-}
-
-/*==========================================================================*
- * Size
- *==========================================================================*/
-
-static
-void
-test_history_size(
- void)
-{
- GUtilIntHistory* h = gutil_int_history_new_full(2, 2,
- test_history_time_func);
- test_history_time = 1;
- g_assert(gutil_int_history_add(h, 1) == 1);
- test_history_time += 1;
- g_assert(gutil_int_history_add(h, 5) == 3);
- g_assert(gutil_int_history_size(h) == 2);
- test_history_time += 1;
- /* Still the same, both ends of the interval are inclusive */
- g_assert(gutil_int_history_size(h) == 2);
- test_history_time += 1;
- /* Now one entry expires */
- g_assert(gutil_int_history_size(h) == 1);
- test_history_time += 1;
- /* The last one expires too */
- g_assert(gutil_int_history_size(h) == 0);
- gutil_int_history_unref(h);
-}
-
-/*==========================================================================*
- * Interval
- *==========================================================================*/
-
-static
-void
-test_history_interval(
- void)
-{
- GUtilIntHistory* h = gutil_int_history_new_full(2, 3,
- test_history_time_func);
- test_history_time = 1;
- g_assert(gutil_int_history_add(h, 1) == 1);
- test_history_time += 1;
- g_assert(gutil_int_history_add(h, 5) == 3);
- g_assert(gutil_int_history_interval(h) == 1);
- test_history_time += 1;
- /* Both ends of the interval are inclusive */
- g_assert(gutil_int_history_interval(h) == 2);
- test_history_time += 2;
- /* Now one entry with timestamp 1 expires, the one remaining has
- * timestamp 2, the current time is 5 so the interval becomes 3 */
- g_assert(gutil_int_history_interval(h) == 3);
- test_history_time += 1;
- /* The last one expires too */
- g_assert(gutil_int_history_interval(h) == 0);
- gutil_int_history_unref(h);
-}
-
-/*==========================================================================*
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_idlepool/Makefile
^
|
@@ -1,5 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-EXE = test_idlepool
-
-include ../common/Makefile
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_idlepool/test_idlepool.c
^
|
@@ -1,477 +0,0 @@
-/*
- * Copyright (C) 2016-2024 Slava Monich <slava@monich.com>
- * Copyright (C) 2016-2018 Jolla Ltd.
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include "gutil_idlepool.h"
-#include "gutil_strv.h"
-#include "gutil_log.h"
-
-#define TEST_TIMEOUT_SEC (10) /* seconds */
-
-static TestOpt test_opt;
-
-static
-gboolean
-test_timeout(
- gpointer loop)
-{
- g_assert(!"TIMEOUT");
- return G_SOURCE_REMOVE;
-}
-
-static
-void
-test_done(
- gpointer loop)
-{
- g_main_loop_quit(loop);
-}
-
-static
-gboolean
-test_done_cb(
- gpointer loop)
-{
- g_main_loop_quit(loop);
- return G_SOURCE_REMOVE;
-}
-
-/*==========================================================================*
- * Test thread
- *==========================================================================*/
-
-typedef struct test_thread TestThread;
-
-typedef
-void
-(*ThreadBeforeProc)(
- TestThread* thread,
- gpointer user_data);
-
-struct test_thread {
- GThread* thread;
- GMutex mutex;
- GCond start_cond;
- GMainLoop* loop;
- GMainContext* context;
- ThreadBeforeProc before_proc;
- gpointer before_data;
-};
-
-static
-gpointer
-test_thread_proc(
- gpointer user_data)
-{
- TestThread* thread = user_data;
- GMainLoop* loop = g_main_loop_ref(thread->loop);
- GMainContext* context = g_main_context_ref(thread->context);
-
- /* Invoke this callback before pushing GMainContext */
- if (thread->before_proc) {
- thread->before_proc(thread, thread->before_data);
- }
-
- /* Lock */
- g_mutex_lock(&thread->mutex);
- g_main_context_push_thread_default(context);
- g_cond_broadcast(&thread->start_cond);
- GDEBUG("Test thread started");
- g_mutex_unlock(&thread->mutex);
- /* Unlock */
-
- g_main_loop_run(loop);
- g_main_loop_unref(loop);
- g_main_context_pop_thread_default(context);
- g_main_context_unref(context);
- GDEBUG("Test thread exiting");
- return NULL;
-}
-
-static
-TestThread*
-test_thread_new(
- ThreadBeforeProc before_proc,
- gpointer before_data)
-{
- TestThread* thread = g_new0(TestThread, 1);
-
- g_cond_init(&thread->start_cond);
- g_mutex_init(&thread->mutex);
- thread->context = g_main_context_new();
- thread->loop = g_main_loop_new(thread->context, FALSE);
- thread->before_proc = before_proc;
- thread->before_data = before_data;
-
- /* Lock */
- g_mutex_lock(&thread->mutex);
- thread->thread = g_thread_new("test", test_thread_proc, thread);
- g_assert(g_cond_wait_until(&thread->start_cond, &thread->mutex,
- g_get_monotonic_time() + TEST_TIMEOUT_SEC * G_TIME_SPAN_SECOND));
- g_mutex_unlock(&thread->mutex);
- /* Unlock */
-
- return thread;
-}
-
-static
-void
-test_thread_invoke_later(
- TestThread* thread,
- GSourceFunc fn,
- gpointer user_data)
-{
- GSource* src = g_idle_source_new();
-
- g_source_set_priority(src, G_PRIORITY_DEFAULT);
- g_source_set_callback(src, fn, user_data, NULL);
- g_source_attach(src, thread->context);
- g_source_unref(src);
-}
-
-static
-void
-test_thread_free(
- TestThread* thread)
-{
- g_main_loop_quit(thread->loop);
- g_thread_join(thread->thread);
- g_main_loop_unref(thread->loop);
- g_main_context_unref(thread->context);
- g_cond_clear(&thread->start_cond);
- g_mutex_clear(&thread->mutex);
- g_free(thread);
-}
-
-/*==========================================================================*
- * Null
- *==========================================================================*/
-
-static
-void
-test_null(
- void)
-{
- GUtilIdlePool* pool = gutil_idle_pool_new();
-
- /* These have no effect, just testing NULL-telerance */
- gutil_idle_pool_add_strv(NULL, NULL);
- gutil_idle_pool_add_strv(pool, NULL);
- gutil_idle_pool_add_ptr_array(NULL, NULL);
- gutil_idle_pool_add_ptr_array(pool, NULL);
- gutil_idle_pool_add_ptr_array_ref(NULL, NULL);
- gutil_idle_pool_add_ptr_array_ref(pool, NULL);
- gutil_idle_pool_add_variant(NULL, NULL);
- gutil_idle_pool_add_variant(pool, NULL);
- gutil_idle_pool_add_variant_ref(NULL, NULL);
- gutil_idle_pool_add_variant_ref(pool, NULL);
- gutil_idle_pool_add_object(NULL, NULL);
- gutil_idle_pool_add_object(pool, NULL);
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_idlequeue/Makefile
^
|
@@ -1,5 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-EXE = test_idlequeue
-
-include ../common/Makefile
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_idlequeue/test_idlequeue.c
^
|
@@ -1,294 +0,0 @@
-/*
- * Copyright (C) 2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Jolla Ltd nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include "gutil_idlequeue.h"
-#include "gutil_log.h"
-
-#define TEST_TIMEOUT (10) /* seconds */
-
-static TestOpt test_opt;
-
-static
-void
-test_idlequeue_noooo(
- gpointer param)
-{
- g_assert(!"NOOO!!!");
-}
-
-static
-gboolean
-test_idlequeue_timeout(
- gpointer param)
-{
- g_assert(!"TIMEOUT");
- return G_SOURCE_REMOVE;
-}
-
-static
-void
-test_idlequeue_loop_quit(
- gpointer loop)
-{
- g_main_loop_quit(loop);
-}
-
-static
-void
-test_idlequeue_int_inc(
- gpointer data)
-{
- int* ptr = data;
- (*ptr)++;
-}
-
-/*==========================================================================*
- * Null
- *==========================================================================*/
-
-static
-void
-test_idlequeue_null(
- void)
-{
- /* Test NULL tolerance */
- int i = 0;
- g_assert(!gutil_idle_queue_ref(NULL));
- gutil_idle_queue_unref(NULL);
- gutil_idle_queue_free(NULL);
- g_assert(!gutil_idle_queue_contains_tag(NULL, 0));
- g_assert(!gutil_idle_queue_cancel_tag(NULL, 0));
- gutil_idle_queue_cancel_all(NULL);
- gutil_idle_queue_add(NULL, NULL, NULL);
- gutil_idle_queue_add_full(NULL, NULL, NULL, NULL);
- gutil_idle_queue_add_tag(NULL, 0, NULL, NULL);
- gutil_idle_queue_add_tag_full(NULL, 0, NULL, NULL, NULL);
- /* IF queue is NULL, the destroy function gets invoked immediately: */
- gutil_idle_queue_add_tag_full(NULL, 0, NULL, &i, test_idlequeue_int_inc);
- g_assert(i == 1);
-}
-
-/*==========================================================================*
- * Basic
- *==========================================================================*/
-
-static
-void
-test_idlequeue_basic(
- void)
-{
- guint timeout_id = 0;
- int count = 0;
- GUtilIdleQueue* q = gutil_idle_queue_new();
- GMainLoop* loop = g_main_loop_new(NULL, TRUE);
-
- gutil_idle_queue_unref(gutil_idle_queue_ref(q));
- gutil_idle_queue_add_tag_full(q, 1, test_idlequeue_int_inc, &count, NULL);
- gutil_idle_queue_add_tag_full(q, 2, NULL, &count, test_idlequeue_int_inc);
- gutil_idle_queue_add_tag_full(q, 3, test_idlequeue_loop_quit, loop, NULL);
- g_assert(!gutil_idle_queue_contains_tag(q, 0));
- g_assert(gutil_idle_queue_contains_tag(q, 1));
- g_assert(gutil_idle_queue_contains_tag(q, 2));
- g_assert(gutil_idle_queue_contains_tag(q, 3));
-
- if (!(test_opt.flags & TEST_FLAG_DEBUG)) {
- timeout_id = g_timeout_add_seconds(TEST_TIMEOUT,
- test_idlequeue_timeout, NULL);
- }
-
- g_main_loop_run(loop);
- g_assert(count == 2);
-
- if (timeout_id) {
- g_source_remove(timeout_id);
- }
-
- gutil_idle_queue_unref(q);
- g_main_loop_unref(loop);
-}
-/*==========================================================================*
- * Add
- *==========================================================================*/
-
-typedef struct test_idlequeue_add_data {
- GUtilIdleQueue* q;
- GMainLoop* loop;
-} TestAdd;
-
-static
-void
-test_idlequeue_add_cb(
- gpointer data)
-{
- /* Adding new item from the callback */
- TestAdd* test = data;
- gutil_idle_queue_add(test->q, test_idlequeue_loop_quit, test->loop);
-}
-
-static
-void
-test_idlequeue_add(
- void)
-{
- guint timeout_id = 0;
- TestAdd test;
-
- test.q = gutil_idle_queue_new();
- test.loop = g_main_loop_new(NULL, TRUE);
-
- if (!(test_opt.flags & TEST_FLAG_DEBUG)) {
- timeout_id = g_timeout_add_seconds(TEST_TIMEOUT,
- test_idlequeue_timeout, NULL);
- }
-
- gutil_idle_queue_add(test.q, test_idlequeue_add_cb, &test);
- g_main_loop_run(test.loop);
-
- if (timeout_id) {
- g_source_remove(timeout_id);
- }
-
- gutil_idle_queue_unref(test.q);
- g_main_loop_unref(test.loop);
-}
-
-/*==========================================================================*
- * Cancel
- *==========================================================================*/
-
-static
-void
-test_idlequeue_cancel(
- void)
-{
- int count = 0;
- GUtilIdleQueue* q = gutil_idle_queue_new();
-
- /* Destroying the queue cancels the callbacks */
- gutil_idle_queue_add(q, test_idlequeue_int_inc, &count);
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_inotify/Makefile
^
|
@@ -1,5 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-EXE = test_inotify
-
-include ../common/Makefile
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_inotify/test_inotify.c
^
|
@@ -1,368 +0,0 @@
-/*
- * Copyright (C) 2016-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the Jolla Ltd nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include "gutil_inotify.h"
-#include "gutil_macros.h"
-#include "gutil_log.h"
-
-#include <sys/inotify.h>
-
-#define TEST_TIMEOUT (10) /* seconds */
-#define TMP_DIR_TEMPLATE "test_inotify_XXXXXX"
-
-static TestOpt test_opt;
-
-typedef struct test_inotify {
- const char* name;
- GMainLoop* loop;
- GUtilInotifyWatch* watch1;
- GUtilInotifyWatch* watch2;
- char* dir1;
- char* dir2;
- guint timeout_id;
- gboolean array_free_count;
- gboolean ok;
-} TestInotify;
-
-static
-gboolean
-test_inotify_timeout(
- gpointer param)
-{
- TestInotify* test = param;
- GERR("%s TIMEOUT", test->name);
- test->timeout_id = 0;
- g_main_loop_quit(test->loop);
- return G_SOURCE_REMOVE;
-}
-
-static
-void
-test_inotify_common(
- TestInotify* test,
- gboolean (*init)(TestInotify* test),
- void (*deinit)(TestInotify* test))
-{
- const int mask = IN_ALL_EVENTS | IN_ONLYDIR | IN_EXCL_UNLINK;
-
- test->ok = FALSE;
- test->dir1 = g_dir_make_tmp(TMP_DIR_TEMPLATE, NULL);
- test->dir2 = g_dir_make_tmp(TMP_DIR_TEMPLATE, NULL);
- test->watch1 = gutil_inotify_watch_new(test->dir1, mask);
- test->watch2 = gutil_inotify_watch_new(test->dir2, mask);
-
- GDEBUG("%s: directory 1: %s", test->name, test->dir1);
- GDEBUG("%s: directory 2: %s", test->name, test->dir2);
-
- /* Initialize the event loop */
- test->loop = g_main_loop_new(NULL, TRUE);
- if (!(test_opt.flags & TEST_FLAG_DEBUG)) {
- test->timeout_id = g_timeout_add_seconds(TEST_TIMEOUT,
- test_inotify_timeout, test);
- }
-
- if (init) {
- init(test);
- }
-
- /* Run the event loop */
- g_main_loop_run(test->loop);
-
- if (deinit) {
- deinit(test);
- }
-
- g_assert(test->ok);
- if (!(test_opt.flags & TEST_FLAG_DEBUG)) {
- g_assert(test->timeout_id);
- g_source_remove(test->timeout_id);
- }
-
- g_main_loop_unref(test->loop);
- gutil_inotify_watch_destroy(test->watch1);
- gutil_inotify_watch_destroy(test->watch2);
- remove(test->dir1);
- remove(test->dir2);
- g_free(test->dir1);
- g_free(test->dir2);
-}
-
-/*==========================================================================*
- * Basic
- *==========================================================================*/
-
-static
-void
-test_inotify_basic(
- void)
-{
- char* dir = g_dir_make_tmp(TMP_DIR_TEMPLATE, NULL);
- GUtilInotifyWatch* watch = gutil_inotify_watch_new(dir, IN_ALL_EVENTS);
-
- /* These have no effect, just testing NULL-telerance */
- g_assert(!gutil_inotify_watch_new(NULL, 0));
- g_assert(!gutil_inotify_watch_ref(NULL));
- gutil_inotify_watch_unref(NULL);
- gutil_inotify_watch_destroy(NULL);
- gutil_inotify_watch_remove_handler(NULL, 0);
- gutil_inotify_watch_remove_handler(watch, 0);
-
- g_assert(!gutil_inotify_watch_callback_new(NULL, 0, NULL, NULL));
- g_assert(!gutil_inotify_watch_add_handler(NULL, NULL, NULL));
- g_assert(!gutil_inotify_watch_add_handler(watch, NULL, NULL));
-
- gutil_inotify_watch_destroy(watch);
-
- /* Remove the directory and try to watch it. That should fail */
- remove(dir);
- g_assert(!gutil_inotify_watch_new(dir, IN_ALL_EVENTS));
- g_free(dir);
-}
-
-/*==========================================================================*
- * Move
- *==========================================================================*/
-
-typedef struct test_inotify_move {
- TestInotify test;
- const char* fname;
- char* dest;
- gulong id1;
- gulong id2;
- int from;
-} TestInotifyMove;
-
-static
-void
-test_inotify_move_from(
- GUtilInotifyWatch* watch,
- guint mask,
- guint cookie,
- const char* name,
- void* arg)
-{
- TestInotifyMove* move = arg;
- if ((mask & IN_MOVED_FROM) && !g_strcmp0(move->fname, name)) {
- GDEBUG("%s moved from %s", name, move->test.dir1);
- move->from++;
- }
-}
-
-static
-void
-test_inotify_move_to(
- GUtilInotifyWatch* watch,
- guint mask,
- guint cookie,
- const char* name,
- void* arg)
-{
- TestInotifyMove* move = arg;
- if ((mask & IN_MOVED_TO) && !g_strcmp0(move->fname, name)) {
- GDEBUG("%s moved to %s", name, move->test.dir2);
- if (move->from == 1) {
- move->test.ok = TRUE;
- g_main_loop_quit(move->test.loop);
- }
- }
-}
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_intarray/Makefile
^
|
@@ -1,5 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-EXE = test_intarray
-
-include ../common/Makefile
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_intarray/test_intarray.c
^
|
@@ -1,325 +0,0 @@
-/*
- * Copyright (C) 2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Jolla Ltd nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include "gutil_intarray.h"
-#include "gutil_ints.h"
-
-static TestOpt test_opt;
-
-/*==========================================================================*
- * NULL tolerance
- *==========================================================================*/
-
-static
-void
-test_intarray_null(
- void)
-{
- gutil_int_array_unref(NULL);
- g_assert(!gutil_int_array_ref(NULL));
- g_assert(!gutil_int_array_free(NULL, FALSE));
- g_assert(!gutil_int_array_free_to_ints(NULL));
- g_assert(!gutil_int_array_append(NULL, 0));
- g_assert(!gutil_int_array_append_vals(NULL, NULL, 0));
- g_assert(!gutil_int_array_prepend(NULL, 0));
- g_assert(!gutil_int_array_prepend_vals(NULL, NULL, 0));
- g_assert(!gutil_int_array_insert(NULL, 0, 0));
- g_assert(!gutil_int_array_insert_vals(NULL, 0, NULL, 0));
- g_assert(gutil_int_array_find(NULL, 0) == -1);
- g_assert(!gutil_int_array_contains(NULL, 0));
- g_assert(!gutil_int_array_remove(NULL, 0));
- g_assert(!gutil_int_array_remove_fast(NULL, 0));
- g_assert(!gutil_int_array_remove_all(NULL, 0));
- g_assert(!gutil_int_array_remove_all_fast(NULL, 0));
- g_assert(!gutil_int_array_set_count(NULL, 0));
- g_assert(!gutil_int_array_remove_index(NULL, 0));
- g_assert(!gutil_int_array_remove_index_fast(NULL, 0));
- g_assert(!gutil_int_array_remove_range(NULL, 0, 0));
- gutil_int_array_sort_ascending(NULL);
- gutil_int_array_sort_descending(NULL);
-}
-
-/*==========================================================================*
- * Basic
- *==========================================================================*/
-
-static
-void
-test_intarray_basic(
- void)
-{
- static const int vals[] = { 0, 1, 2 };
- GUtilIntArray* a = gutil_int_array_new();
- GUtilInts* ints;
-
- g_assert(gutil_int_array_append(a, 0) == a);
- g_assert(a->count == 1);
- g_assert(a->data[0] == 0);
-
- g_assert(gutil_int_array_append(a, 1) == a);
- g_assert(a->count == 2);
- g_assert(a->data[0] == 0);
- g_assert(a->data[1] == 1);
-
- g_assert(gutil_int_array_prepend(a, 2) == a);
- g_assert(a->count == 3);
- g_assert(a->data[0] == 2);
- g_assert(a->data[1] == 0);
- g_assert(a->data[2] == 1);
-
- gutil_int_array_sort_ascending(a);
- g_assert(a->data[0] == 0);
- g_assert(a->data[1] == 1);
- g_assert(a->data[2] == 2);
-
- gutil_int_array_sort_descending(a);
- g_assert(a->data[0] == 2);
- g_assert(a->data[1] == 1);
- g_assert(a->data[2] == 0);
-
- g_assert(gutil_int_array_remove_index_fast(a, 0) == a);
- g_assert(a->count == 2);
- g_assert(a->data[0] == 0);
- g_assert(a->data[1] == 1);
-
- g_assert(gutil_int_array_remove_range(a, 1, 2) == a);
- g_assert(a->count == 1);
- g_assert(a->data[0] == 0);
-
- /* This removes nothing (position out of range) */
- g_assert(gutil_int_array_remove_range(a, 1, 2) == a);
- g_assert(a->count == 1);
- g_assert(a->data[0] == 0);
-
- /* This too (zero count) */
- g_assert(gutil_int_array_remove_range(a, 0, 0) == a);
- g_assert(a->count == 1);
- g_assert(a->data[0] == 0);
-
- g_assert(gutil_int_array_remove_range(a, 0, 1) == a);
- g_assert(a->count == 0);
-
- g_assert(gutil_int_array_insert(a, 0, 0) == a);
- g_assert(gutil_int_array_insert(a, 0, 1) == a);
- g_assert(a->count == 2);
- g_assert(a->data[0] == 1);
- g_assert(a->data[1] == 0);
-
- g_assert(gutil_int_array_insert(a, 2, 2) == a);
- g_assert(a->count == 3);
- g_assert(a->data[0] == 1);
- g_assert(a->data[1] == 0);
- g_assert(a->data[2] == 2);
-
- g_assert(gutil_int_array_set_count(a, 2) == a);
- g_assert(a->count == 2);
- g_assert(a->data[0] == 1);
- g_assert(a->data[1] == 0);
-
- g_assert(gutil_int_array_remove_index(a, 0) == a);
- g_assert(a->count == 1);
- g_assert(a->data[0] == 0);
-
- g_assert(gutil_int_array_remove_index(a, 1) == a);
- g_assert(a->count == 1);
- g_assert(a->data[0] == 0);
-
- gutil_int_array_ref(a);
- gutil_int_array_free(a, TRUE);
- g_assert(!a->data);
- g_assert(!a->count);
- gutil_int_array_unref(a);
-
- a = gutil_int_array_sized_new(0);
- g_assert(!gutil_int_array_free(a, FALSE));
-
- a = gutil_int_array_sized_new(0);
- g_assert(!gutil_int_array_free_to_ints(a));
-
- a = gutil_int_array_sized_new(G_N_ELEMENTS(vals));
- g_assert(gutil_int_array_append_vals(a, vals, G_N_ELEMENTS(vals)) == a);
- g_assert(a->count == G_N_ELEMENTS(vals));
- g_assert(!memcmp(a->data, vals, sizeof(vals)));
- ints = gutil_int_array_free_to_ints(a);
- g_assert(gutil_ints_get_count(ints) == G_N_ELEMENTS(vals));
- g_assert(!memcmp(gutil_ints_get_data(ints, NULL), vals, sizeof(vals)));
- gutil_ints_unref(ints);
-}
-
-/*==========================================================================*
- * Find
- *==========================================================================*/
-
-static
-void
-test_intarray_find(
- void)
-{
- static const int vals[] = { 0, 1, 2 };
- GUtilIntArray* a = gutil_int_array_new();
-
- g_assert(gutil_int_array_append_vals(a, vals, G_N_ELEMENTS(vals)) == a);
- g_assert(gutil_int_array_find(a, -1) == -1);
- g_assert(gutil_int_array_find(a, 0) == 0);
- g_assert(gutil_int_array_find(a, 1) == 1);
- g_assert(gutil_int_array_find(a, 2) == 2);
- g_assert(gutil_int_array_find(a, 3) == -1);
- g_assert(gutil_int_array_contains(a, 2));
- g_assert(!gutil_int_array_contains(a, 3));
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_ints/Makefile
^
|
@@ -1,5 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-EXE = test_ints
-
-include ../common/Makefile
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_ints/test_ints.c
^
|
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2017-2022 Jolla Ltd.
- * Copyright (C) 2017-2022 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include "gutil_ints.h"
-#include "gutil_misc.h"
-
-static TestOpt test_opt;
-
-/*==========================================================================*
- * NULL tolerance
- *==========================================================================*/
-
-static
-void
-test_ints_null(
- void)
-{
- int val = 0;
- guint count;
- gutil_ints_unref(NULL);
- g_assert(!gutil_ints_ref(NULL));
- g_assert(!gutil_ints_new(NULL, 0));
- g_assert(!gutil_ints_new(NULL, 1));
- g_assert(!gutil_ints_new(&val, 0));
- g_assert(!gutil_ints_new_take(NULL, 0));
- g_assert(!gutil_ints_new_take(NULL, 1));
- g_assert(!gutil_ints_new_take(&val, 0));
- g_assert(!gutil_ints_new_static(NULL, 0));
- g_assert(!gutil_ints_new_static(NULL, 1));
- g_assert(!gutil_ints_new_static(&val, 0));
- g_assert(!gutil_ints_new_with_free_func(NULL, 0, NULL, NULL));
- g_assert(!gutil_ints_new_with_free_func(NULL, 1, NULL, NULL));
- g_assert(!gutil_ints_new_with_free_func(&val, 0, NULL, NULL));
- g_assert(!gutil_ints_new_from_ints(NULL, 0, 0));
- g_assert(!gutil_ints_hash(NULL));
- g_assert(!gutil_ints_get_count(NULL));
- g_assert(!gutil_ints_contains(NULL, 0));
- g_assert(gutil_ints_find(NULL, 0) < 0);
- count = 1;
- g_assert(!gutil_ints_get_data(NULL, NULL));
- g_assert(!gutil_ints_get_data(NULL, &count));
- g_assert(!count);
- count = 1;
- g_assert(!gutil_ints_unref_to_data(NULL, NULL));
- g_assert(!gutil_ints_unref_to_data(NULL, &count));
- g_assert(!count);
-}
-
-/*==========================================================================*
- * Basic
- *==========================================================================*/
-
-static
-void
-test_custom_free(
- gpointer data)
-{
- g_free(data);
-}
-
-static
-void
-test_ints_basic(
- void)
-{
- /* First 3 elements match */
- const int a1[] = { 1, 2, 3 };
- const int a2[] = { 1, 2, 3, 4 };
- int* data;
- guint count;
- GUtilInts* i1 = gutil_ints_new(a1, G_N_ELEMENTS(a1));
- GUtilInts* i2 = gutil_ints_new_static(a2, G_N_ELEMENTS(a2));
- GUtilInts* i3;
- GUtilInts* i4;
- g_assert(gutil_ints_get_count(i1) == G_N_ELEMENTS(a1));
- g_assert(gutil_ints_get_count(i2) == G_N_ELEMENTS(a2));
- g_assert(gutil_ints_get_data(i1, NULL) != a2);
- g_assert(gutil_ints_get_data(i2, &count) == a2);
- g_assert(count == G_N_ELEMENTS(a2));
- g_assert(!gutil_ints_new_from_ints(i1, G_N_ELEMENTS(a2), 1));
- i3 = gutil_ints_new_from_ints(i1, 0, G_N_ELEMENTS(a1) + 1);
- i4 = gutil_ints_new_from_ints(i2, 0, G_N_ELEMENTS(a1));
-
- g_assert(gutil_ints_equal(i1, i1));
- g_assert(!gutil_ints_equal(i1, i2));
- g_assert(gutil_ints_equal(i1, i3));
- g_assert(gutil_ints_equal(i1, i3));
-
- g_assert(!gutil_ints_contains(i1, 0));
- g_assert(gutil_ints_contains(i1, 1));
-
- g_assert(gutil_ints_find(i1, 0) < 0);
- g_assert(gutil_ints_find(i1, 1) == 0);
- g_assert(gutil_ints_find(i1, 2) == 1);
-
- /* This gutil_ints_unref_to_data doesn't actually free i1 because
- * a reference to it is held by i3: */
- data = gutil_ints_unref_to_data(i1, &count);
- g_assert(count == G_N_ELEMENTS(a1));
- g_assert(!memcmp(a1, data, count*sizeof(int)));
- g_free(data);
-
- gutil_ints_unref(i2);
- gutil_ints_unref(i3);
- gutil_ints_unref(i4);
-
- /* This gutil_ints_unref_to_data actually does free i1: */
- i1 = gutil_ints_new(a1, G_N_ELEMENTS(a1));
- data = gutil_ints_unref_to_data(i1, NULL);
- g_assert(!memcmp(a1, data, G_N_ELEMENTS(a1)*sizeof(int)));
- g_free(data);
-
- /* And this one duplicates the data because we use test_custom_free: */
- data = gutil_memdup(a1, sizeof(a1));
- i1 = gutil_ints_new_with_free_func(data, G_N_ELEMENTS(a1),
- test_custom_free, data);
- data = gutil_ints_unref_to_data(i1, &count);
- g_assert(count == G_N_ELEMENTS(a1));
- g_assert(!memcmp(a1, data, count*sizeof(int)));
- g_free(data);
-}
-
-/*==========================================================================*
- * Compare
- *==========================================================================*/
-
-static
-void
-test_ints_compare(
- void)
-{
- const int a1[] = { 1 };
- const int a2[] = { 1, 2 };
- const int a3[] = { 2 };
- GUtilInts* i1 = gutil_ints_new_static(a1, G_N_ELEMENTS(a1));
- GUtilInts* i2 = gutil_ints_new_static(a2, G_N_ELEMENTS(a2));
- GUtilInts* i3 = gutil_ints_new_static(a3, G_N_ELEMENTS(a3));
- GUtilInts* i4 = gutil_ints_new_from_ints(i1, 0, G_N_ELEMENTS(a1));
-
- g_assert(gutil_ints_hash(i1) == 1235);
- g_assert(gutil_ints_hash(i2) == 1239);
-
- g_assert(gutil_ints_equal(NULL, NULL));
- g_assert(!gutil_ints_equal(NULL, i1));
- g_assert(!gutil_ints_equal(i1, NULL));
- g_assert(!gutil_ints_equal(i1, i2));
- g_assert(!gutil_ints_equal(i2, i1));
- g_assert(!gutil_ints_equal(i1, i3));
- g_assert(!gutil_ints_equal(i3, i1));
- g_assert(gutil_ints_equal(i1, i4));
- g_assert(gutil_ints_equal(i4, i1));
-
- g_assert(gutil_ints_compare(NULL, NULL) == 0);
- g_assert(gutil_ints_compare(NULL, i1) < 0);
- g_assert(gutil_ints_compare(i1, NULL) > 0);
- g_assert(gutil_ints_compare(i1, i2) < 0);
- g_assert(gutil_ints_compare(i2, i1) > 0);
- g_assert(gutil_ints_compare(i1, i3) < 0);
- g_assert(gutil_ints_compare(i3, i1) > 0);
- g_assert(gutil_ints_compare(i1, i4) == 0);
- g_assert(gutil_ints_compare(i4, i1) == 0);
-
- gutil_ints_unref(i1);
- gutil_ints_unref(i2);
- gutil_ints_unref(i3);
- gutil_ints_unref(i4);
-}
-
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_log/Makefile
^
|
@@ -1,6 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-CFLAGS += -DGLOG_LEVEL_MAX=GLOG_LEVEL_VERBOSE -DGLOG_LEVEL_ASSERT=GLOG_LEVEL_ALWAYS
-EXE = test_log
-
-include ../common/Makefile
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_log/test_log.c
^
|
@@ -1,421 +0,0 @@
-/*
- * Copyright (C) 2017-2023 Slava Monich <slava@monich.com>
- * Copyright (C) 2017-2022 Jolla Ltd.
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#define _GNU_SOURCE /* for fopencookie */
-
-#include "test_common.h"
-
-#include "gutil_strv.h"
-#include "gutil_log.h"
-
-#ifdef __GLIBC__
-/* glibc has writeable stdout */
-# define HAVE_TEST_LOG_FILE
-#endif
-
-static TestOpt test_opt;
-static GString* test_log_buf;
-
-static
-void
-test_log_fn(
- const char* name,
- int level,
- const char* format,
- va_list va)
-{
- g_string_append_vprintf(test_log_buf, format, va);
- g_string_append_c(test_log_buf, '\n');
-}
-
-/*==========================================================================*
- * Basic
- *==========================================================================*/
-
-static
-void
-test_log_basic(
- void)
-{
- const GLogProc fn = gutil_log_func;
- const GLogProc2 fn2 = gutil_log_func2;
- const int level = gutil_log_default.level;
- GLOG_MODULE_DEFINE2_(module, "test", gutil_log_default);
- test_log_buf = g_string_new(NULL);
- gutil_log_func = test_log_fn;
-
- module.level = GLOG_LEVEL_INHERIT;
- gutil_log_default.level = GLOG_LEVEL_ERR;
- gutil_log(NULL, GLOG_LEVEL_NONE, "Debug!");
- gutil_log(NULL, GLOG_LEVEL_DEBUG, "Debug!");
- gutil_log(&module, GLOG_LEVEL_DEBUG, "Debug!");
- gutil_log_assert(NULL, GLOG_LEVEL_WARN, "Test!", __FILE__, __LINE__);
- g_assert(!test_log_buf->len);
- gutil_log(&module, GLOG_LEVEL_ERR, "Err!");
- g_assert(test_log_buf->len);
- g_string_set_size(test_log_buf, 0);
-
- /* With NULL parent, still gutil_log_default is going to be checked */
- module.parent = NULL;
- gutil_log(NULL, GLOG_LEVEL_NONE, "Debug!");
- gutil_log(NULL, GLOG_LEVEL_DEBUG, "Debug!");
- gutil_log(&module, GLOG_LEVEL_DEBUG, "Debug!");
- gutil_log_assert(NULL, GLOG_LEVEL_WARN, "Test!", __FILE__, __LINE__);
- g_assert(!test_log_buf->len);
- gutil_log(&module, GLOG_LEVEL_ERR, "Err!");
- g_assert(test_log_buf->len);
- g_string_set_size(test_log_buf, 0);
-
- gutil_log(&module, GLOG_LEVEL_ALWAYS, "Always!");
- g_assert(test_log_buf->len);
- g_string_set_size(test_log_buf, 0);
-
- /* Test GLOG_FLAG_DISABLE */
- module.flags |= GLOG_FLAG_DISABLE;
- gutil_log(&module, GLOG_LEVEL_ALWAYS, "Always!");
- g_assert(!test_log_buf->len);
- module.flags &= ~GLOG_FLAG_DISABLE;
-
- /* Without log functions these calls have no effect */
- gutil_log_func = NULL;
- gutil_log(NULL, GLOG_LEVEL_ALWAYS, "Always!");
- gutil_log_func2 = NULL;
- gutil_log(NULL, GLOG_LEVEL_ALWAYS, "Always!");
-
- g_string_free(test_log_buf, TRUE);
- test_log_buf = NULL;
- gutil_log_default.level = level;
- gutil_log_func = fn;
- gutil_log_func2 = fn2;
-}
-
-/*==========================================================================*
- * File
- *==========================================================================*/
-
-#ifdef HAVE_TEST_LOG_FILE
-
-static
-ssize_t
-test_log_file_write(
- void* buf,
- const char* chars,
- size_t size)
-{
- g_string_append_len(buf, chars, size);
- return size;
-}
-
-static
-void
-test_log_drop(
- const GLogModule* module,
- int level,
- const char* format,
- va_list va)
-{
-}
-
-static
-void
-test_log_file(
- void)
-{
- static const cookie_io_functions_t funcs = {
- .write = test_log_file_write
- };
- GString* buf = g_string_new(NULL);
- FILE* out = fopencookie(buf, "w", funcs);
- FILE* default_stdout = stdout;
- const int level = gutil_log_default.level;
- gboolean use_timestamp;
- GLogProc2 log_proc;
-
- g_assert(out);
- g_assert(gutil_log_set_type(GLOG_TYPE_STDOUT, NULL));
- g_assert(gutil_log_func == gutil_log_stdout);
- gutil_log_timestamp = FALSE;
- gutil_log_default.level = GLOG_LEVEL_WARN;
-
- /* Warning pefix */
- stdout = out;
- gutil_log(NULL, GLOG_LEVEL_WARN, "Test");
- stdout = default_stdout;
- g_assert(fflush(out) == 0);
- GDEBUG("%s", buf->str);
- g_assert_cmpstr(buf->str, == ,"WARNING: Test\n");
- g_string_set_size(buf, 0);
-
- /* Error prefix */
- stdout = out;
- gutil_log(NULL, GLOG_LEVEL_ERR, "Test");
- stdout = default_stdout;
- g_assert(fflush(out) == 0);
- GDEBUG("%s", buf->str);
- g_assert_cmpstr(buf->str, == ,"ERROR: Test\n");
- g_string_set_size(buf, 0);
-
- /* Empty name (dropped) */
- gutil_log_default.name = "";
- stdout = out;
- gutil_log(NULL, GLOG_LEVEL_ALWAYS, "Test");
- stdout = default_stdout;
- g_assert(fflush(out) == 0);
- GDEBUG("%s", buf->str);
- g_assert_cmpstr(buf->str, == ,"Test\n");
- g_string_set_size(buf, 0);
-
- /* Non-empty name */
- gutil_log_default.name = "test";
- stdout = out;
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_misc/Makefile
^
|
@@ -1,5 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-EXE = test_misc
-
-include ../common/Makefile
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_misc/test_misc.c
^
|
@@ -1,1083 +0,0 @@
-/*
- * Copyright (C) 2023-2024 Slava Monich <slava@monich.com>
- * Copyright (C) 2016-2022 Jolla Ltd.
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include "gutil_misc.h"
-#include "gutil_idlepool.h"
-#include "gutil_log.h"
-#include "gutil_version.h"
-
-static TestOpt test_opt;
-
-/*==========================================================================*
- * version
- *==========================================================================*/
-
-static
-void
-test_version(
- void)
-{
- g_assert_cmpuint(gutil_version(), == ,GUTIL_VERSION);
-}
-
-/*==========================================================================*
- * disconnect
- *==========================================================================*/
-
-static
-void
-test_notify(
- GObject* object,
- GParamSpec* spec,
- gpointer data)
-{
-}
-
-static
-void
-test_disconnect(
- void)
-{
- gulong id[2];
- GObject* obj = g_object_new(TEST_OBJECT_TYPE, NULL);
-
- /* These have no effect */
- gutil_disconnect_handlers(NULL, id, G_N_ELEMENTS(id));
- gutil_disconnect_handlers(obj, NULL, 0);
-
- id[0] = g_signal_connect(obj, "notify", G_CALLBACK(test_notify), NULL);
- id[1] = g_signal_connect(obj, "notify", G_CALLBACK(test_notify), NULL);
- GASSERT(id[0] && id[1]);
-
- /* gutil_disconnect_handlers zeros the ids */
- gutil_disconnect_handlers(obj, id, G_N_ELEMENTS(id));
- g_assert(!id[0]);
- g_assert(!id[1]);
-
- /* Second time has no effect */
- gutil_disconnect_handlers(obj, id, G_N_ELEMENTS(id));
- g_assert(!id[0]);
- g_assert(!id[1]);
-
- g_object_unref(obj);
-}
-
-/*==========================================================================*
- * ref
- *==========================================================================*/
-
-static
-void
-test_ref(
- void)
-{
- GObject* obj = g_object_new(TEST_OBJECT_TYPE, NULL);
-
- g_assert(!gutil_object_ref(NULL));
- g_assert(gutil_object_ref(obj) == obj);
- g_object_unref(obj);
- g_object_unref(obj);
-}
-
-/*==========================================================================*
- * unref
- *==========================================================================*/
-
-static
-void
-test_unref(
- void)
-{
- gutil_object_unref(NULL);
- gutil_object_unref(g_object_new(TEST_OBJECT_TYPE, NULL));
-}
-
-/*==========================================================================*
- * source
- *==========================================================================*/
-
-static
-gboolean
-test_source_cb(
- gpointer data)
-{
- g_assert_not_reached();
- return G_SOURCE_REMOVE;
-}
-
-static
-void
-test_source(
- void)
-{
- guint id = 0;
-
- g_assert(!gutil_source_clear(NULL));
- g_assert(!gutil_source_clear(&id));
- id = g_idle_add(test_source_cb, NULL);
- g_assert(gutil_source_clear(&id));
- g_assert_cmpuint(id, == ,0);
-
- g_assert(!gutil_source_remove(0));
- g_assert(gutil_source_remove(g_idle_add(test_source_cb, NULL)));
-}
-
-/*==========================================================================*
- * hex2bin
- *==========================================================================*/
-
-static
-void
-test_hex2bin(
- void)
-{
- guint8 buf[4];
- GBytes* bytes;
- gsize size;
- const void* data;
- static const guint8 buf1[4] = { 0x01, 0x23, 0x45, 0x67 };
- static const guint8 buf2[4] = { 0x89, 0xab, 0xcd, 0xef };
-
- g_assert(!gutil_hex2bin(NULL, 0, NULL));
- g_assert(!gutil_hex2bin("x", 0, NULL));
- g_assert(!gutil_hex2bin("x", 0, buf));
- g_assert(!gutil_hex2bin("x", -1, buf));
- g_assert(!gutil_hex2bin("x", 1, buf));
- g_assert(!gutil_hex2bin("xy", 2, buf));
- g_assert(!gutil_hex2bin(" 1", 2, buf));
- g_assert(!gutil_hex2bin("1 ", 2, buf));
- g_assert(!gutil_hex2bin("1234FG", 6, buf));
- g_assert(gutil_hex2bin("01234567", 8, buf));
- g_assert(!memcmp(buf, buf1, sizeof(buf)));
- g_assert(gutil_hex2bin("89abcdef", 8, buf));
- g_assert(!memcmp(buf, buf2, sizeof(buf)));
- g_assert(gutil_hex2bin("89ABCDEF", 8, buf));
- g_assert(!memcmp(buf, buf2, sizeof(buf)));
-
- g_assert(!gutil_hex2bytes(NULL, 0));
- g_assert(!gutil_hex2bytes("x", 0));
- g_assert(!gutil_hex2bytes("x", 1));
- g_assert(!gutil_hex2bytes("x", -1));
- g_assert(!gutil_hex2bytes("xy", -1));
- bytes = gutil_hex2bytes("01234567", -1);
- g_assert(bytes);
- data = g_bytes_get_data(bytes, &size);
- g_assert(data);
- g_assert(size == 4);
- g_assert(!memcmp(data, buf1, sizeof(buf1)));
- g_bytes_unref(bytes);
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_objv/Makefile
^
|
@@ -1,5 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-EXE = test_objv
-
-include ../common/Makefile
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_objv/test_objv.c
^
|
@@ -1,408 +0,0 @@
-/*
- * Copyright (C) 2023 Slava Monich <slava@monich.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include "gutil_objv.h"
-#include "gutil_misc.h"
-
-static TestOpt test_opt;
-
-/*==========================================================================*
- * null
- *==========================================================================*/
-
-static
-void
-test_null(
- void)
-{
- g_assert(!gutil_objv_copy(NULL));
- g_assert(!gutil_objv_add(NULL, NULL));
- g_assert(!gutil_objv_append(NULL, NULL));
- g_assert(!gutil_objv_insert(NULL, NULL, 0));
- g_assert(!gutil_objv_remove(NULL, NULL, FALSE));
- g_assert(!gutil_objv_remove_at(NULL, 0));
- g_assert(!gutil_objv_at(NULL, 0));
- g_assert(!gutil_objv_first(NULL));
- g_assert(!gutil_objv_last(NULL));
- g_assert(!gutil_objv_contains(NULL, NULL));
- g_assert_cmpint(gutil_objv_find(NULL, NULL), < ,0);
- g_assert_cmpint(gutil_objv_find_last(NULL, NULL), < ,0);
- g_assert(gutil_objv_equal(NULL, NULL));
- gutil_objv_free(NULL);
-}
-
-/*==========================================================================*
- * basic
- *==========================================================================*/
-
-static
-void
-test_basic(
- void)
-{
- GObject* o1 = g_object_new(TEST_OBJECT_TYPE, NULL);
- GObject* o2 = g_object_new(TEST_OBJECT_TYPE, NULL);
- GObject** v = gutil_objv_add(NULL, o1);
- GWeakRef r1, r2;
-
- g_weak_ref_init(&r1, o1);
- g_weak_ref_init(&r2, o2);
-
- /* v keeps references to both objects */
- g_object_unref(o1);
- g_assert(g_weak_ref_get(&r1) == o1);
- g_object_unref(o1);
-
- g_assert(gutil_objv_contains(v, o1));
- g_assert(!gutil_objv_contains(v, o2));
-
- g_assert_cmpuint(gutil_ptrv_length(v), == ,1);
- v = gutil_objv_add(v, o2);
- g_assert_cmpuint(gutil_ptrv_length(v), == ,2);
- g_assert(gutil_objv_contains(v, o2));
-
- g_assert(gutil_objv_at(v, 0) == o1);
- g_assert(gutil_objv_at(v, 1) == o2);
- g_assert(!gutil_objv_at(v, 2));
- g_assert(!gutil_objv_at(v, 3));
-
- g_assert(gutil_objv_first(v) == o1);
- g_assert(gutil_objv_last(v) == o2);
- g_assert_cmpint(gutil_objv_find(v, o1), == ,0);
- g_assert_cmpint(gutil_objv_find_last(v, o1), == ,0);
-
- v = gutil_objv_remove(v, o1, FALSE);
- g_assert_cmpuint(gutil_ptrv_length(v), == ,1);
- g_assert(!gutil_objv_at(v, 1));
- g_assert(gutil_objv_remove(v, o1, FALSE) == v);
- g_assert(gutil_objv_remove(v, NULL, FALSE) == v);
- g_assert_cmpuint(gutil_ptrv_length(v), == ,1);
- g_assert(!g_weak_ref_get(&r1));
-
- g_object_unref(o2);
- gutil_objv_free(v);
- g_assert(!g_weak_ref_get(&r2));
-}
-
-/*==========================================================================*
- * new
- *==========================================================================*/
-
-static
-void
-test_new(
- void)
-{
- GObject* o1 = g_object_new(TEST_OBJECT_TYPE, NULL);
- GObject* o2 = g_object_new(TEST_OBJECT_TYPE, NULL);
- GObject** v;
- GWeakRef r1, r2;
-
- g_weak_ref_init(&r1, o1);
- g_weak_ref_init(&r2, o2);
-
- v = gutil_objv_new(NULL, NULL);
- g_assert(v);
- g_assert(!gutil_ptrv_length(v));
- gutil_objv_free(v);
-
- /* v keeps references to both objects */
- v = gutil_objv_new(o1, o2, NULL);
- g_assert(v[0] == o1);
- g_assert(v[1] == o2);
- g_assert(!v[2]);
-
- g_object_unref(o1);
- g_assert(g_weak_ref_get(&r1) == o1);
- g_object_unref(o1);
-
- g_object_unref(o2);
- g_assert(g_weak_ref_get(&r2) == o2);
- g_object_unref(o2);
-
- gutil_objv_free(v);
- g_assert(!g_weak_ref_get(&r1));
- g_assert(!g_weak_ref_get(&r2));
-}
-
-/*==========================================================================*
- * insert
- *==========================================================================*/
-
-static
-void
-test_insert(
- void)
-{
- GObject* o1 = g_object_new(TEST_OBJECT_TYPE, NULL);
- GObject* o2 = g_object_new(TEST_OBJECT_TYPE, NULL);
- GObject* o3 = g_object_new(TEST_OBJECT_TYPE, NULL);
- GObject** v;
- GWeakRef r1, r2, r3;
-
- g_weak_ref_init(&r1, o1);
- g_weak_ref_init(&r2, o2);
- g_weak_ref_init(&r3, o3);
-
- v = gutil_objv_add(gutil_objv_add(NULL, o1), o2);
-
- /* Insert at the end (with index beyond the valid range) */
- v = gutil_objv_insert(v, o3, 100);
-
- g_assert_cmpuint(gutil_ptrv_length(v), == ,3);
- g_assert(gutil_objv_at(v, 0) == o1);
- g_assert(gutil_objv_at(v, 1) == o2);
- g_assert(gutil_objv_at(v, 2) == o3);
-
- /* Again at the end (with the right index) */
- v = gutil_objv_remove_at(v, 2);
-
- g_assert_cmpuint(gutil_ptrv_length(v), == ,2);
- g_assert(gutil_objv_at(v, 0) == o1);
- g_assert(gutil_objv_at(v, 1) == o2);
-
- v = gutil_objv_insert(v, o3, 2);
-
- g_assert_cmpuint(gutil_ptrv_length(v), == ,3);
- g_assert(gutil_objv_at(v, 0) == o1);
- g_assert(gutil_objv_at(v, 1) == o2);
- g_assert(gutil_objv_at(v, 2) == o3);
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_ring/Makefile
^
|
@@ -1,5 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-EXE = test_ring
-
-include ../common/Makefile
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_ring/test_ring.c
^
|
@@ -1,464 +0,0 @@
-/*
- * Copyright (C) 2016-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Jolla Ltd nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include "gutil_ring.h"
-
-static TestOpt test_opt;
-
-/*==========================================================================*
- * Basic
- *==========================================================================*/
-
-static
-void
-test_basic(
- void)
-{
- int i, n = 5;
- GUtilRing* r = gutil_ring_new();
-
- /* Test NULL tolerance */
- g_assert(!gutil_ring_ref(NULL));
- gutil_ring_unref(NULL);
- gutil_ring_set_free_func(NULL, NULL);
- gutil_ring_set_free_func(r, NULL);
- gutil_ring_set_free_func(NULL, g_free);
- gutil_ring_clear(NULL);
- gutil_ring_compact(NULL);
- gutil_ring_reserve(NULL, 0);
- g_assert(!gutil_ring_size(NULL));
- g_assert(!gutil_ring_can_put(NULL, 1));
- g_assert(!gutil_ring_put(NULL, NULL));
- g_assert(!gutil_ring_put_front(NULL, NULL));
- g_assert(!gutil_ring_get(NULL));
- g_assert(!gutil_ring_data_at(NULL, 0));
- g_assert(!gutil_ring_get_last(NULL));
- g_assert(!gutil_ring_drop(NULL, 1));
- g_assert(!gutil_ring_drop_last(NULL, 1));
- g_assert(!gutil_ring_flatten(NULL, NULL));
-
- g_assert(gutil_ring_ref(r) == r);
- gutil_ring_unref(r);
-
- /* Put some data in */
- for (i=0; i<n; i++) {
- g_assert(gutil_ring_can_put(r, 1));
- g_assert(gutil_ring_put(r, GINT_TO_POINTER(i)));
- }
-
- /* Access at invalid index */
- g_assert(!gutil_ring_data_at(r, -1));
- g_assert(!gutil_ring_data_at(r, n));
-
- /* Peek the data */
- for (i=0; i<n; i++) {
- g_assert(gutil_ring_data_at(r, i) == GINT_TO_POINTER(i));
- }
-
- /* Get the data */
- for (i=0; i<n; i++) {
- gutil_ring_flatten(r, NULL);
- gutil_ring_compact(r);
- g_assert(gutil_ring_get(r) == GINT_TO_POINTER(i));
- }
-
- /* There should be nothing left */
- g_assert(!gutil_ring_get(r));
-
- gutil_ring_compact(r);
- gutil_ring_compact(r);
- gutil_ring_clear(r);
- g_assert(!gutil_ring_flatten(r, &i));
- g_assert(!i);
-
- gutil_ring_unref(r);
-}
-
-/*==========================================================================*
- * PutFront
- *==========================================================================*/
-
-static
-void
-test_put_front(
- void)
-{
- int i, n = 5;
- GUtilRing* r = gutil_ring_new();
-
- for (i=0; i<n; i++) {
- g_assert(gutil_ring_can_put(r, 1));
- g_assert(gutil_ring_put_front(r, GINT_TO_POINTER(n-i-1)));
- }
-
- for (i=0; i<n; i++) {
- gutil_ring_compact(r);
- g_assert(gutil_ring_get(r) == GINT_TO_POINTER(i));
- }
-
- /* The same but take it out with get_last */
- for (i=0; i<n; i++) {
- g_assert(gutil_ring_can_put(r, 1));
- g_assert(gutil_ring_put_front(r, GINT_TO_POINTER(n-i-1)));
- }
-
- for (i=0; i<n; i++) {
- gutil_ring_compact(r);
- g_assert(gutil_ring_get_last(r) == GINT_TO_POINTER(n-i-1));
- }
-
- g_assert(!gutil_ring_get_last(r));
- gutil_ring_unref(r);
-}
-
-/*==========================================================================*
- * Drop
- *==========================================================================*/
-
-static
-void
-test_drop(
- void)
-{
- int i, n = 5, get = 3, drop = 3;
- GUtilRing* r = gutil_ring_sized_new(0,n);
-
- /* [01234] */
- for (i=0; i<n; i++) {
- gutil_ring_put(r, GINT_TO_POINTER(i));
- }
-
- /* ...[34] */
- for (i=0; i<get; i++) {
- g_assert(gutil_ring_get(r) == GINT_TO_POINTER(i));
- }
-
- /* 567][34 */
- for (i=0; i<get; i++) {
- gutil_ring_put(r, GINT_TO_POINTER(n+i));
- }
-
- /* ..[67].. */
- g_assert(gutil_ring_drop(r, drop) == drop);
- for (i=0; i<(n-drop); i++) {
- g_assert(gutil_ring_get(r) == GINT_TO_POINTER(get+drop+i));
- }
-
- /* Drop more than the size of the buffer (i.e. clear it) */
- for (i=0; i<n; i++) {
- gutil_ring_put(r, GINT_TO_POINTER(i));
- }
-
- g_assert(!gutil_ring_drop(r, 0));
- g_assert(gutil_ring_drop(r, n+1) == n);
- g_assert(!gutil_ring_drop(r, 1));
- g_assert(!gutil_ring_size(r));
-
- gutil_ring_unref(r);
-}
-
-/*==========================================================================*
- * DropLast
- *==========================================================================*/
-
-static
-void
-test_drop_last(
- void)
-{
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_weakref/Makefile
^
|
@@ -1,5 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-EXE = test_weakref
-
-include ../common/Makefile
|
[-]
[+]
|
Deleted |
_service:tar_git:libglibutil-1.0.79.tar.bz2/test/test_weakref/test_weakref.c
^
|
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2023 Slava Monich <slava@monich.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include "gutil_weakref.h"
-
-#include <glib-object.h>
-
-static TestOpt test_opt;
-
-/*==========================================================================*
- * null
- *==========================================================================*/
-
-static
-void
-test_null()
-{
- gutil_weakref_unref(NULL);
- gutil_weakref_set(NULL, NULL);
- g_assert(!gutil_weakref_ref(NULL));
- g_assert(!gutil_weakref_get(NULL));
-}
-
-/*==========================================================================*
- * basic
- *==========================================================================*/
-
-static
-void
-test_basic()
-{
- GObject* obj = g_object_new(TEST_OBJECT_TYPE, NULL);
- GUtilWeakRef* ref = gutil_weakref_new(obj);
-
- g_assert(gutil_weakref_ref(ref) == ref);
- gutil_weakref_unref(ref);
- g_assert(gutil_weakref_get(ref) == obj);
- g_object_unref(obj);
- gutil_weakref_unref(ref);
-
- ref = gutil_weakref_new(NULL);
- g_assert(!gutil_weakref_get(ref));
- gutil_weakref_set(ref, obj);
- g_assert(gutil_weakref_get(ref) == obj);
- g_object_unref(obj);
- g_object_unref(obj); /* This actually deallocates the object */
- g_assert(!gutil_weakref_get(ref));
- gutil_weakref_unref(ref);
-}
-
-/*==========================================================================*
- * Common
- *==========================================================================*/
-
-#define TEST_(name) "/weakref/" name
-
-int main(int argc, char* argv[])
-{
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- g_type_init();
- G_GNUC_END_IGNORE_DEPRECATIONS;
- g_test_init(&argc, &argv, NULL);
- test_init(&test_opt, argc, argv);
- g_test_add_func(TEST_("null"), test_null);
- g_test_add_func(TEST_("basic"), test_basic);
- return g_test_run();
-}
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|