libc updates
This commit is contained in:
parent
fec9781c23
commit
bea8d8f6db
@ -38,14 +38,17 @@ extern int snprintf(char * buf, size_t size, const char * fmt, ...);
|
|||||||
extern int vsprintf(char * buf, const char *fmt, va_list args);
|
extern int vsprintf(char * buf, const char *fmt, va_list args);
|
||||||
extern int vsnprintf(char * buf, size_t size, const char *fmt, va_list args);
|
extern int vsnprintf(char * buf, size_t size, const char *fmt, va_list args);
|
||||||
extern int vfprintf(FILE * device, const char *format, va_list ap);
|
extern int vfprintf(FILE * device, const char *format, va_list ap);
|
||||||
|
extern int vprintf(const char *format, va_list ap);
|
||||||
|
|
||||||
extern int puts(const char *s);
|
extern int puts(const char *s);
|
||||||
extern int fputs(const char *s, FILE *stream);
|
extern int fputs(const char *s, FILE *stream);
|
||||||
extern int fputc(int c, FILE *stream);
|
extern int fputc(int c, FILE *stream);
|
||||||
#define putc(c,s) fputc((c),(s))
|
extern int putc(int c, FILE *stream);
|
||||||
extern int putchar(int c);
|
extern int putchar(int c);
|
||||||
extern int fgetc(FILE *stream);
|
extern int fgetc(FILE *stream);
|
||||||
|
extern int getc(FILE *stream);
|
||||||
extern char *fgets(char *s, int size, FILE *stream);
|
extern char *fgets(char *s, int size, FILE *stream);
|
||||||
|
extern int getchar(void);
|
||||||
|
|
||||||
extern void rewind(FILE *stream);
|
extern void rewind(FILE *stream);
|
||||||
extern void setbuf(FILE * stream, char * buf);
|
extern void setbuf(FILE * stream, char * buf);
|
||||||
@ -73,7 +76,5 @@ extern int rename(const char * oldpath, const char * newpath);
|
|||||||
#define _IOLBF 1
|
#define _IOLBF 1
|
||||||
#define _IOFBF 2
|
#define _IOFBF 2
|
||||||
|
|
||||||
#define getc(s) fgetc(s)
|
|
||||||
|
|
||||||
extern char * tmpnam(char * s);
|
extern char * tmpnam(char * s);
|
||||||
#define L_tmpnam 256
|
#define L_tmpnam 256
|
||||||
|
@ -26,6 +26,9 @@ extern time_t time(time_t * out);
|
|||||||
extern double difftime(time_t a, time_t b);
|
extern double difftime(time_t a, time_t b);
|
||||||
extern time_t mktime(struct tm *tm);
|
extern time_t mktime(struct tm *tm);
|
||||||
|
|
||||||
|
extern char * asctime(const struct tm *tm);
|
||||||
|
extern char * ctime(const time_t * timep);
|
||||||
|
|
||||||
typedef int clock_t;
|
typedef int clock_t;
|
||||||
|
|
||||||
extern clock_t clock(void);
|
extern clock_t clock(void);
|
||||||
|
@ -282,6 +282,9 @@ int vfprintf(FILE * device, const char *fmt, va_list args) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int vprintf(const char *fmt, va_list args) {
|
||||||
|
return vfprintf(stdout, fmt, args);
|
||||||
|
}
|
||||||
|
|
||||||
int fprintf(FILE * device, const char *fmt, ...) {
|
int fprintf(FILE * device, const char *fmt, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
|
@ -341,6 +341,8 @@ int fputc(int c, FILE *stream) {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int putc(int c, FILE *stream) __attribute__((weak, alias("fputc")));
|
||||||
|
|
||||||
int fgetc(FILE * stream) {
|
int fgetc(FILE * stream) {
|
||||||
char buf[1];
|
char buf[1];
|
||||||
int r;
|
int r;
|
||||||
@ -355,6 +357,12 @@ int fgetc(FILE * stream) {
|
|||||||
return (unsigned char)buf[0];
|
return (unsigned char)buf[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getc(FILE * stream) __attribute__((weak, alias("fgetc")));
|
||||||
|
|
||||||
|
int getchar(void) {
|
||||||
|
return fgetc(stdin);
|
||||||
|
}
|
||||||
|
|
||||||
char *fgets(char *s, int size, FILE *stream) {
|
char *fgets(char *s, int size, FILE *stream) {
|
||||||
int c;
|
int c;
|
||||||
char * out = s;
|
char * out = s;
|
||||||
|
9
libc/time/ctime.c
Normal file
9
libc/time/ctime.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include <time.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: Also supposed to set tz values...
|
||||||
|
*/
|
||||||
|
char * ctime(const time_t * timep) {
|
||||||
|
return asctime(localtime(timep));
|
||||||
|
}
|
@ -195,3 +195,10 @@ size_t strftime(char *s, size_t max, const char *fmt, const struct tm *tm) {
|
|||||||
*b = '\0';
|
*b = '\0';
|
||||||
return b - s;
|
return b - s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char output[26];
|
||||||
|
char * asctime(const struct tm *tm) {
|
||||||
|
strftime(output, 26, "%a %b %d %T %Y\n", tm);
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user