Skip to content

Commit

Permalink
axlibc: include time.h in pthread.h
Browse files Browse the repository at this point in the history
- that fixes the implicit function declaration of gmtime in iperf
  • Loading branch information
equation314 committed Aug 4, 2023
1 parent ef35f47 commit a6e34ef
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 49 deletions.
1 change: 1 addition & 0 deletions apps/c/iperf/axbuild.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ $(APP)/%.c:
@echo "Download iperf source code"
wget https://downloads.es.net/pub/iperf/$(iperf_pkg).tar.gz -P $(APP)
tar -zxvf $(APP)/$(iperf_pkg).tar.gz -C $(APP) && rm -f $(APP)/$(iperf_pkg).tar.gz
cd $(iperf_dir) && git init && git add .
patch -p1 -N -d $(iperf_dir) --no-backup-if-mismatch -r - < $(APP)/iperf.patch
2 changes: 1 addition & 1 deletion ulib/axlibc/c/fcntl.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <fcntl.h>
#include <axlibc.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>

Expand Down
24 changes: 12 additions & 12 deletions ulib/axlibc/c/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ void freeaddrinfo(struct addrinfo *__restrict res)
}

static const char gai_msgs[] = "Invalid flags\0"
"Name does not resolve\0"
"Try again\0"
"Non-recoverable error\0"
"Unknown error\0"
"Unrecognized address family or invalid length\0"
"Unrecognized socket type\0"
"Unrecognized service\0"
"Unknown error\0"
"Out of memory\0"
"System error\0"
"Overflow\0"
"\0Unknown error";
"Name does not resolve\0"
"Try again\0"
"Non-recoverable error\0"
"Unknown error\0"
"Unrecognized address family or invalid length\0"
"Unrecognized socket type\0"
"Unrecognized service\0"
"Unknown error\0"
"Out of memory\0"
"System error\0"
"Overflow\0"
"\0Unknown error";

const char *gai_strerror(int ecode)
{
Expand Down
2 changes: 1 addition & 1 deletion ulib/axlibc/c/resource.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <errno.h>
#include <axlibc.h>
#include <errno.h>
#include <stdio.h>
#include <sys/resource.h>

Expand Down
2 changes: 1 addition & 1 deletion ulib/axlibc/c/select.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifdef AX_CONFIG_SELECT

#include <errno.h>
#include <axlibc.h>
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/select.h>
Expand Down
5 changes: 2 additions & 3 deletions ulib/axlibc/c/stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,9 @@ int fclose(FILE *f)
}

// TODO
int rename(const char *__old, const char *__new)
int rename(const char *old, const char *new)
{
unimplemented();
return 0;
return ax_rename(old, new);
}

int fileno(FILE *f)
Expand Down
9 changes: 4 additions & 5 deletions ulib/axlibc/c/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,22 @@ int __secs_to_tm(long long t, struct tm *tm)
return 0;
}

struct tm *__gmtime_r(const time_t *restrict t, struct tm *restrict tm)
struct tm *gmtime_r(const time_t *restrict t, struct tm *restrict tm)
{
if (__secs_to_tm(*t, tm) < 0) {
errno = EOVERFLOW;
return 0;
}
tm->tm_isdst = 0;
tm->__tm_gmtoff = 0;
// TODO: set timezone
// tm->__tm_zone = __utc;
tm->__tm_zone = __utc;
return tm;
}

struct tm *gmtime(const time_t *timer)
{
static struct tm tm;
return __gmtime_r(timer, &tm);
return gmtime_r(timer, &tm);
}

struct tm *localtime_r(const time_t *restrict t, struct tm *restrict tm)
Expand All @@ -139,7 +138,7 @@ struct tm *localtime_r(const time_t *restrict t, struct tm *restrict tm)

tm->tm_isdst = 0;
tm->__tm_gmtoff = 0;
tm->__tm_zone = 0;
tm->__tm_zone = __utc;

return tm;
}
Expand Down
2 changes: 1 addition & 1 deletion ulib/axlibc/c/unistd.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <axlibc.h>
#include <errno.h>
#include <fcntl.h>
#include <axlibc.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
Expand Down
3 changes: 1 addition & 2 deletions ulib/axlibc/include/pthread.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#ifndef _PTHREAD_H
#define _PTHREAD_H

