Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1010 from joakim-noah/separate_glibc
Browse files Browse the repository at this point in the history
Separate linux kernel and glibc APIs as much as possible
  • Loading branch information
MartinNowak committed May 15, 2015
2 parents 186025a + 570b6fc commit e66f034
Show file tree
Hide file tree
Showing 59 changed files with 511 additions and 573 deletions.
6 changes: 3 additions & 3 deletions src/core/runtime.d
Expand Up @@ -337,7 +337,7 @@ private:
extern (C) bool runModuleUnitTests()
{
// backtrace
version( linux )
version( CRuntime_Glibc )
import core.sys.linux.execinfo;
else version( OSX )
import core.sys.osx.execinfo;
Expand Down Expand Up @@ -419,7 +419,7 @@ extern (C) bool runModuleUnitTests()
Throwable.TraceInfo defaultTraceHandler( void* ptr = null )
{
// backtrace
version( linux )
version( CRuntime_Glibc )
import core.sys.linux.execinfo;
else version( OSX )
import core.sys.osx.execinfo;
Expand Down Expand Up @@ -557,7 +557,7 @@ Throwable.TraceInfo defaultTraceHandler( void* ptr = null )
}
}
}
else version( linux )
else version( CRuntime_Glibc )
{
// format is: module(_D6module4funcAFZv) [0x00000000]
// or: module(_D6module4funcAFZv+0x78) [0x00000000]
Expand Down
512 changes: 241 additions & 271 deletions src/core/stdc/errno.d

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/core/stdc/fenv.d
Expand Up @@ -21,7 +21,7 @@ nothrow:

version( MinGW )
version = GNUFP;
version( linux )
version( CRuntime_Glibc )
version = GNUFP;

version( GNUFP )
Expand Down Expand Up @@ -176,7 +176,7 @@ else version ( FreeBSD )

alias ushort fexcept_t;
}
else version( Android )
else version( CRuntime_Bionic )
{
version(X86)
{
Expand Down Expand Up @@ -290,7 +290,7 @@ else version( FreeBSD )
///
enum FE_DFL_ENV = &__fe_dfl_env;
}
else version( Android )
else version( CRuntime_Bionic )
{
private extern const fenv_t __fe_dfl_env;
///
Expand Down
4 changes: 2 additions & 2 deletions src/core/stdc/locale.d
Expand Up @@ -48,7 +48,7 @@ struct lconv
byte int_n_sign_posn;
}

version(linux)
version(CRuntime_Glibc)
{
///
enum LC_CTYPE = 0;
Expand Down Expand Up @@ -126,7 +126,7 @@ else version(FreeBSD)
///
enum LC_MESSAGES = 6;
}
else version(Android)
else version(CRuntime_Bionic)
{
enum
{
Expand Down
8 changes: 4 additions & 4 deletions src/core/stdc/math.d
Expand Up @@ -372,7 +372,7 @@ else version( CRuntime_Microsoft ) // fully supported since MSVCRT 12 (VS 2013)
}
}
}
else version( linux )
else version( CRuntime_Glibc )
{
enum
{
Expand Down Expand Up @@ -827,7 +827,7 @@ else version( Solaris )
}
}
}
else version( Android )
else version( CRuntime_Bionic )
{
enum
{
Expand Down Expand Up @@ -1842,9 +1842,9 @@ else version( FreeBSD )
///
float fmaf(float x, float y, float z);
}
else version(Android)
else version(CRuntime_Bionic)
{
// Android defines long double as 64 bits, same as double, so several long
// Bionic defines long double as 64 bits, same as double, so several long
// double functions are missing. nexttoward was modified to reflect this.
///
double acos(double x);
Expand Down
16 changes: 8 additions & 8 deletions src/core/stdc/stdio.d
Expand Up @@ -86,7 +86,7 @@ else version( CRuntime_Microsoft )
///
enum int L_tmpnam = _P_tmpdir.length + 12;
}
else version( linux )
else version( CRuntime_Glibc )
{
enum
{
Expand Down Expand Up @@ -191,7 +191,7 @@ else version (Solaris)
///
enum int _NFILE = 20;
}
else version( Android )
else version( CRuntime_Bionic )
{
enum
{
Expand Down Expand Up @@ -272,7 +272,7 @@ else version( CRuntime_Microsoft )
///
alias shared(_iobuf) FILE;
}
else version( linux )
else version( CRuntime_Glibc )
{
import core.stdc.wchar_ : mbstate_t;
///
Expand Down Expand Up @@ -423,7 +423,7 @@ else version (Solaris)
///
alias shared(_iobuf) FILE;
}
else version( Android )
else version( CRuntime_Bionic )
{
import core.sys.posix.sys.types : off_t;
///
Expand Down Expand Up @@ -583,7 +583,7 @@ else version( CRuntime_Microsoft )
///
shared FILE* stderr; // = &__iob_func()[2];
}
else version( linux )
else version( CRuntime_Glibc )
{
enum
{
Expand Down Expand Up @@ -681,7 +681,7 @@ else version (Solaris)
///
shared stderr = &__iob[2];
}
else version( Android )
else version( CRuntime_Bionic )
{
enum
{
Expand Down Expand Up @@ -1008,7 +1008,7 @@ else version( CRuntime_Microsoft )
///
int _open_osfhandle(intptr_t osfhandle, int flags);
}
else version( linux )
else version( CRuntime_Glibc )
{
// No unsafe pointer manipulation.
@trusted
Expand Down Expand Up @@ -1096,7 +1096,7 @@ else version (Solaris)
///
int vsnprintf(char* s, size_t n, in char* format, va_list arg);
}
else version( Android )
else version( CRuntime_Bionic )
{
// No unsafe pointer manipulation.
@trusted
Expand Down
8 changes: 4 additions & 4 deletions src/core/stdc/stdlib.d
Expand Up @@ -63,11 +63,11 @@ enum MB_CUR_MAX = 1;

///
version(Windows) enum RAND_MAX = 0x7fff;
else version(linux) enum RAND_MAX = 0x7fffffff;
else version(CRuntime_Glibc) enum RAND_MAX = 0x7fffffff;
else version(OSX) enum RAND_MAX = 0x7fffffff;
else version(FreeBSD) enum RAND_MAX = 0x7fffffff;
else version(Solaris) enum RAND_MAX = 0x7fff;
else version(Android) enum RAND_MAX = 0x7fffffff;
else version(CRuntime_Bionic) enum RAND_MAX = 0x7fffffff;
else static assert( false, "Unsupported platform" );

///
Expand Down Expand Up @@ -108,7 +108,7 @@ else version (MinGW)
///
alias __mingw_strtold strtold;
}
else version (Android)
else version (CRuntime_Bionic)
{
///
real strtold(in char* nptr, char** endptr)
Expand All @@ -125,7 +125,7 @@ else
// No unsafe pointer manipulation.
@trusted
{
version(Android)
version(CRuntime_Bionic)
{
import core.sys.posix.stdlib: lrand48, srand48;
///
Expand Down
8 changes: 4 additions & 4 deletions src/core/stdc/time.d
Expand Up @@ -82,11 +82,11 @@ else version( FreeBSD )
{
enum clock_t CLOCKS_PER_SEC = 128;
}
else version (linux)
else version (CRuntime_Glibc)
{
enum clock_t CLOCKS_PER_SEC = 1_000_000;
}
else version (Android)
else version (CRuntime_Bionic)
{
enum clock_t CLOCKS_PER_SEC = 1_000_000;
}
Expand Down Expand Up @@ -131,7 +131,7 @@ else version( OSX )
///
extern __gshared const(char)*[2] tzname; // non-standard
}
else version( linux )
else version( CRuntime_Glibc )
{
///
void tzset(); // non-standard
Expand All @@ -152,7 +152,7 @@ else version (Solaris)
///
extern __gshared const(char)*[2] tzname;
}
else version( Android )
else version( CRuntime_Bionic )
{
///
void tzset();
Expand Down
2 changes: 1 addition & 1 deletion src/core/sys/linux/stdio.d
Expand Up @@ -6,7 +6,7 @@
* Authors: Danny Milosavljevic
*/
module core.sys.linux.stdio;
version (linux):
version (CRuntime_Glibc):
public import core.sys.posix.stdio;
import core.sys.posix.sys.types : ssize_t, off64_t = off_t;
import core.sys.linux.config : __USE_FILE_OFFSET64;
Expand Down
4 changes: 2 additions & 2 deletions src/core/sys/posix/arpa/inet.d
Expand Up @@ -49,7 +49,7 @@ char* inet_ntop(int, in void*, char*, socklen_t);
int inet_pton(int, in char*, void*);
*/

version( linux )
version( CRuntime_Glibc )
{
alias uint16_t in_port_t;
alias uint32_t in_addr_t;
Expand Down Expand Up @@ -148,7 +148,7 @@ else version( Solaris )
const(char)* inet_ntop(int, in void*, char*, socklen_t);
int inet_pton(int, in char*, void*);
}
else version( Android )
else version( CRuntime_Bionic )
{
alias uint32_t in_addr_t;

Expand Down
2 changes: 1 addition & 1 deletion src/core/sys/posix/config.d
Expand Up @@ -24,7 +24,7 @@ enum _XOPEN_SOURCE = 600;
enum _POSIX_SOURCE = true;
enum _POSIX_C_SOURCE = 200112L;

version (linux)
version (CRuntime_Glibc)
{
// man 7 feature_test_macros
// http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
Expand Down
12 changes: 6 additions & 6 deletions src/core/sys/posix/dirent.d
Expand Up @@ -40,7 +40,7 @@ dirent* readdir(DIR*);
void rewinddir(DIR*);
*/

version( linux )
version( CRuntime_Glibc )
{
// NOTE: The following constants are non-standard Linux definitions
// for dirent.d_type.
Expand Down Expand Up @@ -170,7 +170,7 @@ else version (Solaris)
dirent* readdir(DIR*);
}
}
else version( Android )
else version( CRuntime_Bionic )
{
enum
{
Expand Down Expand Up @@ -217,7 +217,7 @@ void rewinddir(DIR*);
int readdir_r(DIR*, dirent*, dirent**);
*/

version( linux )
version( CRuntime_Glibc )
{
static if( __USE_LARGEFILE64 )
{
Expand Down Expand Up @@ -249,7 +249,7 @@ else version (Solaris)
int readdir_r(DIR*, dirent*, dirent**);
}
}
else version( Android )
else version( CRuntime_Bionic )
{
int readdir_r(DIR*, dirent*, dirent**);
}
Expand All @@ -266,7 +266,7 @@ void seekdir(DIR*, c_long);
c_long telldir(DIR*);
*/

version( linux )
version( CRuntime_Glibc )
{
void seekdir(DIR*, c_long);
c_long telldir(DIR*);
Expand All @@ -284,7 +284,7 @@ else version (Solaris)
c_long telldir(DIR*);
void seekdir(DIR*, c_long);
}
else version (Android)
else version (CRuntime_Bionic)
{
}
else
Expand Down
4 changes: 2 additions & 2 deletions src/core/sys/posix/dlfcn.d
Expand Up @@ -36,7 +36,7 @@ void* dlopen(in char*, int);
void* dlsym(void*, in char*);
*/

version( linux )
version( CRuntime_Glibc )
{
version (X86)
{
Expand Down Expand Up @@ -179,7 +179,7 @@ else version( Solaris )
void* dli_saddr;
}
}
else version( Android )
else version( CRuntime_Bionic )
{
enum
{
Expand Down
6 changes: 4 additions & 2 deletions src/core/sys/posix/fcntl.d
Expand Up @@ -75,7 +75,7 @@ int creat(in char*, mode_t);
int fcntl(int, int, ...);
int open(in char*, int, ...);
*/
version( linux )
version( CRuntime_Glibc )
{
enum F_DUPFD = 0;
enum F_GETFD = 1;
Expand Down Expand Up @@ -465,8 +465,10 @@ else version (Solaris)
}
}
}
else version( Android )
else version( CRuntime_Bionic )
{
// All these except for the two functions open and creat really come from
// the linux kernel and can probably be merged.
enum F_DUPFD = 0;
enum F_GETFD = 1;
enum F_SETFD = 2;
Expand Down

0 comments on commit e66f034

Please sign in to comment.