mirror of
https://github.com/tailix/libclayer.git
synced 2024-11-20 11:06:24 -05:00
Separate libc and libclayer
This commit is contained in:
parent
c06e977c84
commit
881f6ecb5b
25 changed files with 249 additions and 199 deletions
20
.github/workflows/main.yml
vendored
20
.github/workflows/main.yml
vendored
|
@ -83,26 +83,6 @@ jobs:
|
||||||
- name: install
|
- name: install
|
||||||
run: sudo make install
|
run: sudo make install
|
||||||
|
|
||||||
cond:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
packages:
|
|
||||||
- without: 'all'
|
|
||||||
- without: 'io'
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: autogen
|
|
||||||
run: ./autogen.sh
|
|
||||||
- name: configure
|
|
||||||
run: ./configure --enable-checks --without-${{matrix.packages.without}}
|
|
||||||
- name: make
|
|
||||||
run: make
|
|
||||||
- name: check
|
|
||||||
run: make check
|
|
||||||
- name: install
|
|
||||||
run: sudo make install
|
|
||||||
|
|
||||||
freestanding:
|
freestanding:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
19
Makefile.am
19
Makefile.am
|
@ -10,7 +10,18 @@ if ENABLE_CHECKS
|
||||||
SUBDIRS += tests
|
SUBDIRS += tests
|
||||||
endif
|
endif
|
||||||
|
|
||||||
lib_LTLIBRARIES = libclayer.la
|
lib_LTLIBRARIES =
|
||||||
|
|
||||||
|
if ENABLE_LIBCLAYER
|
||||||
|
lib_LTLIBRARIES += libclayer.la
|
||||||
|
libclayer_la_SOURCES = $(common_sources)
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ENABLE_LIBC
|
||||||
|
lib_LTLIBRARIES += libc.la
|
||||||
|
libc_la_SOURCES = $(common_sources)
|
||||||
|
libc_la_CFLAGS = $(AM_CFLAGS) -DLIBCLAYER_NOPREFIX
|
||||||
|
endif
|
||||||
|
|
||||||
if ENABLE_PKG_CONFIG
|
if ENABLE_PKG_CONFIG
|
||||||
pkgconfigdir = @pkgconfdir@
|
pkgconfigdir = @pkgconfdir@
|
||||||
|
@ -21,7 +32,7 @@ endif
|
||||||
# Required files #
|
# Required files #
|
||||||
##################
|
##################
|
||||||
|
|
||||||
libclayer_la_SOURCES = \
|
common_sources = \
|
||||||
src/ctype.c \
|
src/ctype.c \
|
||||||
src/errno.c \
|
src/errno.c \
|
||||||
src/libclayer.c \
|
src/libclayer.c \
|
||||||
|
@ -29,13 +40,13 @@ libclayer_la_SOURCES = \
|
||||||
src/string.c
|
src/string.c
|
||||||
|
|
||||||
if ASM_I386
|
if ASM_I386
|
||||||
libclayer_la_SOURCES += \
|
common_sources += \
|
||||||
src/asm/i386/longjmp.S \
|
src/asm/i386/longjmp.S \
|
||||||
src/asm/i386/setjmp.S
|
src/asm/i386/setjmp.S
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if ASM_X86_64
|
if ASM_X86_64
|
||||||
libclayer_la_SOURCES += \
|
common_sources += \
|
||||||
src/asm/x86_64/longjmp.S \
|
src/asm/x86_64/longjmp.S \
|
||||||
src/asm/x86_64/setjmp.S
|
src/asm/x86_64/setjmp.S
|
||||||
endif
|
endif
|
||||||
|
|
16
configure.ac
16
configure.ac
|
@ -42,7 +42,7 @@ AC_SUBST([PACKAGE_DESCR], ['libc for both hosted and freestanding environments']
|
||||||
|
|
||||||
dnl Features (enabled by default)
|
dnl Features (enabled by default)
|
||||||
AC_ARG_ENABLE([float], AS_HELP_STRING([--disable-float], [disable floating-point arithmetic]))
|
AC_ARG_ENABLE([float], AS_HELP_STRING([--disable-float], [disable floating-point arithmetic]))
|
||||||
AC_ARG_ENABLE([prefix], AS_HELP_STRING([--disable-prefix], [disable name prefix]))
|
AC_ARG_ENABLE([libclayer], AS_HELP_STRING([--disable-libclayer], [install as libclayer]))
|
||||||
AC_ARG_ENABLE([werror], AS_HELP_STRING([--disable-werror], [disable -Werror]))
|
AC_ARG_ENABLE([werror], AS_HELP_STRING([--disable-werror], [disable -Werror]))
|
||||||
|
|
||||||
dnl Features (disabled by default)
|
dnl Features (disabled by default)
|
||||||
|
@ -50,6 +50,7 @@ AC_ARG_ENABLE([freestanding], AS_HELP_STRING([--enable-freestanding], [bui
|
||||||
AC_ARG_ENABLE([checks], AS_HELP_STRING([--enable-checks], [enable usual tests]))
|
AC_ARG_ENABLE([checks], AS_HELP_STRING([--enable-checks], [enable usual tests]))
|
||||||
AC_ARG_ENABLE([checks-all], AS_HELP_STRING([--enable-checks-all], [enable all checks]))
|
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-cppcheck], AS_HELP_STRING([--enable-checks-cppcheck], [enable cppcheck]))
|
||||||
|
AC_ARG_ENABLE([libc], AS_HELP_STRING([--enable-libc], [install as libc]))
|
||||||
|
|
||||||
dnl Features (with parameter)
|
dnl Features (with parameter)
|
||||||
AC_ARG_ENABLE([pkg-config], AS_HELP_STRING([--enable-pkg-config@<:@=PATH@:>@], [install pkg-config files @<:@PATH='${libdir}/pkgconfig'@:>@]))
|
AC_ARG_ENABLE([pkg-config], AS_HELP_STRING([--enable-pkg-config@<:@=PATH@:>@], [install pkg-config files @<:@PATH='${libdir}/pkgconfig'@:>@]))
|
||||||
|
@ -75,7 +76,7 @@ AS_IF([test "$enable_checks_all" = yes], do_enable_checks_all)
|
||||||
|
|
||||||
dnl Features (enabled by default)
|
dnl Features (enabled by default)
|
||||||
AS_IF([test "$enable_float" = no ], [enable_float=no], [enable_float=yes])
|
AS_IF([test "$enable_float" = no ], [enable_float=no], [enable_float=yes])
|
||||||
AS_IF([test "$enable_prefix" = no ], [enable_prefix=no], [enable_prefix=yes])
|
AS_IF([test "$enable_libclayer" = no ], [enable_libclayer=no], [enable_libclayer=yes])
|
||||||
AS_IF([test "$enable_werror" = no ], [enable_werror=no], [enable_werror=yes])
|
AS_IF([test "$enable_werror" = no ], [enable_werror=no], [enable_werror=yes])
|
||||||
|
|
||||||
dnl Features (disabled by default)
|
dnl Features (disabled by default)
|
||||||
|
@ -83,6 +84,7 @@ 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" = 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_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_cppcheck" = yes], [enable_checks_cppcheck=yes], [enable_checks_cppcheck=no])
|
||||||
|
AS_IF([test "$enable_libc" = yes], [enable_libc=yes], [enable_libc=no])
|
||||||
|
|
||||||
dnl Features (with parameter)
|
dnl Features (with parameter)
|
||||||
AS_IF([test "$enable_pkg_config" = yes], [enable_pkg_config='${libdir}/pkgconfig'])
|
AS_IF([test "$enable_pkg_config" = yes], [enable_pkg_config='${libdir}/pkgconfig'])
|
||||||
|
@ -95,7 +97,6 @@ AS_IF([test "$enable_pkg_config" = no ], [enable_pkg_config=''])
|
||||||
#############
|
#############
|
||||||
|
|
||||||
AS_IF([test "$enable_checks" = yes -a "$enable_freestanding" = yes], AC_MSG_ERROR([can not build freestanding tests]))
|
AS_IF([test "$enable_checks" = yes -a "$enable_freestanding" = yes], AC_MSG_ERROR([can not build freestanding tests]))
|
||||||
AS_IF([test "$enable_checks" = yes -a "$enable_prefix" = no ], AC_MSG_ERROR([can not build tests without prefix]))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,13 +114,14 @@ AM_CONDITIONAL([ASM_X86], [test "$host_cpu" = i386 -o "$host_cpu"
|
||||||
|
|
||||||
dnl Features (enabled by default)
|
dnl Features (enabled by default)
|
||||||
AM_CONDITIONAL([ENABLE_FLOAT], [test "$enable_float" = yes])
|
AM_CONDITIONAL([ENABLE_FLOAT], [test "$enable_float" = yes])
|
||||||
AM_CONDITIONAL([ENABLE_PREFIX], [test "$enable_prefix" = yes])
|
AM_CONDITIONAL([ENABLE_LIBCLAYER], [test "$enable_libclayer" = yes])
|
||||||
AM_CONDITIONAL([ENABLE_WERROR], [test "$enable_werror" = yes])
|
AM_CONDITIONAL([ENABLE_WERROR], [test "$enable_werror" = yes])
|
||||||
|
|
||||||
dnl Features (disabled by default)
|
dnl Features (disabled by default)
|
||||||
AM_CONDITIONAL([ENABLE_FREESTANDING], [test "$enable_freestanding" = yes])
|
AM_CONDITIONAL([ENABLE_FREESTANDING], [test "$enable_freestanding" = yes])
|
||||||
AM_CONDITIONAL([ENABLE_CHECKS], [test "$enable_checks" = yes])
|
AM_CONDITIONAL([ENABLE_CHECKS], [test "$enable_checks" = yes])
|
||||||
AM_CONDITIONAL([ENABLE_CHECKS_CPPCHECK], [test "$enable_checks_cppcheck" = yes])
|
AM_CONDITIONAL([ENABLE_CHECKS_CPPCHECK], [test "$enable_checks_cppcheck" = yes])
|
||||||
|
AM_CONDITIONAL([ENABLE_LIBC], [test "$enable_libc" = yes])
|
||||||
|
|
||||||
dnl Features (with parameter)
|
dnl Features (with parameter)
|
||||||
AM_CONDITIONAL([ENABLE_PKG_CONFIG], [test ! -z "$enable_pkg_config"])
|
AM_CONDITIONAL([ENABLE_PKG_CONFIG], [test ! -z "$enable_pkg_config"])
|
||||||
|
@ -141,16 +143,14 @@ AS_IF([test "$host_cpu" = x86_64], [AC_DEFINE([ASM_X86],
|
||||||
|
|
||||||
dnl Features (enabled by default)
|
dnl Features (enabled by default)
|
||||||
AS_IF([test "$enable_float" = yes], [AC_DEFINE([ENABLE_FLOAT], [1], [enabled floating-point arithmetic])])
|
AS_IF([test "$enable_float" = yes], [AC_DEFINE([ENABLE_FLOAT], [1], [enabled floating-point arithmetic])])
|
||||||
AS_IF([test "$enable_prefix" = yes], [AC_DEFINE([ENABLE_PREFIX], [1], [enabled prefix])])
|
AS_IF([test "$enable_libclayer" = yes], [AC_DEFINE([ENABLE_LIBCLAYER], [1], [install as libclayer])])
|
||||||
AS_IF([test "$enable_werror" = yes], [AC_DEFINE([ENABLE_WERROR], [1], [enabled -Werror])])
|
AS_IF([test "$enable_werror" = yes], [AC_DEFINE([ENABLE_WERROR], [1], [enabled -Werror])])
|
||||||
|
|
||||||
dnl Features (disabled by default)
|
dnl Features (disabled by default)
|
||||||
AS_IF([test "$enable_freestanding" = yes], [AC_DEFINE([ENABLE_FREESTANDING], [1], [build for freestanding environment])])
|
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])])
|
AS_IF([test "$enable_checks" = yes], [AC_DEFINE([ENABLE_CHECKS], [1], [enabled usual tests])])
|
||||||
AS_IF([test "$enable_checks_cppcheck" = yes], [AC_DEFINE([ENABLE_CHECKS_CPPCHECK], [1], [enabled cppcheck])])
|
AS_IF([test "$enable_checks_cppcheck" = yes], [AC_DEFINE([ENABLE_CHECKS_CPPCHECK], [1], [enabled cppcheck])])
|
||||||
|
AS_IF([test "$enable_libc" = yes], [AC_DEFINE([ENABLE_LIBC], [1], [install as libc])])
|
||||||
dnl Additional
|
|
||||||
AS_IF([test "$enable_prefix" = yes], [AC_DEFINE([LIBCLAYER_PREFIX], [libclayer_], [prefix])])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,20 @@
|
||||||
nobase_include_HEADERS = \
|
nobase_include_HEADERS = \
|
||||||
|
libclayer.h \
|
||||||
|
libclayer/ctype.h \
|
||||||
|
libclayer/errno.h \
|
||||||
|
libclayer/inttypes.h \
|
||||||
|
libclayer/setjmp.h \
|
||||||
|
libclayer/stdlib.h \
|
||||||
|
libclayer/string.h \
|
||||||
|
libclayer/sys/types.h
|
||||||
|
|
||||||
|
if ENABLE_LIBC
|
||||||
|
nobase_include_HEADERS += \
|
||||||
ctype.h \
|
ctype.h \
|
||||||
errno.h \
|
errno.h \
|
||||||
inttypes.h \
|
inttypes.h \
|
||||||
libclayer.h \
|
|
||||||
setjmp.h \
|
setjmp.h \
|
||||||
stdlib.h \
|
stdlib.h \
|
||||||
string.h \
|
string.h \
|
||||||
sys/types.h
|
sys/types.h
|
||||||
|
endif
|
||||||
|
|
|
@ -1,22 +1,7 @@
|
||||||
#ifndef _CTYPE_H
|
#ifdef LIBCLAYER_NOPREFIX
|
||||||
#define _CTYPE_H 1
|
#include <libclayer/ctype.h>
|
||||||
|
#else
|
||||||
#ifdef __cplusplus
|
#define LIBCLAYER_NOPREFIX
|
||||||
extern "C" {
|
#include <libclayer/ctype.h>
|
||||||
#endif
|
#undef LIBCLAYER_NOPREFIX
|
||||||
|
|
||||||
#include <libclayer.h>
|
|
||||||
|
|
||||||
int LIBCLAYER(isdigit)(int c);
|
|
||||||
int LIBCLAYER(islower)(int c);
|
|
||||||
int LIBCLAYER(isspace)(int c);
|
|
||||||
int LIBCLAYER(isupper)(int c);
|
|
||||||
|
|
||||||
int LIBCLAYER(tolower)(int c);
|
|
||||||
int LIBCLAYER(toupper)(int c);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,18 +1,7 @@
|
||||||
#ifndef _ERRNO_H
|
#ifdef LIBCLAYER_NOPREFIX
|
||||||
#define _ERRNO_H 1
|
#include <libclayer/errno.h>
|
||||||
|
#else
|
||||||
#ifdef __cplusplus
|
#define LIBCLAYER_NOPREFIX
|
||||||
extern "C" {
|
#include <libclayer/errno.h>
|
||||||
#endif
|
#undef LIBCLAYER_NOPREFIX
|
||||||
|
|
||||||
#include <libclayer.h>
|
|
||||||
|
|
||||||
#define ERANGE 1
|
|
||||||
|
|
||||||
extern int LIBCLAYER(errno);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
#ifndef _INTTYPES_H
|
#ifdef LIBCLAYER_NOPREFIX
|
||||||
#define _INTTYPES_H 1
|
#include <libclayer/inttypes.h>
|
||||||
|
#else
|
||||||
#ifdef __cplusplus
|
#define LIBCLAYER_NOPREFIX
|
||||||
extern "C" {
|
#include <libclayer/inttypes.h>
|
||||||
#endif
|
#undef LIBCLAYER_NOPREFIX
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,12 +7,10 @@ extern "C" {
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifndef LIBCLAYER_PREFIX
|
#ifdef LIBCLAYER_NOPREFIX
|
||||||
#define LIBCLAYER(name) name
|
#define LIBCLAYER(name) name
|
||||||
#else
|
#else
|
||||||
#define LIBCLAYER(name) LIBCLAYER2(LIBCLAYER_PREFIX, name)
|
#define LIBCLAYER(name) libclayer_ ## name
|
||||||
#define LIBCLAYER2(prefix, name) LIBCLAYER3(prefix, name)
|
|
||||||
#define LIBCLAYER3(prefix, name) prefix ## name
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct Libclayer {
|
struct Libclayer {
|
||||||
|
|
22
include/libclayer/ctype.h
Normal file
22
include/libclayer/ctype.h
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef _LIBCLAYER_CTYPE_H
|
||||||
|
#define _LIBCLAYER_CTYPE_H 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <libclayer.h>
|
||||||
|
|
||||||
|
int LIBCLAYER(isdigit)(int c);
|
||||||
|
int LIBCLAYER(islower)(int c);
|
||||||
|
int LIBCLAYER(isspace)(int c);
|
||||||
|
int LIBCLAYER(isupper)(int c);
|
||||||
|
|
||||||
|
int LIBCLAYER(tolower)(int c);
|
||||||
|
int LIBCLAYER(toupper)(int c);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
18
include/libclayer/errno.h
Normal file
18
include/libclayer/errno.h
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef _LIBCLAYER_ERRNO_H
|
||||||
|
#define _LIBCLAYER_ERRNO_H 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <libclayer.h>
|
||||||
|
|
||||||
|
#define ERANGE 1
|
||||||
|
|
||||||
|
extern int LIBCLAYER(errno);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
12
include/libclayer/inttypes.h
Normal file
12
include/libclayer/inttypes.h
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef _LIBCLAYER_INTTYPES_H
|
||||||
|
#define _LIBCLAYER_INTTYPES_H 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
26
include/libclayer/setjmp.h
Normal file
26
include/libclayer/setjmp.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef _LIBCLAYER_SETJMP_H
|
||||||
|
#define _LIBCLAYER_SETJMP_H 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <libclayer.h>
|
||||||
|
|
||||||
|
// TODO: define in architecture-specific header
|
||||||
|
typedef unsigned long __jmp_buf[sizeof(long) == 8 ? 8 : 6];
|
||||||
|
|
||||||
|
typedef struct __jmp_buf_tag {
|
||||||
|
__jmp_buf __jb;
|
||||||
|
unsigned long __fl;
|
||||||
|
unsigned long __ss[128 / sizeof(long)];
|
||||||
|
} jmp_buf[1];
|
||||||
|
|
||||||
|
int LIBCLAYER(setjmp)(jmp_buf env) __attribute__((returns_twice));
|
||||||
|
void LIBCLAYER(longjmp)(jmp_buf env, int val) __attribute__((noreturn));
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
28
include/libclayer/stdlib.h
Normal file
28
include/libclayer/stdlib.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef _LIBCLAYER_STDLIB_H
|
||||||
|
#define _LIBCLAYER_STDLIB_H 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <libclayer.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#define EXIT_SUCCESS 0
|
||||||
|
#define EXIT_FAILURE 1
|
||||||
|
|
||||||
|
int LIBCLAYER(atoi)(const char *str);
|
||||||
|
|
||||||
|
void LIBCLAYER(abort)() __attribute__((noreturn));
|
||||||
|
void LIBCLAYER(exit)(int status) __attribute__((noreturn));
|
||||||
|
|
||||||
|
void *LIBCLAYER(calloc)(size_t nmemb, size_t size);
|
||||||
|
void LIBCLAYER(free)(void *ptr);
|
||||||
|
void *LIBCLAYER(malloc)(size_t size);
|
||||||
|
void *LIBCLAYER(realloc)(void *ptr, size_t size);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
38
include/libclayer/string.h
Normal file
38
include/libclayer/string.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#ifndef _LIBCLAYER_STRING_H
|
||||||
|
#define _LIBCLAYER_STRING_H 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <libclayer.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
// mem*
|
||||||
|
int LIBCLAYER(memcmp)(const void *s1, const void *s2, size_t n);
|
||||||
|
void *LIBCLAYER(memcpy)(void *dest, const void *src, size_t n);
|
||||||
|
void *LIBCLAYER(memmove)(void *dest, const void *src, size_t n);
|
||||||
|
void *LIBCLAYER(memchr)(const void *s, int c, size_t n);
|
||||||
|
void *LIBCLAYER(memset)(void *s, int c, size_t n);
|
||||||
|
|
||||||
|
// str*
|
||||||
|
char *LIBCLAYER(strcat)(char *dest, const char *src);
|
||||||
|
char *LIBCLAYER(strchr)(const char *s, int c);
|
||||||
|
int LIBCLAYER(strcmp)(const char *s1, const char *s2);
|
||||||
|
char *LIBCLAYER(strcpy)(char *dest, const char *src);
|
||||||
|
size_t LIBCLAYER(strlen)(const char *s);
|
||||||
|
|
||||||
|
// strn*
|
||||||
|
char *LIBCLAYER(strncat)(char *dest, const char *src, size_t n);
|
||||||
|
int LIBCLAYER(strncmp)(const char *s1, const char *s2, size_t n);
|
||||||
|
char *LIBCLAYER(strncpy)(char *dest, const char *src, size_t n);
|
||||||
|
size_t LIBCLAYER(strnlen)(const char *s, size_t maxlen);
|
||||||
|
|
||||||
|
// str*
|
||||||
|
char *LIBCLAYER(strstr)(const char *haystack, const char *needle);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
12
include/libclayer/sys/types.h
Normal file
12
include/libclayer/sys/types.h
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef _SYS_TYPES_H
|
||||||
|
#define _SYS_TYPES_H 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,26 +1,7 @@
|
||||||
#ifndef _SETJMP_H
|
#ifdef LIBCLAYER_NOPREFIX
|
||||||
#define _SETJMP_H 1
|
#include <libclayer/setjmp.h>
|
||||||
|
#else
|
||||||
#ifdef __cplusplus
|
#define LIBCLAYER_NOPREFIX
|
||||||
extern "C" {
|
#include <libclayer/setjmp.h>
|
||||||
#endif
|
#undef LIBCLAYER_NOPREFIX
|
||||||
|
|
||||||
#include <libclayer.h>
|
|
||||||
|
|
||||||
// TODO: define in architecture-specific header
|
|
||||||
typedef unsigned long __jmp_buf[sizeof(long) == 8 ? 8 : 6];
|
|
||||||
|
|
||||||
typedef struct __jmp_buf_tag {
|
|
||||||
__jmp_buf __jb;
|
|
||||||
unsigned long __fl;
|
|
||||||
unsigned long __ss[128 / sizeof(long)];
|
|
||||||
} jmp_buf[1];
|
|
||||||
|
|
||||||
int LIBCLAYER(setjmp)(jmp_buf env) __attribute__((returns_twice));
|
|
||||||
void LIBCLAYER(longjmp)(jmp_buf env, int val) __attribute__((noreturn));
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,28 +1,7 @@
|
||||||
#ifndef _STDLIB_H
|
#ifdef LIBCLAYER_NOPREFIX
|
||||||
#define _STDLIB_H 1
|
#include <libclayer/stdlib.h>
|
||||||
|
#else
|
||||||
#ifdef __cplusplus
|
#define LIBCLAYER_NOPREFIX
|
||||||
extern "C" {
|
#include <libclayer/stdlib.h>
|
||||||
#endif
|
#undef LIBCLAYER_NOPREFIX
|
||||||
|
|
||||||
#include <libclayer.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#define EXIT_SUCCESS 0
|
|
||||||
#define EXIT_FAILURE 1
|
|
||||||
|
|
||||||
int LIBCLAYER(atoi)(const char *str);
|
|
||||||
|
|
||||||
void LIBCLAYER(abort)() __attribute__((noreturn));
|
|
||||||
void LIBCLAYER(exit)(int status) __attribute__((noreturn));
|
|
||||||
|
|
||||||
void *LIBCLAYER(calloc)(size_t nmemb, size_t size);
|
|
||||||
void LIBCLAYER(free)(void *ptr);
|
|
||||||
void *LIBCLAYER(malloc)(size_t size);
|
|
||||||
void *LIBCLAYER(realloc)(void *ptr, size_t size);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,38 +1,7 @@
|
||||||
#ifndef _STRING_H
|
#ifdef LIBCLAYER_NOPREFIX
|
||||||
#define _STRING_H 1
|
#include <libclayer/string.h>
|
||||||
|
#else
|
||||||
#ifdef __cplusplus
|
#define LIBCLAYER_NOPREFIX
|
||||||
extern "C" {
|
#include <libclayer/string.h>
|
||||||
#endif
|
#undef LIBCLAYER_NOPREFIX
|
||||||
|
|
||||||
#include <libclayer.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
// mem*
|
|
||||||
int LIBCLAYER(memcmp)(const void *s1, const void *s2, size_t n);
|
|
||||||
void *LIBCLAYER(memcpy)(void *dest, const void *src, size_t n);
|
|
||||||
void *LIBCLAYER(memmove)(void *dest, const void *src, size_t n);
|
|
||||||
void *LIBCLAYER(memchr)(const void *s, int c, size_t n);
|
|
||||||
void *LIBCLAYER(memset)(void *s, int c, size_t n);
|
|
||||||
|
|
||||||
// str*
|
|
||||||
char *LIBCLAYER(strcat)(char *dest, const char *src);
|
|
||||||
char *LIBCLAYER(strchr)(const char *s, int c);
|
|
||||||
int LIBCLAYER(strcmp)(const char *s1, const char *s2);
|
|
||||||
char *LIBCLAYER(strcpy)(char *dest, const char *src);
|
|
||||||
size_t LIBCLAYER(strlen)(const char *s);
|
|
||||||
|
|
||||||
// strn*
|
|
||||||
char *LIBCLAYER(strncat)(char *dest, const char *src, size_t n);
|
|
||||||
int LIBCLAYER(strncmp)(const char *s1, const char *s2, size_t n);
|
|
||||||
char *LIBCLAYER(strncpy)(char *dest, const char *src, size_t n);
|
|
||||||
size_t LIBCLAYER(strnlen)(const char *s, size_t maxlen);
|
|
||||||
|
|
||||||
// str*
|
|
||||||
char *LIBCLAYER(strstr)(const char *haystack, const char *needle);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
#ifndef _SYS_TYPES_H
|
#ifdef LIBCLAYER_NOPREFIX
|
||||||
#define _SYS_TYPES_H 1
|
#include <libclayer/sys/types.h>
|
||||||
|
#else
|
||||||
#ifdef __cplusplus
|
#define LIBCLAYER_NOPREFIX
|
||||||
extern "C" {
|
#include <libclayer/sys/types.h>
|
||||||
#endif
|
#undef LIBCLAYER_NOPREFIX
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,7 +13,6 @@ CPPCHECK_ARGS = \
|
||||||
--error-exitcode=1 \
|
--error-exitcode=1 \
|
||||||
--std=c99 \
|
--std=c99 \
|
||||||
--inline-suppr \
|
--inline-suppr \
|
||||||
-ULIBCLAYER_PREFIX \
|
|
||||||
--enable=warning,style,performance,portability
|
--enable=warning,style,performance,portability
|
||||||
|
|
||||||
CPPCHECK_INC = \
|
CPPCHECK_INC = \
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <libclayer/ctype.h>
|
||||||
|
|
||||||
int LIBCLAYER(isdigit)(const int c)
|
int LIBCLAYER(isdigit)(const int c)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <errno.h>
|
#include <libclayer/errno.h>
|
||||||
|
|
||||||
int LIBCLAYER(errno) = 0;
|
int LIBCLAYER(errno) = 0;
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <libclayer.h>
|
#include <libclayer.h>
|
||||||
|
#include <libclayer/ctype.h>
|
||||||
|
#include <libclayer/stdlib.h>
|
||||||
|
#include <libclayer/string.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
void LIBCLAYER(exit)(const int status)
|
void LIBCLAYER(exit)(const int status)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <libclayer/string.h>
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
int LIBCLAYER(memcmp)(const void *s1, const void *s2, size_t n)
|
int LIBCLAYER(memcmp)(const void *s1, const void *s2, size_t n)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
#include <libclayer/string.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
void test_main()
|
void test_main()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue