Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
[SOL] Add explicit declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
dmakarov committed Oct 20, 2023
1 parent 17accd3 commit f0f8003
Show file tree
Hide file tree
Showing 87 changed files with 301 additions and 102 deletions.
2 changes: 2 additions & 0 deletions newlib/libc/ssp/chk_fail.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <string.h>
#include <unistd.h>

void raise(int);

void
__attribute__((__noreturn__))
__chk_fail(void)
Expand Down
2 changes: 2 additions & 0 deletions newlib/libc/ssp/stack_protector.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ __stack_chk_init (void)
}
#endif

void raise(int);

void
__attribute__((__noreturn__))
__stack_chk_fail (void)
Expand Down
2 changes: 2 additions & 0 deletions newlib/libc/ssp/vsnprintf_chk.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ __RCSID("$NetBSD: vsnprintf_chk.c,v 1.5 2008/04/28 20:23:00 martin Exp $");

#undef vsnprintf

int vsnprintf (char *__restrict, size_t, const char *__restrict, __VALIST);

int
__vsnprintf_chk(char * __restrict buf, size_t len, int flags, size_t slen,
const char * __restrict fmt, va_list ap)
Expand Down
2 changes: 2 additions & 0 deletions newlib/libc/ssp/vsprintf_chk.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ __RCSID("$NetBSD: vsprintf_chk.c,v 1.6 2009/02/05 05:39:38 lukem Exp $");
#undef vsprintf
#undef vsnprintf

int vsnprintf (char *__restrict, size_t, const char *__restrict, __VALIST);

