diff options
author | Ayrton Munoz <ayrton@google.com> | 2022-10-25 18:45:15 -0400 |
---|---|---|
committer | Ayrton Munoz <ayrton@google.com> | 2022-10-28 23:50:55 -0400 |
commit | 4633fc72d113c9631cbc608118ed011cf5bd114f (patch) | |
tree | 4ef02adf4443c0dedf59eae81fa28c85ba6413b4 /lib | |
parent | 2e2bdc689d6306a3d1e61dadc0a11b0cda783ed3 (diff) | |
download | common-4633fc72d113c9631cbc608118ed011cf5bd114f.tar.gz |
lib/libc: Add option to replace LK libc with musl
This commit adds an LK_LIBC_IMPLEMENTATION build flag that
can be set to `musl` or `lk` to select the kernel's libc.
The default (musl) is set in engine.mk to allow projects
that want to keep using lk to override it. This is also
required to allow conditionally building tests in
kerneltests-inc.mk as libc-trusty/test only compiles with
musl (LK libc is missing many headers and function
definitions). When a libc module is selected in
kernel/rules.mk we also define an
LK_LIBC_IMPLEMENTATION_IS_[LK,MUSL] macro to allow
conditionally compiling code based on which libc is used if
it's necessary.
This commit also moves off_t and ssize_t from lk/types.h to
LK's sys/types.h to only keep the LK definitions (which
differ from musl on some archs) when using LK libc. It also
includes inttypes.h in lk/types.h (used by both musl and
LK) to allow using the PRI macros it defines.
Bug: 230134581
Change-Id: I7a6c4b6d50d206241775e83961ee166689906515
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/include/sys/types.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/libc/include/sys/types.h b/lib/libc/include/sys/types.h new file mode 100644 index 00000000..a897589a --- /dev/null +++ b/lib/libc/include/sys/types.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022, Google, Inc. All rights reserved + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#pragma once + +#include <lk/types.h> + +/* LK and musl have different definitions for these types so only keep the old + * definitions when building with LK libc. */ +typedef long long off_t; +typedef signed long int ssize_t; |