Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: adapt to gcc 14.2 #384

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions include/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,27 @@ void pthread_cleanup_push(void (*routine)(void *), void *arg);
void pthread_cleanup_pop(int execute);


int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);


int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);


int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);


int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);


int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);


int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);


int pthread_rwlock_init(pthread_rwlock_t *__restrict__ rwlock, const pthread_rwlockattr_t *__restrict__ attr);


#ifdef __cplusplus
}
#endif
Expand Down
5 changes: 5 additions & 0 deletions include/sys/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ typedef struct {
volatile int initialized;
} pthread_mutex_t;

/* TODO */
typedef int pthread_rwlock_t;

typedef int pthread_rwlockattr_t;


typedef struct lockAttr pthread_mutexattr_t;

Expand Down
3 changes: 3 additions & 0 deletions include/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ extern int ttyname_r(int fildes, char *name, size_t namesize);
extern int pause(void);


int chroot(const char *path);


extern char *optarg;


Expand Down
51 changes: 51 additions & 0 deletions pthread/pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,57 @@ void pthread_cleanup_pop(int execute)
}


/* FIXME: rwlocks are yet to be implemented, that breaks shared_mutex in cpp. */
int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
{
(void)rwlock;
return ENOSYS;
}


int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock)
{
(void)rwlock;
return ENOSYS;
}


int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock)
{
(void)rwlock;
return ENOSYS;
}


int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock)
{
(void)rwlock;
return ENOSYS;
}


int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
{
(void)rwlock;
return ENOSYS;
}


int pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
{
(void)rwlock;
return ENOSYS;
}


int pthread_rwlock_init(pthread_rwlock_t *__restrict__ rwlock, const pthread_rwlockattr_t *__restrict__ attr)
{
(void)rwlock;
(void)attr;
return ENOSYS;
}


void _pthread_init(void)
{
mutexCreate(&pthread_common.pthread_key_lock);
Expand Down
4 changes: 3 additions & 1 deletion string/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ int memcmp(const void *s1, const void *s2, size_t count)

#ifndef __STRLEN
#define __STRLEN
size_t strlen(const char *s)
/* FIXME: long-standing bug in gcc https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725
* it occurs in strlen causing inf loop, can be avoided if all platform implement strlen in asm. */
__attribute__((optimize("-fno-tree-loop-distribute-patterns"))) size_t strlen(const char *s)
{
unsigned int k;

Expand Down
2 changes: 1 addition & 1 deletion sys/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ WRAP_ERRNO_DEF(int, listen, (int socket, int backlog), (socket, backlog))
WRAP_ERRNO_DEF(ssize_t, recvfrom, (int socket, void *message, size_t length, int flags, struct sockaddr *src_addr, socklen_t *src_len), (socket, message, length, flags, src_addr, src_len))
WRAP_ERRNO_DEF(ssize_t, sendto, (int socket, const void *message, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t dest_len), (socket, message, length, flags, dest_addr, dest_len))
WRAP_ERRNO_DEF(int, socket, (int domain, int type, int protocol), (domain, type, protocol))
WRAP_ERRNO_DEF(int, socketpair, (int domain, int type, int protocol, int *sv), (domain, type, protocol, sv))
WRAP_ERRNO_DEF(int, socketpair, (int domain, int type, int protocol, int sv[2]), (domain, type, protocol, sv))
WRAP_ERRNO_DEF(int, shutdown, (int socket, int how), (socket, how))
WRAP_ERRNO_DEF(int, setsockopt, (int socket, int level, int optname, const void *optval, socklen_t optlen), (socket, level, optname, optval, optlen))

Expand Down
Loading