/* -*-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.
*
#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
/* -*-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.
*
#include_next <limits.h>
#else // ! WITH_GLIBC
+
#define CHAR_BIT 8
#define UCHAR_MAX 255
#define INT_MIN -2147483648
#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
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
#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
-
};
struct tm *localtime (time_t const *timep);
+struct tm *gmtime (time_t const *time);
+
time_t time (time_t *tloc);
#ifndef __MES_STRUCT_TIMESPEC
#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
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
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
#include <libmes.h>
#include <stdint.h>
+#include <stdlib.h>
int
abs (int x)
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)
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;
+}
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;
+}