portability: implement skeleton with memrchr function
parent
9ed4785f1c
commit
a7a0c0a6ca
|
@ -33,6 +33,7 @@ add_project_arguments('-D_FILE_OFFSET_BITS=64', language: 'c')
|
||||||
subproject = meson.is_subproject()
|
subproject = meson.is_subproject()
|
||||||
|
|
||||||
subdir('doc')
|
subdir('doc')
|
||||||
|
subdir('portability')
|
||||||
subdir('libfetch')
|
subdir('libfetch')
|
||||||
subdir('src')
|
subdir('src')
|
||||||
subdir('tests')
|
subdir('tests')
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
void *memrchr(const void *m, int c, size_t n)
|
||||||
|
{
|
||||||
|
const unsigned char *s = m;
|
||||||
|
c = (unsigned char)c;
|
||||||
|
while (n--) if (s[n]==c) return (void *)(s+n);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
cc = meson.get_compiler('c')
|
||||||
|
|
||||||
|
|
||||||
|
libportability_src = []
|
||||||
|
|
||||||
|
|
||||||
|
check_functions = [
|
||||||
|
['memrchr', 'memrchr.c', 'NEED_MEMRCHR', 'string.h'],
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
foreach f : check_functions
|
||||||
|
if not cc.has_function(f.get(0), prefix: '#include <' + f.get(3) + '>', args: ['-D_GNU_SOURCE']) or not cc.has_header_symbol(f.get(3), f.get(0), args: ['-D_GNU_SOURCE'])
|
||||||
|
add_project_arguments('-D' + f.get(2), language: 'c')
|
||||||
|
libportability_src += [f.get(1)]
|
||||||
|
endif
|
||||||
|
endforeach
|
||||||
|
|
||||||
|
|
||||||
|
if libportability_src.length() > 0
|
||||||
|
libportability = static_library(
|
||||||
|
'portability',
|
||||||
|
libportability_src,
|
||||||
|
dependencies: static_deps,
|
||||||
|
)
|
||||||
|
|
||||||
|
libportability_dep = declare_dependency(
|
||||||
|
link_whole: libportability,
|
||||||
|
include_directories: include_directories('.'),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
libportability_dep = declare_dependency(
|
||||||
|
include_directories: include_directories('.'),
|
||||||
|
)
|
||||||
|
endif
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include_next <string.h>
|
||||||
|
|
||||||
|
#ifdef NEED_MEMRCHR
|
||||||
|
extern void *memrchr(const void *m, int c, size_t n);
|
||||||
|
#endif
|
|
@ -117,6 +117,7 @@ libapk_shared = shared_library(
|
||||||
install: not subproject,
|
install: not subproject,
|
||||||
dependencies: [
|
dependencies: [
|
||||||
libfetch_dep,
|
libfetch_dep,
|
||||||
|
libportability_dep,
|
||||||
shared_deps,
|
shared_deps,
|
||||||
],
|
],
|
||||||
c_args: apk_cargs,
|
c_args: apk_cargs,
|
||||||
|
@ -128,6 +129,7 @@ libapk_static = static_library(
|
||||||
install: not subproject,
|
install: not subproject,
|
||||||
dependencies: [
|
dependencies: [
|
||||||
libfetch_dep,
|
libfetch_dep,
|
||||||
|
libportability_dep,
|
||||||
static_deps,
|
static_deps,
|
||||||
],
|
],
|
||||||
c_args: [apk_cargs, '-DOPENSSL_NO_ENGINE'],
|
c_args: [apk_cargs, '-DOPENSSL_NO_ENGINE'],
|
||||||
|
@ -158,7 +160,12 @@ if(lua_dep.found())
|
||||||
libluaapk = library(
|
libluaapk = library(
|
||||||
'luaapk',
|
'luaapk',
|
||||||
luaapk_src,
|
luaapk_src,
|
||||||
dependencies: [lua_dep, libapk_dep, shared_deps],
|
dependencies: [
|
||||||
|
lua_dep,
|
||||||
|
libapk_dep,
|
||||||
|
shared_deps,
|
||||||
|
libportability_dep.partial_dependency(includes: true),
|
||||||
|
],
|
||||||
install: true,
|
install: true,
|
||||||
install_dir: lua_dep.get_pkgconfig_variable('libdir'),
|
install_dir: lua_dep.get_pkgconfig_variable('libdir'),
|
||||||
c_args: apk_cargs,
|
c_args: apk_cargs,
|
||||||
|
@ -173,6 +180,7 @@ apk_exe = executable(
|
||||||
libapk_dep,
|
libapk_dep,
|
||||||
shared_deps,
|
shared_deps,
|
||||||
libfetch_dep.partial_dependency(includes: true),
|
libfetch_dep.partial_dependency(includes: true),
|
||||||
|
libportability_dep.partial_dependency(includes: true),
|
||||||
],
|
],
|
||||||
c_args: apk_cargs,
|
c_args: apk_cargs,
|
||||||
)
|
)
|
||||||
|
@ -185,6 +193,7 @@ if get_option('static_apk')
|
||||||
dependencies: [
|
dependencies: [
|
||||||
static_deps,
|
static_deps,
|
||||||
libfetch_dep.partial_dependency(includes: true),
|
libfetch_dep.partial_dependency(includes: true),
|
||||||
|
libportability_dep.partial_dependency(includes: true),
|
||||||
],
|
],
|
||||||
link_with: libapk_static,
|
link_with: libapk_static,
|
||||||
c_args: [apk_cargs, '-DOPENSSL_NO_ENGINE'],
|
c_args: [apk_cargs, '-DOPENSSL_NO_ENGINE'],
|
||||||
|
|
Loading…
Reference in New Issue