mescc: Mes C Library: Support make: Add chdir, getlogin, setvbuf, sigblock.
* 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.
This commit is contained in:
parent
543ae4df32
commit
8b9d51e4a4
56
include/ar.h
Normal file
56
include/ar.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* -*-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
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-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.
|
||||
*
|
||||
|
@ -39,7 +39,9 @@ int errno;
|
|||
#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
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#define SYS_getcwd 0xb7
|
||||
|
||||
// libc+gnu
|
||||
#define SYS_chdir 0x0c
|
||||
#define SYS_link 0x09
|
||||
#define SYS_getpid 0x14
|
||||
#define SYS_getuid 0x18
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#define SYS_getcwd 0x4f
|
||||
|
||||
// libc+gnu
|
||||
#define SYS_chdir 0x50
|
||||
#define SYS_link 0x56
|
||||
#define SYS_getpid 0x27
|
||||
#define SYS_getuid 0x66
|
||||
|
|
|
@ -45,6 +45,12 @@ int g_stdout;
|
|||
|
||||
#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
|
||||
|
@ -80,11 +86,13 @@ int fputs (char const* s, FILE *stream);
|
|||
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, ...);
|
||||
|
|
|
@ -58,7 +58,6 @@ int strcmp (char const*, char const*);
|
|||
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);
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
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);
|
||||
|
||||
|
|
|
@ -104,4 +104,10 @@
|
|||
#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>
|
||||
|
|
|
@ -20,6 +20,12 @@
|
|||
|
||||
#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)
|
||||
{
|
||||
|
|
33
lib/stub/getlogin.c
Normal file
33
lib/stub/getlogin.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* -*-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;
|
||||
}
|
32
lib/stub/setvbuf.c
Normal file
32
lib/stub/setvbuf.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* -*-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;
|
||||
}
|
28
lib/stub/sigblock.c
Normal file
28
lib/stub/sigblock.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
/* -*-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;
|
||||
}
|
Loading…
Reference in a new issue