Remove unused alternative const safe sortix string functions.

This commit is contained in:
Jonas 'Sortie' Termansen 2024-06-23 12:03:40 +02:00
parent d631aaafeb
commit 73f8f26efb
7 changed files with 19 additions and 54 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, 2013, 2014 Jonas 'Sortie' Termansen.
* Copyright (c) 2011, 2012, 2013, 2014, 2024 Jonas 'Sortie' Termansen.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -69,7 +69,6 @@
#endif
#if !defined(_SORTIX_SOURCE)
#define _SORTIX_SOURCE 1
#define __IMPLICIT_SORTIX_SOURCE
#endif
#endif
@ -90,7 +89,6 @@
/* Use the Sortix API if the default API was requested. */
#if defined(_DEFAULT_SOURCE) && !defined(_SORTIX_SOURCE)
#define _SORTIX_SOURCE 1
#define __IMPLICIT_SORTIX_SOURCE
#endif
/* Particular XSI revisions imply certain POSIX revisions. */
@ -192,15 +190,6 @@
#define __USE_SORTIX 0
#endif
/* Whether to override some "standard" functions with Sortix alternatives. */
#if !defined(__SORTIX_STDLIB_REDIRECTS)
#if __USE_SORTIX && !defined(__IMPLICIT_SORTIX_SOURCE)
#define __SORTIX_STDLIB_REDIRECTS 1
#else
#define __SORTIX_STDLIB_REDIRECTS 0
#endif
#endif
/* Provide the restrict keyword when building system components. */
#if defined(__is_sortix_system_component) && !defined(__want_restrict)
#define __want_restrict 1

View file

@ -62,11 +62,7 @@ int strcmp(const char*, const char*);
int strcoll(const char*, const char*);
char* strcpy(char* __restrict, const char* __restrict);
size_t strcspn(const char*, const char*);
#if __USE_SORTIX && __SORTIX_STDLIB_REDIRECTS
const char* strerror(int errnum) __asm__ ("sortix_strerror");
#else
char* strerror(int errnum);
#endif
size_t strlen(const char*);
char* strncat(char* __restrict, const char* __restrict, size_t);
int strncmp(const char*, const char*, size_t);
@ -97,11 +93,7 @@ char* strdup(const char*);
/* Functions from POSIX 2001. */
#if __USE_SORTIX || 200112L <= __USE_POSIX
int ffs(int);
#if __USE_SORTIX && __SORTIX_STDLIB_REDIRECTS
const char* strerror_l(int, locale_t) __asm__ ("sortix_strerror_l");
#else
char* strerror_l(int, locale_t);
#endif
int strerror_r(int, char*, size_t);
char* strtok_r(char* __restrict, const char* __restrict, char** __restrict);
#endif
@ -113,11 +105,7 @@ char* stpncpy(char* __restrict, const char* __restrict, size_t);
int strcoll_l(const char*, const char*, locale_t);
char* strndup(const char*, size_t);
size_t strnlen(const char*, size_t);
#if __USE_SORTIX && __SORTIX_STDLIB_REDIRECTS
const char* strsignal(int signum) __asm__ ("sortix_strsignal");
#else
char* strsignal(int signum);
#endif
size_t strxfrm_l(char* __restrict, const char* __restrict, size_t, locale_t);
#endif
@ -140,9 +128,6 @@ int timingsafe_memcmp(const void*, const void*, size_t);
/* Functions that are Sortix extensions. */
#if __USE_SORTIX
int ffsll(long long int);
const char* sortix_strerror(int errnum);
const char* sortix_strerror_l(int, locale_t);
const char* sortix_strsignal(int signum);
#endif
#if __USE_SORTIX

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2016, 2020-2022 Jonas 'Sortie' Termansen.
* Copyright (c) 2011-2016, 2020-2022, 2024 Jonas 'Sortie' Termansen.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -17,11 +17,10 @@
* Convert error code to a string.
*/
#define __SORTIX_STDLIB_REDIRECTS 0
#include <errno.h>
#include <string.h>
const char* sortix_strerror(int errnum)
char* strerror(int errnum)
{
switch ( errnum )
{
@ -116,7 +115,9 @@ const char* sortix_strerror(int errnum)
}
}
char* strerror(int errnum)
{
return (char*) sortix_strerror(errnum);
}
// TODO: After releasing Sortix 1.1, or after fixing ffmpeg, remove this symbol
// retained for compatibility. ffmpeg has a native sysroot issue where it
// accidentally taints it with the local system's headers instead of the
// sysroot headers, which accidentally pulls in an old removed symbol when
// bootstrapping on an old system.
weak_alias(strerror, sortix_strerror);

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 Jonas 'Sortie' Termansen.
* Copyright (c) 2013, 2024 Jonas 'Sortie' Termansen.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -17,16 +17,10 @@
* Convert error code to a string.
*/
#define __SORTIX_STDLIB_REDIRECTS 0
#include <string.h>
const char* sortix_strerror_l(int errnum, locale_t locale)
{
(void) locale;
return sortix_strerror(errnum);
}
char* strerror_l(int errnum, locale_t locale)
{
return (char*) sortix_strerror_l(errnum, locale);
(void) locale;
return (char*) strerror(errnum);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, 2013, 2014 Jonas 'Sortie' Termansen.
* Copyright (c) 2011, 2012, 2013, 2014, 2024 Jonas 'Sortie' Termansen.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -22,7 +22,7 @@
int strerror_r(int errnum, char* dest, size_t dest_len)
{
const char* msg = sortix_strerror(errnum);
const char* msg = strerror(errnum);
if ( !msg )
return -1;
if ( dest_len < strlen(msg) + 1 )

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2014 Jonas 'Sortie' Termansen.
* Copyright (c) 2012, 2014, 2024 Jonas 'Sortie' Termansen.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -17,11 +17,10 @@
* Convert signal number to a string.
*/
#define __SORTIX_STDLIB_REDIRECTS 0
#include <signal.h>
#include <string.h>
const char* sortix_strsignal(int signum)
char* strsignal(int signum)
{
switch ( signum )
{
@ -61,8 +60,3 @@ const char* sortix_strsignal(int signum)
return "Unknown signal value";
}
char* strsignal(int signum)
{
return (char*) sortix_strsignal(signum);
}

View file

@ -49,6 +49,8 @@
pid_t forward_sigterm_to = 0;
volatile sig_atomic_t got_sigterm = 0;
const char* sortix_strerror(int);
void on_interrupt_signal(int signum)
{
if ( signum == SIGINT )
@ -510,7 +512,7 @@ int textual(void)
{
const char* msg = "Invalid username/password";
if ( errno != EACCES )
msg = strerror(errno);
msg = sortix_strerror(errno);
printf("%s\n", msg);
printf("\n");
continue;