cross-build: Define __*int*_t and include sys/cdefs.h

FreeBSD assumes that sys/types.h includes sys/cdefs.h, so add it here.
FreeBSD also needs __*int*_t defined for software we bootstrap (a lot of
it). GLIBC defines these, but musl does not, so we have to define them
here, even though it looks backwards. There's no good #define to key off
of, so use !defined GLIBC since on Linux defacto there's only two libc
implementations.

Co-authored-by:		Val Packett <val@packett.cool>
Sponsored by:		Netflix
Pull Request:		https://github.com/freebsd/freebsd-src/pull/1066
Reviewed by:		val_packett.cool
Differential Revision:	https://reviews.freebsd.org/D45354
This commit is contained in:
Warner Losh 2024-05-26 11:39:18 -06:00
parent 27326f895e
commit 3c5f0da510

View File

@ -35,6 +35,27 @@
*/
#pragma once
#include <sys/cdefs.h> /* FreeBSD source assumes sys/types.h includes this */
/*
* MUSL doesn't define the __intXX_t that FreeBSD does, but many of our headers
* assume that will always be present. Define them here. We assume !defined
* __GLIBC__ is musl since musl doesn't have a define to key off of. Thesee
* typedefs look backwards, but it's not circular because MUSL never defines the
* __*int*_t. Also, we don't have to work in the kernel, so it's OK to include
* stdint.h here.
*/
#ifndef __GLIBC__
#include <stdint.h>
typedef int64_t __int64_t;
typedef int32_t __int32_t;
typedef int16_t __int16_t;
typedef int8_t __int8_t;
typedef uint64_t __uint64_t;
typedef uint32_t __uint32_t;
typedef uint16_t __uint16_t;
typedef uint8_t __uint8_t;
#endif
#include_next <sys/types.h>
/*