use preprocessed musl

This commit is contained in:
Jan (janneke) Nieuwenhuizen 2022-10-30 22:24:36 +01:00
parent 00096e6c9a
commit 299f63e823
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
4 changed files with 817 additions and 173 deletions

View File

@ -1,88 +1,405 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright (C) 1991-1996,98,2000,2001 Free Software Foundation, Inc.
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
# 1 "src/dirent/opendir.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "src/dirent/opendir.c"
// Taken from GNU C Library 2.2.5
# 1 "./include/dirent.h" 1
#include <mes/lib.h>
#include <errno.h>
#include <limits.h>
#include <stddef.h>
#include <stdlib.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <dirstream.h>
/* Open a directory stream on NAME. */
DIR *
opendir (char const *name)
# 1 "./src/include/features.h" 1
# 1 "./src/include/../../include/features.h" 1
# 5 "./src/include/features.h" 2
# 9 "./include/dirent.h" 2
# 1 "obj/include/bits/alltypes.h" 1
# 136 "obj/include/bits/alltypes.h"
typedef unsigned int size_t;
# 238 "obj/include/bits/alltypes.h"
typedef long long off_t;
typedef unsigned long long ino_t;
# 17 "./include/dirent.h" 2
typedef struct __dirstream DIR;
struct dirent {
ino_t d_ino;
off_t d_off;
unsigned short d_reclen;
unsigned char d_type;
char d_name[256];
};
int closedir(DIR *);
DIR *fdopendir(int);
DIR *opendir(const char *);
struct dirent *readdir(DIR *);
int readdir_r(DIR *restrict, struct dirent *restrict, struct dirent **restrict);
void rewinddir(DIR *);
int dirfd(DIR *);
int alphasort(const struct dirent **, const struct dirent **);
int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **));
void seekdir(DIR *, long);
long telldir(DIR *);
# 62 "./include/dirent.h"
int getdents(int, struct dirent *, size_t);
int versionsort(const struct dirent **, const struct dirent **);
# 3 "src/dirent/opendir.c" 2
# 1 "./include/fcntl.h" 1
# 20 "./include/fcntl.h"
# 1 "obj/include/bits/alltypes.h" 1
# 151 "obj/include/bits/alltypes.h"
typedef int ssize_t;
# 228 "obj/include/bits/alltypes.h"
typedef unsigned mode_t;
# 311 "obj/include/bits/alltypes.h"
typedef int pid_t;
# 420 "obj/include/bits/alltypes.h"
struct iovec { void *iov_base; size_t iov_len; };
# 21 "./include/fcntl.h" 2
# 1 "./arch/generic/bits/fcntl.h" 1
# 23 "./include/fcntl.h" 2
struct flock {
short l_type;
short l_whence;
off_t l_start;
off_t l_len;
pid_t l_pid;
};
int creat(const char *, mode_t);
int fcntl(int, int, ...);
int open(const char *, int, ...);
int openat(int, const char *, int, ...);
int posix_fadvise(int, off_t, off_t, int);
int posix_fallocate(int, off_t, off_t);
# 159 "./include/fcntl.h"
int lockf(int, int, off_t);
struct file_handle {
unsigned handle_bytes;
int handle_type;
unsigned char f_handle[];
};
struct f_owner_ex {
int type;
pid_t pid;
};
# 186 "./include/fcntl.h"
int fallocate(int, int, off_t, off_t);
int name_to_handle_at(int, const char *, struct file_handle *, int *, int);
int open_by_handle_at(int, struct file_handle *, int);
ssize_t readahead(int, off_t, size_t);
int sync_file_range(int, off_t, off_t, unsigned);
ssize_t vmsplice(int, const struct iovec *, size_t, unsigned);
ssize_t splice(int, off_t *, int, off_t *, size_t, unsigned);
ssize_t tee(int, int, size_t, unsigned);
# 4 "src/dirent/opendir.c" 2
# 1 "./src/include/stdlib.h" 1
# 1 "./src/include/../../include/stdlib.h" 1
# 19 "./src/include/../../include/stdlib.h"
# 1 "obj/include/bits/alltypes.h" 1
# 32 "obj/include/bits/alltypes.h"
typedef long int wchar_t;
# 20 "./src/include/../../include/stdlib.h" 2
int atoi (const char *);
long atol (const char *);
long long atoll (const char *);
double atof (const char *);
float strtof (const char *restrict, char **restrict);
double strtod (const char *restrict, char **restrict);
long double strtold (const char *restrict, char **restrict);
long strtol (const char *restrict, char **restrict, int);
unsigned long strtoul (const char *restrict, char **restrict, int);
long long strtoll (const char *restrict, char **restrict, int);
unsigned long long strtoull (const char *restrict, char **restrict, int);
int rand (void);
void srand (unsigned);
void *malloc (size_t);
void *calloc (size_t, size_t);
void *realloc (void *, size_t);
void free (void *);
void *aligned_alloc(size_t, size_t);
__attribute__((__noreturn__)) void abort (void);
int atexit (void (*) (void));
__attribute__((__noreturn__)) void exit (int);
__attribute__((__noreturn__)) void _Exit (int);
int at_quick_exit (void (*) (void));
__attribute__((__noreturn__)) void quick_exit (int);
char *getenv (const char *);
int system (const char *);
void *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
void qsort (void *, size_t, size_t, int (*)(const void *, const void *));
int abs (int);
long labs (long);
long long llabs (long long);
typedef struct { int quot, rem; } div_t;
typedef struct { long quot, rem; } ldiv_t;
typedef struct { long long quot, rem; } lldiv_t;
div_t div (int, int);
ldiv_t ldiv (long, long);
lldiv_t lldiv (long long, long long);
int mblen (const char *, size_t);
int mbtowc (wchar_t *restrict, const char *restrict, size_t);
int wctomb (char *, wchar_t);
size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t);
size_t wcstombs (char *restrict, const wchar_t *restrict, size_t);
size_t __ctype_get_mb_cur_max(void);
# 99 "./src/include/../../include/stdlib.h"
int posix_memalign (void **, size_t, size_t);
int setenv (const char *, const char *, int);
int unsetenv (const char *);
int mkstemp (char *);
int mkostemp (char *, int);
char *mkdtemp (char *);
int getsubopt (char **, char *const *, char **);
int rand_r (unsigned *);
char *realpath (const char *restrict, char *restrict);
long int random (void);
void srandom (unsigned int);
char *initstate (unsigned int, char *, size_t);
char *setstate (char *);
int putenv (char *);
int posix_openpt (int);
int grantpt (int);
int unlockpt (int);
char *ptsname (int);
char *l64a (long);
long a64l (const char *);
void setkey (const char *);
double drand48 (void);
double erand48 (unsigned short [3]);
long int lrand48 (void);
long int nrand48 (unsigned short [3]);
long mrand48 (void);
long jrand48 (unsigned short [3]);
void srand48 (long);
unsigned short *seed48 (unsigned short [3]);
void lcong48 (unsigned short [7]);
# 1 "./include/alloca.h" 1
# 9 "./include/alloca.h"
# 1 "obj/include/bits/alltypes.h" 1
# 10 "./include/alloca.h" 2
void *alloca(size_t);
# 139 "./src/include/../../include/stdlib.h" 2
char *mktemp (char *);
int mkstemps (char *, int);
int mkostemps (char *, int, int);
void *valloc (size_t);
void *memalign(size_t, size_t);
int getloadavg(double *, int);
int clearenv(void);
int ptsname_r(int, char *, size_t);
char *ecvt(double, int, int *, int *);
char *fcvt(double, int, int *, int *);
char *gcvt(double, int, char *);
char *secure_getenv(const char *);
struct __locale_struct;
float strtof_l(const char *restrict, char **restrict, struct __locale_struct *);
double strtod_l(const char *restrict, char **restrict, struct __locale_struct *);
long double strtold_l(const char *restrict, char **restrict, struct __locale_struct *);
# 5 "./src/include/stdlib.h" 2
__attribute__((__visibility__("hidden"))) int __putenv(char *, size_t, char *);
__attribute__((__visibility__("hidden"))) void __env_rm_add(char *, char *);
__attribute__((__visibility__("hidden"))) int __mkostemps(char *, int, int);
__attribute__((__visibility__("hidden"))) int __ptsname_r(int, char *, size_t);
__attribute__((__visibility__("hidden"))) char *__randname(char *);
# 5 "src/dirent/opendir.c" 2
# 1 "src/dirent/__dirent.h" 1
struct __dirstream
{
DIR *dirp;
struct stat statbuf;
int fd;
size_t allocation;
int save_errno;
off_t tell;
int fd;
int buf_pos;
int buf_end;
volatile int lock[1];
if (name[0] == '\0')
{
/* POSIX.1-1990 says an empty name gets ENOENT;
but `open' might like it fine. */
errno = ENOENT;
return 0;
}
int flags = O_RDONLY | O_DIRECTORY;
#if __SIZEOF_LONG_LONG__ == 8
flags |= O_LARGEFILE;
#endif
fd = open (name, flags);
if (fd < 0)
return 0;
char buf[2048];
};
# 6 "src/dirent/opendir.c" 2
# 1 "./src/internal/syscall.h" 1
if (fstat (fd, &statbuf) < 0)
goto lose;
if (fcntl (fd, F_SETFD, FD_CLOEXEC) < 0)
goto lose;
allocation = statbuf.st_blksize;
dirp = (DIR *) calloc (1, sizeof (DIR) + allocation);
if (!dirp)
lose:
{
save_errno = errno;
close (fd);
errno = save_errno;
return 0;
}
#if __SIZEOF_LONG_LONG__ != 8
dirp->data = (char *) (dirp + 1);
dirp->allocation = allocation;
#endif
dirp->fd = fd;
# 1 "./include/sys/syscall.h" 1
return dirp;
# 1 "obj/include/bits/syscall.h" 1
# 5 "./include/sys/syscall.h" 2
# 6 "./src/internal/syscall.h" 2
# 1 "./arch/i386/syscall_arch.h" 1
# 15 "./arch/i386/syscall_arch.h"
static inline long __syscall0(long n)
{
unsigned long __ret;
__asm__ __volatile__ ("call *%%gs:16" : "=a"(__ret) : "a"(n) : "memory");
return __ret;
}
static inline long __syscall1(long n, long a1)
{
unsigned long __ret;
__asm__ __volatile__ ("xchg %%ebx,%%edx ; " "call *%%gs:16" " ; xchg %%ebx,%%edx" : "=a"(__ret) : "a"(n), "d"(a1) : "memory");
return __ret;
}
static inline long __syscall2(long n, long a1, long a2)
{
unsigned long __ret;
__asm__ __volatile__ ("xchg %%ebx,%%edx ; " "call *%%gs:16" " ; xchg %%ebx,%%edx" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2) : "memory");
return __ret;
}
static inline long __syscall3(long n, long a1, long a2, long a3)
{
unsigned long __ret;
__asm__ __volatile__ ("call *%%gs:16" : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3) : "memory");
return __ret;
}
static inline long __syscall4(long n, long a1, long a2, long a3, long a4)
{
unsigned long __ret;
__asm__ __volatile__ ("call *%%gs:16" : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4) : "memory");
return __ret;
}
static inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5)
{
unsigned long __ret;
__asm__ __volatile__ ("call *%%gs:16"
: "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4), "D"(a5) : "memory");
return __ret;
}
static inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6)
{
unsigned long __ret;
__asm__ __volatile__ ("pushl %7 ; push %%ebp ; mov 4(%%esp),%%ebp ; " "call *%%gs:16" " ; pop %%ebp ; add $4,%%esp"
: "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4), "D"(a5), "g"(a6) : "memory");
return __ret;
}
# 7 "./src/internal/syscall.h" 2
# 22 "./src/internal/syscall.h"
typedef long syscall_arg_t;
__attribute__((__visibility__("hidden"))) long __syscall_ret(unsigned long),
__syscall_cp(syscall_arg_t, syscall_arg_t, syscall_arg_t, syscall_arg_t,
syscall_arg_t, syscall_arg_t, syscall_arg_t);
# 335 "./src/internal/syscall.h"
__attribute__((__visibility__("hidden"))) void __procfdname(char __buf[27], unsigned);
__attribute__((__visibility__("hidden"))) void *__vdsosym(const char *, const char *);
# 7 "src/dirent/opendir.c" 2
DIR *opendir(const char *name)
{
int fd;
DIR *dir;
if ((fd = open(name, 00|0200000|02000000)) < 0)
return 0;
if (!(dir = calloc(1, sizeof *dir))) {
__syscall1(6,((long) (fd)));
return 0;
}
dir->fd = fd;
return dir;
}

View File

@ -1,88 +1,231 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright (C) 1991,92,93,94,95,96,97,99,2000 Free Software Foundation, Inc.
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
# 1 "src/dirent/readdir.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "src/dirent/readdir.c"
# 1 "./include/dirent.h" 1
// Taken from GNU C Library 2.2.5
#include <errno.h>
#include <limits.h>
#include <stddef.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/types.h>
#include <assert.h>
#include <dirstream.h>
int getdents (int filedes, char *buffer, size_t nbytes);
/* Read a directory entry from DIRP. */
struct dirent *
readdir (DIR * dirp)
# 1 "./src/include/features.h" 1
# 1 "./src/include/../../include/features.h" 1
# 5 "./src/include/features.h" 2
# 9 "./include/dirent.h" 2
# 1 "obj/include/bits/alltypes.h" 1
# 238 "obj/include/bits/alltypes.h"
typedef long long off_t;
typedef unsigned long long ino_t;
# 17 "./include/dirent.h" 2
typedef struct __dirstream DIR;
struct dirent {
ino_t d_ino;
off_t d_off;
unsigned short d_reclen;
unsigned char d_type;
char d_name[256];
};
int closedir(DIR *);
DIR *fdopendir(int);
DIR *opendir(const char *);
struct dirent *readdir(DIR *);
int readdir_r(DIR *restrict, struct dirent *restrict, struct dirent **restrict);
void rewinddir(DIR *);
int dirfd(DIR *);
int alphasort(const struct dirent **, const struct dirent **);
int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **));
void seekdir(DIR *, long);
long telldir(DIR *);
# 2 "src/dirent/readdir.c" 2
# 1 "./src/include/errno.h" 1
extern int errno;
# 1 "./src/include/../../include/errno.h" 1
# 10 "./src/include/../../include/errno.h"
# 1 "./arch/generic/bits/errno.h" 1
# 11 "./src/include/../../include/errno.h" 2
__attribute__((const))
//int *__errno_location(void);
# 5 "./src/include/errno.h" 2
__attribute__((const))
//__attribute__((__visibility__("hidden"))) int *___errno_location(void);
# 3 "src/dirent/readdir.c" 2
# 1 "./include/stddef.h" 1
# 17 "./include/stddef.h"
# 1 "obj/include/bits/alltypes.h" 1
# 32 "obj/include/bits/alltypes.h"
typedef long int wchar_t;
# 136 "obj/include/bits/alltypes.h"
typedef unsigned int size_t;
# 146 "obj/include/bits/alltypes.h"
typedef int ptrdiff_t;
# 18 "./include/stddef.h" 2
# 4 "src/dirent/readdir.c" 2
# 1 "src/dirent/__dirent.h" 1
struct __dirstream
{
struct dirent *dp;
int save_errno = errno;
off_t tell;
int fd;
int buf_pos;
int buf_end;
volatile int lock[1];
do
{
size_t reclen;
if (dirp->offset >= dirp->size)
{
/* We've emptied out our buffer. Refill it. */
char buf[2048];
};
# 5 "src/dirent/readdir.c" 2
# 1 "./src/internal/syscall.h" 1
size_t maxread;
ssize_t bytes;
maxread = dirp->allocation;
#if 0
off_t base;
bytes = __getdirentries (dirp->fd, dirp->data, maxread, &base);
#else
bytes = getdents (dirp->fd, dirp->data, maxread);
#endif
if (bytes <= 0)
{
/* Don't modifiy errno when reaching EOF. */
if (bytes == 0)
errno = save_errno;
dp = 0;
break;
}
dirp->size = (size_t) bytes;
/* Reset the offset into the buffer. */
dirp->offset = 0;
}
# 1 "./include/sys/syscall.h" 1
dp = (struct dirent *) &dirp->data[dirp->offset];
reclen = dp->d_reclen;
dirp->offset += reclen;
dirp->filepos = dp->d_off;
/* Skip deleted files. */
}
while (dp->d_ino == 0);
return dp;
# 1 "obj/include/bits/syscall.h" 1
# 5 "./include/sys/syscall.h" 2
# 6 "./src/internal/syscall.h" 2
# 1 "./arch/i386/syscall_arch.h" 1
# 15 "./arch/i386/syscall_arch.h"
static inline long __syscall0(long n)
{
unsigned long __ret;
__asm__ __volatile__ ("call *%%gs:16" : "=a"(__ret) : "a"(n) : "memory");
return __ret;
}
static inline long __syscall1(long n, long a1)
{
unsigned long __ret;
__asm__ __volatile__ ("xchg %%ebx,%%edx ; " "call *%%gs:16" " ; xchg %%ebx,%%edx" : "=a"(__ret) : "a"(n), "d"(a1) : "memory");
return __ret;
}
static inline long __syscall2(long n, long a1, long a2)
{
unsigned long __ret;
__asm__ __volatile__ ("xchg %%ebx,%%edx ; " "call *%%gs:16" " ; xchg %%ebx,%%edx" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2) : "memory");
return __ret;
}
static inline long __syscall3(long n, long a1, long a2, long a3)
{
unsigned long __ret;
__asm__ __volatile__ ("call *%%gs:16" : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3) : "memory");
return __ret;
}
static inline long __syscall4(long n, long a1, long a2, long a3, long a4)
{
unsigned long __ret;
__asm__ __volatile__ ("call *%%gs:16" : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4) : "memory");
return __ret;
}
static inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5)
{
unsigned long __ret;
__asm__ __volatile__ ("call *%%gs:16"
: "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4), "D"(a5) : "memory");
return __ret;
}
static inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6)
{
unsigned long __ret;
__asm__ __volatile__ ("pushl %7 ; push %%ebp ; mov 4(%%esp),%%ebp ; " "call *%%gs:16" " ; pop %%ebp ; add $4,%%esp"
: "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4), "D"(a5), "g"(a6) : "memory");
return __ret;
}
# 7 "./src/internal/syscall.h" 2
# 22 "./src/internal/syscall.h"
typedef long syscall_arg_t;
__attribute__((__visibility__("hidden"))) long __syscall_ret(unsigned long),
__syscall_cp(syscall_arg_t, syscall_arg_t, syscall_arg_t, syscall_arg_t,
syscall_arg_t, syscall_arg_t, syscall_arg_t);
# 335 "./src/internal/syscall.h"
__attribute__((__visibility__("hidden"))) void __procfdname(char __buf[27], unsigned);
__attribute__((__visibility__("hidden"))) void *__vdsosym(const char *, const char *);
# 6 "src/dirent/readdir.c" 2
typedef char dirstream_buf_alignment_check[1-2*(int)(
__builtin_offsetof(struct __dirstream, buf) % sizeof(off_t))];
struct dirent *readdir(DIR *dir)
{
struct dirent *de;
if (dir->buf_pos >= dir->buf_end) {
int len = __syscall3(220,((long) (dir->fd)),((long) (dir->buf)),((long) (sizeof dir->buf)));
if (len <= 0) {
if (len < 0 && len != -2) errno = -len;
return 0;
}
dir->buf_end = len;
dir->buf_pos = 0;
}
de = (void *)(dir->buf + dir->buf_pos);
dir->buf_pos += de->d_reclen;
dir->tell = de->d_off;
return de;
}
extern __typeof(readdir) readdir64 __attribute__((__weak__, __alias__("readdir")));

View File

@ -1,29 +1,187 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
# 1 "src/linux/getdents.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "src/linux/getdents.c"
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <sys/types.h>
# 1 "./include/dirent.h" 1
int
getdents (int filedes, char *buffer, size_t nbytes)
# 1 "./src/include/features.h" 1
# 1 "./src/include/../../include/features.h" 1
# 5 "./src/include/features.h" 2
# 9 "./include/dirent.h" 2
# 1 "obj/include/bits/alltypes.h" 1
# 136 "obj/include/bits/alltypes.h"
typedef unsigned int size_t;
# 238 "obj/include/bits/alltypes.h"
typedef long long off_t;
typedef unsigned long long ino_t;
# 17 "./include/dirent.h" 2
typedef struct __dirstream DIR;
struct dirent {
ino_t d_ino;
off_t d_off;
unsigned short d_reclen;
unsigned char d_type;
char d_name[256];
};
int closedir(DIR *);
DIR *fdopendir(int);
DIR *opendir(const char *);
struct dirent *readdir(DIR *);
int readdir_r(DIR *restrict, struct dirent *restrict, struct dirent **restrict);
void rewinddir(DIR *);
int dirfd(DIR *);
int alphasort(const struct dirent **, const struct dirent **);
int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **));
void seekdir(DIR *, long);
long telldir(DIR *);
# 62 "./include/dirent.h"
int getdents(int, struct dirent *, size_t);
# 3 "src/linux/getdents.c" 2
# 1 "./include/limits.h" 1
# 1 "./arch/i386/bits/limits.h" 1
# 9 "./include/limits.h" 2
# 4 "src/linux/getdents.c" 2
# 1 "./src/internal/syscall.h" 1
# 1 "./include/sys/syscall.h" 1
# 1 "obj/include/bits/syscall.h" 1
# 5 "./include/sys/syscall.h" 2
# 6 "./src/internal/syscall.h" 2
# 1 "./arch/i386/syscall_arch.h" 1
# 15 "./arch/i386/syscall_arch.h"
static inline long __syscall0(long n)
{
return _sys_call3 (SYS_getdents, (int) filedes, (long) buffer, (long) nbytes);
unsigned long __ret;
__asm__ __volatile__ ("call *%%gs:16" : "=a"(__ret) : "a"(n) : "memory");
return __ret;
}
static inline long __syscall1(long n, long a1)
{
unsigned long __ret;
__asm__ __volatile__ ("xchg %%ebx,%%edx ; " "call *%%gs:16" " ; xchg %%ebx,%%edx" : "=a"(__ret) : "a"(n), "d"(a1) : "memory");
return __ret;
}
static inline long __syscall2(long n, long a1, long a2)
{
unsigned long __ret;
__asm__ __volatile__ ("xchg %%ebx,%%edx ; " "call *%%gs:16" " ; xchg %%ebx,%%edx" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2) : "memory");
return __ret;
}
static inline long __syscall3(long n, long a1, long a2, long a3)
{
unsigned long __ret;
__asm__ __volatile__ ("call *%%gs:16" : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3) : "memory");
return __ret;
}
static inline long __syscall4(long n, long a1, long a2, long a3, long a4)
{
unsigned long __ret;
__asm__ __volatile__ ("call *%%gs:16" : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4) : "memory");
return __ret;
}
static inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5)
{
unsigned long __ret;
__asm__ __volatile__ ("call *%%gs:16"
: "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4), "D"(a5) : "memory");
return __ret;
}
static inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6)
{
unsigned long __ret;
__asm__ __volatile__ ("pushl %7 ; push %%ebp ; mov 4(%%esp),%%ebp ; " "call *%%gs:16" " ; pop %%ebp ; add $4,%%esp"
: "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4), "D"(a5), "g"(a6) : "memory");
return __ret;
}
# 7 "./src/internal/syscall.h" 2
# 22 "./src/internal/syscall.h"
typedef long syscall_arg_t;
__attribute__((__visibility__("hidden"))) long __syscall_ret(unsigned long),
__syscall_cp(syscall_arg_t, syscall_arg_t, syscall_arg_t, syscall_arg_t,
syscall_arg_t, syscall_arg_t, syscall_arg_t);
# 335 "./src/internal/syscall.h"
__attribute__((__visibility__("hidden"))) void __procfdname(char __buf[27], unsigned);
__attribute__((__visibility__("hidden"))) void *__vdsosym(const char *, const char *);
# 5 "src/linux/getdents.c" 2
int getdents(int fd, struct dirent *buf, size_t len)
{
if (len>0x7fffffff) len = 0x7fffffff;
return __syscall_ret(__syscall3(220,((long) (fd)),((long) (buf)),((long) (len))));
}
extern __typeof(getdents) getdents64 __attribute__((__weak__, __alias__("getdents")));

View File

@ -19,8 +19,34 @@
*/
#include <mes/lib.h>
#include <sys/types.h>
//#include <dirent.h>
struct dirent {
ino_t d_ino;
off_t d_off;
unsigned short d_reclen;
unsigned char d_type;
char d_name[256];
};
struct __dirstream
{
off_t tell;
int fd;
int buf_pos;
int buf_end;
volatile int lock[1];
char buf[2048];
};
typedef struct __dirstream DIR;
struct dirent *readdir(DIR *);
DIR *opendir(const char *);
#include <dirent.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>