mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-04-29 15:01:30 +02:00
[svn r5] Initial commit. Most things are very rough.
This commit is contained in:
112
lphobos/std/c/fenv.d
Normal file
112
lphobos/std/c/fenv.d
Normal file
@@ -0,0 +1,112 @@
|
||||
|
||||
/**
|
||||
* C's <fenv.h>
|
||||
* Authors: Walter Bright, Digital Mars, www.digitalmars.com
|
||||
* License: Public Domain
|
||||
* Macros:
|
||||
* WIKI=Phobos/StdCFenv
|
||||
*/
|
||||
|
||||
module std.c.fenv;
|
||||
|
||||
extern (C):
|
||||
|
||||
/// Entire floating point environment
|
||||
|
||||
struct fenv_t
|
||||
{
|
||||
version (Windows)
|
||||
{
|
||||
ushort status;
|
||||
ushort control;
|
||||
ushort round;
|
||||
ushort reserved[2];
|
||||
}
|
||||
else version (linux)
|
||||
{
|
||||
ushort __control_word;
|
||||
ushort __unused1;
|
||||
ushort __status_word;
|
||||
ushort __unused2;
|
||||
ushort __tags;
|
||||
ushort __unused3;
|
||||
uint __eip;
|
||||
ushort __cs_selector;
|
||||
ushort __opcode;
|
||||
uint __data_offset;
|
||||
ushort __data_selector;
|
||||
ushort __unused5;
|
||||
}
|
||||
else
|
||||
{
|
||||
static assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
alias int fexcept_t; /// Floating point status flags
|
||||
|
||||
/// The various floating point exceptions
|
||||
enum
|
||||
{
|
||||
FE_INVALID = 1, ///
|
||||
FE_DENORMAL = 2, ///
|
||||
FE_DIVBYZERO = 4, ///
|
||||
FE_OVERFLOW = 8, ///
|
||||
FE_UNDERFLOW = 0x10, ///
|
||||
FE_INEXACT = 0x20, ///
|
||||
FE_ALL_EXCEPT = 0x3F, /// Mask of all the exceptions
|
||||
}
|
||||
|
||||
/// Rounding modes
|
||||
enum
|
||||
{
|
||||
FE_TONEAREST = 0, ///
|
||||
FE_UPWARD = 0x800, ///
|
||||
FE_DOWNWARD = 0x400, ///
|
||||
FE_TOWARDZERO = 0xC00, ///
|
||||
}
|
||||
|
||||
version (Windows)
|
||||
{
|
||||
extern fenv_t _FE_DFL_ENV;
|
||||
|
||||
/// Default floating point environment
|
||||
fenv_t* FE_DFL_ENV = &_FE_DFL_ENV;
|
||||
}
|
||||
else version (linux)
|
||||
{
|
||||
/// Default floating point environment
|
||||
fenv_t* FE_DFL_ENV = cast(fenv_t*)(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
static assert(0);
|
||||
}
|
||||
|
||||
/// Floating point precision
|
||||
enum
|
||||
{
|
||||
FE_FLTPREC = 0, ///
|
||||
FE_DBLPREC = 0x200, ///
|
||||
FE_LDBLPREC = 0x300, ///
|
||||
}
|
||||
|
||||
int fetestexcept(int excepts); ///
|
||||
int feraiseexcept(int excepts); ///
|
||||
int feclearexcept(int excepts); ///
|
||||
//int fegetexcept(fexcept_t *flagp,int excepts); ///
|
||||
//int fesetexcept(fexcept_t *flagp,int excepts); ///
|
||||
int fegetround(); ///
|
||||
int fesetround(int round); ///
|
||||
int fegetprec(); ///
|
||||
int fesetprec(int prec); ///
|
||||
int fegetenv(fenv_t *envp); ///
|
||||
int fesetenv(fenv_t *envp); ///
|
||||
//void feprocentry(fenv_t *envp); ///
|
||||
//void feprocexit(const fenv_t *envp); ///
|
||||
|
||||
int fegetexceptflag(fexcept_t *flagp,int excepts); ///
|
||||
int fesetexceptflag(fexcept_t *flagp,int excepts); ///
|
||||
int feholdexcept(fenv_t *envp); ///
|
||||
int feupdateenv(fenv_t *envp); ///
|
||||
|
||||
478
lphobos/std/c/linux/linux.d
Normal file
478
lphobos/std/c/linux/linux.d
Normal file
@@ -0,0 +1,478 @@
|
||||
|
||||
/* Written by Walter Bright, Christopher E. Miller, and many others.
|
||||
* www.digitalmars.com
|
||||
* Placed into public domain.
|
||||
* Linux(R) is the registered trademark of Linus Torvalds in the U.S. and other
|
||||
* countries.
|
||||
*/
|
||||
|
||||
module std.c.linux.linux;
|
||||
|
||||
public import std.c.linux.linuxextern;
|
||||
public import std.c.linux.pthread;
|
||||
|
||||
private import std.c.stdio;
|
||||
|
||||
alias int pid_t;
|
||||
alias int off_t;
|
||||
alias uint mode_t;
|
||||
|
||||
alias uint uid_t;
|
||||
alias uint gid_t;
|
||||
|
||||
static if (size_t.sizeof == 4)
|
||||
alias int ssize_t;
|
||||
else
|
||||
alias long ssize_t;
|
||||
|
||||
enum : int
|
||||
{
|
||||
SIGHUP = 1,
|
||||
SIGINT = 2,
|
||||
SIGQUIT = 3,
|
||||
SIGILL = 4,
|
||||
SIGTRAP = 5,
|
||||
SIGABRT = 6,
|
||||
SIGIOT = 6,
|
||||
SIGBUS = 7,
|
||||
SIGFPE = 8,
|
||||
SIGKILL = 9,
|
||||
SIGUSR1 = 10,
|
||||
SIGSEGV = 11,
|
||||
SIGUSR2 = 12,
|
||||
SIGPIPE = 13,
|
||||
SIGALRM = 14,
|
||||
SIGTERM = 15,
|
||||
SIGSTKFLT = 16,
|
||||
SIGCHLD = 17,
|
||||
SIGCONT = 18,
|
||||
SIGSTOP = 19,
|
||||
SIGTSTP = 20,
|
||||
SIGTTIN = 21,
|
||||
SIGTTOU = 22,
|
||||
SIGURG = 23,
|
||||
SIGXCPU = 24,
|
||||
SIGXFSZ = 25,
|
||||
SIGVTALRM = 26,
|
||||
SIGPROF = 27,
|
||||
SIGWINCH = 28,
|
||||
SIGPOLL = 29,
|
||||
SIGIO = 29,
|
||||
SIGPWR = 30,
|
||||
SIGSYS = 31,
|
||||
SIGUNUSED = 31,
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
O_RDONLY = 0,
|
||||
O_WRONLY = 1,
|
||||
O_RDWR = 2,
|
||||
O_CREAT = 0100,
|
||||
O_EXCL = 0200,
|
||||
O_TRUNC = 01000,
|
||||
O_APPEND = 02000,
|
||||
}
|
||||
|
||||
struct struct_stat // distinguish it from the stat() function
|
||||
{
|
||||
ulong st_dev; /// device
|
||||
ushort __pad1;
|
||||
uint st_ino; /// file serial number
|
||||
uint st_mode; /// file mode
|
||||
uint st_nlink; /// link count
|
||||
uint st_uid; /// user ID of file's owner
|
||||
uint st_gid; /// user ID of group's owner
|
||||
ulong st_rdev; /// if device then device number
|
||||
ushort __pad2;
|
||||
int st_size; /// file size in bytes
|
||||
int st_blksize; /// optimal I/O block size
|
||||
int st_blocks; /// number of allocated 512 byte blocks
|
||||
int st_atime;
|
||||
uint st_atimensec;
|
||||
int st_mtime;
|
||||
uint st_mtimensec;
|
||||
int st_ctime;
|
||||
uint st_ctimensec;
|
||||
|
||||
uint __unused4;
|
||||
uint __unused5;
|
||||
}
|
||||
|
||||
static assert(struct_stat.sizeof == 88);
|
||||
|
||||
enum : int
|
||||
{
|
||||
S_IFIFO = 0010000,
|
||||
S_IFCHR = 0020000,
|
||||
S_IFDIR = 0040000,
|
||||
S_IFBLK = 0060000,
|
||||
S_IFREG = 0100000,
|
||||
S_IFLNK = 0120000,
|
||||
S_IFSOCK = 0140000,
|
||||
|
||||
S_IFMT = 0170000,
|
||||
|
||||
S_IREAD = 0000400,
|
||||
S_IWRITE = 0000200,
|
||||
S_IEXEC = 0000100,
|
||||
}
|
||||
|
||||
extern (C)
|
||||
{
|
||||
int access(char*, int);
|
||||
int open(char*, int, ...);
|
||||
int read(int, void*, int);
|
||||
int write(int, void*, int);
|
||||
int close(int);
|
||||
int lseek(int, int, int);
|
||||
int fstat(int, struct_stat*);
|
||||
int lstat(char*, struct_stat*);
|
||||
int stat(char*, struct_stat*);
|
||||
int chdir(char*);
|
||||
int mkdir(char*, int);
|
||||
int rmdir(char*);
|
||||
char* getcwd(char*, int);
|
||||
int chmod(char*, mode_t);
|
||||
int fork();
|
||||
int dup(int);
|
||||
int dup2(int, int);
|
||||
int pipe(int[2]);
|
||||
pid_t wait(int*);
|
||||
int waitpid(pid_t, int*, int);
|
||||
|
||||
uint alarm(uint);
|
||||
char* basename(char*);
|
||||
//wint_t btowc(int);
|
||||
int chown(char*, uid_t, gid_t);
|
||||
int chroot(char*);
|
||||
size_t confstr(int, char*, size_t);
|
||||
int creat(char*, mode_t);
|
||||
char* ctermid(char*);
|
||||
int dirfd(DIR*);
|
||||
char* dirname(char*);
|
||||
int fattach(int, char*);
|
||||
int fchmod(int, mode_t);
|
||||
int fdatasync(int);
|
||||
int ffs(int);
|
||||
int fmtmsg(int, char*, int, char*, char*, char*);
|
||||
int fpathconf(int, int);
|
||||
int fseeko(FILE*, off_t, int);
|
||||
off_t ftello(FILE*);
|
||||
|
||||
extern char** environ;
|
||||
}
|
||||
|
||||
struct timeval
|
||||
{
|
||||
int tv_sec;
|
||||
int tv_usec;
|
||||
}
|
||||
|
||||
struct struct_timezone
|
||||
{
|
||||
int tz_minuteswest;
|
||||
int tz_dstime;
|
||||
}
|
||||
|
||||
struct tm
|
||||
{
|
||||
int tm_sec;
|
||||
int tm_min;
|
||||
int tm_hour;
|
||||
int tm_mday;
|
||||
int tm_mon;
|
||||
int tm_year;
|
||||
int tm_wday;
|
||||
int tm_yday;
|
||||
int tm_isdst;
|
||||
int tm_gmtoff;
|
||||
int tm_zone;
|
||||
}
|
||||
|
||||
extern (C)
|
||||
{
|
||||
int gettimeofday(timeval*, struct_timezone*);
|
||||
__time_t time(__time_t*);
|
||||
char* asctime(tm*);
|
||||
char* ctime(__time_t*);
|
||||
tm* gmtime(__time_t*);
|
||||
tm* localtime(__time_t*);
|
||||
__time_t mktime(tm*);
|
||||
char* asctime_r(tm* t, char* buf);
|
||||
char* ctime_r(__time_t* timep, char* buf);
|
||||
tm* gmtime_r(__time_t* timep, tm* result);
|
||||
tm* localtime_r(__time_t* timep, tm* result);
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
// Memory mapping from <sys/mman.h> and <bits/mman.h>
|
||||
|
||||
enum
|
||||
{
|
||||
PROT_NONE = 0,
|
||||
PROT_READ = 1,
|
||||
PROT_WRITE = 2,
|
||||
PROT_EXEC = 4,
|
||||
}
|
||||
|
||||
// Memory mapping sharing types
|
||||
|
||||
enum
|
||||
{ MAP_SHARED = 1,
|
||||
MAP_PRIVATE = 2,
|
||||
MAP_TYPE = 0x0F,
|
||||
MAP_FIXED = 0x10,
|
||||
MAP_FILE = 0,
|
||||
MAP_ANONYMOUS = 0x20,
|
||||
MAP_ANON = 0x20,
|
||||
MAP_GROWSDOWN = 0x100,
|
||||
MAP_DENYWRITE = 0x800,
|
||||
MAP_EXECUTABLE = 0x1000,
|
||||
MAP_LOCKED = 0x2000,
|
||||
MAP_NORESERVE = 0x4000,
|
||||
MAP_POPULATE = 0x8000,
|
||||
MAP_NONBLOCK = 0x10000,
|
||||
}
|
||||
|
||||
// Values for msync()
|
||||
|
||||
enum
|
||||
{ MS_ASYNC = 1,
|
||||
MS_INVALIDATE = 2,
|
||||
MS_SYNC = 4,
|
||||
}
|
||||
|
||||
// Values for mlockall()
|
||||
|
||||
enum
|
||||
{
|
||||
MCL_CURRENT = 1,
|
||||
MCL_FUTURE = 2,
|
||||
}
|
||||
|
||||
// Values for mremap()
|
||||
|
||||
enum
|
||||
{
|
||||
MREMAP_MAYMOVE = 1,
|
||||
}
|
||||
|
||||
// Values for madvise
|
||||
|
||||
enum
|
||||
{ MADV_NORMAL = 0,
|
||||
MADV_RANDOM = 1,
|
||||
MADV_SEQUENTIAL = 2,
|
||||
MADV_WILLNEED = 3,
|
||||
MADV_DONTNEED = 4,
|
||||
}
|
||||
|
||||
extern (C)
|
||||
{
|
||||
void* mmap(void*, size_t, int, int, int, off_t);
|
||||
const void* MAP_FAILED = cast(void*)-1;
|
||||
|
||||
int munmap(void*, size_t);
|
||||
int mprotect(void*, size_t, int);
|
||||
int msync(void*, size_t, int);
|
||||
int madvise(void*, size_t, int);
|
||||
int mlock(void*, size_t);
|
||||
int munlock(void*, size_t);
|
||||
int mlockall(int);
|
||||
int munlockall();
|
||||
void* mremap(void*, size_t, size_t, int);
|
||||
int mincore(void*, size_t, ubyte*);
|
||||
int remap_file_pages(void*, size_t, int, size_t, int);
|
||||
int shm_open(char*, int, int);
|
||||
int shm_unlink(char*);
|
||||
}
|
||||
|
||||
extern(C)
|
||||
{
|
||||
|
||||
enum
|
||||
{
|
||||
DT_UNKNOWN = 0,
|
||||
DT_FIFO = 1,
|
||||
DT_CHR = 2,
|
||||
DT_DIR = 4,
|
||||
DT_BLK = 6,
|
||||
DT_REG = 8,
|
||||
DT_LNK = 10,
|
||||
DT_SOCK = 12,
|
||||
DT_WHT = 14,
|
||||
}
|
||||
|
||||
struct dirent
|
||||
{
|
||||
int d_ino;
|
||||
off_t d_off;
|
||||
ushort d_reclen;
|
||||
ubyte d_type;
|
||||
char[256] d_name;
|
||||
}
|
||||
|
||||
struct DIR
|
||||
{
|
||||
// Managed by OS.
|
||||
}
|
||||
|
||||
DIR* opendir(char* name);
|
||||
int closedir(DIR* dir);
|
||||
dirent* readdir(DIR* dir);
|
||||
void rewinddir(DIR* dir);
|
||||
off_t telldir(DIR* dir);
|
||||
void seekdir(DIR* dir, off_t offset);
|
||||
}
|
||||
|
||||
|
||||
extern(C)
|
||||
{
|
||||
private import std.intrinsic;
|
||||
|
||||
|
||||
int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* errorfds, timeval* timeout);
|
||||
int fcntl(int s, int f, ...);
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
EINTR = 4,
|
||||
EINPROGRESS = 115,
|
||||
}
|
||||
|
||||
|
||||
const uint FD_SETSIZE = 1024;
|
||||
//const uint NFDBITS = 8 * int.sizeof; // DMD 0.110: 8 * (int).sizeof is not an expression
|
||||
const int NFDBITS = 32;
|
||||
|
||||
|
||||
struct fd_set
|
||||
{
|
||||
int[FD_SETSIZE / NFDBITS] fds_bits;
|
||||
alias fds_bits __fds_bits;
|
||||
}
|
||||
|
||||
|
||||
int FDELT(int d)
|
||||
{
|
||||
return d / NFDBITS;
|
||||
}
|
||||
|
||||
|
||||
int FDMASK(int d)
|
||||
{
|
||||
return 1 << (d % NFDBITS);
|
||||
}
|
||||
|
||||
|
||||
// Removes.
|
||||
void FD_CLR(int fd, fd_set* set)
|
||||
{
|
||||
btr(cast(uint*)&set.fds_bits.ptr[FDELT(fd)], cast(uint)(fd % NFDBITS));
|
||||
}
|
||||
|
||||
|
||||
// Tests.
|
||||
int FD_ISSET(int fd, fd_set* set)
|
||||
{
|
||||
return bt(cast(uint*)&set.fds_bits.ptr[FDELT(fd)], cast(uint)(fd % NFDBITS));
|
||||
}
|
||||
|
||||
|
||||
// Adds.
|
||||
void FD_SET(int fd, fd_set* set)
|
||||
{
|
||||
bts(cast(uint*)&set.fds_bits.ptr[FDELT(fd)], cast(uint)(fd % NFDBITS));
|
||||
}
|
||||
|
||||
|
||||
// Resets to zero.
|
||||
void FD_ZERO(fd_set* set)
|
||||
{
|
||||
set.fds_bits[] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
extern (C)
|
||||
{
|
||||
/* From <dlfcn.h>
|
||||
* See http://www.opengroup.org/onlinepubs/007908799/xsh/dlsym.html
|
||||
*/
|
||||
|
||||
const int RTLD_NOW = 0x00002; // Correct for Red Hat 8
|
||||
|
||||
void* dlopen(char* file, int mode);
|
||||
int dlclose(void* handle);
|
||||
void* dlsym(void* handle, char* name);
|
||||
char* dlerror();
|
||||
}
|
||||
|
||||
extern (C)
|
||||
{
|
||||
/* from <pwd.h>
|
||||
*/
|
||||
|
||||
struct passwd
|
||||
{
|
||||
char *pw_name;
|
||||
char *pw_passwd;
|
||||
uid_t pw_uid;
|
||||
gid_t pw_gid;
|
||||
char *pw_gecos;
|
||||
char *pw_dir;
|
||||
char *pw_shell;
|
||||
}
|
||||
|
||||
const size_t _SIGSET_NWORDS = 1024 / (8 * uint.sizeof);
|
||||
struct sigset_t
|
||||
{
|
||||
uint[_SIGSET_NWORDS] __val;
|
||||
}
|
||||
|
||||
int getpwnam_r(char*, passwd*, void*, size_t, passwd**);
|
||||
passwd* getpwnam(char*);
|
||||
passwd* getpwuid(uid_t);
|
||||
int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
|
||||
int kill(pid_t, int);
|
||||
int sem_close(sem_t*);
|
||||
int sigemptyset(sigset_t*);
|
||||
int sigfillset(sigset_t*);
|
||||
int sigismember(sigset_t*, int);
|
||||
int sigsuspend(sigset_t*);
|
||||
}
|
||||
|
||||
extern (C)
|
||||
{
|
||||
/* from semaphore.h
|
||||
*/
|
||||
|
||||
struct sem_t
|
||||
{
|
||||
_pthread_fastlock __sem_lock;
|
||||
int __sem_value;
|
||||
void* __sem_waiting;
|
||||
}
|
||||
|
||||
int sem_init(sem_t*, int, uint);
|
||||
int sem_wait(sem_t*);
|
||||
int sem_trywait(sem_t*);
|
||||
int sem_post(sem_t*);
|
||||
int sem_getvalue(sem_t*, int*);
|
||||
int sem_destroy(sem_t*);
|
||||
}
|
||||
|
||||
extern (C)
|
||||
{
|
||||
/* from utime.h
|
||||
*/
|
||||
|
||||
struct utimbuf
|
||||
{
|
||||
__time_t actime;
|
||||
__time_t modtime;
|
||||
}
|
||||
|
||||
int utime(char* filename, utimbuf* buf);
|
||||
}
|
||||
25
lphobos/std/c/linux/linuxextern.d
Normal file
25
lphobos/std/c/linux/linuxextern.d
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
/* Written by Walter Bright.
|
||||
* www.digitalmars.com
|
||||
* Placed into public domain.
|
||||
* Linux(R) is the registered trademark of Linus Torvalds in the U.S. and other
|
||||
* countries.
|
||||
*/
|
||||
|
||||
/* These are all the globals defined by the linux C runtime library.
|
||||
* Put them separate so they'll be externed - do not link in linuxextern.o
|
||||
*/
|
||||
|
||||
module std.c.linux.linuxextern;
|
||||
|
||||
extern (C)
|
||||
{
|
||||
void* __libc_stack_end;
|
||||
int __data_start;
|
||||
int _end;
|
||||
int timezone;
|
||||
|
||||
void *_deh_beg;
|
||||
void *_deh_end;
|
||||
}
|
||||
|
||||
257
lphobos/std/c/linux/pthread.d
Normal file
257
lphobos/std/c/linux/pthread.d
Normal file
@@ -0,0 +1,257 @@
|
||||
/* Written by Walter Bright, Christopher E. Miller, and many others.
|
||||
* www.digitalmars.com
|
||||
* Placed into public domain.
|
||||
*/
|
||||
|
||||
module std.c.linux.pthread;
|
||||
|
||||
extern (C)
|
||||
{
|
||||
/* pthread declarations taken from pthread headers and
|
||||
http://svn.dsource.org/projects/bindings/trunk/pthreads.d
|
||||
*/
|
||||
|
||||
/* from bits/types.h
|
||||
*/
|
||||
|
||||
typedef int __time_t;
|
||||
|
||||
/* from time.h
|
||||
*/
|
||||
|
||||
struct timespec
|
||||
{
|
||||
__time_t tv_sec; /* seconds */
|
||||
int tv_nsec; /* nanosecs. */
|
||||
}
|
||||
|
||||
/* from bits/pthreadtypes.h
|
||||
*/
|
||||
|
||||
alias uint pthread_t;
|
||||
alias uint pthread_key_t;
|
||||
alias int pthread_once_t;
|
||||
alias int clockid_t;
|
||||
alias int pthread_spinlock_t; // volatile
|
||||
|
||||
struct _pthread_descr_struct
|
||||
{
|
||||
/* Not defined in the headers ???
|
||||
Just needed here to typedef
|
||||
the _pthread_descr pointer
|
||||
*/
|
||||
}
|
||||
|
||||
typedef _pthread_descr_struct* _pthread_descr;
|
||||
|
||||
struct _pthread_fastlock
|
||||
{
|
||||
int __status;
|
||||
int __spinlock;
|
||||
}
|
||||
|
||||
typedef long __pthread_cond_align_t;
|
||||
|
||||
struct pthread_cond_t
|
||||
{
|
||||
_pthread_fastlock __c_lock;
|
||||
_pthread_descr __c_waiting;
|
||||
char[48
|
||||
- _pthread_fastlock.sizeof
|
||||
- _pthread_descr.sizeof
|
||||
- __pthread_cond_align_t.sizeof
|
||||
] __padding;
|
||||
__pthread_cond_align_t __align;
|
||||
}
|
||||
|
||||
struct pthread_condattr_t
|
||||
{
|
||||
int __dummy;
|
||||
}
|
||||
|
||||
struct pthread_mutex_t
|
||||
{
|
||||
int __m_reserved;
|
||||
int __m_count;
|
||||
_pthread_descr __m_owner;
|
||||
int __m_kind;
|
||||
_pthread_fastlock __m_lock;
|
||||
}
|
||||
|
||||
struct pthread_mutexattr_t
|
||||
{
|
||||
int __mutexkind;
|
||||
}
|
||||
|
||||
/* from pthread.h
|
||||
*/
|
||||
|
||||
struct _pthread_cleanup_buffer
|
||||
{
|
||||
void function(void*) __routine;
|
||||
void* __arg;
|
||||
int __canceltype;
|
||||
_pthread_cleanup_buffer* __prev;
|
||||
}
|
||||
|
||||
struct __sched_param // bits/sched.h
|
||||
{
|
||||
int __sched_priority;
|
||||
}
|
||||
|
||||
struct pthread_attr_t
|
||||
{
|
||||
int __detachstate;
|
||||
int __schedpolicy;
|
||||
__sched_param schedparam;
|
||||
int __inheritshed;
|
||||
int __scope;
|
||||
size_t __guardsize;
|
||||
int __stackaddr_set;
|
||||
void* __stackaddr;
|
||||
size_t __stacksize;
|
||||
}
|
||||
|
||||
struct pthread_barrier_t
|
||||
{
|
||||
_pthread_fastlock __ba_lock;
|
||||
int __ba_required;
|
||||
int __ba_present;
|
||||
_pthread_descr __ba_waiting;
|
||||
}
|
||||
|
||||
struct pthread_barrierattr_t
|
||||
{
|
||||
int __pshared;
|
||||
}
|
||||
|
||||
struct pthread_rwlockattr_t
|
||||
{
|
||||
int __lockkind;
|
||||
int __pshared;
|
||||
}
|
||||
|
||||
struct pthread_rwlock_t
|
||||
{
|
||||
_pthread_fastlock __rw_lock;
|
||||
int __rw_readers;
|
||||
_pthread_descr __rw_writer;
|
||||
_pthread_descr __rw_read_waiting;
|
||||
_pthread_descr __rw_write_waiting;
|
||||
int __rw_kind;
|
||||
int __rw_pshared;
|
||||
}
|
||||
|
||||
int pthread_mutex_init(pthread_mutex_t*, pthread_mutexattr_t*);
|
||||
int pthread_mutex_destroy(pthread_mutex_t*);
|
||||
int pthread_mutex_trylock(pthread_mutex_t*);
|
||||
int pthread_mutex_lock(pthread_mutex_t*);
|
||||
int pthread_mutex_unlock(pthread_mutex_t*);
|
||||
|
||||
int pthread_mutexattr_init(pthread_mutexattr_t*);
|
||||
int pthread_mutexattr_destroy(pthread_mutexattr_t*);
|
||||
|
||||
int pthread_cond_init(pthread_cond_t*, pthread_condattr_t*);
|
||||
int pthread_cond_destroy(pthread_cond_t*);
|
||||
int pthread_cond_signal(pthread_cond_t*);
|
||||
int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*);
|
||||
int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, timespec*);
|
||||
|
||||
int pthread_attr_init(pthread_attr_t*);
|
||||
int pthread_attr_destroy(pthread_attr_t*);
|
||||
int pthread_attr_setdetachstate(pthread_attr_t*, int);
|
||||
int pthread_attr_getdetachstate(pthread_attr_t*, int*);
|
||||
int pthread_attr_setinheritsched(pthread_attr_t*, int);
|
||||
int pthread_attr_getinheritsched(pthread_attr_t*, int*);
|
||||
int pthread_attr_setschedparam(pthread_attr_t*, __sched_param*);
|
||||
int pthread_attr_getschedparam(pthread_attr_t*, __sched_param*);
|
||||
int pthread_attr_setschedpolicy(pthread_attr_t*, int);
|
||||
int pthread_attr_getschedpolicy(pthread_attr_t*, int*);
|
||||
int pthread_attr_setscope(pthread_attr_t*, int);
|
||||
int pthread_attr_getscope(pthread_attr_t*, int*);
|
||||
int pthread_attr_setguardsize(pthread_attr_t*, size_t);
|
||||
int pthread_attr_getguardsize(pthread_attr_t*, size_t*);
|
||||
int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
|
||||
int pthread_attr_getstack(pthread_attr_t*, void**, size_t*);
|
||||
int pthread_attr_setstackaddr(pthread_attr_t*, void*);
|
||||
int pthread_attr_getstackaddr(pthread_attr_t*, void**);
|
||||
int pthread_attr_setstacksize(pthread_attr_t*, size_t);
|
||||
int pthread_attr_getstacksize(pthread_attr_t*, size_t*);
|
||||
|
||||
int pthread_barrierattr_init(pthread_barrierattr_t*);
|
||||
int pthread_barrierattr_getpshared(pthread_barrierattr_t*, int*);
|
||||
int pthread_barrierattr_destroy(pthread_barrierattr_t*);
|
||||
int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
|
||||
|
||||
int pthread_barrier_init(pthread_barrier_t*, pthread_barrierattr_t*, uint);
|
||||
int pthread_barrier_destroy(pthread_barrier_t*);
|
||||
int pthread_barrier_wait(pthread_barrier_t*);
|
||||
|
||||
int pthread_condattr_init(pthread_condattr_t*);
|
||||
int pthread_condattr_destroy(pthread_condattr_t*);
|
||||
int pthread_condattr_getpshared(pthread_condattr_t*, int*);
|
||||
int pthread_condattr_setpshared(pthread_condattr_t*, int);
|
||||
|
||||
int pthread_detach(pthread_t);
|
||||
void pthread_exit(void*);
|
||||
int pthread_getattr_np(pthread_t, pthread_attr_t*);
|
||||
int pthread_getconcurrency();
|
||||
int pthread_getcpuclockid(pthread_t, clockid_t*);
|
||||
|
||||
int pthread_mutexattr_getpshared(pthread_mutexattr_t*, int*);
|
||||
int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
|
||||
int pthread_mutexattr_settype(pthread_mutexattr_t*, int);
|
||||
int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*);
|
||||
int pthread_mutex_timedlock(pthread_mutex_t*, timespec*);
|
||||
int pthread_yield();
|
||||
|
||||
int pthread_rwlock_init(pthread_rwlock_t*, pthread_rwlockattr_t*);
|
||||
int pthread_rwlock_destroy(pthread_rwlock_t*);
|
||||
int pthread_rwlock_rdlock(pthread_rwlock_t*);
|
||||
int pthread_rwlock_tryrdlock(pthread_rwlock_t*);
|
||||
int pthread_rwlock_timedrdlock(pthread_rwlock_t*, timespec*);
|
||||
int pthread_rwlock_wrlock(pthread_rwlock_t*);
|
||||
int pthread_rwlock_trywrlock(pthread_rwlock_t*);
|
||||
int pthread_rwlock_timedwrlock(pthread_rwlock_t*, timespec*);
|
||||
int pthread_rwlock_unlock(pthread_rwlock_t*);
|
||||
|
||||
int pthread_rwlockattr_init(pthread_rwlockattr_t*);
|
||||
int pthread_rwlockattr_destroy(pthread_rwlockattr_t*);
|
||||
int pthread_rwlockattr_getpshared(pthread_rwlockattr_t*, int*);
|
||||
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
|
||||
int pthread_rwlockattr_getkind_np(pthread_rwlockattr_t*, int*);
|
||||
int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t*, int);
|
||||
|
||||
int pthread_spin_init(pthread_spinlock_t*, int);
|
||||
int pthread_spin_destroy(pthread_spinlock_t*);
|
||||
int pthread_spin_lock(pthread_spinlock_t*);
|
||||
int pthread_spin_trylock(pthread_spinlock_t*);
|
||||
int pthread_spin_unlock(pthread_spinlock_t*);
|
||||
|
||||
int pthread_cancel(pthread_t);
|
||||
void pthread_testcancel();
|
||||
int pthread_once(pthread_once_t*, void function());
|
||||
|
||||
int pthread_join(pthread_t, void**);
|
||||
int pthread_create(pthread_t*, pthread_attr_t*, void*function(void*), void*);
|
||||
pthread_t pthread_self();
|
||||
int pthread_equal(pthread_t, pthread_t);
|
||||
int pthread_atfork(void function(), void function(), void function());
|
||||
void pthread_kill_other_threads_np();
|
||||
int pthread_setschedparam(pthread_t, int, __sched_param*);
|
||||
int pthread_getschedparam(pthread_t, int*, __sched_param*);
|
||||
int pthread_cond_broadcast(pthread_cond_t*);
|
||||
int pthread_key_create(pthread_key_t*, void function(void*));
|
||||
int pthread_key_delete(pthread_key_t);
|
||||
int pthread_setconcurrency(int);
|
||||
int pthread_setspecific(pthread_key_t, void*);
|
||||
void* pthread_getspecific(pthread_key_t);
|
||||
int pthread_setcanceltype(int, int*);
|
||||
int pthread_setcancelstate(int, int*);
|
||||
|
||||
void _pthread_cleanup_push(_pthread_cleanup_buffer*, void function(void*), void*);
|
||||
void _pthread_cleanup_push_defer(_pthread_cleanup_buffer*, void function(void*), void*);
|
||||
void _pthread_cleanup_pop(_pthread_cleanup_buffer*, int);
|
||||
void _pthread_cleanup_pop_restore(_pthread_cleanup_buffer*, int);
|
||||
}
|
||||
|
||||
396
lphobos/std/c/linux/socket.d
Normal file
396
lphobos/std/c/linux/socket.d
Normal file
@@ -0,0 +1,396 @@
|
||||
/*
|
||||
Written by Christopher E. Miller
|
||||
Placed into public domain.
|
||||
*/
|
||||
|
||||
|
||||
module std.c.linux.socket;
|
||||
|
||||
private import std.stdint;
|
||||
|
||||
|
||||
extern(C):
|
||||
|
||||
alias int socklen_t;
|
||||
|
||||
const int F_GETFL = 3;
|
||||
const int F_SETFL = 4;
|
||||
const int O_NONBLOCK = 0x800;
|
||||
|
||||
|
||||
int socket(int af, int type, int protocol);
|
||||
int bind(int s, sockaddr* name, int namelen);
|
||||
int connect(int s, sockaddr* name, int namelen);
|
||||
int listen(int s, int backlog);
|
||||
int accept(int s, sockaddr* addr, int* addrlen);
|
||||
int shutdown(int s, int how);
|
||||
int getpeername(int s, sockaddr* name, int* namelen);
|
||||
int getsockname(int s, sockaddr* name, int* namelen);
|
||||
int send(int s, void* buf, int len, int flags);
|
||||
int sendto(int s, void* buf, int len, int flags, sockaddr* to, int tolen);
|
||||
int recv(int s, void* buf, int len, int flags);
|
||||
int recvfrom(int s, void* buf, int len, int flags, sockaddr* from, int* fromlen);
|
||||
int getsockopt(int s, int level, int optname, void* optval, int* optlen);
|
||||
int setsockopt(int s, int level, int optname, void* optval, int optlen);
|
||||
uint inet_addr(char* cp);
|
||||
char* inet_ntoa(in_addr ina);
|
||||
hostent* gethostbyname(char* name);
|
||||
int gethostbyname_r(char* name, hostent* ret, void* buf, size_t buflen, hostent** result, int* h_errnop);
|
||||
int gethostbyname2_r(char* name, int af, hostent* ret, void* buf, size_t buflen, hostent** result, int* h_errnop);
|
||||
hostent* gethostbyaddr(void* addr, int len, int type);
|
||||
protoent* getprotobyname(char* name);
|
||||
protoent* getprotobynumber(int number);
|
||||
servent* getservbyname(char* name, char* proto);
|
||||
servent* getservbyport(int port, char* proto);
|
||||
int gethostname(char* name, int namelen);
|
||||
int getaddrinfo(char* nodename, char* servname, addrinfo* hints, addrinfo** res);
|
||||
void freeaddrinfo(addrinfo* ai);
|
||||
int getnameinfo(sockaddr* sa, socklen_t salen, char* node, socklen_t nodelen, char* service, socklen_t servicelen, int flags);
|
||||
|
||||
|
||||
|
||||
enum: int
|
||||
{
|
||||
AF_UNSPEC = 0,
|
||||
AF_UNIX = 1,
|
||||
AF_INET = 2,
|
||||
AF_IPX = 4,
|
||||
AF_APPLETALK = 5,
|
||||
AF_INET6 = 10,
|
||||
// ...
|
||||
|
||||
PF_UNSPEC = AF_UNSPEC,
|
||||
PF_UNIX = AF_UNIX,
|
||||
PF_INET = AF_INET,
|
||||
PF_IPX = AF_IPX,
|
||||
PF_APPLETALK = AF_APPLETALK,
|
||||
PF_INET6 = AF_INET6,
|
||||
}
|
||||
|
||||
|
||||
version(X86)
|
||||
version=SOL_SOCKET_IS_1;
|
||||
else version(X86_64)
|
||||
version=SOL_SOCKET_IS_1;
|
||||
else version(PPC)
|
||||
version=SOL_SOCKET_IS_1;
|
||||
else version(PPC64)
|
||||
version=SOL_SOCKET_IS_1;
|
||||
else
|
||||
static assert(0, "Unsupported architecture");
|
||||
|
||||
version(SOL_SOCKET_IS_1)
|
||||
{
|
||||
enum: int
|
||||
{
|
||||
SOL_SOCKET = 1,
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Different values on other platforms.
|
||||
static assert(0);
|
||||
}
|
||||
|
||||
|
||||
enum: int
|
||||
{
|
||||
SO_DEBUG = 1,
|
||||
SO_BROADCAST = 6,
|
||||
SO_REUSEADDR = 2,
|
||||
SO_LINGER = 13,
|
||||
SO_DONTLINGER = ~SO_LINGER,
|
||||
SO_OOBINLINE = 10,
|
||||
SO_SNDBUF = 7,
|
||||
SO_RCVBUF = 8,
|
||||
SO_ACCEPTCONN = 30,
|
||||
SO_DONTROUTE = 5,
|
||||
SO_TYPE = 3,
|
||||
|
||||
TCP_NODELAY = 1,
|
||||
|
||||
IP_MULTICAST_LOOP = 34,
|
||||
IP_ADD_MEMBERSHIP = 35,
|
||||
IP_DROP_MEMBERSHIP = 36,
|
||||
|
||||
// ...
|
||||
|
||||
IPV6_ADDRFORM = 1,
|
||||
IPV6_PKTINFO = 2,
|
||||
IPV6_HOPOPTS = 3,
|
||||
IPV6_DSTOPTS = 4,
|
||||
IPV6_RTHDR = 5,
|
||||
IPV6_PKTOPTIONS = 6,
|
||||
IPV6_CHECKSUM = 7,
|
||||
IPV6_HOPLIMIT = 8,
|
||||
IPV6_NEXTHOP = 9,
|
||||
IPV6_AUTHHDR = 10,
|
||||
IPV6_UNICAST_HOPS = 16,
|
||||
IPV6_MULTICAST_IF = 17,
|
||||
IPV6_MULTICAST_HOPS = 18,
|
||||
IPV6_MULTICAST_LOOP = 19,
|
||||
IPV6_JOIN_GROUP = 20,
|
||||
IPV6_LEAVE_GROUP = 21,
|
||||
IPV6_ROUTER_ALERT = 22,
|
||||
IPV6_MTU_DISCOVER = 23,
|
||||
IPV6_MTU = 24,
|
||||
IPV6_RECVERR = 25,
|
||||
IPV6_V6ONLY = 26,
|
||||
IPV6_JOIN_ANYCAST = 27,
|
||||
IPV6_LEAVE_ANYCAST = 28,
|
||||
IPV6_IPSEC_POLICY = 34,
|
||||
IPV6_XFRM_POLICY = 35,
|
||||
}
|
||||
|
||||
|
||||
struct linger
|
||||
{
|
||||
int32_t l_onoff;
|
||||
int32_t l_linger;
|
||||
}
|
||||
|
||||
|
||||
struct protoent
|
||||
{
|
||||
char* p_name;
|
||||
char** p_aliases;
|
||||
int32_t p_proto;
|
||||
}
|
||||
|
||||
|
||||
struct servent
|
||||
{
|
||||
char* s_name;
|
||||
char** s_aliases;
|
||||
int32_t s_port;
|
||||
char* s_proto;
|
||||
}
|
||||
|
||||
|
||||
version(BigEndian)
|
||||
{
|
||||
uint16_t htons(uint16_t x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
uint32_t htonl(uint32_t x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
}
|
||||
else version(LittleEndian)
|
||||
{
|
||||
private import std.intrinsic;
|
||||
|
||||
|
||||
uint16_t htons(uint16_t x)
|
||||
{
|
||||
return cast(uint16_t)((x >> 8) | (x << 8));
|
||||
}
|
||||
|
||||
|
||||
uint32_t htonl(uint32_t x)
|
||||
{
|
||||
return bswap(x);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
static assert(0);
|
||||
}
|
||||
|
||||
|
||||
uint16_t ntohs(uint16_t x)
|
||||
{
|
||||
return htons(x);
|
||||
}
|
||||
|
||||
|
||||
uint32_t ntohl(uint32_t x)
|
||||
{
|
||||
return htonl(x);
|
||||
}
|
||||
|
||||
|
||||
enum: int
|
||||
{
|
||||
SOCK_STREAM = 1,
|
||||
SOCK_DGRAM = 2,
|
||||
SOCK_RAW = 3,
|
||||
SOCK_RDM = 4,
|
||||
SOCK_SEQPACKET = 5,
|
||||
}
|
||||
|
||||
|
||||
enum: int
|
||||
{
|
||||
IPPROTO_IP = 0,
|
||||
IPPROTO_ICMP = 1,
|
||||
IPPROTO_IGMP = 2,
|
||||
IPPROTO_GGP = 3,
|
||||
IPPROTO_TCP = 6,
|
||||
IPPROTO_PUP = 12,
|
||||
IPPROTO_UDP = 17,
|
||||
IPPROTO_IDP = 22,
|
||||
IPPROTO_IPV6 = 41,
|
||||
IPPROTO_ND = 77,
|
||||
IPPROTO_RAW = 255,
|
||||
|
||||
IPPROTO_MAX = 256,
|
||||
}
|
||||
|
||||
|
||||
enum: int
|
||||
{
|
||||
MSG_OOB = 0x1,
|
||||
MSG_PEEK = 0x2,
|
||||
MSG_DONTROUTE = 0x4,
|
||||
}
|
||||
|
||||
|
||||
enum: int
|
||||
{
|
||||
SD_RECEIVE = 0,
|
||||
SD_SEND = 1,
|
||||
SD_BOTH = 2,
|
||||
}
|
||||
|
||||
|
||||
enum: uint
|
||||
{
|
||||
INADDR_ANY = 0,
|
||||
INADDR_LOOPBACK = 0x7F000001,
|
||||
INADDR_BROADCAST = 0xFFFFFFFF,
|
||||
INADDR_NONE = 0xFFFFFFFF,
|
||||
ADDR_ANY = INADDR_ANY,
|
||||
}
|
||||
|
||||
|
||||
enum: int
|
||||
{
|
||||
AI_PASSIVE = 0x1,
|
||||
AI_CANONNAME = 0x2,
|
||||
AI_NUMERICHOST = 0x4,
|
||||
}
|
||||
|
||||
|
||||
union in_addr
|
||||
{
|
||||
private union _S_un_t
|
||||
{
|
||||
private struct _S_un_b_t
|
||||
{
|
||||
uint8_t s_b1, s_b2, s_b3, s_b4;
|
||||
}
|
||||
_S_un_b_t S_un_b;
|
||||
|
||||
private struct _S_un_w_t
|
||||
{
|
||||
uint16_t s_w1, s_w2;
|
||||
}
|
||||
_S_un_w_t S_un_w;
|
||||
|
||||
uint32_t S_addr;
|
||||
}
|
||||
_S_un_t S_un;
|
||||
|
||||
uint32_t s_addr;
|
||||
|
||||
struct
|
||||
{
|
||||
uint8_t s_net, s_host;
|
||||
|
||||
union
|
||||
{
|
||||
uint16_t s_imp;
|
||||
|
||||
struct
|
||||
{
|
||||
uint8_t s_lh, s_impno;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
union in6_addr
|
||||
{
|
||||
private union _in6_u_t
|
||||
{
|
||||
uint8_t[16] u6_addr8;
|
||||
uint16_t[8] u6_addr16;
|
||||
uint32_t[4] u6_addr32;
|
||||
}
|
||||
_in6_u_t in6_u;
|
||||
|
||||
uint8_t[16] s6_addr8;
|
||||
uint16_t[8] s6_addr16;
|
||||
uint32_t[4] s6_addr32;
|
||||
}
|
||||
|
||||
|
||||
const in6_addr IN6ADDR_ANY = { s6_addr8: [0] };
|
||||
const in6_addr IN6ADDR_LOOPBACK = { s6_addr8: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] };
|
||||
//alias IN6ADDR_ANY IN6ADDR_ANY_INIT;
|
||||
//alias IN6ADDR_LOOPBACK IN6ADDR_LOOPBACK_INIT;
|
||||
|
||||
const uint INET_ADDRSTRLEN = 16;
|
||||
const uint INET6_ADDRSTRLEN = 46;
|
||||
|
||||
|
||||
struct sockaddr
|
||||
{
|
||||
int16_t sa_family;
|
||||
ubyte[14] sa_data;
|
||||
}
|
||||
|
||||
|
||||
struct sockaddr_in
|
||||
{
|
||||
int16_t sin_family = AF_INET;
|
||||
uint16_t sin_port;
|
||||
in_addr sin_addr;
|
||||
ubyte[8] sin_zero;
|
||||
}
|
||||
|
||||
|
||||
struct sockaddr_in6
|
||||
{
|
||||
int16_t sin6_family = AF_INET6;
|
||||
uint16_t sin6_port;
|
||||
uint32_t sin6_flowinfo;
|
||||
in6_addr sin6_addr;
|
||||
uint32_t sin6_scope_id;
|
||||
}
|
||||
|
||||
|
||||
struct addrinfo
|
||||
{
|
||||
int32_t ai_flags;
|
||||
int32_t ai_family;
|
||||
int32_t ai_socktype;
|
||||
int32_t ai_protocol;
|
||||
size_t ai_addrlen;
|
||||
sockaddr* ai_addr;
|
||||
char* ai_canonname;
|
||||
addrinfo* ai_next;
|
||||
}
|
||||
|
||||
|
||||
struct hostent
|
||||
{
|
||||
char* h_name;
|
||||
char** h_aliases;
|
||||
int32_t h_addrtype;
|
||||
int32_t h_length;
|
||||
char** h_addr_list;
|
||||
|
||||
|
||||
char* h_addr()
|
||||
{
|
||||
return h_addr_list[0];
|
||||
}
|
||||
}
|
||||
|
||||
151
lphobos/std/c/locale.d
Normal file
151
lphobos/std/c/locale.d
Normal file
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
* C's <locale.h>
|
||||
* License: Public Domain
|
||||
* Standards:
|
||||
* ISO/IEC 9899:1999 7.11
|
||||
* Macros:
|
||||
* WIKI=Phobos/StdCLocale
|
||||
*/
|
||||
module std.c.locale;
|
||||
|
||||
extern(C):
|
||||
|
||||
/// Structure giving information about numeric and monetary notation.
|
||||
struct lconv{
|
||||
/// The decimal-point character used to format nonmonetary quantities.
|
||||
char* decimal_point;
|
||||
|
||||
/** The character used to separate groups of digits before the
|
||||
* decimal-point character in formatted nonmonetary quantities.
|
||||
**/
|
||||
char* thousands_sep;
|
||||
|
||||
/** A string whose elements indicate the size of each group of digits
|
||||
* in formatted nonmonetary quantities.
|
||||
**/
|
||||
char* grouping;
|
||||
|
||||
/** The international currency symbol applicable to the current locale.
|
||||
* The first three characters contain the alphabetic international
|
||||
* currency symbol in accordance with those specified in ISO 4217.
|
||||
* The fourth character (immediately preceding the null character)
|
||||
* is the character used to separate the international currency symbol
|
||||
* from the monetary quantity.
|
||||
**/
|
||||
char* int_curr_symbol;
|
||||
|
||||
/// The local currency symbol applicable to the current locale.
|
||||
char* currency_symbol;
|
||||
|
||||
/// The decimal-point used to format monetary quantities.
|
||||
char* mon_decimal_point;
|
||||
|
||||
/** The separator for groups of digits before the decimal-point in
|
||||
* formatted monetary quantities.
|
||||
**/
|
||||
char* mon_thousands_sep;
|
||||
|
||||
/** A string whose elements indicate the size of each group of digits
|
||||
* in formatted monetary quantities.
|
||||
**/
|
||||
char* mon_grouping;
|
||||
|
||||
/** The string used to indicate a nonnegative-valued formatted
|
||||
* monetary quantity.
|
||||
**/
|
||||
char* positive_sign;
|
||||
|
||||
/** The string used to indicate a negative-valued formatted monetary
|
||||
* quantity.
|
||||
**/
|
||||
char* negative_sign;
|
||||
|
||||
/** The number of fractional digits (those after the decimal-point) to
|
||||
* be displayed in an internationally formatted monetary quantity.
|
||||
**/
|
||||
char int_frac_digits;
|
||||
|
||||
/** The number of fractional digits (those after the decimal-point) to
|
||||
* be displayed in a locally formatted monetary quantity.
|
||||
**/
|
||||
char frac_digits;
|
||||
|
||||
/// 1 if currency_symbol precedes a positive value, 0 if succeeds.
|
||||
char p_cs_precedes;
|
||||
|
||||
/// 1 if a space separates currency_symbol from a positive value.
|
||||
char p_sep_by_space;
|
||||
|
||||
/// 1 if currency_symbol precedes a negative value, 0 if succeeds.
|
||||
char n_cs_precedes;
|
||||
|
||||
/// 1 if a space separates currency_symbol from a negative value.
|
||||
char n_sep_by_space;
|
||||
|
||||
/* Positive and negative sign positions:
|
||||
0 Parentheses surround the quantity and currency_symbol.
|
||||
1 The sign string precedes the quantity and currency_symbol.
|
||||
2 The sign string follows the quantity and currency_symbol.
|
||||
3 The sign string immediately precedes the currency_symbol.
|
||||
4 The sign string immediately follows the currency_symbol. */
|
||||
char p_sign_posn;
|
||||
char n_sign_posn;
|
||||
|
||||
/// 1 if int_curr_symbol precedes a positive value, 0 if succeeds.
|
||||
char int_p_cs_precedes;
|
||||
|
||||
/// 1 iff a space separates int_curr_symbol from a positive value.
|
||||
char int_p_sep_by_space;
|
||||
|
||||
/// 1 if int_curr_symbol precedes a negative value, 0 if succeeds.
|
||||
char int_n_cs_precedes;
|
||||
|
||||
/// 1 iff a space separates int_curr_symbol from a negative value.
|
||||
char int_n_sep_by_space;
|
||||
|
||||
/* Positive and negative sign positions:
|
||||
0 Parentheses surround the quantity and int_curr_symbol.
|
||||
1 The sign string precedes the quantity and int_curr_symbol.
|
||||
2 The sign string follows the quantity and int_curr_symbol.
|
||||
3 The sign string immediately precedes the int_curr_symbol.
|
||||
4 The sign string immediately follows the int_curr_symbol. */
|
||||
char int_p_sign_posn;
|
||||
char int_n_sign_posn;
|
||||
}
|
||||
|
||||
/** Affects the behavior of C's character handling functions and C's multibyte
|
||||
* and wide character functions.
|
||||
**/
|
||||
const LC_CTYPE = 0;
|
||||
|
||||
/** Affects the decimal-point character for C's formatted input/output functions
|
||||
* and C's string conversion functions, as well as C's nonmonetary formatting
|
||||
* information returned by the localeconv function.
|
||||
**/
|
||||
const LC_NUMERIC = 1;
|
||||
|
||||
/// Affects the behavior of the strftime and wcsftime functions.
|
||||
const LC_TIME = 2;
|
||||
|
||||
/// Affects the behavior of the strcoll and strxfrm functions.
|
||||
const LC_COLLATE = 3;
|
||||
|
||||
/** Affects the monetary formatting information returned by the localeconv
|
||||
* function.
|
||||
**/
|
||||
const LC_MONETARY = 4;
|
||||
|
||||
/// The program's entire locale.
|
||||
const LC_ALL = 6;
|
||||
|
||||
/** The setlocale function selects the appropriate portion of the program's
|
||||
* locale as specified by the category and locale arguments.
|
||||
**/
|
||||
char* setlocale(int category, char* locale);
|
||||
|
||||
/** The localeconv function sets the components of an object with type
|
||||
* lconv with values appropriate for the formatting of numeric quantities
|
||||
* (monetary and otherwise) according to the rules of the current locale.
|
||||
**/
|
||||
lconv* localeconv();
|
||||
|
||||
291
lphobos/std/c/math.d
Normal file
291
lphobos/std/c/math.d
Normal file
@@ -0,0 +1,291 @@
|
||||
|
||||
/**
|
||||
* C's <math.h>
|
||||
* Authors: Walter Bright, Digital Mars, www.digitalmars.com
|
||||
* License: Public Domain
|
||||
* Macros:
|
||||
* WIKI=Phobos/StdCMath
|
||||
*/
|
||||
|
||||
module std.c.math;
|
||||
|
||||
extern (C):
|
||||
|
||||
alias float float_t; ///
|
||||
alias double double_t; ///
|
||||
|
||||
const double HUGE_VAL = double.infinity; ///
|
||||
const float HUGE_VALF = float.infinity; /// ditto
|
||||
const real HUGE_VALL = real.infinity; /// ditto
|
||||
|
||||
const float INFINITY = float.infinity; ///
|
||||
const float NAN = float.nan; ///
|
||||
|
||||
enum
|
||||
{
|
||||
FP_NANS, // extension
|
||||
FP_NANQ, // extension
|
||||
FP_INFINITE, ///
|
||||
FP_NAN = FP_NANQ, ///
|
||||
FP_NORMAL = 3, ///
|
||||
FP_SUBNORMAL = 4, ///
|
||||
FP_ZERO = 5, ///
|
||||
FP_EMPTY = 6, // extension
|
||||
FP_UNSUPPORTED = 7, // extension
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
FP_FAST_FMA = 0, ///
|
||||
FP_FAST_FMAF = 0, ///
|
||||
FP_FAST_FMAL = 0, ///
|
||||
}
|
||||
|
||||
const int FP_ILOGB0 = int.min; ///
|
||||
const int FP_ILOGBNAN = int.min; ///
|
||||
|
||||
const int MATH_ERRNO = 1; ///
|
||||
const int MATH_ERREXCEPT = 2; ///
|
||||
const int math_errhandling = MATH_ERRNO | MATH_ERREXCEPT; ///
|
||||
|
||||
double acos(double x); ///
|
||||
float acosf(float x); /// ditto
|
||||
real acosl(real x); /// ditto
|
||||
|
||||
double asin(double x); ///
|
||||
float asinf(float x); /// ditto
|
||||
real asinl(real x); /// ditto
|
||||
|
||||
double atan(double x); ///
|
||||
float atanf(float x); /// ditto
|
||||
real atanl(real x); /// ditto
|
||||
|
||||
double atan2(double y, double x); ///
|
||||
float atan2f(float y, float x); /// ditto
|
||||
real atan2l(real y, real x); /// ditto
|
||||
|
||||
double cos(double x); ///
|
||||
float cosf(float x); /// ditto
|
||||
real cosl(real x); /// ditto
|
||||
|
||||
double sin(double x); ///
|
||||
float sinf(float x); /// ditto
|
||||
real sinl(real x); /// ditto
|
||||
|
||||
double tan(double x); ///
|
||||
float tanf(float x); /// ditto
|
||||
real tanl(real x); /// ditto
|
||||
|
||||
double acosh(double x); ///
|
||||
float acoshf(float x); /// ditto
|
||||
real acoshl(real x); /// ditto
|
||||
|
||||
double asinh(double x); ///
|
||||
float asinhf(float x); /// ditto
|
||||
real asinhl(real x); /// ditto
|
||||
|
||||
double atanh(double x); ///
|
||||
float atanhf(float x); /// ditto
|
||||
real atanhl(real x); /// ditto
|
||||
|
||||
double cosh(double x); ///
|
||||
float coshf(float x); /// ditto
|
||||
real coshl(real x); /// ditto
|
||||
|
||||
double sinh(double x); ///
|
||||
float sinhf(float x); /// ditto
|
||||
real sinhl(real x); /// ditto
|
||||
|
||||
double tanh(double x); ///
|
||||
float tanhf(float x); /// ditto
|
||||
real tanhl(real x); /// ditto
|
||||
|
||||
double exp(double x); ///
|
||||
float expf(float x); /// ditto
|
||||
real expl(real x); /// ditto
|
||||
|
||||
double exp2(double x); ///
|
||||
float exp2f(float x); /// ditto
|
||||
real exp2l(real x); /// ditto
|
||||
|
||||
double expm1(double x); ///
|
||||
float expm1f(float x); /// ditto
|
||||
real expm1l(real x); /// ditto
|
||||
|
||||
double frexp(double value, int *exp); ///
|
||||
float frexpf(float value, int *exp); /// ditto
|
||||
real frexpl(real value, int *exp); /// ditto
|
||||
|
||||
int ilogb(double x); ///
|
||||
int ilogbf(float x); /// ditto
|
||||
int ilogbl(real x); /// ditto
|
||||
|
||||
double ldexp(double x, int exp); ///
|
||||
float ldexpf(float x, int exp); /// ditto
|
||||
real ldexpl(real x, int exp); /// ditto
|
||||
|
||||
double log(double x); ///
|
||||
float logf(float x); /// ditto
|
||||
real logl(real x); /// ditto
|
||||
|
||||
double log10(double x); ///
|
||||
float log10f(float x); /// ditto
|
||||
real log10l(real x); /// ditto
|
||||
|
||||
double log1p(double x); ///
|
||||
float log1pf(float x); /// ditto
|
||||
real log1pl(real x); /// ditto
|
||||
|
||||
double log2(double x); ///
|
||||
float log2f(float x); /// ditto
|
||||
real log2l(real x); /// ditto
|
||||
|
||||
double logb(double x); ///
|
||||
float logbf(float x); /// ditto
|
||||
real logbl(real x); /// ditto
|
||||
|
||||
double modf(double value, double *iptr); ///
|
||||
float modff(float value, float *iptr); /// ditto
|
||||
real modfl(real value, real *iptr); /// ditto
|
||||
|
||||
double scalbn(double x, int n); ///
|
||||
float scalbnf(float x, int n); /// ditto
|
||||
real scalbnl(real x, int n); /// ditto
|
||||
|
||||
double scalbln(double x, int n); ///
|
||||
float scalblnf(float x, int n); /// ditto
|
||||
real scalblnl(real x, int n); /// ditto
|
||||
|
||||
double cbrt(double x); ///
|
||||
float cbrtf(float x); /// ditto
|
||||
real cbrtl(real x); /// ditto
|
||||
|
||||
double fabs(double x); ///
|
||||
float fabsf(float x); /// ditto
|
||||
real fabsl(real x); /// ditto
|
||||
|
||||
double hypot(double x, double y); ///
|
||||
float hypotf(float x, float y); /// ditto
|
||||
real hypotl(real x, real y); /// ditto
|
||||
|
||||
double pow(double x, double y); ///
|
||||
float powf(float x, float y); /// ditto
|
||||
real powl(real x, real y); /// ditto
|
||||
|
||||
double sqrt(double x); ///
|
||||
float sqrtf(float x); /// ditto
|
||||
real sqrtl(real x); /// ditto
|
||||
|
||||
double erf(double x); ///
|
||||
float erff(float x); /// ditto
|
||||
real erfl(real x); /// ditto
|
||||
|
||||
double erfc(double x); ///
|
||||
float erfcf(float x); /// ditto
|
||||
real erfcl(real x); /// ditto
|
||||
|
||||
double lgamma(double x); ///
|
||||
float lgammaf(float x); /// ditto
|
||||
real lgammal(real x); /// ditto
|
||||
|
||||
double tgamma(double x); ///
|
||||
float tgammaf(float x); /// ditto
|
||||
real tgammal(real x); /// ditto
|
||||
|
||||
double ceil(double x); ///
|
||||
float ceilf(float x); /// ditto
|
||||
real ceill(real x); /// ditto
|
||||
|
||||
double floor(double x); ///
|
||||
float floorf(float x); /// ditto
|
||||
real floorl(real x); /// ditto
|
||||
|
||||
double nearbyint(double x); ///
|
||||
float nearbyintf(float x); /// ditto
|
||||
real nearbyintl(real x); /// ditto
|
||||
|
||||
double rint(double x); ///
|
||||
float rintf(float x); /// ditto
|
||||
real rintl(real x); /// ditto
|
||||
|
||||
int lrint(double x); ///
|
||||
int lrintf(float x); /// ditto
|
||||
int lrintl(real x); /// ditto
|
||||
|
||||
long llrint(double x); ///
|
||||
long llrintf(float x); /// ditto
|
||||
long llrintl(real x); /// ditto
|
||||
|
||||
double round(double x); ///
|
||||
float roundf(float x); /// ditto
|
||||
real roundl(real x); /// ditto
|
||||
|
||||
int lround(double x); ///
|
||||
int lroundf(float x); /// ditto
|
||||
int lroundl(real x); /// ditto
|
||||
|
||||
long llround(double x); ///
|
||||
long llroundf(float x); /// ditto
|
||||
long llroundl(real x); /// ditto
|
||||
|
||||
double trunc(double x); ///
|
||||
float truncf(float x); /// ditto
|
||||
real truncl(real x); /// ditto
|
||||
|
||||
double fmod(double x, double y); ///
|
||||
float fmodf(float x, float y); /// ditto
|
||||
real fmodl(real x, real y); /// ditto
|
||||
|
||||
double remainder(double x, double y); ///
|
||||
float remainderf(float x, float y); /// ditto
|
||||
real remainderl(real x, real y); /// ditto
|
||||
|
||||
double remquo(double x, double y, int *quo); ///
|
||||
float remquof(float x, float y, int *quo); /// ditto
|
||||
real remquol(real x, real y, int *quo); /// ditto
|
||||
|
||||
double copysign(double x, double y); ///
|
||||
float copysignf(float x, float y); /// ditto
|
||||
real copysignl(real x, real y); /// ditto
|
||||
|
||||
double nan(char *tagp); ///
|
||||
float nanf(char *tagp); /// ditto
|
||||
real nanl(char *tagp); /// ditto
|
||||
|
||||
double nextafter(double x, double y); ///
|
||||
float nextafterf(float x, float y); /// ditto
|
||||
real nextafterl(real x, real y); /// ditto
|
||||
|
||||
double nexttoward(double x, real y); ///
|
||||
float nexttowardf(float x, real y); /// ditto
|
||||
real nexttowardl(real x, real y); /// ditto
|
||||
|
||||
double fdim(double x, double y); ///
|
||||
float fdimf(float x, float y); /// ditto
|
||||
real fdiml(real x, real y); /// ditto
|
||||
|
||||
double fmax(double x, double y); ///
|
||||
float fmaxf(float x, float y); /// ditto
|
||||
real fmaxl(real x, real y); /// ditto
|
||||
|
||||
double fmin(double x, double y); ///
|
||||
float fminf(float x, float y); /// ditto
|
||||
real fminl(real x, real y); /// ditto
|
||||
|
||||
double fma(double x, double y, double z); ///
|
||||
float fmaf(float x, float y, float z); /// ditto
|
||||
real fmal(real x, real y, real z); /// ditto
|
||||
|
||||
///
|
||||
int isgreater(real x, real y) { return !(x !> y); }
|
||||
///
|
||||
int isgreaterequal(real x, real y) { return !(x !>= y); }
|
||||
///
|
||||
int isless(real x, real y) { return !(x !< y); }
|
||||
///
|
||||
int islessequal(real x, real y) { return !(x !<= y); }
|
||||
///
|
||||
int islessgreater(real x, real y) { return !(x !<> y); }
|
||||
///
|
||||
int isunordered(real x, real y) { return (x !<>= y); }
|
||||
|
||||
86
lphobos/std/c/process.d
Normal file
86
lphobos/std/c/process.d
Normal file
@@ -0,0 +1,86 @@
|
||||
|
||||
/**
|
||||
* C's <process.h>
|
||||
* Authors: Walter Bright, Digital Mars, www.digitalmars.com
|
||||
* License: Public Domain
|
||||
* Macros:
|
||||
* WIKI=Phobos/StdCProcess
|
||||
*/
|
||||
|
||||
module std.c.process;
|
||||
|
||||
private import std.c.stddef;
|
||||
|
||||
extern (C):
|
||||
|
||||
void exit(int);
|
||||
void _c_exit();
|
||||
void _cexit();
|
||||
void _exit(int);
|
||||
void abort();
|
||||
void _dodtors();
|
||||
int getpid();
|
||||
|
||||
int system(char *);
|
||||
|
||||
enum { _P_WAIT, _P_NOWAIT, _P_OVERLAY };
|
||||
|
||||
int execl(char *, char *,...);
|
||||
int execle(char *, char *,...);
|
||||
int execlp(char *, char *,...);
|
||||
int execlpe(char *, char *,...);
|
||||
int execv(char *, char **);
|
||||
int execve(char *, char **, char **);
|
||||
int execvp(char *, char **);
|
||||
int execvpe(char *, char **, char **);
|
||||
|
||||
|
||||
enum { WAIT_CHILD, WAIT_GRANDCHILD }
|
||||
|
||||
int cwait(int *,int,int);
|
||||
int wait(int *);
|
||||
|
||||
version (Windows)
|
||||
{
|
||||
uint _beginthread(void function(void *),uint,void *);
|
||||
|
||||
extern (Windows) alias uint (*stdfp)(void *);
|
||||
|
||||
uint _beginthreadex(void* security, uint stack_size,
|
||||
stdfp start_addr, void* arglist, uint initflag,
|
||||
uint* thrdaddr);
|
||||
|
||||
void _endthread();
|
||||
void _endthreadex(uint);
|
||||
|
||||
int spawnl(int, char *, char *,...);
|
||||
int spawnle(int, char *, char *,...);
|
||||
int spawnlp(int, char *, char *,...);
|
||||
int spawnlpe(int, char *, char *,...);
|
||||
int spawnv(int, char *, char **);
|
||||
int spawnve(int, char *, char **, char **);
|
||||
int spawnvp(int, char *, char **);
|
||||
int spawnvpe(int, char *, char **, char **);
|
||||
|
||||
|
||||
int _wsystem(wchar_t *);
|
||||
int _wspawnl(int, wchar_t *, wchar_t *, ...);
|
||||
int _wspawnle(int, wchar_t *, wchar_t *, ...);
|
||||
int _wspawnlp(int, wchar_t *, wchar_t *, ...);
|
||||
int _wspawnlpe(int, wchar_t *, wchar_t *, ...);
|
||||
int _wspawnv(int, wchar_t *, wchar_t **);
|
||||
int _wspawnve(int, wchar_t *, wchar_t **, wchar_t **);
|
||||
int _wspawnvp(int, wchar_t *, wchar_t **);
|
||||
int _wspawnvpe(int, wchar_t *, wchar_t **, wchar_t **);
|
||||
|
||||
int _wexecl(wchar_t *, wchar_t *, ...);
|
||||
int _wexecle(wchar_t *, wchar_t *, ...);
|
||||
int _wexeclp(wchar_t *, wchar_t *, ...);
|
||||
int _wexeclpe(wchar_t *, wchar_t *, ...);
|
||||
int _wexecv(wchar_t *, wchar_t **);
|
||||
int _wexecve(wchar_t *, wchar_t **, wchar_t **);
|
||||
int _wexecvp(wchar_t *, wchar_t **);
|
||||
int _wexecvpe(wchar_t *, wchar_t **, wchar_t **);
|
||||
}
|
||||
|
||||
|
||||
42
lphobos/std/c/stdarg.d
Normal file
42
lphobos/std/c/stdarg.d
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
/**
|
||||
* C's <stdarg.h>
|
||||
* Authors: Hauke Duden and Walter Bright, Digital Mars, www.digitalmars.com
|
||||
* License: Public Domain
|
||||
* Macros:
|
||||
* WIKI=Phobos/StdCStdarg
|
||||
*/
|
||||
|
||||
/* This is for use with extern(C) variable argument lists. */
|
||||
|
||||
module std.c.stdarg;
|
||||
|
||||
alias void* va_list;
|
||||
|
||||
template va_start(T)
|
||||
{
|
||||
void va_start(out va_list ap, inout T parmn)
|
||||
{
|
||||
ap = cast(va_list)(cast(void*)&parmn + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1)));
|
||||
}
|
||||
}
|
||||
|
||||
template va_arg(T)
|
||||
{
|
||||
T va_arg(inout va_list ap)
|
||||
{
|
||||
T arg = *cast(T*)ap;
|
||||
ap = cast(va_list)(cast(void*)ap + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1)));
|
||||
return arg;
|
||||
}
|
||||
}
|
||||
|
||||
void va_end(va_list ap)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void va_copy(out va_list dest, va_list src)
|
||||
{
|
||||
dest = src;
|
||||
}
|
||||
23
lphobos/std/c/stddef.d
Normal file
23
lphobos/std/c/stddef.d
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
/**
|
||||
* C's <stddef.h>
|
||||
* Authors: Walter Bright, Digital Mars, www.digitalmars.com
|
||||
* License: Public Domain
|
||||
* Macros:
|
||||
* WIKI=Phobos/StdCStddef
|
||||
*/
|
||||
|
||||
module std.c.stddef;
|
||||
|
||||
version (Win32)
|
||||
{
|
||||
alias wchar wchar_t;
|
||||
}
|
||||
else version (linux)
|
||||
{
|
||||
alias dchar wchar_t;
|
||||
}
|
||||
else
|
||||
{
|
||||
static assert(0);
|
||||
}
|
||||
300
lphobos/std/c/stdio.d
Normal file
300
lphobos/std/c/stdio.d
Normal file
@@ -0,0 +1,300 @@
|
||||
|
||||
/**
|
||||
* C's <stdio.h>
|
||||
* Authors: Walter Bright, Digital Mars, www.digitalmars.com
|
||||
* License: Public Domain
|
||||
* Macros:
|
||||
* WIKI=Phobos/StdCStdio
|
||||
*/
|
||||
|
||||
|
||||
|
||||
module std.c.stdio;
|
||||
|
||||
import std.c.stddef;
|
||||
private import std.c.stdarg;
|
||||
|
||||
extern (C):
|
||||
|
||||
version (Win32)
|
||||
{
|
||||
const int _NFILE = 60; ///
|
||||
const int BUFSIZ = 0x4000; ///
|
||||
const int EOF = -1; ///
|
||||
const int FOPEN_MAX = 20; ///
|
||||
const int FILENAME_MAX = 256; /// 255 plus NULL
|
||||
const int TMP_MAX = 32767; ///
|
||||
const int _SYS_OPEN = 20; ///
|
||||
const int SYS_OPEN = _SYS_OPEN; ///
|
||||
const wchar WEOF = 0xFFFF; ///
|
||||
}
|
||||
|
||||
version (linux)
|
||||
{
|
||||
const int EOF = -1;
|
||||
const int FOPEN_MAX = 16;
|
||||
const int FILENAME_MAX = 4095;
|
||||
const int TMP_MAX = 238328;
|
||||
const int L_tmpnam = 20;
|
||||
}
|
||||
|
||||
enum { SEEK_SET, SEEK_CUR, SEEK_END }
|
||||
|
||||
struct _iobuf
|
||||
{
|
||||
align (1):
|
||||
version (Win32)
|
||||
{
|
||||
char *_ptr;
|
||||
int _cnt;
|
||||
char *_base;
|
||||
int _flag;
|
||||
int _file;
|
||||
int _charbuf;
|
||||
int _bufsiz;
|
||||
int __tmpnum;
|
||||
}
|
||||
version (linux)
|
||||
{
|
||||
char* _read_ptr;
|
||||
char* _read_end;
|
||||
char* _read_base;
|
||||
char* _write_base;
|
||||
char* _write_ptr;
|
||||
char* _write_end;
|
||||
char* _buf_base;
|
||||
char* _buf_end;
|
||||
char* _save_base;
|
||||
char* _backup_base;
|
||||
char* _save_end;
|
||||
void* _markers;
|
||||
_iobuf* _chain;
|
||||
int _fileno;
|
||||
int _blksize;
|
||||
int _old_offset;
|
||||
ushort _cur_column;
|
||||
byte _vtable_offset;
|
||||
char[1] _shortbuf;
|
||||
void* _lock;
|
||||
}
|
||||
}
|
||||
|
||||
alias _iobuf FILE; ///
|
||||
|
||||
enum
|
||||
{
|
||||
_F_RDWR = 0x0003,
|
||||
_F_READ = 0x0001,
|
||||
_F_WRIT = 0x0002,
|
||||
_F_BUF = 0x0004,
|
||||
_F_LBUF = 0x0008,
|
||||
_F_ERR = 0x0010,
|
||||
_F_EOF = 0x0020,
|
||||
_F_BIN = 0x0040,
|
||||
_F_IN = 0x0080,
|
||||
_F_OUT = 0x0100,
|
||||
_F_TERM = 0x0200,
|
||||
}
|
||||
|
||||
version (Win32)
|
||||
{
|
||||
extern FILE _iob[_NFILE];
|
||||
extern void function() _fcloseallp;
|
||||
extern ubyte __fhnd_info[_NFILE];
|
||||
|
||||
enum
|
||||
{
|
||||
FHND_APPEND = 0x04,
|
||||
FHND_DEVICE = 0x08,
|
||||
FHND_TEXT = 0x10,
|
||||
FHND_BYTE = 0x20,
|
||||
FHND_WCHAR = 0x40,
|
||||
}
|
||||
}
|
||||
|
||||
version (Win32)
|
||||
{
|
||||
enum
|
||||
{
|
||||
_IOREAD = 1,
|
||||
_IOWRT = 2,
|
||||
_IONBF = 4,
|
||||
_IOMYBUF = 8,
|
||||
_IOEOF = 0x10,
|
||||
_IOERR = 0x20,
|
||||
_IOLBF = 0x40,
|
||||
_IOSTRG = 0x40,
|
||||
_IORW = 0x80,
|
||||
_IOFBF = 0,
|
||||
_IOAPP = 0x200,
|
||||
_IOTRAN = 0x100,
|
||||
}
|
||||
}
|
||||
|
||||
version (linux)
|
||||
{
|
||||
enum
|
||||
{
|
||||
_IOFBF = 0,
|
||||
_IOLBF = 1,
|
||||
_IONBF = 2,
|
||||
}
|
||||
}
|
||||
|
||||
version (Win32)
|
||||
{
|
||||
const FILE *stdin = &_iob[0]; ///
|
||||
const FILE *stdout = &_iob[1]; ///
|
||||
const FILE *stderr = &_iob[2]; ///
|
||||
const FILE *stdaux = &_iob[3]; ///
|
||||
const FILE *stdprn = &_iob[4]; ///
|
||||
}
|
||||
|
||||
version (linux)
|
||||
{
|
||||
extern FILE *stdin;
|
||||
extern FILE *stdout;
|
||||
extern FILE *stderr;
|
||||
}
|
||||
|
||||
version (Win32)
|
||||
{
|
||||
const char[] _P_tmpdir = "\\";
|
||||
const wchar[] _wP_tmpdir = "\\";
|
||||
const int L_tmpnam = _P_tmpdir.length + 12;
|
||||
}
|
||||
|
||||
alias int fpos_t; ///
|
||||
|
||||
char * tmpnam(char *); ///
|
||||
FILE * fopen(char *,char *); ///
|
||||
FILE * _fsopen(char *,char *,int ); ///
|
||||
FILE * freopen(char *,char *,FILE *); ///
|
||||
int fseek(FILE *,int,int); ///
|
||||
int ftell(FILE *); ///
|
||||
char * fgets(char *,int,FILE *); ///
|
||||
int fgetc(FILE *); ///
|
||||
int _fgetchar(); ///
|
||||
int fflush(FILE *); ///
|
||||
int fclose(FILE *); ///
|
||||
int fputs(char *,FILE *); ///
|
||||
char * gets(char *); ///
|
||||
int fputc(int,FILE *); ///
|
||||
int _fputchar(int); ///
|
||||
int puts(char *); ///
|
||||
int ungetc(int,FILE *); ///
|
||||
size_t fread(void *,size_t,size_t,FILE *); ///
|
||||
size_t fwrite(void *,size_t,size_t,FILE *); ///
|
||||
//int printf(char *,...); ///
|
||||
int fprintf(FILE *,char *,...); ///
|
||||
int vfprintf(FILE *,char *,va_list); ///
|
||||
int vprintf(char *,va_list); ///
|
||||
int sprintf(char *,char *,...); ///
|
||||
int vsprintf(char *,char *,va_list); ///
|
||||
int scanf(char *,...); ///
|
||||
int fscanf(FILE *,char *,...); ///
|
||||
int sscanf(char *,char *,...); ///
|
||||
void setbuf(FILE *,char *); ///
|
||||
int setvbuf(FILE *,char *,int,size_t); ///
|
||||
int remove(char *); ///
|
||||
int rename(char *,char *); ///
|
||||
void perror(char *); ///
|
||||
int fgetpos(FILE *,fpos_t *); ///
|
||||
int fsetpos(FILE *,fpos_t *); ///
|
||||
FILE * tmpfile(); ///
|
||||
int _rmtmp();
|
||||
int _fillbuf(FILE *);
|
||||
int _flushbu(int, FILE *);
|
||||
|
||||
int getw(FILE *FHdl); ///
|
||||
int putw(int Word, FILE *FilePtr); ///
|
||||
|
||||
///
|
||||
int getchar() { return getc(stdin); }
|
||||
///
|
||||
int putchar(int c) { return putc(c,stdout); }
|
||||
///
|
||||
int getc(FILE *fp) { return fgetc(fp); }
|
||||
///
|
||||
int putc(int c,FILE *fp) { return fputc(c,fp); }
|
||||
|
||||
version (Win32)
|
||||
{
|
||||
///
|
||||
int ferror(FILE *fp) { return fp._flag&_IOERR; }
|
||||
///
|
||||
int feof(FILE *fp) { return fp._flag&_IOEOF; }
|
||||
///
|
||||
void clearerr(FILE *fp) { fp._flag &= ~(_IOERR|_IOEOF); }
|
||||
///
|
||||
void rewind(FILE *fp) { fseek(fp,0L,SEEK_SET); fp._flag&=~_IOERR; }
|
||||
int _bufsize(FILE *fp) { return fp._bufsiz; }
|
||||
///
|
||||
int fileno(FILE *fp) { return fp._file; }
|
||||
int _snprintf(char *,size_t,char *,...);
|
||||
int _vsnprintf(char *,size_t,char *,va_list);
|
||||
}
|
||||
|
||||
version (linux)
|
||||
{
|
||||
int ferror(FILE *fp);
|
||||
int feof(FILE *fp);
|
||||
void clearerr(FILE *fp);
|
||||
void rewind(FILE *fp);
|
||||
int _bufsize(FILE *fp);
|
||||
int fileno(FILE *fp);
|
||||
int snprintf(char *,size_t,char *,...);
|
||||
int vsnprintf(char *,size_t,char *,va_list);
|
||||
}
|
||||
|
||||
int unlink(char *); ///
|
||||
FILE * fdopen(int, char *); ///
|
||||
int fgetchar(); ///
|
||||
int fputchar(int); ///
|
||||
int fcloseall(); ///
|
||||
int filesize(char *); ///
|
||||
int flushall(); ///
|
||||
int getch(); ///
|
||||
int getche(); ///
|
||||
int kbhit(); ///
|
||||
char * tempnam (char *dir, char *pfx); ///
|
||||
|
||||
wchar_t * _wtmpnam(wchar_t *); ///
|
||||
FILE * _wfopen(wchar_t *, wchar_t *);
|
||||
FILE * _wfsopen(wchar_t *, wchar_t *, int);
|
||||
FILE * _wfreopen(wchar_t *, wchar_t *, FILE *);
|
||||
wchar_t * fgetws(wchar_t *, int, FILE *); ///
|
||||
int fputws(wchar_t *, FILE *); ///
|
||||
wchar_t * _getws(wchar_t *);
|
||||
int _putws(wchar_t *);
|
||||
int wprintf(wchar_t *, ...); ///
|
||||
int fwprintf(FILE *, wchar_t *, ...); ///
|
||||
int vwprintf(wchar_t *, va_list); ///
|
||||
int vfwprintf(FILE *, wchar_t *, va_list); ///
|
||||
int swprintf(wchar_t *, wchar_t *, ...); ///
|
||||
int vswprintf(wchar_t *, wchar_t *, va_list); ///
|
||||
int _snwprintf(wchar_t *, size_t, wchar_t *, ...);
|
||||
int _vsnwprintf(wchar_t *, size_t, wchar_t *, va_list);
|
||||
int wscanf(wchar_t *, ...); ///
|
||||
int fwscanf(FILE *, wchar_t *, ...); ///
|
||||
int swscanf(wchar_t *, wchar_t *, ...); ///
|
||||
int _wremove(wchar_t *);
|
||||
void _wperror(wchar_t *);
|
||||
FILE * _wfdopen(int, wchar_t *);
|
||||
wchar_t * _wtempnam(wchar_t *, wchar_t *);
|
||||
wchar_t fgetwc(FILE *); ///
|
||||
wchar_t _fgetwchar_t();
|
||||
wchar_t fputwc(wchar_t, FILE *); ///
|
||||
wchar_t _fputwchar_t(wchar_t);
|
||||
wchar_t ungetwc(wchar_t, FILE *); ///
|
||||
|
||||
///
|
||||
wchar_t getwchar_t() { return fgetwc(stdin); }
|
||||
///
|
||||
wchar_t putwchar_t(wchar_t c) { return fputwc(c,stdout); }
|
||||
///
|
||||
wchar_t getwc(FILE *fp) { return fgetwc(fp); }
|
||||
///
|
||||
wchar_t putwc(wchar_t c, FILE *fp) { return fputwc(c, fp); }
|
||||
|
||||
int fwide(FILE* fp, int mode); ///
|
||||
90
lphobos/std/c/stdlib.d
Normal file
90
lphobos/std/c/stdlib.d
Normal file
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* C's <stdlib.h>
|
||||
* Authors: Walter Bright, Digital Mars, www.digitalmars.com
|
||||
* License: Public Domain
|
||||
* Macros:
|
||||
* WIKI=Phobos/StdCStdlib
|
||||
*/
|
||||
|
||||
|
||||
module std.c.stdlib;
|
||||
|
||||
private import std.c.stddef;
|
||||
|
||||
extern (C):
|
||||
|
||||
enum
|
||||
{
|
||||
_MAX_PATH = 260,
|
||||
_MAX_DRIVE = 3,
|
||||
_MAX_DIR = 256,
|
||||
_MAX_FNAME = 256,
|
||||
_MAX_EXT = 256,
|
||||
}
|
||||
|
||||
///
|
||||
struct div_t { int quot,rem; }
|
||||
///
|
||||
struct ldiv_t { int quot,rem; }
|
||||
///
|
||||
struct lldiv_t { long quot,rem; }
|
||||
|
||||
div_t div(int,int); ///
|
||||
ldiv_t ldiv(int,int); /// ditto
|
||||
lldiv_t lldiv(long, long); /// ditto
|
||||
|
||||
const int EXIT_SUCCESS = 0; ///
|
||||
const int EXIT_FAILURE = 1; /// ditto
|
||||
|
||||
int atexit(void (*)()); ///
|
||||
void exit(int); /// ditto
|
||||
void _exit(int); /// ditto
|
||||
|
||||
int system(char *);
|
||||
|
||||
void *alloca(uint); ///
|
||||
|
||||
void *calloc(size_t, size_t); ///
|
||||
void *malloc(size_t); /// ditto
|
||||
void *realloc(void *, size_t); /// ditto
|
||||
void free(void *); /// ditto
|
||||
|
||||
void *bsearch(void *,void *,size_t,size_t,
|
||||
int function(void *,void *)); ///
|
||||
void qsort(void *base, size_t nelems, size_t elemsize,
|
||||
int (*compare)(void *elem1, void *elem2)); /// ditto
|
||||
|
||||
char* getenv(char*); ///
|
||||
int setenv(char*, char*, int); /// extension to ISO C standard, not available on all platforms
|
||||
void unsetenv(char*); /// extension to ISO C standard, not available on all platforms
|
||||
|
||||
int rand(); ///
|
||||
void srand(uint); /// ditto
|
||||
int random(int num); /// ditto
|
||||
void randomize(); /// ditto
|
||||
|
||||
int getErrno(); /// ditto
|
||||
int setErrno(int); /// ditto
|
||||
|
||||
const int ERANGE = 34; // on both Windows and linux
|
||||
|
||||
double atof(char *); ///
|
||||
int atoi(char *); /// ditto
|
||||
int atol(char *); /// ditto
|
||||
float strtof(char *,char **); /// ditto
|
||||
double strtod(char *,char **); /// ditto
|
||||
real strtold(char *,char **); /// ditto
|
||||
long strtol(char *,char **,int); /// ditto
|
||||
uint strtoul(char *,char **,int); /// ditto
|
||||
long atoll(char *); /// ditto
|
||||
long strtoll(char *,char **,int); /// ditto
|
||||
ulong strtoull(char *,char **,int); /// ditto
|
||||
|
||||
char* itoa(int, char*, int); ///
|
||||
char* ultoa(uint, char*, int); /// ditto
|
||||
|
||||
int mblen(char *s, size_t n); ///
|
||||
int mbtowc(wchar_t *pwc, char *s, size_t n); /// ditto
|
||||
int wctomb(char *s, wchar_t wc); /// ditto
|
||||
size_t mbstowcs(wchar_t *pwcs, char *s, size_t n); /// ditto
|
||||
size_t wcstombs(char *s, wchar_t *pwcs, size_t n); /// ditto
|
||||
40
lphobos/std/c/string.d
Normal file
40
lphobos/std/c/string.d
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
/**
|
||||
* C's <string.h>
|
||||
* Authors: Walter Bright, Digital Mars, www.digitalmars.com
|
||||
* License: Public Domain
|
||||
* Macros:
|
||||
* WIKI=Phobos/StdCString
|
||||
*/
|
||||
|
||||
module std.c.string;
|
||||
|
||||
extern (C):
|
||||
|
||||
void* memcpy(void* s1, void* s2, size_t n); ///
|
||||
void* memmove(void* s1, void* s2, size_t n); ///
|
||||
char* strcpy(char* s1, char* s2); ///
|
||||
char* strncpy(char* s1, char* s2, size_t n); ///
|
||||
char* strncat(char* s1, char* s2, size_t n); ///
|
||||
int strcoll(char* s1, char* s2); ///
|
||||
int strncmp(char* s1, char* s2, size_t n); ///
|
||||
size_t strxfrm(char* s1, char* s2, size_t n); ///
|
||||
void* memchr(void* s, int c, size_t n); ///
|
||||
char* strchr(char* s, int c); ///
|
||||
size_t strcspn(char* s1, char* s2); ///
|
||||
char* strpbrk(char* s1, char* s2); ///
|
||||
char* strrchr(char* s, int c); ///
|
||||
size_t strspn(char* s1, char* s2); ///
|
||||
char* strstr(char* s1, char* s2); ///
|
||||
char* strtok(char* s1, char* s2); ///
|
||||
void* memset(void* s, int c, size_t n); ///
|
||||
char* strerror(int errnum); ///
|
||||
size_t strlen(char* s); ///
|
||||
int strcmp(char* s1, char* s2); ///
|
||||
char* strcat(char* s1, char* s2); ///
|
||||
int memcmp(void* s1, void* s2, size_t n); ///
|
||||
|
||||
version (Windows)
|
||||
{
|
||||
int memicmp(char* s1, char* s2, size_t n); ///
|
||||
}
|
||||
94
lphobos/std/c/time.d
Normal file
94
lphobos/std/c/time.d
Normal file
@@ -0,0 +1,94 @@
|
||||
|
||||
/**
|
||||
* C's <time.h>
|
||||
* Authors: Walter Bright, Digital Mars, www.digitalmars.com
|
||||
* License: Public Domain
|
||||
* Macros:
|
||||
* WIKI=Phobos/StdCTime
|
||||
*/
|
||||
|
||||
module std.c.time;
|
||||
|
||||
private import std.c.stddef;
|
||||
|
||||
extern (C):
|
||||
|
||||
alias int clock_t;
|
||||
|
||||
version (Windows)
|
||||
{ const clock_t CLOCKS_PER_SEC = 1000;
|
||||
}
|
||||
else version (linux)
|
||||
{ const clock_t CLOCKS_PER_SEC = 1000000;
|
||||
}
|
||||
else version (darwin)
|
||||
{
|
||||
const clock_t CLOCKS_PER_SEC = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
static assert(0);
|
||||
}
|
||||
|
||||
version (Windows)
|
||||
{
|
||||
const clock_t CLK_TCK = 1000;
|
||||
}
|
||||
else version (linux)
|
||||
{
|
||||
extern (C) int sysconf(int);
|
||||
extern clock_t CLK_TCK;
|
||||
/*static this()
|
||||
{
|
||||
CLK_TCK = cast(clock_t) sysconf(2);
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
static assert(0);
|
||||
}
|
||||
|
||||
const uint TIMEOFFSET = 315558000;
|
||||
|
||||
alias int time_t;
|
||||
|
||||
extern int daylight;
|
||||
extern int timezone;
|
||||
extern int altzone;
|
||||
extern char *tzname[2];
|
||||
|
||||
struct tm
|
||||
{ int tm_sec,
|
||||
tm_min,
|
||||
tm_hour,
|
||||
tm_mday,
|
||||
tm_mon,
|
||||
tm_year,
|
||||
tm_wday,
|
||||
tm_yday,
|
||||
tm_isdst;
|
||||
}
|
||||
|
||||
clock_t clock();
|
||||
time_t time(time_t *);
|
||||
time_t mktime(tm *);
|
||||
char *asctime(tm *);
|
||||
char *ctime(time_t *);
|
||||
tm *localtime(time_t *);
|
||||
tm *gmtime(time_t *);
|
||||
size_t strftime(char *, size_t, char *, tm *);
|
||||
char *_strdate(char *dstring);
|
||||
char *_strtime(char *timestr);
|
||||
double difftime(time_t t1, time_t t2);
|
||||
void _tzset();
|
||||
void tzset();
|
||||
|
||||
void sleep(time_t);
|
||||
void usleep(uint);
|
||||
void msleep(uint);
|
||||
|
||||
wchar_t *_wasctime(tm *);
|
||||
wchar_t *_wctime(time_t *);
|
||||
size_t wcsftime(wchar_t *, size_t, wchar_t *, tm *);
|
||||
wchar_t *_wstrdate(wchar_t *);
|
||||
wchar_t *_wstrtime(wchar_t *);
|
||||
Reference in New Issue
Block a user