core: Prepare for the Hurd.
* lib/linux/libc.c: Move from lib/linux.c. * lib/linux/gcc.c: Move from lib/linux-gcc.c. * lib/linux/gnu.c: Move from lib/linux+gnu.c. * lib/linux/libc.c: Move from lib/linux.c. * lib/linux/mes.c: Move from lib/linux-mes.c. * lib/linux/mini-gcc.c: Move from lib/linux-mini-gcc.c. * lib/linux/mini-mes.c: Move from lib/linux-mini-mes.c. * lib/linux/tcc.c: Move from lib/linux+tcc.c. * lib/linux/crt0.c: Move from lib/crt0.c. * lib/linux/crt1.c: Move from lib/crt1.c. * lib/linux/crti.c: Move from lib/crti.c. * lib/linux/crtn.c: Move from lib/crtn.c. * build-aux/build-cc.sh: Update for new layout. * build-aux/build-cc32.sh: Likewise. * build-aux/build-mes.sh: Likewise. * build-aux/cc-mes.sh: Likewise. * build-aux/cc32-mes.sh: Likewise. * lib/string/argz-count.c: New file taken from GNU C Library, relicensed. * lib/string/argz-extract.c: New file taken from GNU C Library, relicensed. * include/argz.h: New file. * lib/string/memcpy.c: New file, extract from libc. * lib/assert/assert.c: Likewise.
This commit is contained in:
parent
9e1c618b00
commit
573896cc1c
2
AUTHORS
2
AUTHORS
|
@ -3,7 +3,7 @@ Main author
|
|||
All files except the imported files listed below
|
||||
|
||||
Jeremiah Orians <jeremiah@pdp10.guru>
|
||||
lib/libc.c (fopen)
|
||||
lib/libc+tcc.c (fopen)
|
||||
scaffold/tests/98-fopen.c
|
||||
|
||||
Han-Wen Nienhuys <hanwen@xs4all.nl>
|
||||
|
|
|
@ -71,10 +71,10 @@ CC32_CFLAGS=${CC32_CFLAGS-"
|
|||
-Wno-incompatible-pointer-types
|
||||
"}
|
||||
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc32-mes.sh lib/crt0
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc32-mes.sh lib/crt1
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc32-mes.sh lib/crti
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc32-mes.sh lib/crtn
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc32-mes.sh lib/linux/crt0
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc32-mes.sh lib/linux/crt1
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc32-mes.sh lib/linux/crti
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc32-mes.sh lib/linux/crtn
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc32-mes.sh lib/libc-mini
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc32-mes.sh lib/libc
|
||||
ARCHDIR=1 NOLINK=1 sh build-aux/cc32-mes.sh lib/libgetopt
|
||||
|
|
|
@ -105,10 +105,10 @@ if [ ! -d "$MES_SEED" ] \
|
|||
fi
|
||||
|
||||
MES_ARENA=100000000
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/crt0
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/crt1
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/crti
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/crtn
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/linux/crt0
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/linux/crt1
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/linux/crti
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/linux/crtn
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/libc-mini
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/libc
|
||||
ARCHDIR=1 NOLINK=1 bash build-aux/cc-mes.sh lib/libgetopt
|
||||
|
|
|
@ -57,7 +57,7 @@ if [ -z "$ARCHDIR" ]; then
|
|||
p="mes-"
|
||||
else
|
||||
b=${c##*/}
|
||||
d=${c%/*}
|
||||
d=${c%%/*}
|
||||
o="$d/x86-mes/$b"
|
||||
mkdir -p $d/x86-mes
|
||||
fi
|
||||
|
|
|
@ -63,7 +63,7 @@ if [ -z "$ARCHDIR" ]; then
|
|||
p="$a-"
|
||||
else
|
||||
b=${c##*/}
|
||||
d=${c%/*}
|
||||
d=${c%%/*}
|
||||
o="$d/$arch/$b"
|
||||
mkdir -p $d/$arch
|
||||
fi
|
||||
|
|
42
include/argz.h
Normal file
42
include/argz.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of Mes.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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 Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __MES_ARGZ_H
|
||||
#define __MES_ARGZ_H 1
|
||||
|
||||
#if WITH_GLIBC
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#undef __MES_ARGZ_H
|
||||
#include_next <argz.h>
|
||||
|
||||
#else // ! WITH_GLIBC
|
||||
|
||||
#ifndef libc_hidden_def
|
||||
#define libc_hidden_def(x)
|
||||
#define weak_alias(x,y)
|
||||
#endif
|
||||
|
||||
size_t __argz_count (char const *argz, size_t len);
|
||||
void __argz_extract (char const *argz, size_t len, char **argv);
|
||||
|
||||
#endif // ! WITH_GLIBC
|
||||
|
||||
#endif // __MES_ARGZ_H
|
|
@ -27,6 +27,9 @@
|
|||
#undef __MES_ERRNO_H
|
||||
#include_next <errno.h>
|
||||
#else // ! WITH_GLIBC
|
||||
|
||||
typedef int error_t;
|
||||
|
||||
int errno;
|
||||
#define ENOENT 2
|
||||
#define EINTR 4
|
||||
|
|
10
lib/assert/assert.c
Normal file
10
lib/assert/assert.c
Normal file
|
@ -0,0 +1,10 @@
|
|||
void
|
||||
assert_fail (char* s)
|
||||
{
|
||||
eputs ("assert fail: ");
|
||||
eputs (s);
|
||||
eputs ("\n");
|
||||
char *fail = s;
|
||||
fail = 0;
|
||||
*fail = 0;
|
||||
}
|
|
@ -244,7 +244,7 @@ sbrk (intptr_t delta)
|
|||
{
|
||||
if (delta >= 0)
|
||||
return malloc (delta);
|
||||
return g_brk;
|
||||
return __brk;
|
||||
}
|
||||
|
||||
// binutils 2.30
|
||||
|
|
|
@ -19,9 +19,19 @@
|
|||
*/
|
||||
|
||||
#include <libc+tcc.c>
|
||||
#include <linux+gnu.c>
|
||||
|
||||
#if __GNU__
|
||||
#include <linux/gnu.c>
|
||||
#elif __linux__
|
||||
#include <linux/gnu.c>
|
||||
#else
|
||||
#error both __GNU__ and _linux__ are undefined, choose one
|
||||
#endif
|
||||
|
||||
#include <m4.c>
|
||||
#include <binutils.c>
|
||||
#include <gcc.c>
|
||||
#include <alloca.c>
|
||||
#if !__GNU__
|
||||
#include <stdlib/alloca.c>
|
||||
#endif
|
||||
#include <glibc.c>
|
||||
|
|
|
@ -36,7 +36,14 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <libc.c>
|
||||
#include <linux+tcc.c>
|
||||
|
||||
#if __GNU__
|
||||
#include <hurd/tcc.c>
|
||||
#elif __linux__
|
||||
#include <linux/tcc.c>
|
||||
#else
|
||||
#error both __GNU__ and _linux__ are undefined, choose one
|
||||
#endif
|
||||
|
||||
#if __MESC__
|
||||
|
||||
|
|
|
@ -20,17 +20,29 @@
|
|||
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef _SIZE_T
|
||||
#define _SIZE_T
|
||||
#ifndef __SIZE_T
|
||||
#define __SIZE_T
|
||||
#ifndef __MES_SIZE_T
|
||||
#define __MES_SIZE_T
|
||||
#undef size_t
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _SSIZE_T
|
||||
#define _SSIZE_T
|
||||
#ifndef __SSIZE_T
|
||||
#define __SSIZE_T
|
||||
#ifndef __MES_SSIZE_T
|
||||
#define __MES_SSIZE_T
|
||||
#undef ssize_t
|
||||
typedef long ssize_t;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ssize_t write (int filedes, void const *buffer, size_t size);
|
||||
|
||||
|
@ -65,15 +77,13 @@ puts (char const* s)
|
|||
return oputs ("\n");
|
||||
}
|
||||
|
||||
#if __MESC__
|
||||
|
||||
#include <linux-mini-mes.c>
|
||||
|
||||
#else // !__MESC__
|
||||
|
||||
#include <linux-mini-gcc.c>
|
||||
|
||||
#endif // !__MESC__
|
||||
#if __GNU__
|
||||
#include <hurd/libc-mini.c>
|
||||
#elif __linux__
|
||||
#include <linux/libc-mini.c>
|
||||
#else
|
||||
#error both __GNU__ and _linux__ are undefined, choose one
|
||||
#endif
|
||||
|
||||
void (*__call_at_exit) (void);
|
||||
|
||||
|
@ -84,17 +94,3 @@ exit (int code)
|
|||
(*__call_at_exit) ();
|
||||
_exit (code);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
write (int filedes, void const *buffer, size_t size)
|
||||
{
|
||||
int r = _write (filedes, buffer, size);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
|
62
lib/libc.c
62
lib/libc.c
|
@ -29,21 +29,16 @@
|
|||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if __MESC__
|
||||
|
||||
#include <linux-mes.c>
|
||||
|
||||
#else // !__MESC__
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <linux-gcc.c>
|
||||
|
||||
#endif // !__MESC__
|
||||
|
||||
#include <libc-mini.c>
|
||||
#include <libmes.c>
|
||||
#include <linux.c>
|
||||
|
||||
#if __GNU__
|
||||
#include <hurd/libc.c>
|
||||
#elif __linux__
|
||||
#include <linux/libc.c>
|
||||
#else
|
||||
#error both __GNU__ and _linux__ are undefined, choose one
|
||||
#endif
|
||||
|
||||
int g_stdin = 0;
|
||||
|
||||
|
@ -63,6 +58,13 @@ __mes_debug ()
|
|||
return __mes_debug;
|
||||
}
|
||||
|
||||
|
||||
#if !___GNU__
|
||||
#include <string/memcpy.c>
|
||||
#include <stdlib/malloc.c>
|
||||
#include <assert/assert.c>
|
||||
#endif
|
||||
|
||||
int
|
||||
getchar ()
|
||||
{
|
||||
|
@ -94,17 +96,6 @@ putc (int c, FILE* stream)
|
|||
return fdputc (c, (int)stream);
|
||||
}
|
||||
|
||||
void
|
||||
assert_fail (char* s)
|
||||
{
|
||||
eputs ("assert fail: ");
|
||||
eputs (s);
|
||||
eputs ("\n");
|
||||
char *fail = s;
|
||||
fail = 0;
|
||||
*fail = 0;
|
||||
}
|
||||
|
||||
int
|
||||
getc (FILE *stream)
|
||||
{
|
||||
|
@ -147,29 +138,6 @@ strcpy (char *dest, char const *src)
|
|||
return dest;
|
||||
}
|
||||
|
||||
char *g_brk = 0;
|
||||
|
||||
void *
|
||||
malloc (size_t size)
|
||||
{
|
||||
if (!g_brk)
|
||||
g_brk = brk (0);
|
||||
if (brk (g_brk + size) == (void*)-1)
|
||||
return 0;
|
||||
char *p = g_brk;
|
||||
g_brk += size;
|
||||
return p;
|
||||
}
|
||||
|
||||
void *
|
||||
memcpy (void *dest, void const *src, size_t n)
|
||||
{
|
||||
char* p = dest;
|
||||
char const* q = src;
|
||||
while (n--) *p++ = *q++;
|
||||
return dest;
|
||||
}
|
||||
|
||||
void *
|
||||
realloc (void *ptr, size_t size)
|
||||
{
|
||||
|
|
10
lib/libg.c
10
lib/libg.c
|
@ -37,7 +37,15 @@
|
|||
#define sscanf _sscanf
|
||||
|
||||
#include <libc+tcc.c>
|
||||
#include <linux+gnu.c>
|
||||
|
||||
#if __GNU__
|
||||
#include <linux/gnu.c>
|
||||
#elif __linux__
|
||||
#include <linux/gnu.c>
|
||||
#else
|
||||
#error both __GNU__ and _linux__ are undefined, choose one
|
||||
#endif
|
||||
|
||||
#include <m4.c>
|
||||
#include <binutils.c>
|
||||
#include <gcc.c>
|
||||
|
|
43
lib/linux/libc-mini.c
Normal file
43
lib/linux/libc-mini.c
Normal file
|
@ -0,0 +1,43 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of Mes.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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 Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if __MESC__
|
||||
|
||||
#include <linux/mini-mes.c>
|
||||
|
||||
#else // !__MESC__
|
||||
|
||||
#include <linux/mini-gcc.c>
|
||||
|
||||
#endif // !__MESC__
|
||||
|
||||
ssize_t
|
||||
write (int filedes, void const *buffer, size_t size)
|
||||
{
|
||||
int r = _write (filedes, buffer, size);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
|
@ -38,6 +38,18 @@
|
|||
#define SYS_ioctl 0x36
|
||||
#define SYS_fsync 0x76
|
||||
|
||||
#if __MESC__
|
||||
|
||||
#include <linux/mes.c>
|
||||
|
||||
#else // !__MESC__
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <linux/gcc.c>
|
||||
|
||||
#endif // !__MESC__
|
||||
|
||||
int
|
||||
fork ()
|
||||
{
|
10
lib/m4.c
10
lib/m4.c
|
@ -20,15 +20,7 @@
|
|||
|
||||
#include <ctype.h>
|
||||
|
||||
int
|
||||
abort ()
|
||||
{
|
||||
static int stub = 0;
|
||||
if (__mes_debug () && !stub)
|
||||
eputs ("abort stub\n");
|
||||
stub = 1;
|
||||
return 0;
|
||||
}
|
||||
#include "stdlib/abort.c"
|
||||
|
||||
int
|
||||
atof (int x)
|
||||
|
|
29
lib/stdlib/abort.c
Normal file
29
lib/stdlib/abort.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of Mes.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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 Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
void
|
||||
abort (void)
|
||||
{
|
||||
#if __i386__
|
||||
asm ("hlt");
|
||||
#else
|
||||
asm ("break 0");
|
||||
#endif
|
||||
}
|
33
lib/stdlib/malloc.c
Normal file
33
lib/stdlib/malloc.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of Mes.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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 Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
char *__brk = 0;
|
||||
|
||||
void *
|
||||
malloc (size_t size)
|
||||
{
|
||||
if (!__brk)
|
||||
__brk = brk (0);
|
||||
if (brk (__brk + size) == (void*)-1)
|
||||
return 0;
|
||||
char *p = __brk;
|
||||
__brk += size;
|
||||
return p;
|
||||
}
|
44
lib/string/argz-count.c
Normal file
44
lib/string/argz-count.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright (C) 1995-2018 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/* Taken from GNU C Library
|
||||
* Routines for dealing with '\0' separated arg vectors.
|
||||
* Written by Miles Bader <miles@gnu.ai.mit.edu>
|
||||
*/
|
||||
|
||||
#include <argz.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Returns the number of strings in ARGZ. */
|
||||
size_t
|
||||
__argz_count (const char *argz, size_t len)
|
||||
{
|
||||
size_t count = 0;
|
||||
while (len > 0)
|
||||
{
|
||||
size_t part_len = strlen(argz);
|
||||
argz += part_len + 1;
|
||||
len -= part_len + 1;
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
libc_hidden_def (__argz_count)
|
||||
weak_alias (__argz_count, argz_count)
|
42
lib/string/argz-extract.c
Normal file
42
lib/string/argz-extract.c
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright (C) 1995-2018 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/* Taken from GNU C Library
|
||||
* Routines for dealing with '\0' separated arg vectors.
|
||||
* Written by Miles Bader <miles@gnu.org>
|
||||
*/
|
||||
|
||||
#include <argz.h>
|
||||
|
||||
/* Puts pointers to each string in ARGZ, plus a terminating 0 element, into
|
||||
ARGV, which must be large enough to hold them all. */
|
||||
void
|
||||
__argz_extract (const char *argz, size_t len, char **argv)
|
||||
{
|
||||
while (len > 0)
|
||||
{
|
||||
size_t part_len = strlen (argz);
|
||||
*argv++ = (char *) argz;
|
||||
argz += part_len + 1;
|
||||
len -= part_len + 1;
|
||||
}
|
||||
*argv = 0;
|
||||
}
|
||||
weak_alias (__argz_extract, argz_extract)
|
29
lib/string/memcpy.c
Normal file
29
lib/string/memcpy.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of Mes.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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 Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
void *
|
||||
memcpy (void *dest, void const *src, size_t n)
|
||||
{
|
||||
char* p = dest;
|
||||
char const* q = src;
|
||||
while (n--)
|
||||
*p++ = *q++;
|
||||
return dest;
|
||||
}
|
Loading…
Reference in a new issue