/*ARGSUSED*/
int
__vsprintf_chk(char * __restrict buf, int flags, size_t slen,
Expand Down
3 changes: 3 additions & 0 deletions newlib/libc/stdlib/arc4random.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
#define BLOCKSZ 64
#define RSBUFSZ (16*BLOCKSZ)

void explicit_bzero(void *p, size_t n);
int getentropy (void *__ptr, size_t __len);

/* Marked MAP_INHERIT_ZERO, so zero'd out in fork children. */
static struct _rs {
size_t rs_have; /* valid bytes at end of rs_buf */
Expand Down
2 changes: 2 additions & 0 deletions newlib/libc/stdlib/arc4random.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@

#endif /* _ARC4_LOCK_INIT */

void raise(int);

#ifndef __SINGLE_THREAD__
_ARC4_LOCK_INIT
#endif
Expand Down
1 change: 1 addition & 0 deletions newlib/libc/stdlib/arc4random_uniform.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <sys/types.h>
#include <stdlib.h>
uint32_t arc4random(void);

/*
* Calculate a uniformly distributed random number less than upper_bound
Expand Down
2 changes: 2 additions & 0 deletions newlib/libc/stdlib/assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Supporting OS subroutines required (only if enabled): <<close>>, <<fstat>>,
#include <stdlib.h>
#include <stdio.h>

int fiprintf (FILE *, const char *, ...);

#ifndef HAVE_ASSERT_FUNC
/* func can be NULL, in which case no function information is given. */
void
Expand Down
1 change: 1 addition & 0 deletions newlib/libc/stdlib/eprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <stdlib.h>
#include <stdio.h>
int fiprintf (FILE *, const char *, ...);

void
__eprintf (format, file, line, expression)
Expand Down
1 change: 1 addition & 0 deletions newlib/libc/stdlib/erand48.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/

#include "rand48.h"
double ldexp(double x, int expn);

double
_erand48_r (struct _reent *r,
Expand Down
7 changes: 4 additions & 3 deletions newlib/libc/stdlib/ldtoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <string.h>
#include <stdlib.h>
#include "mprec.h"
int sprintf (char *__restrict, const char *__restrict, ...);

/* These are the externally visible entries. */
/* linux name: long double _IO_strtold (char *, char **); */
Expand Down Expand Up @@ -334,7 +335,7 @@ static const char *const ermsg[7] = {
* of octal integers to eliminate decimal to binary conversion
* errors that might be introduced by the compiler.
*
* For computers, such as IBM PC, that follow the IEEE
* For computers, such as IBM PC, that follow the IEEE
* Standard for Binary Floating Point Arithmetic (ANSI/IEEE
* Std 754-1985), the symbol IBMPC should be defined. These
* numbers have 53-bit significands. In this mode, constants
Expand Down Expand Up @@ -2935,7 +2936,7 @@ _ldtoa_r (struct _reent *ptr, long double d, int mode, int ndigits,
return outstr;
}

/* Routine used to tell if long double is NaN or Infinity or regular number.
/* Routine used to tell if long double is NaN or Infinity or regular number.
Returns: 0 = regular number
1 = Nan
2 = Infinity
Expand Down Expand Up @@ -3297,7 +3298,7 @@ else if( ndigs < 0 )
; Convert ASCII string to quadruple precision floating point
;
; Numeric input is free field decimal number
; with max of 15 digits with or without
; with max of 15 digits with or without
; decimal point entered as ASCII from teletype.
; Entering E after the number followed by a second
; number causes the second number to be interpreted
Expand Down
2 changes: 2 additions & 0 deletions newlib/libc/stdlib/mallocr.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ extern void __malloc_unlock(struct _reent *);
extern void __malloc_lock();
extern void __malloc_unlock();
#endif
int fprintf (FILE *__restrict, const char *__restrict, ...);
int fiprintf (FILE *, const char *, ...);

#if __STD_C
#define RARG struct _reent *reent_ptr,
Expand Down
1 change: 1 addition & 0 deletions newlib/libc/stdlib/mstats.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ not portable.
#include <stdlib.h>
#include <malloc.h>
#include <stdio.h>
int fiprintf (FILE *, const char *, ...);

#ifndef _REENT_ONLY

Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/string/explicit_bzero.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

#include <string.h>

void bzero(void *, size_t);
/*
* explicit_bzero - don't let the compiler optimize away bzero
*/
Expand Down
4 changes: 3 additions & 1 deletion newlib/libc/string/strsignal.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ QUICKREF
#include <stdlib.h>
#include <reent.h>

int siprintf (char *, const char *, ...);

char *
strsignal (int signal)
{
Expand Down Expand Up @@ -225,7 +227,7 @@ strsignal (int signal)
buffer = "File size limit exceeded";
break;
#endif
#ifdef SIGVTALRM
#ifdef SIGVTALRM
case SIGVTALRM :
buffer = "Virtual timer expired";
break;
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/syscalls/sysisatty.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ isatty (int fd)
#ifdef REENTRANT_SYSCALLS_PROVIDED
return _isatty_r (_REENT, fd);
#else
return _isatty (fd);
return 0;
#endif
}
6 changes: 3 additions & 3 deletions newlib/libc/time/asctime_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <stdio.h>
#include <time.h>

int siprintf (char *, const char *, ...);
char *
asctime_r (const struct tm *__restrict tim_p,
char *__restrict result)
Expand All @@ -13,12 +13,12 @@ asctime_r (const struct tm *__restrict tim_p,
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
static const char mon_name[12][3] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};

siprintf (result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
day_name[tim_p->tm_wday],
day_name[tim_p->tm_wday],
mon_name[tim_p->tm_mon],
tim_p->tm_mday, tim_p->tm_hour, tim_p->tm_min,
tim_p->tm_sec, 1900 + tim_p->tm_year);
Expand Down
2 changes: 2 additions & 0 deletions newlib/libc/time/strftime.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ locale, hard-coding the "C" locale settings.
# error "YEAR_BASE < 0"
#endif

int sniprintf (char *, size_t, const char *, ...);

/* Using the tm_year, tm_wday, and tm_yday components of TIM_P, return
-1, 0, or 1 as the adjustment to add to the year for the ISO week
numbering used in "%g%G%V", avoiding overflow. */
Expand Down
35 changes: 18 additions & 17 deletions newlib/libc/time/tzset_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
static char __tzname_std[11];
static char __tzname_dst[11];
static char *prev_tzenv = NULL;
int sscanf (const char *__restrict, const char *__restrict, ...);

void
_tzset_unlocked_r (struct _reent *reent_ptr)
Expand Down Expand Up @@ -43,11 +44,11 @@ _tzset_unlocked_r (struct _reent *reent_ptr)

/* ignore implementation-specific format specifier */
if (*tzenv == ':')
++tzenv;
++tzenv;

if (sscanf (tzenv, "%10[^0-9,+-]%n", __tzname_std, &n) <= 0)
return;

tzenv += n;

sign = 1;
Expand All @@ -61,14 +62,14 @@ _tzset_unlocked_r (struct _reent *reent_ptr)

mm = 0;
ss = 0;

if (sscanf (tzenv, "%hu%n:%hu%n:%hu%n", &hh, &n, &mm, &n, &ss, &n) < 1)
return;

tz->__tzrule[0].offset = sign * (ss + SECSPERMIN * mm + SECSPERHOUR * hh);
_tzname[0] = __tzname_std;
tzenv += n;

if (sscanf (tzenv, "%10[^0-9,+-]%n", __tzname_dst, &n) <= 0)
{ /* No dst */
_tzname[1] = _tzname[0];
Expand All @@ -91,10 +92,10 @@ _tzset_unlocked_r (struct _reent *reent_ptr)
else if (*tzenv == '+')
++tzenv;

hh = 0;
hh = 0;
mm = 0;
ss = 0;

n = 0;
if (sscanf (tzenv, "%hu%n:%hu%n:%hu%n", &hh, &n, &mm, &n, &ss, &n) <= 0)
tz->__tzrule[1].offset = tz->__tzrule[0].offset - 3600;
Expand All @@ -113,15 +114,15 @@ _tzset_unlocked_r (struct _reent *reent_ptr)
if (sscanf (tzenv, "M%hu%n.%hu%n.%hu%n", &m, &n, &w, &n, &d, &n) != 3 ||
m < 1 || m > 12 || w < 1 || w > 5 || d > 6)
return;

tz->__tzrule[i].ch = 'M';
tz->__tzrule[i].m = m;
tz->__tzrule[i].n = w;
tz->__tzrule[i].d = d;

tzenv += n;
}
else
else
{
char *end;
if (*tzenv == 'J')
Expand All @@ -131,9 +132,9 @@ _tzset_unlocked_r (struct _reent *reent_ptr)
}
else
ch = 'D';

d = strtoul (tzenv, &end, 10);

/* if unspecified, default to US settings */
/* From 1987-2006, US was M4.1.0,M10.5.0, but starting in 2007 is
* M3.2.0,M11.1.0 (2nd Sunday March through 1st Sunday November) */
Expand All @@ -159,26 +160,26 @@ _tzset_unlocked_r (struct _reent *reent_ptr)
tz->__tzrule[i].ch = ch;
tz->__tzrule[i].d = d;
}

tzenv = end;
}

/* default time is 02:00:00 am */
hh = 2;
mm = 0;
ss = 0;
n = 0;

if (*tzenv == '/')
sscanf (tzenv, "/%hu%n:%hu%n:%hu%n", &hh, &n, &mm, &n, &ss, &n);

tz->__tzrule[i].s = ss + SECSPERMIN * mm + SECSPERHOUR * hh;

tzenv += n;
}

__tzcalc_limits (tz->__tzyear);
_timezone = tz->__tzrule[0].offset;
_timezone = tz->__tzrule[0].offset;
_daylight = tz->__tzrule[0].offset != tz->__tzrule[1].offset;
}

