Skip to content

Commit 0ee8ee9

Browse files
committed
Fixes for GCC compilation
1 parent 56c885a commit 0ee8ee9

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

newlib/libc/include/sys/lock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ typedef struct __lock * _LOCK_T;
4141
extern void __retarget_lock_init(_LOCK_T *lock);
4242
#define __lock_init(lock) __retarget_lock_init(&lock)
4343
extern void __retarget_lock_init_recursive(_LOCK_T *lock);
44-
#define __lock_init_recursive(lock) __retarget_lock_init_recursive(&lock)
44+
#define __lock_init_recursive(lock) __retarget_lock_init_recursive((_LOCK_T*)&lock)
4545
extern void __retarget_lock_close(_LOCK_T lock);
4646
#define __lock_close(lock) __retarget_lock_close(lock)
4747
extern void __retarget_lock_close_recursive(_LOCK_T lock);

newlib/libc/include/sys/stat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ int mkfifo (const char *__path, mode_t __mode );
142142
int stat (const char *__restrict __path, struct stat *__restrict __sbuf );
143143
mode_t umask (mode_t __mask );
144144

145-
#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__)
145+
#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) || defined(__psp__)
146146
int lstat (const char *__restrict __path, struct stat *__restrict __buf );
147147
int mknod (const char *__path, mode_t __mode, dev_t __dev );
148148
#endif

newlib/libc/posix/ftw.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@
2525

2626
#include <ftw.h>
2727

28+
/* Static callback pointer to maintain the ftw callback between calls */
29+
static int (*ftw_callback)(const char *, const struct stat *, int);
30+
31+
static int ftw_wrapper(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
32+
{
33+
return ftw_callback(fpath, sb, typeflag);
34+
}
35+
2836
int ftw(const char *path, int (*fn)(const char *, const struct stat *, int), int fd_limit)
2937
{
30-
/* The following cast assumes that calling a function with one
31-
* argument more than it needs behaves as expected. This is
32-
* actually undefined, but works on all real-world machines. */
33-
return nftw(path, (int (*)())fn, fd_limit, FTW_PHYS);
38+
ftw_callback = fn;
39+
return nftw(path, ftw_wrapper, fd_limit, FTW_PHYS);
3440
}
3541

3642
#endif /* ! HAVE_OPENDIR */

newlib/libc/posix/glob.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ glob3(pathbuf, pathend, pathend_last, pattern, restpattern, pglob, limit)
620620
* and dirent.h as taking pointers to differently typed opaque
621621
* structures.
622622
*/
623-
struct dirent *(*readdirfunc)();
623+
struct dirent *(*readdirfunc)(void *);
624624

625625
if (pathend > pathend_last)
626626
return (1);
@@ -645,7 +645,7 @@ glob3(pathbuf, pathend, pathend_last, pattern, restpattern, pglob, limit)
645645
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
646646
readdirfunc = pglob->gl_readdir;
647647
else
648-
readdirfunc = readdir;
648+
readdirfunc = (struct dirent *(*)(void *))readdir;
649649
while ((dp = (*readdirfunc)(dirp))) {
650650
u_char *sc;
651651
Char *dc;

0 commit comments

Comments
 (0)