* lib/stub/getlogin.c: New file.
* lib/stub/setvbuf.c: New file.
* lib/stub/sigblock.c: New file.
* lib/libc+gnu.c: Include them.
* include/linux/x86/syscall.h (SYS_chdir): New macro.
* include/linux/x86_64/syscall.h (SYS_chdir): New macro.
* include/stdio.h (_IOFBF, _IOLBF, _IONBF): New macro.
* include/errno.h (ENOEXEC, ECHILD): New macro.
* include/sys/wait.h (WNOHANG): New macro.
* lib/linux/gnu.c (chdir): New function.
* include/ar.h: New file.
--- /dev/null
+/* -*-comment-start: "//";comment-end:""-*-
+ * GNU Mes --- Maxwell Equations of Software
+ * Copyright (C) 1996 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/>.
+ */
+#ifndef __MES_AR_H
+#define __MES_AR_H 1
+
+#if WITH_GLIBC
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#undef __MES_AR_H
+#include_next <ar.h>
+
+#else // ! WITH_GLIBC
+
+// Taken from GNU C Library 2.2.5
+
+/* Archive files start with the ARMAG identifying string. Then follows a
+ `struct ar_hdr', and as many bytes of member file data as its `ar_size'
+ member indicates, for each member file. */
+
+#define ARMAG "!<arch>\n" /* String that begins an archive file. */
+#define SARMAG 8 /* Size of that string. */
+
+#define ARFMAG "`\n" /* String in ar_fmag at end of each header. */
+
+struct ar_hdr
+ {
+ char ar_name[16]; /* Member file name, sometimes / terminated. */
+ char ar_date[12]; /* File date, decimal seconds since Epoch. */
+ char ar_uid[6], ar_gid[6]; /* User and group IDs, in ASCII decimal. */
+ char ar_mode[8]; /* File mode, in ASCII octal. */
+ char ar_size[10]; /* File size, in ASCII decimal. */
+ char ar_fmag[2]; /* Always contains ARFMAG. */
+ };
+
+#endif // ! WITH_GLIBC
+
+#endif // __MES_ARGZ_H
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
- * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+ * Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
#define EINTR 4
#define EIO 5
#define E2BIG 7
+#define ENOEXEC 8
#define EBADF 9
+#define ECHILD 10
#define EAGAIN 11
#define ENOMEM 12
#define EEXIST 17
#define SYS_getcwd 0xb7
// libc+gnu
+#define SYS_chdir 0x0c
#define SYS_link 0x09
#define SYS_getpid 0x14
#define SYS_getuid 0x18
#define SYS_getcwd 0x4f
// libc+gnu
+#define SYS_chdir 0x50
#define SYS_link 0x56
#define SYS_getpid 0x27
#define SYS_getuid 0x66
#else // ! WITH_GLIBC
+#ifndef _IOFBF
+#define _IOFBF 0 /* Fully buffered. */
+#define _IOLBF 1 /* Line buffered. */
+#define _IONBF 2 /* No buffering. */
+#endif
+
#ifndef BUFSIZ
#define BUFSIZ 256
#endif
int fseek (FILE *stream, long offset, int whence);
int getc (FILE *stream);
int getchar (void);
+char *getlogin (void);
int printf (char const* format, ...);
int putc (int c, FILE* stream);
int putchar (int c);
int puts (char const* s);
int remove (char const *file_name);
+int setvbuf (FILE *stream, char *buf, int mode, size_t size);
int snprintf(char *str, size_t size, char const *format, ...);
int sprintf (char *str, char const* format, ...);
int sscanf (char const *str, const char *format, ...);
char *strcpy (char *dest, char const *src);
size_t strlen (char const*);
char *strncpy (char *to, char const *from, size_t size);
-int strncasecmp (char const *s1, char const *s2, size_t size);
int strncmp (char const*, char const*, size_t);
char *strrchr (char const *s, int c);
char *strstr (char const *haystack, char const *needle);
typedef int pid_t;
#endif
+#define WNOHANG 1
+
pid_t waitpid (pid_t pid, int *status_ptr, int options);
pid_t wait (int *status_ptr);
#include <dirent/opendir.c>
#include <dirent/readdir.c>
+// diffutils
#include <posix/execl.c>
+
+// make
+#include <stub/getlogin.c>
+#include <stub/setvbuf.c>
+#include <stub/sigblock.c>
#include <sys/resource.h>
+int
+chdir (char const *file_name)
+{
+ return _sys_call1 (SYS_chdir, (long)file_name);
+}
+
int
link (char const *old_name, char const *new_name)
{
--- /dev/null
+/* -*-comment-start: "//";comment-end:""-*-
+ * GNU Mes --- Maxwell Equations of Software
+ * 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/>.
+ */
+
+#include <libmes.h>
+#include <unistd.h>
+
+char *
+getlogin (void)
+{
+ static int stub = 0;
+ if (__mes_debug () && !stub)
+ eputs ("getlogin stub\n");
+ stub = 1;
+ errno = 0;
+ return 0;
+}
--- /dev/null
+/* -*-comment-start: "//";comment-end:""-*-
+ * GNU Mes --- Maxwell Equations of Software
+ * 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/>.
+ */
+
+#include <libmes.h>
+#include <stdio.h>
+
+int
+setvbuf (FILE *stream, char *buf, int mode, size_t size)
+{
+ static int stub = 0;
+ if (__mes_debug () && !stub)
+ eputs ("setvbuf stub\n");
+ stub = 1;
+ return 0;
+}
--- /dev/null
+/* -*-comment-start: "//";comment-end:""-*-
+ * GNU Mes --- Maxwell Equations of Software
+ * 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/>.
+ */
+
+#include <libmes.h>
+#include <signal.h>
+
+int
+sigblock (int mask)
+{
+ return 0;
+}