feat(profile): generate installed features.h exposing VLIBC_LEVEL
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <[email protected]>
This commit is contained in:
@@ -85,6 +85,9 @@ Makefile.in
|
||||
/build-aux/
|
||||
/m4/
|
||||
|
||||
# Generated feature header (from include/vlibc/features.h.in); the template is tracked.
|
||||
/include/vlibc/features.h
|
||||
|
||||
# Libtool build directories and artifacts.
|
||||
.deps/
|
||||
.libs/
|
||||
|
||||
@@ -116,6 +116,7 @@ AS_CASE([$vlibc_profile],
|
||||
[vlibc], [AC_DEFINE([VLIBC_PROFILE_VLIBC], [1], [vlibc (glibc-ext) profile])])
|
||||
|
||||
AC_SUBST([vlibc_profile])
|
||||
AC_SUBST([vlibc_level])
|
||||
|
||||
# ---- Install method ------------------------------------------------------
|
||||
# "alongside" installs vlibc next to the system libc: headers and libraries go
|
||||
@@ -168,6 +169,7 @@ LT_INIT
|
||||
|
||||
AC_CONFIG_FILES([Makefile
|
||||
benchmarks/Makefile
|
||||
include/vlibc/features.h
|
||||
tools/vlibc-gcc
|
||||
tools/vlibc-clang])
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#ifndef VLIBC_FEATURES_H
|
||||
#define VLIBC_FEATURES_H
|
||||
|
||||
/*
|
||||
* vlibc — compatibility feature gate.
|
||||
*
|
||||
* This header is generated by configure from include/vlibc/features.h.in; do
|
||||
* not edit the generated file. It exposes the active compatibility profile as
|
||||
* build-time constants, so headers and sources can gate declarations on the
|
||||
* profile level (see configure.ac and docs/compatibility.md):
|
||||
*
|
||||
* 1 onlyposix pure POSIX, nothing more
|
||||
* 2 muslmimic musl-like, light
|
||||
* 3 muslext musl-extended
|
||||
* 4 spoof glibc replica (drop-in compatibility)
|
||||
* 5 vlibc glibc-extended, the default
|
||||
*
|
||||
* VLIBC_LEVEL is the numeric level (1..5); VLIBC_PROFILE is the profile name.
|
||||
* Both are emitted only when not already defined: the library's own sources
|
||||
* include config.h first (via HAVE_CONFIG_H), whose values win, and this
|
||||
* header skips the redefinition. Consumers of the installed header get the
|
||||
* values baked in at configure time.
|
||||
*/
|
||||
|
||||
#ifndef VLIBC_LEVEL
|
||||
#define VLIBC_LEVEL @vlibc_level@
|
||||
#endif
|
||||
|
||||
#ifndef VLIBC_PROFILE
|
||||
#define VLIBC_PROFILE "@vlibc_profile@"
|
||||
#endif
|
||||
|
||||
/* True when the active profile is at least level n. */
|
||||
#define VLIBC_LEVEL_GE(n) (VLIBC_LEVEL >= (n))
|
||||
|
||||
/*
|
||||
* Per-profile feature booleans, derived from VLIBC_LEVEL. Levels are
|
||||
* cumulative: level 3 implies the POSIX and musl feature sets as well. A
|
||||
* macro is defined (as 1) when its feature set is present and left undefined
|
||||
* otherwise, so `#if VLIBC_HAS_MUSL` works in both cases.
|
||||
*/
|
||||
#if VLIBC_LEVEL >= 1
|
||||
#define VLIBC_HAS_POSIX 1
|
||||
#endif
|
||||
#if VLIBC_LEVEL >= 2
|
||||
#define VLIBC_HAS_MUSL 1
|
||||
#endif
|
||||
#if VLIBC_LEVEL >= 3
|
||||
#define VLIBC_HAS_MUSLEXT 1
|
||||
#endif
|
||||
#if VLIBC_LEVEL >= 4
|
||||
#define VLIBC_HAS_GLIBC 1
|
||||
#endif
|
||||
#if VLIBC_LEVEL >= 5
|
||||
#define VLIBC_HAS_VLIBC 1
|
||||
#endif
|
||||
|
||||
#endif /* VLIBC_FEATURES_H */
|
||||
Reference in New Issue
Block a user