1
0
Fork 0
mirror of https://github.com/tailix/libclayer.git synced 2024-11-20 11:06:24 -05:00

Remove runtime

This commit is contained in:
Alex Kotov 2022-12-25 13:53:54 +04:00
parent 78fbb3e7ec
commit d5330b1744
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
10 changed files with 3 additions and 76 deletions

View file

@ -35,7 +35,7 @@ endif
libkernaux_la_LDFLAGS = -version-info @PACKAGE_VERSION_SO@ libkernaux_la_LDFLAGS = -version-info @PACKAGE_VERSION_SO@
libkernaux_la_LIBADD = libkernaux_la_LIBADD =
libkernaux_la_SOURCES = src/runtime.c libkernaux_la_SOURCES = src/xxxxx.c
######## ########
# libc # # libc #

View file

@ -39,7 +39,6 @@ may only change when major version number is increased (or minor while major is
zero). Work-in-progress APIs can change at any time. zero). Work-in-progress APIs can change at any time.
* Basic features * Basic features
* [Runtime environment](/include/kernaux/runtime.h) (*non-breaking since* **0.7.0**)
* [Macros](/include/kernaux/macro.h) (*non-breaking since* **0.6.0**) * [Macros](/include/kernaux/macro.h) (*non-breaking since* **0.6.0**)
* Stack trace *(planned)* * Stack trace *(planned)*
* libc replacement (*work in progress*) * libc replacement (*work in progress*)
@ -62,19 +61,6 @@ zero). Work-in-progress APIs can change at any time.
* `KERNAUX_BITFIELDS` - enable bitfields in packed structs. It doesn't follow * `KERNAUX_BITFIELDS` - enable bitfields in packed structs. It doesn't follow
the C standard and may be incompatible with some compilers. the C standard and may be incompatible with some compilers.
### Global variables
```c
// in <kernaux/runtime.h>
void (*kernaux_assert_cb)(const char *file, int line, const char *msg)
```
Assertion callback. It's better to always set it to some function which always
interrupts the execution, even when assertions are disabled. It may for example
call `abort()` in hosted environment, raise an exception in Ruby, panic in Rust
or power off the machine in freestanding environment. It may also log the error
location and message.

View file

@ -22,7 +22,7 @@ AC_CANONICAL_HOST
AC_CONFIG_MACRO_DIRS([m4]) AC_CONFIG_MACRO_DIRS([m4])
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([src/runtime.c]) AC_CONFIG_SRCDIR([src/xxxxx.c])
AC_CONFIG_FILES([ AC_CONFIG_FILES([
Makefile Makefile
libkernaux.pc libkernaux.pc

View file

@ -2,5 +2,4 @@ nobase_include_HEADERS = \
kernaux.h \ kernaux.h \
kernaux/macro.h \ kernaux/macro.h \
kernaux/macro/packing_end.run \ kernaux/macro/packing_end.run \
kernaux/macro/packing_start.run \ kernaux/macro/packing_start.run
kernaux/runtime.h

View file

@ -1,2 +1 @@
#include <kernaux/macro.h> #include <kernaux/macro.h>
#include <kernaux/runtime.h>

View file

@ -1,18 +0,0 @@
#ifndef KERNAUX_INCLUDED_RUNTIME
#define KERNAUX_INCLUDED_RUNTIME
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*KernAux_Assert_Cb)(const char *file, int line, const char *msg);
extern KernAux_Assert_Cb kernaux_assert_cb;
void kernaux_assert_do(const char *file, int line, const char *msg);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -2,7 +2,6 @@ include/kernaux.h
include/kernaux/macro.h include/kernaux/macro.h
include/kernaux/macro/packing_end.run include/kernaux/macro/packing_end.run
include/kernaux/macro/packing_start.run include/kernaux/macro/packing_start.run
include/kernaux/runtime.h
lib/libkernaux.a lib/libkernaux.a
lib/libkernaux.so lib/libkernaux.so
lib/libkernaux.so.0 lib/libkernaux.so.0

View file

@ -1,16 +1,8 @@
#ifndef KERNAUX_INCLUDED_ASSERT #ifndef KERNAUX_INCLUDED_ASSERT
#define KERNAUX_INCLUDED_ASSERT #define KERNAUX_INCLUDED_ASSERT
#include <kernaux/runtime.h>
#ifdef ENABLE_ASSERT
#define KERNAUX_PANIC(msg) (kernaux_assert_do(__FILE__, __LINE__, msg))
#define KERNAUX_ASSERT(cond) ((cond) ? (void)0 : KERNAUX_PANIC(#cond))
#else
#define KERNAUX_PANIC(msg) ((void)0) #define KERNAUX_PANIC(msg) ((void)0)
#define KERNAUX_ASSERT(cond) ((void)0) #define KERNAUX_ASSERT(cond) ((void)0)
#endif
#define KERNAUX_NOTNULL(cond) KERNAUX_ASSERT(cond) #define KERNAUX_NOTNULL(cond) KERNAUX_ASSERT(cond)
#endif #endif

View file

@ -1,17 +0,0 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <kernaux/runtime.h>
#include <stddef.h>
KernAux_Assert_Cb kernaux_assert_cb = NULL;
void kernaux_assert_do(
const char *const file,
const int line,
const char *const msg
) {
if (kernaux_assert_cb) kernaux_assert_cb(file, line, msg);
}

View file

@ -2,25 +2,12 @@
#include "config.h" #include "config.h"
#endif #endif
#include <kernaux/runtime.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
void test_main(int argc, char **argv); void test_main(int argc, char **argv);
static void assert_cb(
const char *const file,
const int line,
const char *const msg
) {
fprintf(stderr, "%s:%d:%s\n", file, line, msg);
abort();
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
kernaux_assert_cb = assert_cb;
test_main(argc, argv); test_main(argc, argv);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }