Fix norme + move arch-specific header

This commit is contained in:
Yatis 2020-10-14 15:18:10 +02:00
parent 4eb7b35617
commit 44bd67431c
16 changed files with 60 additions and 24 deletions

View file

@ -3,11 +3,11 @@
// ABI redirection // ABI redirection
#if defined(__SUPPORT_VHEX_KERNEL) #if defined(__SUPPORT_VHEX_KERNEL)
# include <vhex/unistd_32.h> # include <arch/vhex/unistd_32.h>
#elif defined(__SUPPORT_CASIO_ABI_FX9860G) #elif defined(__SUPPORT_CASIO_ABI_FX9860G)
# include <fx9860g/unistd_32.h> # include <arch/fx9860g/unistd_32.h>
#elif defined(__SUPPORT_CASIO_ABI_FXCG50) #elif defined(__SUPPORT_CASIO_ABI_FXCG50)
# include <fxcg50/unistd_32.h> # include <arch/fxcg50/unistd_32.h>
#endif #endif
#endif /*__ASM_UNISTD_32_H__*/ #endif /*__ASM_UNISTD_32_H__*/

View file

@ -34,8 +34,8 @@
#--- #---
MAJOR := 0 MAJOR := 0
MINOR := 2 MINOR := 2
PATCH := 3 PATCH := 4
EXTRAVERSION := -alpha EXTRAVERSION := -beta
#--- #---

View file

@ -1,5 +1,9 @@
#include <stdio.h> #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, ...) int dprintf(int fd, const char *restrict format, ...)
{ {
va_list ap; va_list ap;

View file

@ -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"; char *hexa = (opt->uppercase == 1) ? "0123456789ABCDEF" : "0123456789abcdef";
opt->digits = 0; opt->digits = 0;
while (num != 0 || opt->digits < digits) while (num != 0 || opt->digits < digits) {
{
opt->format[opt->digits++] = hexa[num % base]; opt->format[opt->digits++] = hexa[num % base];
num = num / base; num = num / base;
} }
@ -49,8 +48,7 @@ static void disp_format(struct printf_opt *opt)
(*opt->disp_char)(opt, opt->base[1]); (*opt->disp_char)(opt, opt->base[1]);
// padding // 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') + int total = opt->digits + (opt->sign != '\0') +
(opt->base[0] != '\0') + (opt->base[1] != '\0'); (opt->base[0] != '\0') + (opt->base[1] != '\0');
total = opt->width - total; total = opt->width - total;
@ -65,8 +63,7 @@ static void disp_format(struct printf_opt *opt)
(*opt->disp_char)(opt, opt->format[opt->digits]); (*opt->disp_char)(opt, opt->format[opt->digits]);
// padding // 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') + int total = saved_digits + (opt->sign != '\0') +
(opt->base[0] != '\0') + (opt->base[1] != '\0'); (opt->base[0] != '\0') + (opt->base[1] != '\0');
total = opt->width - total; 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) 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 0: return ((signed char)va_arg(opt->ap, int));
case 1: return ((short int)va_arg(opt->ap, int)); case 1: return ((short int)va_arg(opt->ap, int));
case 2: return (va_arg(opt->ap, long 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) 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 0: return ((unsigned char)va_arg(opt->ap, int));
case 1: return ((unsigned short int)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)); 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; int base;
// Get appropriate base // Get appropriate base
switch (n) switch (n) {
{
case 'o': base = 8; break; case 'o': base = 8; break;
case 'x': base = 16; break; case 'x': base = 16; break;
default: base = 10; break; default: base = 10; break;

View file

@ -1,6 +1,12 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.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, ...) int printf(const char *restrict format, ...)
{ {
va_list ap; va_list ap;

View file

@ -2,6 +2,10 @@
#include <string.h> #include <string.h>
#include <unistd.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) int puts(const char *s)
{ {
size_t size; size_t size;
@ -9,5 +13,6 @@ int puts(const char *s)
size = strlen(s); size = strlen(s);
n = write(STDOUT_FILENO, s, size); n = write(STDOUT_FILENO, s, size);
write(STDOUT_FILENO, "\n", 1);
return (-(n == size)); return (-(n == size));
} }

View file

@ -1,5 +1,11 @@
#include <stdio.h> #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, ...) int snprintf(char *restrict str, size_t size, const char *restrict format, ...)
{ {
va_list ap; va_list ap;

View file

@ -1,5 +1,11 @@
#include <stdio.h> #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, ...) int sprintf(char *restrict str, const char *restrict format, ...)
{ {
va_list ap; va_list ap;

View file

@ -26,6 +26,12 @@ static void disp_char(struct printf_opt *opt, char n)
opt->buffer[opt->buffer_cursor++] = 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) int vdprintf(int fd, const char *restrict format, va_list ap)
{ {
extern int printf_common(struct printf_opt *opt, const char *restrict format); extern int printf_common(struct printf_opt *opt, const char *restrict format);

View file

@ -18,6 +18,12 @@ static void disp_fflush(struct printf_opt *opt)
opt->str[opt->buffer_cursor] = '\0'; 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) 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); 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); va_copy(opt.ap, ap);
return (printf_common(&opt, format) + 1); return (printf_common(&opt, format) + 1);
} }

View file

@ -1,5 +1,11 @@
#include <stdio.h> #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) int vsprintf(char *restrict str, const char *restrict format, va_list ap)
{ {
return (vsnprintf(str, 65535, format, ap)); return (vsnprintf(str, 65535, format, ap));

View file

@ -25,8 +25,7 @@ int mtx_lock(mtx_t *__mutex)
return (-1); return (-1);
// Wait util the mutex is unlocked // Wait util the mutex is unlocked
while (1) while (1) {
{
// Check if the mutex is unlock // Check if the mutex is unlock
__thread_atomic_start(); __thread_atomic_start();
if (__mutex->lock == 0) if (__mutex->lock == 0)
@ -62,8 +61,7 @@ int mtx_trylock(mtx_t *__mutex)
// Check if the mutex is already free // Check if the mutex is already free
int ret = -1; int ret = -1;
if (__mutex->lock == 0) if (__mutex->lock == 0) {
{
//TODO: handle mutex type !! //TODO: handle mutex type !!
(void)__mutex->type; (void)__mutex->type;