Expand Down
4 changes: 3 additions & 1 deletion newlib/libm/common/acoshl.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ POSSIBILITY OF SUCH DAMAGE.

/* On platforms where long double is as wide as double. */
#ifdef _LDBL_EQ_DBL

double acosh(double);

long double
acoshl (long double x)
{
return acosh(x);
}
#endif

4 changes: 3 additions & 1 deletion newlib/libm/common/acosl.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ POSSIBILITY OF SUCH DAMAGE.

/* On platforms where long double is as wide as double. */
#ifdef _LDBL_EQ_DBL

long double acos(long double);

long double
acosl (long double x)
{
return acos(x);
}
#endif

4 changes: 3 additions & 1 deletion newlib/libm/common/asinl.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ POSSIBILITY OF SUCH DAMAGE.

/* On platforms where long double is as wide as double. */
#ifdef _LDBL_EQ_DBL

double asin(double);

long double
asinl (long double x)
{
return asin(x);
}
#endif

4 changes: 3 additions & 1 deletion newlib/libm/common/atan2l.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ POSSIBILITY OF SUCH DAMAGE.

/* On platforms where long double is as wide as double. */
#ifdef _LDBL_EQ_DBL

double atan2(double, double);

long double
atan2l (long double v, long double u)
{
return atan2(v, u);
}
#endif

4 changes: 3 additions & 1 deletion newlib/libm/common/atanhl.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ POSSIBILITY OF SUCH DAMAGE.

/* On platforms where long double is as wide as double. */
#ifdef _LDBL_EQ_DBL

double atanh(double);

long double
atanhl (long double x)
{
return atanh(x);
}
#endif

Loading

0 comments on commit f0f8003

Please sign in to comment.