mirror of
https://github.com/tailix/libclayer.git
synced 2024-11-20 11:06:24 -05:00
Remove pthreads
This commit is contained in:
parent
048969c1db
commit
461ed5dc53
6 changed files with 4 additions and 105 deletions
8
.github/workflows/main.yml
vendored
8
.github/workflows/main.yml
vendored
|
@ -34,7 +34,7 @@ jobs:
|
|||
- name: autogen
|
||||
run: ./autogen.sh
|
||||
- name: configure
|
||||
run: ./configure ${{matrix.assert}} --enable-checks --enable-checks-pthreads --enable-checks-python CC='${{matrix.cc}}' CFLAGS='${{matrix.opt}}'
|
||||
run: ./configure ${{matrix.assert}} --enable-checks --enable-checks-python CC='${{matrix.cc}}' CFLAGS='${{matrix.opt}}'
|
||||
- name: make
|
||||
run: make
|
||||
- name: check
|
||||
|
@ -76,7 +76,7 @@ jobs:
|
|||
- name: autogen
|
||||
run: ./autogen.sh
|
||||
- name: configure
|
||||
run: ./configure --host='${{matrix.cross.arch}}-unknown-elf' --enable-checks --enable-checks-pthreads --enable-checks-python CC='${{matrix.cross.cprefix}}gcc'
|
||||
run: ./configure --host='${{matrix.cross.arch}}-unknown-elf' --enable-checks --enable-checks-python CC='${{matrix.cross.cprefix}}gcc'
|
||||
- name: make
|
||||
run: make
|
||||
- name: check
|
||||
|
@ -100,7 +100,7 @@ jobs:
|
|||
- name: autogen
|
||||
run: ./autogen.sh
|
||||
- name: configure
|
||||
run: ./configure --enable-checks --enable-checks-pthreads --enable-checks-python --without-${{matrix.packages.without}} ${{matrix.packages.dependencies}}
|
||||
run: ./configure --enable-checks --enable-checks-python --without-${{matrix.packages.without}} ${{matrix.packages.dependencies}}
|
||||
- name: make
|
||||
run: make
|
||||
- name: check
|
||||
|
@ -139,7 +139,7 @@ jobs:
|
|||
- name: extract
|
||||
run: tar -xzf "libkernaux-$(cat VERSION).tar.gz"
|
||||
- name: configure
|
||||
run: cd "libkernaux-$(cat VERSION)" && ./configure --enable-checks --enable-checks-pthreads --enable-checks-python
|
||||
run: cd "libkernaux-$(cat VERSION)" && ./configure --enable-checks --enable-checks-python
|
||||
- name: make
|
||||
run: cd "libkernaux-$(cat VERSION)" && make
|
||||
- name: check
|
||||
|
|
|
@ -54,7 +54,6 @@ zero). Work-in-progress APIs can change at any time.
|
|||
* [Memory allocator](/include/kernaux/generic/malloc.h) (*non-breaking since* **0.5.0**)
|
||||
* [Example](/examples/generic_malloc.c)
|
||||
* [Mutex](/include/kernaux/generic/mutex.h) (*non-breaking since* **0.5.0**)
|
||||
* [Example](/examples/generic_mutex.c)
|
||||
* Algorithms
|
||||
* [Free list memory allocator](/include/kernaux/free_list.h) (*non-breaking since* **0.5.0**)
|
||||
* [Simple command line parser](/include/kernaux/cmdline.h) (*non-breaking since* **0.2.0**)
|
||||
|
@ -136,7 +135,6 @@ stable options.
|
|||
* `--enable-checks` - enable usual tests and examples
|
||||
* `--enable-checks-all` - enable all checks
|
||||
* `--enable-checks-cppcheck` - enable cppcheck
|
||||
* `--enable-checks-pthreads` - enable tests that require pthreads
|
||||
* `--enable-checks-python` - enable tests that require Python 3 with YAML and
|
||||
Jinja2
|
||||
* `--enable-pkg-config[=PATH]` - install pkg-config files
|
||||
|
|
|
@ -57,7 +57,6 @@ AC_ARG_ENABLE([freestanding], AS_HELP_STRING([--enable-freestanding], [bui
|
|||
AC_ARG_ENABLE([checks], AS_HELP_STRING([--enable-checks], [enable usual tests and examples]))
|
||||
AC_ARG_ENABLE([checks-all], AS_HELP_STRING([--enable-checks-all], [enable all checks]))
|
||||
AC_ARG_ENABLE([checks-cppcheck], AS_HELP_STRING([--enable-checks-cppcheck], [enable cppcheck]))
|
||||
AC_ARG_ENABLE([checks-pthreads], AS_HELP_STRING([--enable-checks-pthreads], [enable tests that require pthreads]))
|
||||
AC_ARG_ENABLE([checks-python], AS_HELP_STRING([--enable-checks-python], [enable tests that require Python 3 with YAML and Jinja2]))
|
||||
AC_ARG_ENABLE([split-libc], AS_HELP_STRING([--enable-split-libc], [split off libc]))
|
||||
|
||||
|
@ -96,7 +95,6 @@ AC_DEFUN([do_enable_checks_all],
|
|||
[
|
||||
if test -z "$enable_checks"; then enable_checks=yes; fi
|
||||
if test -z "$enable_checks_cppcheck"; then enable_checks_cppcheck=yes; fi
|
||||
if test -z "$enable_checks_pthreads"; then enable_checks_pthreads=yes; fi
|
||||
if test -z "$enable_checks_python"; then enable_checks_python=yes; fi
|
||||
])
|
||||
AS_IF([test "$enable_checks_all" = yes], do_enable_checks_all)
|
||||
|
@ -145,7 +143,6 @@ AS_IF([test "$enable_freestanding" = yes], [enable_freestanding=yes], [ena
|
|||
AS_IF([test "$enable_checks" = yes], [enable_checks=yes], [enable_checks=no])
|
||||
AS_IF([test "$enable_checks_all" = yes], [enable_checks_all=yes], [enable_checks_all=no])
|
||||
AS_IF([test "$enable_checks_cppcheck" = yes], [enable_checks_cppcheck=yes], [enable_checks_cppcheck=no])
|
||||
AS_IF([test "$enable_checks_pthreads" = yes], [enable_checks_pthreads=yes], [enable_checks_pthreads=no])
|
||||
AS_IF([test "$enable_checks_python" = yes], [enable_checks_python=yes], [enable_checks_python=no])
|
||||
AS_IF([test "$enable_split_libc" = yes], [enable_split_libc=yes], [enable_split_libc=no])
|
||||
|
||||
|
@ -211,7 +208,6 @@ dnl Features (disabled by default)
|
|||
AM_CONDITIONAL([ENABLE_FREESTANDING], [test "$enable_freestanding" = yes])
|
||||
AM_CONDITIONAL([ENABLE_CHECKS], [test "$enable_checks" = yes])
|
||||
AM_CONDITIONAL([ENABLE_CHECKS_CPPCHECK], [test "$enable_checks_cppcheck" = yes])
|
||||
AM_CONDITIONAL([ENABLE_CHECKS_PTHREADS], [test "$enable_checks_pthreads" = yes])
|
||||
AM_CONDITIONAL([ENABLE_CHECKS_PYTHON], [test "$enable_checks_python" = yes])
|
||||
AM_CONDITIONAL([ENABLE_SPLIT_LIBC], [test "$enable_split_libc" = yes])
|
||||
|
||||
|
@ -265,7 +261,6 @@ dnl Features (disabled by default)
|
|||
AS_IF([test "$enable_freestanding" = yes], [AC_DEFINE([ENABLE_FREESTANDING], [1], [build for freestanding environment])])
|
||||
AS_IF([test "$enable_checks" = yes], [AC_DEFINE([ENABLE_CHECKS], [1], [enabled usual tests and examples])])
|
||||
AS_IF([test "$enable_checks_cppcheck" = yes], [AC_DEFINE([ENABLE_CHECKS_CPPCHECK], [1], [enabled cppcheck])])
|
||||
AS_IF([test "$enable_checks_pthreads" = yes], [AC_DEFINE([ENABLE_CHECKS_PTHREADS], [1], [enabled tests that require pthreads])])
|
||||
AS_IF([test "$enable_checks_python" = yes], [AC_DEFINE([ENABLE_CHECKS_PYTHON], [1], [enabled tests that require Python 3 with YAML and Jinja2])])
|
||||
AS_IF([test "$enable_split_libc" = yes], [AC_DEFINE([ENABLE_SPLIT_LIBC], [1], [split off libc])])
|
||||
|
||||
|
@ -350,10 +345,6 @@ AS_IF([test "$enable_checks" = yes],
|
|||
[AC_CHECK_HEADERS([assert.h setjmp.h stdio.h stdlib.h string.h],,
|
||||
[AC_MSG_ERROR([the headers are required])])])
|
||||
|
||||
AS_IF([test "$enable_checks" = yes -a "$enable_checks_pthreads" = yes],
|
||||
[AC_CHECK_HEADERS([pthread.h],,
|
||||
[AC_MSG_ERROR([the header is required])])])
|
||||
|
||||
AM_PATH_PYTHON([3.8],, [:])
|
||||
AS_IF([test "$enable_checks_python" = yes -a "$enable_checks" = yes -a "$PYTHON" = ':'],
|
||||
[AC_MSG_ERROR([Python is required])])
|
||||
|
|
1
examples/.gitignore
vendored
1
examples/.gitignore
vendored
|
@ -1,7 +1,6 @@
|
|||
/cmdline
|
||||
/generic_display
|
||||
/generic_malloc
|
||||
/generic_mutex
|
||||
/macro_bits
|
||||
/macro_cast
|
||||
/macro_container_of
|
||||
|
|
|
@ -29,16 +29,6 @@ TESTS += generic_malloc
|
|||
generic_malloc_LDADD = $(top_builddir)/libkernaux.la
|
||||
generic_malloc_SOURCES = main.c generic_malloc.c
|
||||
|
||||
#################
|
||||
# generic_mutex #
|
||||
#################
|
||||
|
||||
if ENABLE_CHECKS_PTHREADS
|
||||
TESTS += generic_mutex
|
||||
generic_mutex_LDADD = $(top_builddir)/libkernaux.la
|
||||
generic_mutex_SOURCES = main.c generic_mutex.c
|
||||
endif
|
||||
|
||||
##############
|
||||
# macro_bits #
|
||||
##############
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
//============
|
||||
// my_mutex.c
|
||||
//============
|
||||
|
||||
// To not always use macro "KERNAUX_PROTECTED_FIELD" around the names of
|
||||
// structure fields you may define "KERNAUX_ACCESS_PROTECTED" before including
|
||||
// any other headers, but ONLY in the file where you implement a generic type.
|
||||
//
|
||||
#define KERNAUX_ACCESS_PROTECTED
|
||||
|
||||
//============
|
||||
// my_mutex.h
|
||||
//============
|
||||
|
||||
#include <kernaux/generic/mutex.h>
|
||||
#include <pthread.h>
|
||||
|
||||
typedef struct MyMutex {
|
||||
struct KernAux_Mutex mutex;
|
||||
pthread_mutex_t pthread_mutex;
|
||||
} *MyMutex;
|
||||
|
||||
struct MyMutex MyMytex_create();
|
||||
|
||||
//============
|
||||
// my_mutex.c
|
||||
//============
|
||||
|
||||
#include <kernaux/generic/mutex.h>
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void MyMutex_lock (void *mutex);
|
||||
static void MyMutex_unlock(void *mutex);
|
||||
|
||||
struct MyMutex MyMutex_create()
|
||||
{
|
||||
struct MyMutex my_mutex = {
|
||||
.mutex = {
|
||||
.lock = MyMutex_lock,
|
||||
.unlock = MyMutex_unlock,
|
||||
},
|
||||
};
|
||||
if (pthread_mutex_init(&my_mutex.pthread_mutex, NULL) != 0) abort();
|
||||
return my_mutex;
|
||||
}
|
||||
|
||||
void MyMutex_lock(void *const mutex)
|
||||
{
|
||||
const MyMutex my_mutex = mutex;
|
||||
pthread_mutex_lock(&my_mutex->pthread_mutex);
|
||||
}
|
||||
|
||||
void MyMutex_unlock(void *const mutex)
|
||||
{
|
||||
const MyMutex my_mutex = mutex;
|
||||
pthread_mutex_unlock(&my_mutex->pthread_mutex);
|
||||
}
|
||||
|
||||
//========
|
||||
// main.c
|
||||
//========
|
||||
|
||||
static int shared_counter = 0;
|
||||
|
||||
void example_main()
|
||||
{
|
||||
// Create mutex
|
||||
struct MyMutex my_mutex = MyMutex_create();
|
||||
|
||||
// Lock mutex
|
||||
KernAux_Mutex_lock(&my_mutex.mutex);
|
||||
|
||||
// Access shared data
|
||||
++shared_counter;
|
||||
|
||||
// Unlock mutex
|
||||
KernAux_Mutex_unlock(&my_mutex.mutex);
|
||||
}
|
Loading…
Reference in a new issue