Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tinystdio: added fgetpos and fsetpos files #10

Merged
merged 28 commits into from
Jul 10, 2024

Conversation

HanaMAshour
Copy link
Collaborator

Added fgetpos.c and fsetpos.c files to resolve compilation error of: undefined symbol: fgetpos
undefined symbol: fsetpos

Changed the prototype of these functions in the file stdio.h to match with the ISO/IEC 9899_1999

@HanaMAshour HanaMAshour requested a review from keith-packard as a code owner May 7, 2024 10:27
@HanaMAshour HanaMAshour force-pushed the hanaa_fgetpos_fsetpos branch from 0412a25 to 67a423d Compare May 7, 2024 10:28
keith-packard and others added 28 commits June 26, 2024 17:32
This file is just a wrapper for picolibc.h. Delete unnecessary
references to newlib.h or picolibc.h and replace the remaining ones
with sys/features.h as that defines all of the features the library
supports, not just those defined by the build system.

Signed-off-by: Keith Packard <[email protected]>
Make sure any .c file includes picolibc.h before testing build
parameters.

Signed-off-by: Keith Packard <[email protected]>
Make this match other asm source in the library, even
though it doesn't strictly need to as it doesn't use
any C preprocessor stuff.

Signed-off-by: Keith Packard <[email protected]>
Remove C library-specific bits for glibc or picolibc as the
code is just plain-old POSIX and doesn't need any magic.

Signed-off-by: Keith Packard <[email protected]>
Make sure library feature test macros are defined before
being used.

Signed-off-by: Keith Packard <[email protected]>
This file includes the regular strftime implementation, which also
defines _DEFAULT_SOURCE. Fix that by undefining before including.

Signed-off-by: Keith Packard <[email protected]>
Tinystdio uses a bunch of feature macros before including any headers.

Signed-off-by: Keith Packard <[email protected]>
Go through all of the machine-specific source code and make sure
picolibc.h is included so that all of the feature test macros are set
before being used.

Signed-off-by: Keith Packard <[email protected]>
These come from glibc where various 64-bit explicit APIs are provided
under the protection of _LARGEFILE64_SOURCE, which is defined by
_GNU_SOURCE.

Replace the __LARGE64_FILES stuff with these and then use _GNU_SOURCE
where needed as that exposes these APIs. We could use
_LARGEFILE64_SOURCE instead, but it seems better to just expose the
GNU API instead.

Signed-off-by: Keith Packard <[email protected]>
This sets up a sample interrupt vector to show how this works.

Signed-off-by: Keith Packard <[email protected]>
This mirrors the existing __signbit and __signbitf functions and
allows a complete implementation of the non-builtin signbit macro.

Change the internal inline version name to signbitl_inline like
the other similar functions.

Signed-off-by: Keith Packard <[email protected]>
Make sure all functions are declared fully in header files before
being defined or used.

Signed-off-by: Keith Packard <[email protected]>
This was needed before all source files were fixed to ensure
all feature test macros were defined before being used by
including sys/features.h

Signed-off-by: Keith Packard <[email protected]>
Exposes these when _POSIX_C_SOURCE >= 199309L:

int	getc_unlocked (FILE *);
int	getchar_unlocked (void);
void	flockfile (FILE *);
int	ftrylockfile (FILE *);
void	funlockfile (FILE *);
int	putc_unlocked (int, FILE *);
int	putchar_unlocked (int);

The I/O functions don't do anything different as tinystdio doesn't
have any locking at the top level APIs. Getting these to poke down
inside the buffered layer would improve performance at a pretty
significant cost in complexity.

flockfile/funlockfile is implemented using the global libc lock. This
should at least serialize threads which all use this API. ftrylockfile
is the same as flockfile as there's no try-lock API to use.

Signed-off-by: Keith Packard <[email protected]>
According to ISO/IEC 9899/1999 section 7.19.2: Streams

before this change wide character input/output functions were applied to
byte-oriented stream resulting in erroneous results handling wide characters
input/output to/from files.

Signed-off-by: Ahmed Shehab <[email protected]>
Added testcase that checks input/output wide-chars to/from a file.
issue found by running SuperTest by Solid Sands

Signed-off-by: Ahmed Shehab <[email protected]>
This fixes up the accelerated math functions and setjmp implementation
to support aarch64 targets without an FPU via the aapcs-soft ABI
specification.

Signed-off-by: Keith Packard <[email protected]>
Soft float aarch64 targets also don't have the neon instructions
necessary for all of the hand-written string functions.

Signed-off-by: Keith Packard <[email protected]>
Clang has a bug where FLT_ROUNDS doesn't respect the ABI target and
continues to access FPSR, causing a fault on hardware without an FPU.

Hack around this by manually defining FLT_ROUNDS as 1 in this case.

Signed-off-by: Keith Packard <[email protected]>
A couple of long double error handling paths weren't working for
targets without exception support (aarch64 softfp) because
they returned the wrong sign. Also make the /0 code path
look like the 32- and 64- bit paths for symmetry.

Signed-off-by: Keith Packard <[email protected]>
compiler-rt appears to have incorrect ieee support resulting in
a slightly different answer for one jn computation.

Signed-off-by: Keith Packard <[email protected]>
Check __ARM_FP compiler flag and if zero, the application is compiled
in soft-float mode and cannot use the FPU.

Signed-off-by: Keith Packard <[email protected]>
Check for either of atomic-ungetc or atomic-signal and only run
the atomic test if at least one of them is enabled.

Signed-off-by: Keith Packard <[email protected]>
Make sure -fno-stack-protector isn't mixed in with stack protector
enable flags. Add -fno-stack-protector when not using it in tests.

Signed-off-by: Keith Packard <[email protected]>
Instead of writing 64 bytes into a 16 byte temp, make the temp 48
bytes to avoid really trashing memory.

Signed-off-by: Keith Packard <[email protected]>
This uses a custom llvm toolchain and compiler-rt runtime library to
demonstrate running aarch64 without floating point. This should work
on armv8-r as well, but there's no qemu model for that, so we're using
armv8-a.

Signed-off-by: Keith Packard <[email protected]>
added fgetpos.c and fsetpos.c files to resolve compilation error of:
undefined symbol: fgetpos
undefined symbol: fsetpos

changed the prototype of these functions in the file stdio.h to match
with the ISO/IEC 9899_1999

Signed-off-by: Hana Ashour <[email protected]>
@keith-packard keith-packard force-pushed the hanaa_fgetpos_fsetpos branch from 67a423d to d3e49a4 Compare June 30, 2024 00:06
@mostafa-salmaan mostafa-salmaan merged commit d3e49a4 into main Jul 10, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants