mirror of
https://git.planet-casio.com/Vhex-Kernel-Core/fxlibc.git
synced 2025-04-19 09:27:00 +02:00
Fix norme + move arch-specific header
This commit is contained in:
parent
4eb7b35617
commit
44bd67431c
16 changed files with 60 additions and 24 deletions
|
@ -3,11 +3,11 @@
|
|||
|
||||
// ABI redirection
|
||||
#if defined(__SUPPORT_VHEX_KERNEL)
|
||||
# include <vhex/unistd_32.h>
|
||||
# include <arch/vhex/unistd_32.h>
|
||||
#elif defined(__SUPPORT_CASIO_ABI_FX9860G)
|
||||
# include <fx9860g/unistd_32.h>
|
||||
# include <arch/fx9860g/unistd_32.h>
|
||||
#elif defined(__SUPPORT_CASIO_ABI_FXCG50)
|
||||
# include <fxcg50/unistd_32.h>
|
||||
# include <arch/fxcg50/unistd_32.h>
|
||||
#endif
|
||||
|
||||
#endif /*__ASM_UNISTD_32_H__*/
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
#---
|
||||
MAJOR := 0
|
||||
MINOR := 2
|
||||
PATCH := 3
|
||||
EXTRAVERSION := -alpha
|
||||
PATCH := 4
|
||||
EXTRAVERSION := -beta
|
||||
|
||||
|
||||
#---
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
** The function dprintf() is the same as fprintf() except that it outputs to a
|
||||
** file descriptor, fd, instead of to a stdio stream.
|
||||
*/
|
||||
int dprintf(int fd, const char *restrict format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
|
|
@ -31,8 +31,7 @@ static void base_to_str(struct printf_opt *opt, uint32_t num, int base, int digi
|
|||
char *hexa = (opt->uppercase == 1) ? "0123456789ABCDEF" : "0123456789abcdef";
|
||||
|
||||
opt->digits = 0;
|
||||
while (num != 0 || opt->digits < digits)
|
||||
{
|
||||
while (num != 0 || opt->digits < digits) {
|
||||
opt->format[opt->digits++] = hexa[num % base];
|
||||
num = num / base;
|
||||
}
|
||||
|
@ -49,8 +48,7 @@ static void disp_format(struct printf_opt *opt)
|
|||
(*opt->disp_char)(opt, opt->base[1]);
|
||||
|
||||
// padding
|
||||
if (opt->flags.minus == 1 && opt->width > opt->digits)
|
||||
{
|
||||
if (opt->flags.minus == 1 && opt->width > opt->digits) {
|
||||
int total = opt->digits + (opt->sign != '\0') +
|
||||
(opt->base[0] != '\0') + (opt->base[1] != '\0');
|
||||
total = opt->width - total;
|
||||
|
@ -65,8 +63,7 @@ static void disp_format(struct printf_opt *opt)
|
|||
(*opt->disp_char)(opt, opt->format[opt->digits]);
|
||||
|
||||
// padding
|
||||
if (opt->flags.minus == 0 && opt->width > saved_digits)
|
||||
{
|
||||
if (opt->flags.minus == 0 && opt->width > saved_digits) {
|
||||
int total = saved_digits + (opt->sign != '\0') +
|
||||
(opt->base[0] != '\0') + (opt->base[1] != '\0');
|
||||
total = opt->width - total;
|
||||
|
@ -81,8 +78,7 @@ static void disp_format(struct printf_opt *opt)
|
|||
//---
|
||||
static uint32_t get_arg_i(struct printf_opt *opt)
|
||||
{
|
||||
switch (opt->lenght)
|
||||
{
|
||||
switch (opt->lenght) {
|
||||
case 0: return ((signed char)va_arg(opt->ap, int));
|
||||
case 1: return ((short int)va_arg(opt->ap, int));
|
||||
case 2: return (va_arg(opt->ap, long int));
|
||||
|
@ -96,8 +92,7 @@ static uint32_t get_arg_i(struct printf_opt *opt)
|
|||
|
||||
static uint32_t get_arg_u(struct printf_opt *opt)
|
||||
{
|
||||
switch (opt->lenght)
|
||||
{
|
||||
switch (opt->lenght) {
|
||||
case 0: return ((unsigned char)va_arg(opt->ap, int));
|
||||
case 1: return ((unsigned short int)va_arg(opt->ap, int));
|
||||
case 2: return (va_arg(opt->ap, unsigned long int));
|
||||
|
@ -165,8 +160,7 @@ static void action_uint(struct printf_opt *opt, char n)
|
|||
int base;
|
||||
|
||||
// Get appropriate base
|
||||
switch (n)
|
||||
{
|
||||
switch (n) {
|
||||
case 'o': base = 8; break;
|
||||
case 'x': base = 16; break;
|
||||
default: base = 10; break;
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/*
|
||||
** printf() write the output under the control of a format string that specifies
|
||||
** how subsequent arguments (or arguments accessed via the variable-length
|
||||
** argument facilities of stdarg(3)) are converted for output then write to
|
||||
** the STDOUT.
|
||||
*/
|
||||
int printf(const char *restrict format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/*
|
||||
** puts() writes the string s and a trailing newline to stdout.
|
||||
** FIXME: check last write error !
|
||||
*/
|
||||
int puts(const char *s)
|
||||
{
|
||||
size_t size;
|
||||
|
@ -9,5 +13,6 @@ int puts(const char *s)
|
|||
|
||||
size = strlen(s);
|
||||
n = write(STDOUT_FILENO, s, size);
|
||||
write(STDOUT_FILENO, "\n", 1);
|
||||
return (-(n == size));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
** sprintf(), snprintf(), vsprintf() and vsnprintf() write the output under the
|
||||
** control of a format string that specifies how subsequent arguments (or
|
||||
** arguments accessed via the variable-length argument facilities of stdarg(3))
|
||||
** are converted for output then write to the character string str.
|
||||
*/
|
||||
int snprintf(char *restrict str, size_t size, const char *restrict format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
** sprintf(), snprintf(), vsprintf() and vsnprintf() write the output under the
|
||||
** control of a format string that specifies how subsequent arguments (or
|
||||
** arguments accessed via the variable-length argument facilities of stdarg(3))
|
||||
** are converted for output then write to the character string str.
|
||||
*/
|
||||
int sprintf(char *restrict str, const char *restrict format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
|
|
@ -26,6 +26,12 @@ static void disp_char(struct printf_opt *opt, char n)
|
|||
opt->buffer[opt->buffer_cursor++] = n;
|
||||
}
|
||||
|
||||
/*
|
||||
** The functions vdprintf() are equivalent to the dprintf() except that they
|
||||
** are called with a va_list instead of a variable number of arguments. These
|
||||
** functions do not call the va_end macro. Because they invoke the va_arg macro,
|
||||
** the value of ap is undefined after the call.
|
||||
*/
|
||||
int vdprintf(int fd, const char *restrict format, va_list ap)
|
||||
{
|
||||
extern int printf_common(struct printf_opt *opt, const char *restrict format);
|
||||
|
|
|
@ -18,6 +18,12 @@ static void disp_fflush(struct printf_opt *opt)
|
|||
opt->str[opt->buffer_cursor] = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
** The functions vsnprintf() are equivalent to the snprintf() except that they
|
||||
** are called with a va_list instead of a variable number of arguments. These
|
||||
** functions do not call the va_end macro. Because they invoke the va_arg macro,
|
||||
** the value of ap is undefined after the call.
|
||||
*/
|
||||
int vsnprintf(char *restrict str, size_t size, const char *restrict format, va_list ap)
|
||||
{
|
||||
extern int printf_common(struct printf_opt *opt, const char *restrict format);
|
||||
|
@ -30,4 +36,3 @@ int vsnprintf(char *restrict str, size_t size, const char *restrict format, va_l
|
|||
va_copy(opt.ap, ap);
|
||||
return (printf_common(&opt, format) + 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
** The functions vsprintf() are equivalent to the sprintf() except that they
|
||||
** are called with a va_list instead of a variable number of arguments. These
|
||||
** functions do not call the va_end macro. Because they invoke the va_arg macro,
|
||||
** the value of ap is undefined after the call.
|
||||
*/
|
||||
int vsprintf(char *restrict str, const char *restrict format, va_list ap)
|
||||
{
|
||||
return (vsnprintf(str, 65535, format, ap));
|
||||
return (vsnprintf(str, 65535, format, ap));
|
||||
}
|
||||
|
|
|
@ -15,5 +15,5 @@
|
|||
*/
|
||||
void *reallocarray(void *ptr, size_t nmemb, size_t size)
|
||||
{
|
||||
return (realloc(ptr, nmemb * size));
|
||||
return (realloc(ptr, nmemb * size));
|
||||
}
|
||||
|
|
|
@ -25,8 +25,7 @@ int mtx_lock(mtx_t *__mutex)
|
|||
return (-1);
|
||||
|
||||
// Wait util the mutex is unlocked
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
// Check if the mutex is unlock
|
||||
__thread_atomic_start();
|
||||
if (__mutex->lock == 0)
|
||||
|
@ -62,8 +61,7 @@ int mtx_trylock(mtx_t *__mutex)
|
|||
|
||||
// Check if the mutex is already free
|
||||
int ret = -1;
|
||||
if (__mutex->lock == 0)
|
||||
{
|
||||
if (__mutex->lock == 0) {
|
||||
//TODO: handle mutex type !!
|
||||
(void)__mutex->type;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue