mescc: Support binutils-2.10.1.

xx
This commit is contained in:
Jan Nieuwenhuizen 2018-06-06 13:16:25 +02:00
parent 635dfd03a2
commit eb939b11b8
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
8 changed files with 122 additions and 18 deletions

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* 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 Mes.
*
@ -29,9 +29,11 @@
#else // ! WITH_GLIBC
#include <endian.h>
int isdigit (int);
int isxdigit (int);
int isspace (int);
int isalpha (int c);
int isascii (int c);
int isdigit (int c);
int isxdigit (int c);
int isspace (int c);
#endif // ! WITH_GLIBC
#endif // __MES_CTYPE_H

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* 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 Mes.
*
@ -28,6 +28,7 @@
#include_next <limits.h>
#else // ! WITH_GLIBC
#define CHAR_BIT 8
#define UCHAR_MAX 255
#define INT_MIN -2147483648
@ -35,7 +36,7 @@
#define MB_CUR_MAX 1
#define LONG_MIN -2147483648
#define LONG_MAX 2147483647
#define LONG_MAX _POSIX_OPEN_MAX 16
#define _POSIX_OPEN_MAX 16
#endif // ! WITH_GLIBC

View File

@ -63,13 +63,22 @@ typedef long long int64_t;
typedef unsigned long size_t;
#endif
#ifndef __MES_INTPTR_T
#define __MES_INTPTR_T
#undef intptr_t
typedef long intptr_t;
#endif
// FIXME
typedef int intmax_t;
typedef unsigned uintmax_t;
typedef int* intptr_t;
typedef unsigned* uintptr_t;
typedef unsigned ptrdiff_t;
#ifndef __MES_PTRDIFF_T
#define __MES_PTRDIFF_T
#undef ptrdiff_t
typedef long ptrdiff_t;
#endif
#endif // ! WITH_GLIBC

View File

@ -54,9 +54,17 @@ unsigned long long strtoull (char const *nptr, char **endptr, int base);
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
#if __MESC__
typedef int (*comparison_fn_t) (void const *, void const *);
#else
typedef void (*comparison_fn_t) ();
#endif
void * bsearch (void const *key, void const *array, size_t count, size_t size, comparison_fn_t compare);
#include <endian.h>
#endif // ! WITH_GLIBC
#endif // __MES_STDLIB_H

View File

@ -43,6 +43,8 @@ struct tm {
};
struct tm *localtime (time_t const *timep);
struct tm *gmtime (time_t const *time);
time_t time (time_t *tloc);
#ifndef __MES_STRUCT_TIMESPEC

View File

@ -33,6 +33,12 @@
#define NULL 0
#endif
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
#endif // STDIN_FILENO
#ifndef __MES_OFF_T
#define __MES_OFF_T
#undef off_t
@ -51,6 +57,18 @@ typedef unsigned long size_t;
typedef long ssize_t;
#endif
#ifndef __MES_INTPTR_T
#define __MES_INTPTR_T
#undef intptr_t
typedef long intptr_t;
#endif
#ifndef __MES_PTRDIFF_T
#define __MES_PTRDIFF_T
#undef ptrdiff_t
typedef long ptrdiff_t;
#endif
#ifndef R_OK
#define F_OK 0
#define X_OK 1
@ -72,6 +90,12 @@ char *getcwd (char *buf, size_t size);
int isatty (int fd);
off_t lseek (int fd, off_t offset, int whence);
ssize_t read (int fd, void *buffer, size_t size);
#if __SBRK_CHAR_PTRDIFF
/* xmalloc in binutils <= 2.10.1 uses this old prototype */
char * sbrk (ptrdiff_t delta);
#else
void * sbrk (intptr_t delta);
#endif
int unlink (char const *file_name);
ssize_t write (int filedes, void const *buffer, size_t size);
#endif // ! WITH_GLIBC

View File

@ -20,6 +20,7 @@
#include <libmes.h>
#include <stdint.h>
#include <stdlib.h>
int
abs (int x)
@ -117,15 +118,6 @@ perror (char const *message)
fprintf (stderr, "%s: %s\n", strerror (errno), message);
}
void*
sbrk (ptrdiff_t delta)
{
void *p = malloc (delta);
if (p <= 0)
return 0;
return p+delta;
}
int
setitimer (int which, struct itimerval const *new,
struct itimerval *old)
@ -209,3 +201,48 @@ utime (int x)
eputs ("utime stub\n");
return 0;
}
// binutils-2.10.1
int
fscanf (FILE *stream, char const *template, ...)
{
eputs ("fscan stub\n");
return 0;
}
int
isascii (int c)
{
return c >= 0 && c <= 127;
}
void *
#if __MESC__
bsearch (void const *key, void const *array, size_t count, size_t size, void (*compare) ())
#else
bsearch (void const *key, void const *array, size_t count, size_t size, comparison_fn_t compare)
#endif
{
eputs ("bsearch stub\n");
return 0;
}
struct tm *
gmtime (time_t const *time)
{
eputs ("gmtime stub\n");
return localtime (time);
}
#if __SBRK_CHAR_PTRDIFF
char *
sbrk (ptrdiff_t)
#else
void *
sbrk (intptr_t delta)
#endif
{
if (delta >= 0)
return malloc (delta);
return g_brk;
}

View File

@ -48,3 +48,24 @@ __cleanup ()
eputs ("__cleanup stub\n");
return 0;
}
int
__libc_subinit ()
{
eputs ("__libc_subinit stub\n");
return 0;
}
int
__syscall_error ()
{
eputs ("__syscall_error stub\n");
return 0;
}
int
__fpu_control ()
{
eputs ("__fpu_control stub\n");
return 0;
}