diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2016-08-30 04:46:47 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2016-08-30 04:46:47 -0500 |
commit | 7515ce3fa8b30f7b7d67bc2a659e15276c0923d7 (patch) | |
tree | 3d727e06ad85417602e7e933dc751c6a6a40a59c | |
download | gcompat-7515ce3fa8b30f7b7d67bc2a659e15276c0923d7.tar.gz gcompat-7515ce3fa8b30f7b7d67bc2a659e15276c0923d7.tar.bz2 gcompat-7515ce3fa8b30f7b7d67bc2a659e15276c0923d7.tar.xz gcompat-7515ce3fa8b30f7b7d67bc2a659e15276c0923d7.zip |
Initial commit
-rw-r--r-- | dlvsym.c | 14 | ||||
-rw-r--r-- | malloc.c | 46 | ||||
-rw-r--r-- | math.c | 21 | ||||
-rw-r--r-- | stdio.c | 3 | ||||
-rw-r--r-- | stdlib.c | 8 | ||||
-rw-r--r-- | string.c | 32 | ||||
-rw-r--r-- | version.c | 14 |
7 files changed, 138 insertions, 0 deletions
diff --git a/dlvsym.c b/dlvsym.c new file mode 100644 index 0000000..3d744ea --- /dev/null +++ b/dlvsym.c @@ -0,0 +1,14 @@ +#include <dlfcn.h> // dlsym +#include <stdio.h> // fprintf +#include <stdlib.h> // getenv + +void *dlvsym(void *handle, char *symbol, char *version) +{ + if(getenv("GLIBC_FAKE_DEBUG")) + { + fprintf(stderr, "symbol %s with version %s is being redirected", + symbol, version); + } + + return dlsym(handle, symbol); +} diff --git a/malloc.c b/malloc.c new file mode 100644 index 0000000..3a5818c --- /dev/null +++ b/malloc.c @@ -0,0 +1,46 @@ +/* struct mallinfo pulled from mallinfo.3: + * + * Copyright (c) 2012 by Michael Kerrisk <mtk.manpages@gmail.com> + * + * Permission is granted to make and distribute verbatim copies of this + * manual provided the copyright notice and this permission notice are + * preserved on all copies. + * + * Permission is granted to copy and distribute modified versions of this + * manual under the conditions for verbatim copying, provided that the + * entire resulting derived work is distributed under the terms of a + * permission notice identical to this one. + * + * Since the Linux kernel and libraries are constantly changing, this + * manual page may be incorrect or out-of-date. The author(s) assume no + * responsibility for errors or omissions, or for damages resulting from + * the use of the information contained herein. The author(s) may not + * have taken the same level of care in the production of this manual, + * which is licensed free of charge, as they might when working + * professionally. + * + * Formatted or processed versions of this manual, if unaccompanied by + * the source, must acknowledge the copyright and authors of this work. + */ + +#include <string.h> /* memset */ + +struct mallinfo { + int arena; /* Non-mmapped space allocated (bytes) */ + int ordblks; /* Number of free chunks */ + int smblks; /* Number of free fastbin blocks */ + int hblks; /* Number of mmapped regions */ + int hblkhd; /* Space allocated in mmapped regions (bytes) */ + int usmblks; /* Maximum total allocated space (bytes) */ + int fsmblks; /* Space in freed fastbin blocks (bytes) */ + int uordblks; /* Total allocated space (bytes) */ + int fordblks; /* Total free space (bytes) */ + int keepcost; /* Top-most, releasable space (bytes) */ +}; + +struct mallinfo mallinfo(void) +{ + struct mallinfo my_info; + memset(&my_info, 0, sizeof(struct mallinfo)); + return my_info; +} @@ -0,0 +1,21 @@ +#include <math.h> // isinf, isnan + +int __isinff(float number) +{ + return isinf(number); +} + +int __isinf(double number) +{ + return isinf(number); +} + +int __isnanf(float number) +{ + return isnan(number); +} + +int __isnan(double number) +{ + return isnan(number); +} @@ -0,0 +1,3 @@ +#include <stdio.h> + +asm(".equ __IO_2_1_stdout_, _stdout"); diff --git a/stdlib.c b/stdlib.c new file mode 100644 index 0000000..b81eb91 --- /dev/null +++ b/stdlib.c @@ -0,0 +1,8 @@ +#include <assert.h> // assert +#include <stdlib.h> // strtod + +double __strtod_internal(const char *__nptr, char **__endptr, int __group) +{ + assert(__group == 0); + return strtod(__nptr, __endptr); +} diff --git a/string.c b/string.c new file mode 100644 index 0000000..5bbb1b3 --- /dev/null +++ b/string.c @@ -0,0 +1,32 @@ +#include <string.h> /* strndup */ + +/* Literally a useless __ alias. */ +char *__strndup(const char *str, size_t count) +{ + return strndup(str, count); +} + +/* The existance of this method, and the fact it is used in real code, gives + * me nightmares. */ +void *rawmemchr(const void *s, int c) +{ + const unsigned char *haystack = s; + unsigned char needle = (unsigned char)c; + while(*haystack++ != needle); + return (void *)haystack; +} + +extern __typeof(rawmemchr) __rawmemchr __attribute__((weak, alias("rawmemchr"))); + +/* Another useless __ alias */ +char *__strtok_r(char *str, const char *delim, char **saveptr) +{ + return strtok_r(str, delim, saveptr); +} + +/* The "global" definition of strsep in glibc, used when architecture dependent + * assembler versions aren't good enough. */ +char *__strsep_g(char **stringp, const char *delim) +{ + return strsep(stringp, delim); +} diff --git a/version.c b/version.c new file mode 100644 index 0000000..63146f8 --- /dev/null +++ b/version.c @@ -0,0 +1,14 @@ +#include <stdlib.h> // getenv + +const char *gnu_get_libc_version(void) +{ + char *ver = getenv("GLIBC_FAKE_VERSION"); + if(ver == NULL) ver = "2.8"; + + return ver; +} + +const char *gnu_get_libc_release(void) +{ + return "stable"; +} |