Compare commits
2 Commits
e8d1a179d6
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| f7f4ead790 | |||
| 0c5cf2edc1 |
40
README.md
40
README.md
@@ -182,6 +182,44 @@ $ gcc -Wall -O2 -o hawk02 hawk02.c -lhawk
|
|||||||
|
|
||||||
The actual command may vary depending on the compiler used and the `configure` options used.
|
The actual command may vary depending on the compiler used and the `configure` options used.
|
||||||
|
|
||||||
|
## Embedding Signal Handling
|
||||||
|
|
||||||
|
Signal handling is provided via a callback hook. The core library does not install OS-level signal handlers; the embedding application must do that and notify the runtime.
|
||||||
|
|
||||||
|
- Register a runtime callback with `hawk_rtx_pushecb()` and fill `hawk_rtx_ecb_t.sigset` (type `hawk_rtx_ecb_sigset_t`).
|
||||||
|
- Your callback is invoked when `sys::signal()` sets or clears a handler; use it to install or reset the OS signal handler.
|
||||||
|
- When the OS handler runs, call `hawk_rtx_raisesig()` on the target runtime.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```c
|
||||||
|
static hawk_rtx_t* g_rtx = HAWK_NULL;
|
||||||
|
|
||||||
|
static void on_os_signal (int sig)
|
||||||
|
{
|
||||||
|
if (g_rtx) hawk_rtx_raisesig(g_rtx, sig);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void on_sigset (hawk_rtx_t* rtx, int sig, hawk_fun_t* fun)
|
||||||
|
{
|
||||||
|
if (fun)
|
||||||
|
{
|
||||||
|
g_rtx = rtx;
|
||||||
|
signal(sig, on_os_signal);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (g_rtx == rtx) g_rtx = HAWK_NULL;
|
||||||
|
signal(sig, SIG_DFL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hawk_rtx_ecb_t ecb;
|
||||||
|
memset(&ecb, 0, HAWK_SIZEOF(ecb));
|
||||||
|
ecb.sigset = on_sigset;
|
||||||
|
hawk_rtx_pushecb(rtx, &ecb);
|
||||||
|
```
|
||||||
|
|
||||||
# Embedding Hawk in C++ Applications
|
# Embedding Hawk in C++ Applications
|
||||||
|
|
||||||
Hawk can also be embedded in C++ applications. Here's an example:
|
Hawk can also be embedded in C++ applications. Here's an example:
|
||||||
@@ -1002,9 +1040,11 @@ The `sys` module provides various functions concerning the underlying operation
|
|||||||
- sys::opendir
|
- sys::opendir
|
||||||
- sys::openfd
|
- sys::openfd
|
||||||
- sys::pipe
|
- sys::pipe
|
||||||
|
- sys::raise
|
||||||
- sys::read
|
- sys::read
|
||||||
- sys::readdir
|
- sys::readdir
|
||||||
- sys::setttime
|
- sys::setttime
|
||||||
|
- sys::signal
|
||||||
- sys::sleep
|
- sys::sleep
|
||||||
- sys::strftime
|
- sys::strftime
|
||||||
- sys::system
|
- sys::system
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
%define __brp_remove_la_files /bin/true
|
%define __brp_remove_la_files /bin/true
|
||||||
%define source_date_epoch_from_changelog 0
|
%define source_date_epoch_from_changelog 0
|
||||||
|
|
||||||
%define enable_mod_ffi 1
|
%{!?enable_mod_ffi:%define enable_mod_ffi 1}
|
||||||
%define enable_mod_memc 0
|
%{!?enable_mod_memc:%define enable_mod_memc 0}
|
||||||
%define enable_mod_mysql 1
|
%{!?enable_mod_mysql:%define enable_mod_mysql 1}
|
||||||
%define enable_mod_sqlite 1
|
%{!?enable_mod_sqlite:%define enable_mod_sqlite 1}
|
||||||
%define enable_mod_uci 0
|
%{!?enable_mod_uci:%define enable_mod_uci 0}
|
||||||
|
|
||||||
Summary: Hawk Interpreter
|
Summary: Hawk Interpreter
|
||||||
Name: @PACKAGE_NAME@
|
Name: @PACKAGE_NAME@
|
||||||
@@ -26,20 +26,31 @@ Requires: %{name}-libs%{?_isa}
|
|||||||
## prep_cif_var() available since 3.0.11
|
## prep_cif_var() available since 3.0.11
|
||||||
BuildRequires: libffi-devel%{?_isa} >= 3.0.11
|
BuildRequires: libffi-devel%{?_isa} >= 3.0.11
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%if %{enable_mod_memc}
|
%if %{enable_mod_memc}
|
||||||
BuildRequires: libmemcached-devel%{?_isa} >= 1.0.18
|
BuildRequires: libmemcached-devel%{?_isa} >= 1.0.18
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%if %{enable_mod_mysql}
|
%if %{enable_mod_mysql}
|
||||||
##BuildRequires: mariadb-connector-c-devel%{?_isa}
|
|
||||||
|
%if 0%{?fedora} > 22
|
||||||
|
BuildRequires: mariadb-connector-c-devel%{?_isa}
|
||||||
|
%else
|
||||||
|
|
||||||
%if 0%{?suse_version} > 0
|
%if 0%{?suse_version} > 0
|
||||||
BuildRequires: libmariadb-devel%{?_isa}
|
BuildRequires: libmariadb-devel%{?_isa}
|
||||||
%else
|
%else
|
||||||
BuildRequires: mysql-devel%{?_isa}
|
BuildRequires: mysql-devel%{?_isa}
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
%endif
|
||||||
|
|
||||||
%if %{enable_mod_sqlite}
|
%if %{enable_mod_sqlite}
|
||||||
BuildRequires: sqlite-devel%{?_isa}
|
BuildRequires: sqlite-devel%{?_isa}
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%if %{enable_mod_uci}
|
%if %{enable_mod_uci}
|
||||||
BuildRequires: libuci-devel%{?_isa}
|
BuildRequires: libuci-devel%{?_isa}
|
||||||
%endif
|
%endif
|
||||||
@@ -83,8 +94,19 @@ This package contains the memc module file for Hawk.
|
|||||||
Summary: Hawk mysql module
|
Summary: Hawk mysql module
|
||||||
Group: System Environment/Libraries
|
Group: System Environment/Libraries
|
||||||
Requires: %{name}-libs%{?_isa} = %{version}
|
Requires: %{name}-libs%{?_isa} = %{version}
|
||||||
|
|
||||||
|
%if 0%{?fedora} > 22
|
||||||
|
Requires: mariadb-connector-c%{?_isa}
|
||||||
|
%else
|
||||||
|
|
||||||
|
%if 0%{?suse_version} > 0
|
||||||
|
Requires: libmariadb%{?_isa}
|
||||||
|
%else
|
||||||
## tricky to specify the right mysql/mariadb client library.
|
## tricky to specify the right mysql/mariadb client library.
|
||||||
##Requires: mariadb-connector-c%{?_isa}
|
Requires:
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%endif
|
||||||
|
|
||||||
%description mysql
|
%description mysql
|
||||||
This package contains the mysql module file for Hawk.
|
This package contains the mysql module file for Hawk.
|
||||||
|
|||||||
Reference in New Issue
Block a user