#include <stddef.h>
#include <stdint.h>
#include <features.h>
#include <time.h>

#define PTHREAD_CANCEL_ENABLE 0
#define PTHREAD_CANCEL_DISABLE 1
Expand Down
4 changes: 2 additions & 2 deletions ulib/axlibc/include/stdbool.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

/* Represents true-or-false values */
#ifndef __cplusplus
#define true 1
#define true 1
#define false 0
#define bool _Bool
#define bool _Bool
#endif

#endif // __STDBOOL_H__
6 changes: 4 additions & 2 deletions ulib/axlibc/include/stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ extern FILE *const stderr;
##__VA_ARGS__)
#else

#define unimplemented(fmt, ...) do {} while (0)
#define unimplemented(fmt, ...) \
do { \
} while (0)

#endif

Expand All @@ -58,7 +60,7 @@ FILE *freopen(const char *__restrict, const char *__restrict, FILE *__restrict);
int fclose(FILE *);

int remove(const char *);
int rename(const char *__old, const char *__new);
int rename(const char *, const char *);

int feof(FILE *__stream);
int ferror(FILE *);
Expand Down
4 changes: 2 additions & 2 deletions ulib/axlibc/include/stdlib.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef __STDLIB_H__
#define __STDLIB_H__

#include <stddef.h>
#include <features.h>
#include <stddef.h>

#define RAND_MAX (0x7fffffff)

Expand Down Expand Up @@ -51,7 +51,7 @@ int abs(int);
long labs(long);
long long llabs(long long);

int mkstemp (char *);
int mkstemp(char *);
int mkostemp(char *, int);
int setenv(const char *, const char *, int);
int unsetenv(const char *);
Expand Down
3 changes: 3 additions & 0 deletions ulib/axlibc/include/sys/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ struct itimerval {
};

int gettimeofday(struct timeval *tv, struct timezone *tz);

int getitimer(int, struct itimerval *);
int setitimer(int, const struct itimerval *__restrict, struct itimerval *__restrict);
int utimes(const char *filename, const struct timeval times[2]);

#endif
29 changes: 13 additions & 16 deletions ulib/axlibc/include/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,22 @@ struct tm {
const char *__tm_zone;
};

size_t strftime(char *__restrict__ _Buf, size_t _SizeInBytes, const char *__restrict__ _Format,
const struct tm *__restrict__ _Tm);

struct tm *gmtime(const time_t *timer);
clock_t clock(void);
time_t time(time_t *);
double difftime(time_t, time_t);
time_t mktime(struct tm *);
size_t strftime(char *__restrict, size_t, const char *__restrict, const struct tm *__restrict);
struct tm *gmtime(const time_t *);
struct tm *localtime(const time_t *);

struct tm *localtime(const time_t *timep);
struct tm *localtime_r(const time_t *__restrict__ __timer, struct tm *__restrict__ __tp);
struct tm *gmtime_r(const time_t *__restrict, struct tm *__restrict);
struct tm *localtime_r(const time_t *__restrict, struct tm *__restrict);
char *asctime_r(const struct tm *__restrict, char *__restrict);
char *ctime_r(const time_t *, char *);

time_t time(time_t *t);
int clock_gettime(clockid_t _clk, struct timespec *ts);
int nanosleep(const struct timespec *requested_time, struct timespec *remaining);
void tzset(void);

int setitimer(int which, const struct itimerval *restrict new, struct itimerval *restrict old);
char *ctime_r(const time_t *t, char *buf);
clock_t clock(void);

double difftime(time_t, time_t);

time_t mktime(struct tm *);
int nanosleep(const struct timespec *requested_time, struct timespec *remaining);
int clock_gettime(clockid_t _clk, struct timespec *ts);

#endif // __TIME_H__
2 changes: 1 addition & 1 deletion ulib/axlibc/include/unistd.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef __UNISTD_H__
#define __UNISTD_H__

#include <stddef.h>
#include <features.h>
#include <stddef.h>
#include <sys/stat.h>

#define STDIN_FILENO 0
Expand Down

0 comments on commit a6e34ef

Please sign in to comment.