Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

[WIP] Add declarations for AIX. #55

Open
wants to merge 1 commit into
base: ldc
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions src/core/stdc/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,19 @@ else version ( FreeBSD )
long _mbstateL;
}
}
else version (AIX)
{
enum
{
BUFSIZ = 4096,
EOF = -1,
FOPEN_MAX = 32767,
FILENAME_MAX = 255,
TMP_MAX = 16384,
L_tmpnam = 21
}
enum int _NFILE = 16;
}
else version (Solaris)
{
enum
Expand Down Expand Up @@ -392,6 +405,42 @@ else version( FreeBSD )
///
alias shared(__sFILE) FILE;
}
else version (AIX)
{
alias c_long fpos_t;

struct _iobuf
{
ubyte*_ptr;
version (D_LP64) {}
else
{
int _cnt;
}
ubyte* _base;
ubyte* _bufendp;
version (D_LP64) {}
else
{
short _flag;
short _file;
int __stdioid;
}
char* __newbase;
void* _lock;
version (D_LP64)
{
int _cnt;
int _file;
int __stdioid;
short _flag;
short _unused;
c_long[4] _unused1;
}
}

alias shared(_iobuf) FILE;
}
else version (Solaris)
{
///
Expand Down Expand Up @@ -637,6 +686,23 @@ else version( FreeBSD )
///
alias __stderrp stderr;
}
else version (AIX)
{
enum
{
_IOFBF = 0x00,
_IOLBF = 0x40,
_IONBF = 0x04,
_IOEOF = 0x10,
_IOERR = 0x20,
}

private extern shared FILE[_NFILE] _iob;

shared stdin = &_iob[0];
shared stdout = &_iob[1];
shared stderr = &_iob[2];
}
else version (Solaris)
{
enum
Expand Down Expand Up @@ -1039,6 +1105,21 @@ else version( FreeBSD )
///
int vsnprintf(char* s, size_t n, in char* format, va_list arg);
}
else version (AIX)
{
// No unsafe pointer manipulation.
@trusted
{
void rewind(FILE* stream);
pure void clearerr(FILE* stream);
pure int feof(FILE* stream);
pure int ferror(FILE* stream);
int fileno(FILE *);
}

int snprintf(char* s, size_t n, in char* format, ...);
int vsnprintf(char* s, size_t n, in char* format, va_list arg);
}
else version (Solaris)
{
// No unsafe pointer manipulation.
Expand Down
1 change: 1 addition & 0 deletions src/core/stdc/stdlib.d
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ version(Windows) enum RAND_MAX = 0x7fff;
else version(CRuntime_Glibc) enum RAND_MAX = 0x7fffffff;
else version(OSX) enum RAND_MAX = 0x7fffffff;
else version(FreeBSD) enum RAND_MAX = 0x7fffffff;
else version(AIX) enum RAND_MAX = 0x7ffff;
else version(Solaris) enum RAND_MAX = 0x7fff;
else version(CRuntime_Bionic) enum RAND_MAX = 0x7fffffff;
else static assert( false, "Unsupported platform" );
Expand Down
9 changes: 9 additions & 0 deletions src/core/stdc/time.d
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ else version( FreeBSD )
{
enum clock_t CLOCKS_PER_SEC = 128;
}
else version( AIX )
{
enum clock_t CLOCKS_PER_SEC = 1_000_000;
}
else version (CRuntime_Glibc)
{
enum clock_t CLOCKS_PER_SEC = 1_000_000;
Expand Down Expand Up @@ -145,6 +149,11 @@ else version( FreeBSD )
///
extern __gshared const(char)*[2] tzname; // non-standard
}
else version( AIX )
{
void tzset();
extern __gshared const(char)*[2] tzname;
}
else version (Solaris)
{
///
Expand Down
34 changes: 34 additions & 0 deletions src/core/sys/aix/dlfcn.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* D header file for AIX.
*
* Copyright: Copyright Kai Nacke 2014.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
* Authors: Kai Nacke
*/
module core.sys.aix.dlfcn;

public import core.sys.posix.dlfcn;

version (AIX):
extern (C):
nothrow:

/*
* Modes and flags for dlopen().
*/
static assert(RTLD_NOW == 0x00000002);
static assert(RTLD_LAZY == 0x00000004);
static assert(RTLD_GLOBAL == 0x00010000);
enum RTLD_NOAUTODEFER = 0x00020000;
enum RTLD_MEMBER = 0x00040000;
static assert(RTLD_LOCAL == 0x00080000);

/*
* Special handle arguments for dlsym().
*/
enum RTLD_DEFAULT = cast(void *)-1; /* Start search from the executable module. */
enum RTLD_MYSELF = cast(void *)-2; /* Start search from the module calling dlsym(). */
enum RTLD_NEXT = cast(void *)-3; /* Start search from the module after the module which called dlsym(). */

enum RTLD_ENTRY = cast(char *)-1; /* Return the module's entry point from dlsym(). */

38 changes: 38 additions & 0 deletions src/core/sys/posix/dirent.d
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,35 @@ else version( FreeBSD )

dirent* readdir(DIR*);
}
else version (AIX)
{
struct dirent
{
ulong d_offset;
ino_t d_ino;
ushort d_reclen;
ushort d_namlen;
char[256] d_name;
}

struct DIR
{
int dd_fd;
blksize_t dd_blksize;
char* dd_buf;
c_long dd_size;
c_long dd_flag;
off_t dd_loc;
off_t dd_curoff;
/* Only for the thread safe functions, used for inter-thread locking */
void* dd_lock;
}

dirent *readdir(DIR*);

DIR* fdopendir(int);
int dirfd(DIR*);
}
else version (Solaris)
{
struct dirent
Expand Down Expand Up @@ -237,6 +266,10 @@ else version( FreeBSD )
{
int readdir_r(DIR*, dirent*, dirent**);
}
else version (AIX)
{
int readdir_r(DIR*, dirent*, dirent**);
}
else version (Solaris)
{
static if (__USE_LARGEFILE64)
Expand Down Expand Up @@ -279,6 +312,11 @@ else version( FreeBSD )
else version (OSX)
{
}
else version (AIX)
{
void seekdir(DIR*, c_long);
c_long telldir(DIR*);
}
else version (Solaris)
{
c_long telldir(DIR*);
Expand Down
12 changes: 12 additions & 0 deletions src/core/sys/posix/dlfcn.d
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ else version( FreeBSD )
void* dli_saddr;
}
}
else version( AIX )
{
enum RTLD_LAZY = 0x00000004;
enum RTLD_NOW = 0x00000002;
enum RTLD_GLOBAL = 0x00010000;
enum RTLD_LOCAL = 0x00080000;

int dlclose(void*);
char* dlerror();
void* dlopen(in char*, int);
void* dlsym(void*, in char*);
}
else version( Solaris )
{
enum RTLD_LAZY = 1;
Expand Down
24 changes: 24 additions & 0 deletions src/core/sys/posix/grp.d
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ else version( FreeBSD )
char** gr_mem;
}
}
else version( AIX )
{
struct group
{
char* gr_name;
char* gr_passwd;
gid_t gr_gid;
char** gr_mem;
}
}
else version( Solaris )
{
struct group
Expand Down Expand Up @@ -119,6 +129,14 @@ else version( FreeBSD )
int getgrnam_r(in char*, group*, char*, size_t, group**);
int getgrgid_r(gid_t, group*, char*, size_t, group**);
}
else version( AIX )
{
int _posix_getgrnam_r(in char*, group*, char*, size_t, group**);
int _posix_getgrgid_r(gid_t, group*, char*, size_t, group**);

alias _posix_getgrnam_r getgrnam_r; // Named differently
alias _posix_getgrgid_r getgrgid_r;
}
else version( Solaris )
{
int getgrnam_r(in char*, group*, char*, int, group**);
Expand Down Expand Up @@ -159,6 +177,12 @@ else version( FreeBSD )
@trusted void endgrent();
@trusted void setgrent();
}
else version( AIX )
{
group* getgrent();
@trusted void endgrent();
@trusted void setgrent();
}
else version( Solaris )
{
group* getgrent();
Expand Down
Loading