Change some header file from djgpp to mingw32

svn path=/trunk/; revision=259
This commit is contained in:
Boudewijn Dekker 1999-02-21 13:29:57 +00:00
parent 37f381130a
commit 77ed4e360b
12 changed files with 1556 additions and 1576 deletions

View file

@ -1,164 +1,113 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef __dj_include_fcntl_h_
#define __dj_include_fcntl_h_
/*
* fcntl.h
*
* Access constants for _open. Note that the permissions constants are
* in sys/stat.h (ick).
*
* This code is part of the Mingw32 package.
*
* Contributors:
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.2 $
* $Author: ariadne $
* $Date: 1999/02/21 13:29:56 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
/* added _O_RANDOM_O_SEQUENTIAL _O_SHORT_LIVED*/
#ifndef _FCNTL_H_
#define _FCNTL_H_
#ifdef __cplusplus
/*
* It appears that fcntl.h should include io.h for compatibility...
*/
#include <io.h>
/*
* This variable determines the default file mode.
* TODO: Which flags work?
*/
#if __MSVCRT__
extern unsigned int* __imp__fmode;
#define _fmode (*__imp__fmode)
#else
/* CRTDLL */
extern unsigned int* __imp__fmode_dll;
#define _fmode (*__imp__fmode_dll)
#endif
/* Specifiy one of these flags to define the access mode. */
#define _O_RDONLY 0
#define _O_WRONLY 1
#define _O_RDWR 2
/* Mask for access mode bits in the _open flags. */
#define _O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
#define _O_APPEND 0x0008 /* Writes will add to the end of the file. */
#define _O_CREAT 0x0100 /* Create the file if it does not exist. */
#define _O_TRUNC 0x0200 /* Truncate the file if it does exist. */
#define _O_EXCL 0x0400 /* Open only if the file does not exist. */
/* NOTE: Text is the default even if the given _O_TEXT bit is not on. */
#define _O_TEXT 0x4000 /* CR-LF in file becomes LF in memory. */
#define _O_BINARY 0x8000 /* Input and output is not translated. */
#define _O_RAW _O_BINARY
#define _O_TEMPORARY 0x0040 /* Make the file dissappear after closing.
* WARNING: Even if not created by _open! */
#define _O_RANDOM 0x0010
#define _O_SEQUENTIAL _O_RANDOM
#define _O_SHORT_LIVED 0x1000
#ifndef __STRICT_ANSI__
#ifndef _NO_OLDNAMES
/* POSIX/Non-ANSI names for increased portability */
#define O_RDONLY _O_RDONLY
#define O_WRONLY _O_WRONLY
#define O_RDWR _O_RDWR
#define O_ACCMODE _O_ACCMODE
#define O_APPEND _O_APPEND
#define O_CREAT _O_CREAT
#define O_TRUNC _O_TRUNC
#define O_EXCL _O_EXCL
#define O_TEXT _O_TEXT
#define O_BINARY _O_BINARY
#define O_TEMPORARY _O_TEMPORARY
#define O_RANDOM _O_RANDOM
#define O_SEQUENTIAL _O_RANDOM
#define O_SHORT_LIVED _O_SHORT_LIVED
#endif /* Not _NO_OLDNAMES */
#ifdef __cplusplus
extern "C" {
#endif
#define _IOREAD 000010
#define _IOWRT 000020
#define _IOMYBUF 000040
#define _IOEOF 000100
#define _IOERR 000200
#define _IOSTRG 000400
#define _IORW 001000
#define _IOAPPEND 002000
#define _IORMONCL 004000 /* remove on close, for temp files */
/* if _flag & _IORMONCL, ._name_to_remove needs freeing */
#define _IOUNGETC 010000 /* there is an ungetc'ed character in the buffer */
int _setmode (int nHandle, int nAccessMode);
#ifndef _NO_OLDNAMES
int setmode (int nHandle, int nAccessMode);
#endif /* Not _NO_OLDNAMES */
#ifndef __dj_ENFORCE_ANSI_FREESTANDING
#ifndef __STRICT_ANSI__
#define FD_CLOEXEC 0x0001
#define F_DUPFD 1
#define F_GETFD 2
#define F_GETFL 3
#define F_GETLK 4
#define F_SETFD 5
#define F_SETFL 6
#define F_SETLK 7
#define F_SETLKW 8
#define F_UNLCK 0
#define F_RDLCK 1
#define F_WRLCK 2
#define O_RDONLY 0x0000
#define O_WRONLY 0x0001
#define O_RDWR 0x0002
#define O_ACCMODE 0x0003
#define O_BINARY 0x0004 /* must fit in char, reserved by dos */
#define O_TEXT 0x0008 /* must fit in char, reserved by dos */
#define O_RANDOM 0x0010
#define O_SEQUENTIAL 0x0020
#define O_TEMPORARY 0x0040
/* temporary access hint */
/* sequential/random access hints */
#define O_NOINHERIT 0x0080 /* DOS-specific */
#define O_CREAT 0x0100 /* second byte, away from DOS bits */
#define O_EXCL 0x0200
#define O_NOCTTY 0x0400
#define O_TRUNC 0x0800
#define O_APPEND 0x1000
#define O_NONBLOCK 0x2000
#define O_SHORT_LIVED 0x1000
//#include <sys/types.h>
#include <sys/stat.h>
//typedef int dev_t;
//typedef int ino_t;
//typedef int mode_t;
//typedef int nlink_t;
#include <io.h>
struct flock {
off_t l_len;
pid_t l_pid;
off_t l_start;
short l_type;
short l_whence;
};
extern int _fmode; /* O_TEXT or O_BINARY */
//int open(const char *_path, int _oflag, ...);
//int creat(const char *_path, int _mode);
int fcntl(int _fildes, int _cmd, ...);
#ifndef _POSIX_SOURCE
#define S_IREAD S_IRUSR
#define S_IWRITE S_IWUSR
#define S_IEXEC S_IXUSR
/*
* For compatibility with other DOS C compilers.
*/
#define _O_RDONLY O_RDONLY
#define _O_WRONLY O_WRONLY
#define _O_RDWR O_RDWR
#define _O_APPEND O_APPEND
#define _O_CREAT O_CREAT
#define _O_TRUNC O_TRUNC
#define _O_EXCL O_EXCL
#define _O_TEXT O_TEXT
#define _O_BINARY O_BINARY
#define _O_NOINHERIT O_NOINHERIT
#define _O_RANDOM O_RANDOM
#define _O_SEQUENTIAL O_RANDOM
#define _O_SHORT_LIVED O_SHORT_LIVED
#define _O_TEMPORARY O_TEMPORARY
#define _S_IREAD S_IRUSR
#define _S_IWRITE S_IWUSR
#define _S_IEXEC S_IXUSR
/*
* Support for advanced filesystems (Windows 9x VFAT, NTFS, LFN etc.)
*/
#define _FILESYS_UNKNOWN 0x80000000U
#define _FILESYS_CASE_SENSITIVE 0x0001
#define _FILESYS_CASE_PRESERVED 0x0002
#define _FILESYS_UNICODE 0x0004
#define _FILESYS_LFN_SUPPORTED 0x4000
#define _FILESYS_VOL_COMPRESSED 0x8000
unsigned _get_volume_info (const char *_path, int *_max_file_len, int *_max_path_len, char *_filesystype);
char _use_lfn (const char *_path);
char *_lfn_gen_short_fname (const char *_long_fname, char *_short_fname);
#define _LFN_CTIME 1
#define _LFN_ATIME 2
unsigned _lfn_get_ftime (int _handle, int _which);
char _preserve_fncase (void);
#define _USE_LFN _use_lfn(0) /* assume it's the same on ALL drives */
#endif /* !_POSIX_SOURCE */
#endif /* !__STRICT_ANSI__ */
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
#ifndef __dj_ENFORCE_FUNCTION_CALLS
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */
#ifdef __cplusplus
#ifdef __cplusplus
}
#endif
#endif /* !__dj_include_fcntl_h_ */
#endif /* Not __STRICT_ANSI__ */
#endif /* Not _FCNTL_H_ */

View file

@ -1,123 +1,138 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef __dj_include_io_h_
#define __dj_include_io_h_
/*
* io.h
*
* System level I/O functions and types.
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.3 $
* $Author: ariadne $
* $Date: 1999/02/21 13:29:56 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
/* added D_OK */
/* changed get_osfhandle and open_osfhandle */
#ifndef _IO_H_
#define _IO_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __dj_ENFORCE_ANSI_FREESTANDING
#ifndef __STRICT_ANSI__
#ifndef _POSIX_SOURCE
#ifndef __STRICT_ANSI__
#include <sys/types.h>
#include <internal/types.h>
#include <sys/stat.h>
/*
* For compatibility with other DOS C compilers.
*/
/* We need the definition of FILE anyway... */
#include <stdio.h>
#define _A_NORMAL 0x00 /* Normal file - No read/write restrictions */
#define _A_RDONLY 0x01 /* Read only file */
#define _A_HIDDEN 0x02 /* Hidden file */
#define _A_SYSTEM 0x04 /* System file */
#define _A_VOLID 0x08 /* Volume ID file */
#define _A_SUBDIR 0x10 /* Subdirectory */
#define _A_ARCH 0x20 /* Archive file */
/* MSVC's io.h contains the stuff from dir.h, so I will too.
* NOTE: This also defines off_t, the file offset type, through
* and inclusion of sys/types.h */
#include <dir.h>
/* TODO: Maximum number of open handles has not been tested, I just set
* it the same as FOPEN_MAX. */
#define HANDLE_MAX FOPEN_MAX
#define F_OK 0x01
#define R_OK 0x02
#define W_OK 0x04
#define X_OK 0x08
/* Some defines for _access nAccessMode (MS doesn't define them, but
* it doesn't seem to hurt to add them). */
#define F_OK 0 /* Check for file existence */
#define W_OK 2 /* Check for write permission */
#define R_OK 4 /* Check for read permission */
/* TODO: Is this safe? X_OK not supported directly... */
#define X_OK R_OK /* Check for execute permission */
#define D_OK 0x10
struct _finddata_t {
char reserved[21] __attribute__((packed));
unsigned char attrib __attribute__((packed));
unsigned short time_create __attribute__((packed));
unsigned short time_access __attribute__((packed));
unsigned short time_write __attribute__((packed));
unsigned long size __attribute__((packed));
char name[256] __attribute__((packed));
};
int _access( const char *_path, int _amode );
int _chmod(const char *filename, int func);
int _chsize(int _fd, long size);
int _close(int _fd);
int _creat(const char *_path, int _attrib);
unsigned int _commit(int _fd);
int _dup(int _fd);
int _dup2( int _fd1, int _fd2 );
int _eof( int _fd );
long _filelength(int _fd);
long _findfirst(char *_name, struct _finddata_t *_result);
int _findnext(long handle, struct _finddata_t *_result);
int _findclose(long handle);
void * _get_osfhandle(int fileno);
int _locking( int _fd, int mode, long nbytes );
#ifdef __cplusplus
extern "C" {
#endif
int _access (const char* szFileName, int nAccessMode);
int _chsize (int nHandle, long lnNewSize);
int _close (int nHandle);
int _creat (const char* szFileName, int nAccessMode);
int _dup (int nHandle);
int _dup2 (int nOldHandle, int nNewHandle);
long _filelength (int nHandle);
int _fileno (FILE* fileGetHandle);
void* _get_osfhandle (int nHandle);
int _isatty (int nHandle);
/* In a very odd turn of events this function is excluded from those
* files which define _STREAM_COMPAT. This is required in order to
* build GNU libio because of a conflict with _eof in streambuf.h
* line 107. Actually I might just be able to change the name of
* the enum member in streambuf.h... we'll see. TODO */
#ifndef _STREAM_COMPAT
int _eof (int nHandle);
#endif
/* LK_... locking commands defined in sys/locking.h. */
int _locking (int nHandle, int nCmd, long lnLockRegionLength);
off_t _lseek(int _fd, off_t _offset, int _whence);
char * _mktemp (char *_template);
int _open(const char *_path, int _oflag, ...);
int _open_osfhandle ( void *osfhandle, int flags );
int _pipe(int _fildes[2], unsigned int size, int mode );
size_t _read(int _fd, void *_buf,size_t _nbyte);
int remove(const char *fn);
int rename(const char *old, const char *new);
int _setmode(int _fd, int _newmode);
int _sopen(const char *path, int access, int shflag, ...);
off_t _tell(int _fd);
mode_t _umask(mode_t newmask);
int _unlink(const char *_path);
//int unlock(int _fd, long _offset, long _length);
int _open (const char* szFileName, int nFlags, ...);
int _open_osfhandle (void *lnOSHandle, int nFlags);
int _pipe (int *naHandles, unsigned int unSize, int nMode);
size_t _read(int _fd, void *_buf, size_t _nbyte);
/* SH_... flags for nFlag defined in share.h */
int _sopen (char* szFileName, int nAccess, int nFlag, int nMode);
long _tell (int nHandle);
unsigned _umask (unsigned unMode);
int _unlink (const char* szFileName);
size_t _write(int _fd, const void *_buf, size_t _nbyte);
#ifndef _NO_OLDNAMES
/*
* Non-underscored versions of non-ANSI functions to improve portability.
* These functions live in libmoldname.a.
*/
#define access _access
#define chmod _chmod
#define chsize _chsize
#define close _close
#define creat _creat
#define commit _commit
#define dup _dup
#define dup2 _dup2
#define eof _eof
#define filelength _filelength
#define findfirst _findfirst
#define findnext _findnext
#define findclose _findclose
#define get_osfhandle _get_osfhandle
#define locking _locking
#define lseek _lseek
#define mktemp _mktemp
#define open _open
#define open_osfhandle _open_osfhandle
#define pipe _pipe
#define read _read
#define setmode _setmode
#define sopen(path, access, shflag, mode) \
_open((path), (access)|(shflag), (mode))
#define tell _tell
#define umask _umask
#define unlink _unlink
#define unlock unlock
#define write _write
int access (const char* szFileName, int nAccessMode);
int chsize (int nHandle, long lnNewSize);
int close (int nHandle);
int creat (const char* szFileName, int nAccessMode);
int dup (int nHandle);
int dup2 (int nOldHandle, int nNewHandle);
int eof (int nHandle);
long filelength (int nHandle);
int fileno (FILE* fileGetHandle);
int isatty (int nHandle);
long lseek (int nHandle, long lnOffset, int nOrigin);
int open (const char* szFileName, int nFlags, ...);
int read (int nHandle, void* caBuffer, unsigned int nToRead);
int sopen (char* szFileName, int nAccess, int nFlag, int nMode);
long tell (int nHandle);
unsigned umask (unsigned unMode);
int unlink (const char* szFileName);
int write (int nHandle, const void* caBuffer,
unsigned int nToWrite);
#endif /* Not _NO_OLDNAMES */
#endif /* !_POSIX_SOURCE */
#endif /* !__STRICT_ANSI__ */
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
#ifndef __dj_ENFORCE_FUNCTION_CALLS
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */
#ifdef __cplusplus
#ifdef __cplusplus
}
#endif
#endif /* !__dj_include_io_h_ */
#endif /* Not strict ANSI */
#endif /* _IO_H_ not defined */

View file

@ -1,52 +1,156 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef __dj_include_process_h_
#define __dj_include_process_h_
/*
* process.h
*
* Function calls for spawning child processes.
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.2 $
* $Author: ariadne $
* $Date: 1999/02/21 13:29:56 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
#ifdef __cplusplus
#ifndef _PROCESS_H_
#define _PROCESS_H_
#ifndef __STRICT_ANSI__
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __dj_ENFORCE_ANSI_FREESTANDING
void _cexit(void);
void _c_exit(void);
#ifndef __STRICT_ANSI__
/*
* Constants for cwait actions.
* Obsolete for Win32.
*/
#define _WAIT_CHILD 0
#define _WAIT_GRANDCHILD 1
#ifndef _POSIX_SOURCE
#ifndef _NO_OLDNAMES
#define WAIT_CHILD _WAIT_CHILD
#define WAIT_GRANDCHILD _WAIT_GRANDCHILD
#endif /* Not _NO_OLDNAMES */
int _dos_exec(const char *program, const char *args, char *const _envp[]);
int _cwait (int* pnStatus, int nPID, int nAction);
int execl(const char *_path, const char *_argv0, ...);
int execle(const char *_path, const char *_argv0, ... /*, char *const _envp[] */);
int execlp(const char *_path, const char *_argv0, ...);
int execlpe(const char *_path, const char *_argv0, ... /*, char *const _envp[] */);
int _getpid(void);
int execv(const char *_path,const char *const _argv[]);
int execve(const char *_path,const char *const _argv[],const char *const _envp[]);
int execvp(const char *_path,const char *const _argv[]);
int execvpe(const char *_path,const char *const _argv[],const char *const _envp[]);
int _execl(const char *_path, const char *_argv0, ...);
int _execle(const char *_path, const char *_argv0, ... /*, char *const _envp[] */);
int _execlp(const char *_path, const char *_argv0, ...);
int _execlpe(const char *_path, const char *_argv0, ... /*, char *const _envp[] */);
int spawnl(int _mode, const char *_path, const char *_argv0, ...);
int spawnle(int _mode, const char *_path, const char *_argv0, ... /*, char *const _envp[] */);
int spawnlp(int _mode, const char *_path, const char *_argv0, ...);
int spawnlpe(int _mode, const char *_path, const char *_argv0, ... /*, char *const _envp[] */);
int _execv(const char *_path,const char *const _argv[]);
int _execve(const char *_path,const char *const _argv[],const char *const _envp[]);
int _execvp(const char *_path,const char *const _argv[]);
int _execvpe(const char *_path,const char *const _argv[],const char *const _envp[]);
int spawnv(int _mode, const char *_path,const char *const _argv[]);
int spawnve(int _mode, const char *_path,const char *const _argv[],const char *const _envp[]);
int spawnvp(int _mode, const char *_path,const char *const _argv[]);
int spawnvpe(int _mode, const char *_path,const char *const _argv[],const char *const _envp[]);
#define P_WAIT 1
#define P_NOWAIT 2 /* always generates error */
#define P_OVERLAY 3
#endif /* !_POSIX_SOURCE */
#endif /* !__STRICT_ANSI__ */
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
#ifndef __dj_ENFORCE_FUNCTION_CALLS
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */
/*
* Mode constants for spawn functions.
*/
#define _P_WAIT 0
#define _P_NOWAIT 1
#define _P_OVERLAY 2
#define _OLD_P_OVERLAY _P_OVERLAY
#define _P_NOWAITO 3
#define _P_DETACH 4
#ifdef __cplusplus
#ifndef _NO_OLDNAMES
#define P_WAIT _P_WAIT
#define P_NOWAIT _P_NOWAIT
#define P_OVERLAY _P_OVERLAY
#define OLD_P_OVERLAY _OLD_P_OVERLAY
#define P_NOWAITO _P_NOWAITO
#define P_DETACH _P_DETACH
#endif /* Not _NO_OLDNAMES */
int _spawnl(int _mode, const char *_path, const char *_argv0, ...);
int _spawnle(int _mode, const char *_path, const char *_argv0, ... /*, char *const _envp[] */);
int _spawnlp(int _mode, const char *_path, const char *_argv0, ...);
int _spawnlpe(int _mode, const char *_path, const char *_argv0, ... /*, char *const _envp[] */);
int _spawnv(int _mode, const char *_path,const char *const _argv[]);
int _spawnve(int _mode, const char *_path,const char *const _argv[],const char *const _envp[]);
int _spawnvp(int _mode, const char *_path,const char *const _argv[]);
int _spawnvpe(int _mode, const char *_path,const char *const _argv[],const char *const _envp[]);
/*
* The functions _beginthreadex and _endthreadex are not provided by CRTDLL.
* They are provided by MSVCRT.
*
* NOTE: Apparently _endthread calls CloseHandle on the handle of the thread,
* making for race conditions if you are not careful. Basically you have to
* make sure that no-one is going to do *anything* with the thread handle
* after the thread calls _endthread or returns from the thread function.
*
* NOTE: No old names for these functions. Use the underscore.
*/
unsigned long
_beginthread (void (*pfuncStart)(void *),
unsigned unStackSize, void* pArgList);
void _endthread (void);
#if __MSVCRT__
unsigned long
_beginthreadex (void *pSecurity, unsigned unStackSize,
unsigned (*pfuncStart)(void*), void* pArgList,
unsigned unInitFlags, unsigned* pThreadAddr);
void _endthreadex (unsigned unExitCode);
#endif
#ifndef _NO_OLDNAMES
#define cwait _cwait
#define getpid _getpid
#define execl _execl
#define execle _execle
#define execlp _execlp
#define execlpe _execlpe
#define execv _execv
#define execve _execve
#define execvp _execvp
#define execvpe _execvpe
#define spawnl _spawnl
#define spawnle _spawnle
#define spawnlp _spawnlp
#define spawnlpe _spawnlpe
#define spawnv _spawnv
#define spawnve _spawnve
#define spawnvp _spawnvp
#define spawnvpe _spawnvpe
#endif /* Not _NO_OLDNAMES */
#ifdef __cplusplus
}
#endif
#endif /* !__dj_include_process_h_ */
#endif /* Not __STRICT_ANSI__ */
#endif /* _PROCESS_H_ not defined */

107
reactos/include/stdarg.h Normal file
View file

@ -0,0 +1,107 @@
/*
* stdarg.h
*
* Provides facilities for stepping through a list of function arguments of
* an unknown number and type.
*
* NOTE: Gcc should provide stdarg.h, and I believe their version will work
* with crtdll. If necessary I think you can replace this with the GCC
* stdarg.h (or is it vararg.h).
*
* Note that the type used in va_arg is supposed to match the actual type
* *after default promotions*. Thus, va_arg (..., short) is not valid.
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.1 $
* $Author: ariadne $
* $Date: 1999/02/21 13:29:56 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
#ifndef _STDARG_H_
#define _STDARG_H_
/*
* Don't do any of this stuff for the resource compiler.
*/
#ifndef RC_INVOKED
/*
* I was told that Win NT likes this.
*/
#ifndef _VA_LIST_DEFINED
#define _VA_LIST_DEFINED
#endif
#ifndef _VA_LIST
#define _VA_LIST
typedef char* va_list;
#endif
/*
* Amount of space required in an argument list (ie. the stack) for an
* argument of type t.
*/
#define __va_argsiz(t) \
(((sizeof(t) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
/*
* Start variable argument list processing by setting AP to point to the
* argument after pN.
*/
#ifdef __GNUC__
/*
* In GNU the stack is not necessarily arranged very neatly in order to
* pack shorts and such into a smaller argument list. Fortunately a
* neatly arranged version is available through the use of __builtin_next_arg.
*/
#define va_start(ap, pN) \
((ap) = ((va_list) __builtin_next_arg(pN)))
#else
/*
* For a simple minded compiler this should work (it works in GNU too for
* vararg lists that don't follow shorts and such).
*/
#define va_start(ap, pN) \
((ap) = ((va_list) (&pN) + __va_argsiz(pN)))
#endif
/*
* End processing of variable argument list. In this case we do nothing.
*/
#define va_end(ap) ((void)0)
/*
* Increment ap to the next argument in the list while returing a
* pointer to what ap pointed to first, which is of type t.
*
* We cast to void* and then to t* because this avoids a warning about
* increasing the alignment requirement.
*/
#define va_arg(ap, t) \
(((ap) = (ap) + __va_argsiz(t)), \
*((t*) (void*) ((ap) - __va_argsiz(t))))
#endif /* Not RC_INVOKED */
#endif /* not _STDARG_H_ */

171
reactos/include/stddef.h Normal file
View file

@ -0,0 +1,171 @@
/*
* stddef.h
*
* Standard type definitions provided by the C library.
*
* NOTE: Actually supplied by the compiler (correct?). As such, GCC
* supplies a version of this header file. Unfortunately, GCC's
* version is all tied up with the way other headers for the
* GNU C library are implemented (or vice-versa), in a similar
* way to how the other Mingw32 headers are dependent on
* certain internals of this file. It is not clear to me whether
* you can safely use the GCC version in place of this version.
* TODO: Line up usage in other header files to work with GCC
* stddef.h.
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.1 $
* $Author: ariadne $
* $Date: 1999/02/21 13:29:56 $
*
*/
#ifndef _STDDEF_H_
/*
* Any one of these symbols __need_* means that a standard header file
* wants us just to define one data type. So don't define
* the symbols that indicate this file's entire job has been done.
*/
#if (!defined(__need_wchar_t) && !defined(__need_wint_t) \
&& !defined(__need_size_t) && !defined(__need_ptrdiff_t) \
&& !defined(__need_NULL))
#define _STDDEF_H_
#endif
/*
* NOTE: The following typedefs are done using __xxx_TYPE__ defines followed
* by typedefs using those defines. I have chosen to do it this way because
* GCC supplies definitions for __xxx_TYPE__ macros and if, for example, your
* size_t is typedef'ed differently from what GCC expects it will give you
* warnings when you prototype functions like memcmp and memcpy. The values
* for __xxx_TYPE__ in this header file are the same as those given by GCC.
* Those values appear to work with the CRTDLL functions.
*/
/*
* Signed type of difference of two pointers.
*/
/* Define this type if we are doing the whole job, or if we want this type
* in particular. */
#if defined (_STDDEF_H_) || defined (__need_ptrdiff_t)
#ifndef _PTRDIFF_T_
#define _PTRDIFF_T_
#ifndef __PTRDIFF_TYPE__
#define __PTRDIFF_TYPE__ int
#endif
typedef __PTRDIFF_TYPE__ ptrdiff_t;
#endif
/* If this symbol has done its job, get rid of it. */
#undef __need_ptrdiff_t
#endif /* _STDDEF_H_ or __need_ptrdiff_t. */
/*
* Unsigned type of `sizeof' something.
*/
/* Define this type if we are doing the whole job,
* or if we want this type in particular. */
#if defined (_STDDEF_H_) || defined (__need_size_t)
#ifndef _SIZE_T_
#define _SIZE_T_
#define SIZE_T_DEFINED
#define _SIZE_T
#ifndef __SIZE_TYPE__
#define __SIZE_TYPE__ unsigned int
#endif
typedef __SIZE_TYPE__ size_t;
#endif
#undef __need_size_t
#endif /* _STDDEF_H_ or __need_size_t. */
/* Wide character type.
Locale-writers should change this as necessary to
be big enough to hold unique values not between 0 and 127,
and not (wchar_t) -1, for each defined multibyte character. */
/* Define this type if we are doing the whole job,
or if we want this type in particular. */
#if defined (_STDDEF_H_) || defined (__need_wchar_t)
#ifndef _WCHAR_T_
#define _WCHAR_T_
#define _WCHAR_T
#ifndef __WCHAR_TYPE__
#define __WCHAR_TYPE__ short unsigned int
#endif
#ifndef __cplusplus
typedef __WCHAR_TYPE__ wchar_t;
#endif /* C++ */
#endif /* wchar_t not already defined */
#undef __need_wchar_t
#endif /* _STDDEF_H_ or __need_wchar_t. */
/*
* wint_t, the equivalent of int in wchar ctype functions.
*/
#if defined (_STDDEF_H_) || defined (__need_wint_t)
#ifndef _WINT_T_
#define _WINT_T_
#define _WINT_T /* To satisfy libstdc++ */
#ifndef __WINT_TYPE__
#define __WINT_TYPE__ short int
#endif /* Not defined __WINT_TYPE__ */
typedef __WINT_TYPE__ wint_t;
#endif /* Not defined _WINT_T_ */
#undef __need_wint_t
#endif /* _STDDEF_H_ or __need_wint_t. */
/*
* A null pointer constant.
*/
#if defined (_STDDEF_H_) || defined (__need_NULL)
#undef NULL
#define NULL (0)
#endif /* _STDDEF_H_ or __need_NULL */
#undef __need_NULL
/*
* Offsetof, a macro for finding the offset of a member in a structure.
* Works by returning the 'address' of the MEMBER of a TYPE struct at address
* zero.
*/
#if defined (_STDDEF_H_)
#define offsetof(TYPE, MEMBER) ((size_t) &( ((TYPE *) 0)->MEMBER ))
#endif /* _STDDEF_H_ */
#endif /* not _STDDEF_H_ */

View file

@ -1,35 +1,48 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef __dj_include_stdio_h_
#define __dj_include_stdio_h_
/*
* stdio.h
*
* Definitions of types and prototypes of functions for standard input and
* output.
*
* NOTE: The file manipulation functions provided by Microsoft seem to
* work with either slash (/) or backslash (\) as the path separator.
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.4 $
* $Author: ariadne $
* $Date: 1999/02/21 13:29:56 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
/* modified _iob */
#ifndef _STDIO_H_
#define _STDIO_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __dj_ENFORCE_ANSI_FREESTANDING
#define __need_size_t
#define __need_NULL
#define __need_wchar_t
#include <stddef.h>
#include <sys/djtypes.h>
#define _IOFBF 00001
#define _IONBF 00002
#define _IOLBF 00004
#define BUFSIZ 16384
#define EOF (-1)
#define FILENAME_MAX 260
#define FOPEN_MAX 20
#define L_tmpnam 260
#ifndef NULL
#define NULL 0
#endif
#define TMP_MAX 999999
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
/* Some flags for the iobuf structure provided by djgpp stdio.h */
#define _IOREAD 000010
#define _IOWRT 000020
#define _IOMYBUF 000040
@ -43,9 +56,20 @@ extern "C" {
#define _IOUNGETC 010000 /* there is an ungetc'ed character in the buffer */
#include <internal/types.h>
/*
* I used to include stdarg.h at this point, in order to allow for the
* functions later on in the file which use va_list. That conflicts with
* using stdio.h and varargs.h in the same file, so I do the typedef myself.
*/
#ifndef _VA_LIST
#define _VA_LIST
typedef char* va_list;
#endif
/*
* FILE should be used as a pointer to an opaque data type. Do not rely on
* anything else, especially the size or contents of this structure!
*/
#ifndef _FILE_DEFINED
typedef struct {
char *_ptr;
@ -60,96 +84,248 @@ typedef struct {
#define _FILE_DEFINED
#endif
typedef unsigned long fpos_t;
extern FILE _iob[];
/*
* The three standard file pointers provided by the run time library.
* NOTE: These will go to the bit-bucket silently in GUI applications!
*/
extern FILE (*__imp__iob)[]; /* A pointer to an array of FILE */
extern FILE _iob[]; /* An array of FILE */
#define stdin (&_iob[0])
#define stdout (&_iob[1])
#define stderr (&_iob[2])
#define stdaux (&_iob[3])
#define stdprn (&_iob[4])
void clearerr(FILE *_stream);
int fclose(FILE *_stream);
int feof(FILE *_stream);
int ferror(FILE *_stream);
int fflush(FILE *_stream);
int fgetc(FILE *_stream);
int fgetpos(FILE *_stream, fpos_t *_pos);
char * fgets(char *_s, int _n, FILE *_stream);
FILE * fopen(const char *_filename, const char *_mode);
int fprintf(FILE *_stream, const char *_format, ...);
int fputc(int _c, FILE *_stream);
int fputs(const char *_s, FILE *_stream);
size_t fread(void *_ptr, size_t _size, size_t _nelem, FILE *_stream);
FILE * freopen(const char *_filename, const char *_mode, FILE *_stream);
int fscanf(FILE *_stream, const char *_format, ...);
int fseek(FILE *_stream, long _offset, int _mode);
int fsetpos(FILE *_stream, const fpos_t *_pos);
long ftell(FILE *_stream);
size_t fwrite(const void *_ptr, size_t _size, size_t _nelem, FILE *_stream);
int getc(FILE *_stream);
int getchar(void);
char * gets(char *_s);
void perror(const char *_s);
int printf(const char *_format, ...);
int putc(int _c, FILE *_stream);
int putchar(int _c);
int puts(const char *_s);
int remove(const char *_filename);
int rename(const char *_old, const char *_new);
void rewind(FILE *_stream);
int scanf(const char *_format, ...);
void setbuf(FILE *_stream, char *_buf);
int setvbuf(FILE *_stream, char *_buf, int _mode, size_t _size);
int sprintf(char *_s, const char *_format, ...);
int sscanf(const char *_s, const char *_format, ...);
FILE * tmpfile(void);
char * tmpnam(char *_s);
char * _tmpnam(char *_s);
int ungetc(int _c, FILE *_stream);
int vfprintf(FILE *_stream, const char *_format, va_list _ap);
int vprintf(const char *_format, va_list _ap);
int vsprintf(char *_s, const char *_format, va_list _ap);
/* Returned by various functions on end of file condition or error. */
#define EOF (-1)
/*
* The maximum length of a file name. You should use GetVolumeInformation
* instead of this constant. But hey, this works.
*
* NOTE: This is used in the structure _finddata_t (see dir.h) so changing it
* is probably not a good idea.
*/
#define FILENAME_MAX (260)
/*
* The maximum number of files that may be open at once. I have set this to
* a conservative number. The actual value may be higher.
*/
#define FOPEN_MAX (20)
/*
* File Operations
*/
FILE* fopen (const char* szFileName, const char* szMode);
FILE* freopen (const char* szNewFileName, const char* szNewMode,
FILE* fileChangeAssociation);
int fflush (FILE* fileFlush);
int fclose (FILE* fileClose);
int remove (const char* szFileName);
int rename (const char* szOldFileName, const char* szNewFileName);
FILE* tmpfile (void);
/*
* The maximum size of name (including NUL) that will be put in the user
* supplied buffer caName.
* NOTE: This has not been determined by experiment, but based on the
* maximum file name length above it is probably reasonable. I could be
* wrong...
*/
#define L_tmpnam (260)
char* tmpnam (char caName[]);
char* _tempnam (const char *szDir, const char *szPfx);
#ifndef _NO_OLDNAMES
#define tempnam _tempnam
#endif /* Not _NO_OLDNAMES */
/*
* The three possible buffering mode (nMode) values for setvbuf.
* NOTE: _IOFBF works, but _IOLBF seems to work like unbuffered...
* maybe I'm testing it wrong?
*/
#define _IOFBF 0 /* fully buffered */
#define _IOLBF 1 /* line buffered */
#define _IONBF 2 /* unbuffered */
int setvbuf (FILE* fileSetBuffer, char* caBuffer, int nMode,
size_t sizeBuffer);
/*
* The buffer size as used by setbuf such that it is equivalent to
* (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ).
*/
#define BUFSIZ 512
void setbuf (FILE* fileSetBuffer, char* caBuffer);
/*
* Pipe Operations
*/
int _pclose (FILE* pipeClose);
FILE* _popen (const char* szPipeName, const char* szMode);
#define popen _popen
#define pclose _pclose
/* Wide character version */
FILE* _wpopen (const wchar_t* szPipeName, const wchar_t* szMode);
/*
* Formatted Output
*/
int fprintf (FILE* filePrintTo, const char* szFormat, ...);
int printf (const char* szFormat, ...);
int sprintf (char* caBuffer, const char* szFormat, ...);
int vfprintf (FILE* filePrintTo, const char* szFormat, va_list varg);
int vprintf (const char* szFormat, va_list varg);
int vsprintf (char* caBuffer, const char* szFormat, va_list varg);
/* Wide character versions */
int fwprintf (FILE* filePrintTo, const wchar_t* wsFormat, ...);
int wprintf (const wchar_t* wsFormat, ...);
int swprintf (wchar_t* wcaBuffer, const wchar_t* wsFormat, ...);
int vfwprintf (FILE* filePrintTo, const wchar_t* wsFormat, va_list varg);
int vwprintf (const wchar_t* wsFormat, va_list varg);
int vswprintf (wchar_t* wcaBuffer, const wchar_t* wsFormat, va_list varg);
/*
* Formatted Input
*/
int fscanf (FILE* fileReadFrom, const char* szFormat, ...);
int scanf (const char* szFormat, ...);
int sscanf (const char* szReadFrom, const char* szFormat, ...);
/* Wide character versions */
int fwscanf (FILE* fileReadFrom, const wchar_t* wsFormat, ...);
int wscanf (const wchar_t* wsFormat, ...);
int swscanf (wchar_t* wsReadFrom, const wchar_t* wsFormat, ...);
/*
* Character Input and Output Functions
*/
int fgetc (FILE* fileRead);
char* fgets (char* caBuffer, int nBufferSize, FILE* fileRead);
int fputc (int c, FILE* fileWrite);
int fputs (const char* szOutput, FILE* fileWrite);
int getc (FILE* fileRead);
//int getchar ();
char* gets (char* caBuffer); /* Unsafe: how does gets know how long the
* buffer is? */
int putc (int c, FILE* fileWrite);
int putchar (int c);
int puts (const char* szOutput);
int ungetc (int c, FILE* fileWasRead);
/* Wide character versions */
int fgetwc (FILE* fileRead);
int fputwc (wchar_t wc, FILE* fileWrite);
int ungetwc (wchar_t wc, FILE* fileWasRead);
/*
* Not exported by CRTDLL.DLL included for reference purposes.
*/
#if 0
wchar_t* fgetws (wchar_t* wcaBuffer, int nBufferSize, FILE* fileRead);
int fputws (const wchar_t* wsOutput, FILE* fileWrite);
int getwc (FILE* fileRead);
int getwchar ();
wchar_t* getws (wchar_t* wcaBuffer);
int putwc (wchar_t wc, FILE* fileWrite);
int putws (const wchar_t* wsOutput);
#endif /* 0 */
/* NOTE: putchar has no wide char equivalent even in tchar.h */
/*
* Direct Input and Output Functions
*/
size_t fread (void* pBuffer, size_t sizeObject, size_t sizeObjCount,
FILE* fileRead);
size_t fwrite (const void* pObjArray, size_t sizeObject, size_t sizeObjCount,
FILE* fileWrite);
/*
* File Positioning Functions
*/
/* Constants for nOrigin indicating the position relative to which fseek
* sets the file position. Enclosed in ifdefs because io.h could also
* define them. (Though not anymore since io.h includes this file now.) */
#ifndef SEEK_SET
#define SEEK_SET (0)
#endif
#ifndef SEEK_CUR
#define SEEK_CUR (1)
#endif
#ifndef SEEK_END
#define SEEK_END (2)
#endif
int fseek (FILE* fileSetPosition, long lnOffset, int nOrigin);
long ftell (FILE* fileGetPosition);
void rewind (FILE* fileRewind);
/*
* An opaque data type used for storing file positions... The contents of
* this type are unknown, but we (the compiler) need to know the size
* because the programmer using fgetpos and fsetpos will be setting aside
* storage for fpos_t structres. Actually I tested using a byte array and
* it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL).
* Perhaps an unsigned long? TODO?
*/
typedef long fpos_t;
int fgetpos (FILE* fileGetPosition, fpos_t* pfpos);
int fsetpos (FILE* fileSetPosition, fpos_t* pfpos);
/*
* Error Functions
*/
void clearerr (FILE* fileClearErrors);
int feof (FILE* fileIsAtEnd);
int ferror (FILE* fileIsError);
void perror (const char* szErrorMessage);
/*
* Non ANSI functions
*/
#ifndef __STRICT_ANSI__
int _fgetchar (void);
int _fputchar (int c);
FILE* _fdopen (int nHandle, char* szMode);
#define L_ctermid
#define L_cusrid
/* #define STREAM_MAX 20 - DOS can change this */
#ifndef _NO_OLDNAMES
//int fgetchar ();
int fputchar (int c);
FILE* fdopen (int nHandle, char* szMode);
#endif /* Not _NO_OLDNAMES */
int fileno(FILE *_stream);
int _fileno(FILE *_stream);
FILE * fdopen(int _fildes, const char *_type);
int pclose(FILE *_pf);
FILE * popen(const char *_command, const char *_mode);
#ifndef _POSIX_SOURCE
void _djstat_describe_lossage(FILE *_to_where);
int _doprnt(const char *_fmt, va_list _args, FILE *_f);
int _doscan(FILE *_f, const char *_fmt, void **_argp);
int _doscan_low(FILE *, int (*)(FILE *_get), int (*_unget)(int, FILE *), const char *_fmt, void **_argp);
int fpurge(FILE *_f);
int getw(FILE *_f);
int mkstemp(char *_template);
char * mktemp(char *_template);
int putw(int _v, FILE *_f);
void setbuffer(FILE *_f, void *_buf, int _size);
void setlinebuf(FILE *_f);
char * tempnam(const char *_dir, const char *_prefix);
int _rename(const char *_old, const char *_new); /* Simple (no directory) */
#endif /* !_POSIX_SOURCE */
#endif /* !__STRICT_ANSI__ */
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
#ifndef __dj_ENFORCE_FUNCTION_CALLS
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */
#endif /* Not __STRICT_ANSI__ */
#ifdef __cplusplus
}
#endif
#endif /* !__dj_include_stdio_h_ */
#endif /* _STDIO_H_ */

View file

@ -1,131 +1,186 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef __dj_include_stdlib_h_
#define __dj_include_stdlib_h_
/*
* stdlib.h
*
* Definitions for common types, variables, and functions.
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.2 $
* $Author: ariadne $
* $Date: 1999/02/21 13:29:56 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
#ifndef _STDLIB_H_
#define _STDLIB_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __dj_ENFORCE_ANSI_FREESTANDING
//#include <sys/djtypes.h>
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
#define MB_CUR_MAX __dj_mb_cur_max
#ifndef NULL
#define NULL 0
#endif
#define RAND_MAX 2147483647
#define _MAX_DRIVE 26
#define _MAX_FNAME 100
#define _MAX_EXT 100
#define _MAX_DIR 26
#define _MAX_PATH 250
/*
* This seems like a convenient place to declare these variables, which
* give programs using WinMain (or main for that matter) access to main-ish
* argc and argv. environ is a pointer to a table of environment variables.
* NOTE: Strings in _argv and environ are ANSI strings.
*/
extern int _argc;
extern char** _argv;
extern char** environ;
extern int errno;
extern int __dj_mb_cur_max;
#define __need_size_t
#define __need_wchar_t
#define __need_NULL
#include <stddef.h>
extern char ** environ;
#ifdef __GNUC__
#define _ATTRIB_NORETURN __attribute__ ((noreturn))
#else /* Not __GNUC__ */
#define _ATTRIB_NORETURN
#endif /* __GNUC__ */
double atof (const char* szNumber);
int atoi (const char* szNumber);
long atol (const char* szNumber);
typedef struct {
int quot;
int rem;
} div_t;
double strtod (const char* szNumber, char** pszAfterNumber);
double wcstod (const wchar_t* wsNumber, wchar_t** pwsAfterNumber);
long strtol (const char* szNumber, char** pszAfterNumber, int nBase);
long wcstol (const wchar_t* wsNumber, wchar_t** pwsAfterNumber, int nBase);
typedef struct {
long quot;
long rem;
} ldiv_t;
unsigned long strtoul (const char* szNumber, char** pszAfterNumber,
int nBase);
unsigned long wcstoul (const wchar_t* wsNumber, wchar_t** pwsAfterNumber,
int nBase);
#include <internal/types.h>
#ifndef _WCHAR_T_
#define _WCHAR_T_
#define _WCHAR_T
typedef int wchar_t;
#endif
size_t wcstombs (char* mbsDest, const wchar_t* wsConvert, size_t size);
int wctomb (char* mbDest, wchar_t wc);
int mblen (const char* mbs, size_t sizeString);
size_t mbstowcs (wchar_t* wcaDest, const char* mbsConvert,
size_t size);
int mbtowc (wchar_t* wcDest, const char* mbConvert, size_t size);
void abort(void) __attribute__((noreturn));
int abs(int _i);
int atexit(void (*_func)(void));
double atof(const char *_s);
int atoi(const char *_s);
long atol(const char *_s);
void * bsearch(const void *_key, const void *_base, size_t _nelem,
size_t _size, int (*_cmp)(const void *_ck, const void *_ce));
void * calloc(size_t _nelem, size_t _size);
div_t div(int _numer, int _denom);
void exit(int _status) __attribute__((noreturn));
void free(void *_ptr);
char * getenv(const char *_name);
long labs(long _i);
ldiv_t ldiv(long _numer, long _denom);
void * malloc(size_t _size);
int mblen(const char *_s, size_t _n);
size_t mbstowcs(wchar_t *_wcs, const char *_s, size_t _n);
int mbtowc(wchar_t *_pwc, const char *_s, size_t _n);
void qsort(void *_base, size_t _nelem, size_t _size,
int (*_cmp)(const void *_e1, const void *_e2));
int rand(void);
void * realloc(void *_ptr, size_t _size);
void srand(unsigned _seed);
double strtod(const char *_s, char **_endptr);
long strtol(const char *_s, char **_endptr, int _base);
unsigned long strtoul(const char *_s, char **_endptr, int _base);
int system(const char *_s);
size_t wcstombs(char *_s, const wchar_t *_wcs, size_t _n);
int wctomb(char *_s, wchar_t _wchar);
/*
* RAND_MAX is the maximum value that may be returned by rand.
* The minimum is zero.
*/
#define RAND_MAX 0x7FFF
#ifndef __STRICT_ANSI__
#ifndef _POSIX_SOURCE
typedef struct {
long long quot;
long long rem;
} lldiv_t;
void * alloca(size_t _size);
long double _atold(const char *_s);
long long atoll(const char *_s);
void cfree(void *_ptr);
char * getpass(const char *_prompt);
int getlongpass(const char *_prompt, char *_buffer, int _max_len);
char * itoa(int value, char *buffer, int radix);
long long llabs(long long _i);
lldiv_t lldiv(long long _numer, long long _denom);
int putenv(const char *_val);
int setenv(const char *_var, const char *_val, int _replace);
double _strtold(const char *_s, char **_endptr);
long strtoll(const char *_s, char **_endptr, int _base);
unsigned long strtoull(const char *_s, char **_endptr, int _base);
void swab(const void *from, void *to, int nbytes);
#ifndef alloca
#define alloca __builtin_alloca
#endif
/* BSD Random Number Generator */
char * initstate (unsigned _seed, char *_arg_state, int _n);
char * setstate(char *_arg_state);
long random(void);
int srandom(int _seed);
int rand (void);
void srand (unsigned int nSeed);
void* calloc (size_t sizeObjCnt, size_t sizeObject);
void* malloc (size_t sizeObject);
void* realloc (void* pObject, size_t sizeNew);
void free (void* pObject);
#endif /* !_POSIX_SOURCE */
#endif /* !__STRICT_ANSI__ */
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
/* These values may be used as exit status codes. */
#define EXIT_SUCCESS 0
#define EXIT_FAILURE -1
#ifndef __dj_ENFORCE_FUNCTION_CALLS
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */
void abort (void) _ATTRIB_NORETURN;
void exit (int nStatus) _ATTRIB_NORETURN;
int atexit (void (*pfuncExitProcessing)(void));
int system (const char* szCommand);
char* getenv (const char* szVarName);
typedef int (*_pfunccmp_t)(const void*, const void*);
void* bsearch (const void* pKey, const void* pBase, size_t cntObjects,
size_t sizeObject, _pfunccmp_t pfuncCmp);
void qsort (const void* pBase, size_t cntObjects, size_t sizeObject,
_pfunccmp_t pfuncCmp);
int abs (int n);
long labs (long n);
/*
* div_t and ldiv_t are structures used to return the results of div and
* ldiv.
*
* NOTE: div and ldiv appear not to work correctly unless
* -fno-pcc-struct-return is specified. This is included in the
* mingw32 specs file.
*/
typedef struct { int quot, rem; } div_t;
typedef struct { long quot, rem; } ldiv_t;
typedef struct { long long quot, rem; } lldiv_t;
div_t div (int nNumerator, int nDenominator);
ldiv_t ldiv (long lNumerator, long lDenominator);
lldiv_t lldiv (long long lNumerator, long long lDenominator);
#ifndef __STRICT_ANSI__
/*
* NOTE: Officially the three following functions are obsolete. The Win32 API
* functions SetErrorMode, Beep and Sleep are their replacements.
*/
void _beep (unsigned int, unsigned int);
void _seterrormode (int nMode);
void _sleep (unsigned long ulTime);
void _exit (int nStatus) _ATTRIB_NORETURN;
int _putenv (const char* szNameEqValue);
void _searchenv (const char* szFileName, const char* szVar,
char* szFullPathBuf);
char* _itoa (int nValue, char* sz, int nRadix);
char* _ltoa (long lnValue, char* sz, int nRadix);
char* _ecvt (double dValue, int nDig, int* pnDec, int* pnSign);
char* _fcvt (double dValue, int nDig, int* pnDec, int* pnSign);
char* _gcvt (double dValue, int nDec, char* caBuf);
char* _fullpath (char* caBuf, const char* szPath, size_t sizeMax);
#ifndef _NO_OLDNAMES
void beep (unsigned int, unsigned int);
void seterrormode (int nMode);
void sleep (unsigned long ulTime);
int putenv (const char* szNameEqValue);
void searchenv (const char* szFileName, const char* szVar,
char* szFullPathBuf);
char* itoa (int nValue, char* sz, int nRadix);
char* ltoa (long lnValue, char* sz, int nRadix);
char* ecvt (double dValue, int nDig, int* pnDec, int* pnSign);
char* fcvt (double dValue, int nDig, int* pnDec, int* pnSign);
char* gcvt (double dValue, int nDec, char* caBuf);
#endif /* Not _NO_OLDNAMES */
#endif /* Not __STRICT_ANSI__ */
/*
* Undefine the no return attribute used in some function definitions
*/
#undef _ATTRIB_NORETURN
#ifdef __cplusplus
}
#endif
#endif /* !__dj_include_stdlib_h_ */
#endif /* _STDLIB_H_ */

View file

@ -1,786 +1,187 @@
/*
* Adapted from linux for the reactos kernel, march 1998 -- David Welch
* Removed extern specifier from ___strtok and ___wcstok, june 1998 -- Boudewijn Dekker
* Added stricmp and strnicmp -- Boudewijn Dekker
* string.h
*
* Definitions for memory and string functions.
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.3 $
* $Author: ariadne $
* $Date: 1999/02/21 13:29:57 $
*
*/
#ifndef _LINUX_STRING_H_
#define _LINUX_STRING_H_
#include <types.h> /* for size_t */
#ifndef NULL
#define NULL ((void *) 0)
#endif
/* Appropriated for Reactos Crtdll by Ariadne */
/* changed prototype for _strerror */
#ifndef _STRING_H_
#define _STRING_H_
#ifdef __cplusplus
extern "C" {
#endif
#define __kernel_size_t size_t
/*
* Define size_t, wchar_t and NULL
*/
#define __need_size_t
#define __need_wchar_t
#define __need_NULL
#include <stddef.h>
char * ___strtok; // removed extern specifier 02-06-98, BD
/*
* Prototypes of the ANSI Standard C library string functions.
*/
void* memchr (const void* p, int cSearchFor, size_t sizeSearch);
int memcmp (const void* p1, const void* p2, size_t sizeSearch);
void* memcpy (void* pCopyTo, const void* pSource, size_t sizeSource);
void* memmove (void* pMoveTo, const void* pSource, size_t sizeSource);
void* memset (void* p, int cFill, size_t sizeRepeatCount);
char* strcat (char* szAddTo, const char* szAdd);
char* strchr (const char* szSearch, int cFor);
int strcmp (const char* sz1, const char* sz2);
int strcoll (const char* sz1, const char* sz2); /* Compare using locale */
char* strcpy (char* szCopyTo, const char* szSource);
size_t strcspn (const char* szGetPrefix, const char* szNotIncluding);
char* strerror (int nError); /* NOTE: NOT an old name wrapper. */
char * _strerror(const char *s);
size_t strlen (const char* sz);
char* strncat (char* szAddTo, const char* szAdd, size_t sizeMaxAdd);
int strncmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
char* strncpy (char* szCopyTo, const char* szSource, size_t sizeMaxCopy);
char* strpbrk (const char* szSearch, const char* szAnyOf);
char* strrchr (const char* szSearch, int cFor);
size_t strspn (const char* szGetPrefix, const char *szIncluding);
char* strstr (const char* szSearch, const char *szFor);
char* strtok (char* szTokenize, const char* szDelimiters);
size_t strxfrm (char* szTransformed, const char *szSource,
size_t sizeTransform);
extern char * strcpy(char *,const char *);
extern char * strncpy(char *,const char *, __kernel_size_t);
extern char * strcat(char *, const char *);
extern char * strncat(char *, const char *, __kernel_size_t);
extern char * strchr(const char *,int);
extern char * strrchr(const char *,int);
extern char * strpbrk(const char *,const char *);
extern char * strtok(char *,const char *);
extern char * strstr(const char *,const char *);
extern __kernel_size_t strlen(const char *);
extern __kernel_size_t strnlen(const char *,__kernel_size_t);
extern __kernel_size_t strspn(const char *,const char *);
extern int strcmp(const char *,const char *);
extern int strncmp(const char *,const char *,__kernel_size_t);
extern int stricmp(const char* cs,const char * ct);
extern int strnicmp(const char* cs,const char * ct, size_t count);
#ifndef __STRICT_ANSI__
/*
* Extra non-ANSI functions provided by the CRTDLL library
*/
void* _memccpy (void* pCopyTo, const void* pSource, int cTerminator,
size_t sizeMaxCopy);
int _memicmp (const void* p1, const void* p2, size_t sizeSearch);
char* _strdup (const char *szDuplicate);
int _strcmpi (const char* sz1, const char* sz2);
int _stricmp (const char* sz1, const char* sz2);
int _stricoll (const char* sz1, const char* sz2);
char* _strlwr (char* szToConvert);
int _strnicmp (const char* sz1, const char* sz2,
size_t sizeMaxCompare);
char* _strnset (char* szToFill, int cFill, size_t sizeMaxFill);
char* _strrev (char* szToReverse);
char* _strset (char* szToFill, int cFill);
char* _strupr (char* szToConvert);
void _swab (const char* caFrom, char* caTo, size_t sizeToCopy);
extern void * memset(void *,int,__kernel_size_t);
extern void * memcpy(void *,const void *,__kernel_size_t);
extern void * memmove(void *,const void *,__kernel_size_t);
extern void * memscan(void *,int,__kernel_size_t);
extern int memcmp(const void *,const void *,__kernel_size_t);
char *strerror( int errnum );
char *_strerror( const char *string );
// obsolete
int strcasecmp (const char* sz1, const char* sz2);
int strncasecmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
#endif /* Not __STRICT_ANSI__ */
/*
* Include machine specific inline routines
* Unicode versions of the standard calls.
*/
#ifndef _I386_STRING_H_
#define _I386_STRING_H_
wchar_t* wcscat (wchar_t* wsAddTo, const wchar_t* wsAdd);
wchar_t* wcschr (const wchar_t* wsSearch, wchar_t wcFor);
int wcscmp (const wchar_t* ws1, const wchar_t* ws2);
int wcscoll (const wchar_t* ws1, const wchar_t* ws2);
wchar_t* wcscpy (wchar_t* wsCopyTo, const wchar_t* wsSource);
size_t wcscspn (const wchar_t* wsGetPrefix, const wchar_t* wsNotIncluding);
/* Note: No wcserror in CRTDLL. */
size_t wcslen (const wchar_t* ws);
wchar_t* wcsncat (wchar_t* wsAddTo, const wchar_t* wsAdd, size_t sizeMaxAdd);
int wcsncmp(const wchar_t* ws1, const wchar_t* ws2, size_t sizeMaxCompare);
wchar_t* wcsncpy(wchar_t* wsCopyTo, const wchar_t* wsSource,
size_t sizeMaxCopy);
wchar_t* wcspbrk(const wchar_t* wsSearch, const wchar_t* wsAnyOf);
wchar_t* wcsrchr(const wchar_t* wsSearch, wchar_t wcFor);
size_t wcsspn(const wchar_t* wsGetPrefix, const wchar_t* wsIncluding);
wchar_t* wcsstr(const wchar_t* wsSearch, const wchar_t* wsFor);
wchar_t* wcstok(wchar_t* wsTokenize, const wchar_t* wsDelimiters);
size_t wcsxfrm(wchar_t* wsTransformed, const wchar_t *wsSource,
size_t sizeTransform);
#ifndef __STRICT_ANSI__
/*
* Unicode versions of non-ANSI functions provided by CRTDLL.
*/
/* NOTE: _wcscmpi not provided by CRTDLL, this define is for portability */
#define _wcscmpi _wcsicmp
wchar_t* _wcsdup (wchar_t* wsToDuplicate);
int _wcsicmp (const wchar_t* ws1, const wchar_t* ws2);
int _wcsicoll (const wchar_t* ws1, const wchar_t* ws2);
wchar_t* _wcslwr (wchar_t* wsToConvert);
int _wcsnicmp (const wchar_t* ws1, const wchar_t* ws2,
size_t sizeMaxCompare);
wchar_t* _wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill);
wchar_t* _wcsrev (wchar_t* wsToReverse);
wchar_t* _wcsset (wchar_t* wsToFill, wchar_t wcToFill);
wchar_t* _wcsupr (wchar_t* wsToConvert);
#endif /* Not __STRICT_ANSI__ */
#ifndef __STRICT_ANSI__
#ifndef _NO_OLDNAMES
/*
* On a 486 or Pentium, we are better off not using the
* byte string operations. But on a 386 or a PPro the
* byte string ops are faster than doing it by hand
* (MUCH faster on a Pentium).
*
* Also, the byte strings actually work correctly. Forget
* the i486 routines for now as they may be broken..
*/
#if FIXED_486_STRING && (CPU == 486 || CPU == 586)
#include <asm/string-486.h>
#else
/*
* This string-include defines all string functions as inline
* functions. Use gcc. It also assumes ds=es=data space, this should be
* normal. Most of the string-functions are rather heavily hand-optimized,
* see especially strtok,strstr,str[c]spn. They should work, but are not
* very easy to understand. Everything is done entirely within the register
* set, making the functions fast and clean. String instructions have been
* used through-out, making for "slightly" unclear code :-)
*
* Copyright (C) 1991, 1992 Linus Torvalds
* Non-underscored versions of non-ANSI functions. They live in liboldnames.a
* and provide a little extra portability. Also a few extra UNIX-isms like
* strcasecmp.
*/
#define __HAVE_ARCH_STRCPY
extern inline char * strcpy(char * dest,const char *src)
{
__asm__ __volatile__(
"cld\n"
"1:\tlodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b"
: /* no output */
:"S" (src),"D" (dest):"si","di","ax","memory");
return dest;
}
void* memccpy (void* pCopyTo, const void* pSource, int cTerminator,
size_t sizeMaxCopy);
int memicmp (const void* p1, const void* p2, size_t sizeSearch);
char* strdup (const char *szDuplicate);
int strcmpi (const char* sz1, const char* sz2);
int stricmp (const char* sz1, const char* sz2);
int strcasecmp (const char* sz1, const char* sz2);
int stricoll (const char* sz1, const char* sz2);
char* strlwr (char* szToConvert);
int strnicmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
int strncasecmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
char* strnset (char* szToFill, int cFill, size_t sizeMaxFill);
char* strrev (char* szToReverse);
char* strset (char* szToFill, int cFill);
char* strupr (char* szToConvert);
void swab (const char* caFrom, char* caTo, size_t sizeToCopy);
#define __HAVE_ARCH_STRNCPY
extern inline char * strncpy(char * dest,const char *src,size_t count)
{
__asm__ __volatile__(
"cld\n"
"1:\tdecl %2\n\t"
"js 2f\n\t"
"lodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n\t"
"rep\n\t"
"stosb\n"
"2:"
: /* no output */
:"S" (src),"D" (dest),"c" (count):"si","di","ax","cx","memory");
return dest;
}
/* NOTE: There is no _wcscmpi, but this is for compatibility. */
int wcscmpi (const wchar_t* ws1, const wchar_t* ws2);
wchar_t* wcsdup (wchar_t* wsToDuplicate);
int wcsicmp (const wchar_t* ws1, const wchar_t* ws2);
int wcsicoll (const wchar_t* ws1, const wchar_t* ws2);
wchar_t* wcslwr (wchar_t* wsToConvert);
int wcsnicmp (const wchar_t* ws1, const wchar_t* ws2,
size_t sizeMaxCompare);
wchar_t* wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill);
wchar_t* wcsrev (wchar_t* wsToReverse);
wchar_t* wcsset (wchar_t* wsToFill, wchar_t wcToFill);
wchar_t* wcsupr (wchar_t* wsToConvert);
#define __HAVE_ARCH_STRCAT
extern inline char * strcat(char * dest,const char * src)
{
__asm__ __volatile__(
"cld\n\t"
"repne\n\t"
"scasb\n\t"
"decl %1\n"
"1:\tlodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b"
: /* no output */
:"S" (src),"D" (dest),"a" (0),"c" (0xffffffff):"si","di","ax","cx");
return dest;
}
#endif /* Not _NO_OLDNAMES */
#endif /* Not strict ANSI */
#define __HAVE_ARCH_STRNCAT
extern inline char * strncat(char * dest,const char * src,size_t count)
{
__asm__ __volatile__(
"cld\n\t"
"repne\n\t"
"scasb\n\t"
"decl %1\n\t"
"movl %4,%3\n"
"1:\tdecl %3\n\t"
"js 2f\n\t"
"lodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n"
"2:\txorl %2,%2\n\t"
"stosb"
: /* no output */
:"S" (src),"D" (dest),"a" (0),"c" (0xffffffff),"g" (count)
:"si","di","ax","cx","memory");
return dest;
}
#define __HAVE_ARCH_STRCMP
extern inline int strcmp(const char * cs,const char * ct)
{
register int __res;
__asm__ __volatile__(
"cld\n"
"1:\tlodsb\n\t"
"scasb\n\t"
"jne 2f\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n\t"
"xorl %%eax,%%eax\n\t"
"jmp 3f\n"
"2:\tsbbl %%eax,%%eax\n\t"
"orb $1,%%eax\n"
"3:"
:"=a" (__res):"S" (cs),"D" (ct):"si","di");
return __res;
}
#define __HAVE_ARCH_STRNCMP
extern inline int strncmp(const char * cs,const char * ct,size_t count)
{
register int __res;
__asm__ __volatile__(
"cld\n"
"1:\tdecl %3\n\t"
"js 2f\n\t"
"lodsb\n\t"
"scasb\n\t"
"jne 3f\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n"
"2:\txorl %%eax,%%eax\n\t"
"jmp 4f\n"
"3:\tsbbl %%eax,%%eax\n\t"
"orb $1,%%al\n"
"4:"
:"=a" (__res):"S" (cs),"D" (ct),"c" (count):"si","di","cx");
return __res;
}
#define __HAVE_ARCH_STRCHR
extern inline char * strchr(const char * s, int c)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"movb %%al,%%ah\n"
"1:\tlodsb\n\t"
"cmpb %%ah,%%al\n\t"
"je 2f\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n\t"
"movl $1,%1\n"
"2:\tmovl %1,%0\n\t"
"decl %0"
:"=a" (__res):"S" (s),"0" (c):"si");
return __res;
}
#define __HAVE_ARCH_STRRCHR
extern inline char * strrchr(const char * s, int c)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"movb %%al,%%ah\n"
"1:\tlodsb\n\t"
"cmpb %%ah,%%al\n\t"
"jne 2f\n\t"
"leal -1(%%esi),%0\n"
"2:\ttestb %%al,%%al\n\t"
"jne 1b"
:"=d" (__res):"0" (0),"S" (s),"a" (c):"ax","si");
return __res;
}
#define __HAVE_ARCH_STRSPN
extern inline size_t strspn(const char * cs, const char * ct)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"movl %4,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t"
"movl %%ecx,%%edx\n"
"1:\tlodsb\n\t"
"testb %%al,%%al\n\t"
"je 2f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasb\n\t"
"je 1b\n"
"2:\tdecl %0"
:"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
:"ax","cx","dx","di");
return __res-cs;
}
#define __HAVE_ARCH_STRCSPN
extern inline size_t strcspn(const char * cs, const char * ct)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"movl %4,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t"
"movl %%ecx,%%edx\n"
"1:\tlodsb\n\t"
"testb %%al,%%al\n\t"
"je 2f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasb\n\t"
"jne 1b\n"
"2:\tdecl %0"
:"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
:"ax","cx","dx","di");
return __res-cs;
}
#define __HAVE_ARCH_STRPBRK
extern inline char * strpbrk(const char * cs,const char * ct)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"movl %4,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t"
"movl %%ecx,%%edx\n"
"1:\tlodsb\n\t"
"testb %%al,%%al\n\t"
"je 2f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasb\n\t"
"jne 1b\n\t"
"decl %0\n\t"
"jmp 3f\n"
"2:\txorl %0,%0\n"
"3:"
:"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
:"ax","cx","dx","di");
return __res;
}
#define __HAVE_ARCH_STRSTR
extern inline char * strstr(const char * cs,const char * ct)
{
register char * __res;
__asm__ __volatile__(
"cld\n\t" \
"movl %4,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */
"movl %%ecx,%%edx\n"
"1:\tmovl %4,%%edi\n\t"
"movl %%esi,%%eax\n\t"
"movl %%edx,%%ecx\n\t"
"repe\n\t"
"cmpsb\n\t"
"je 2f\n\t" /* also works for empty string, see above */
"xchgl %%eax,%%esi\n\t"
"incl %%esi\n\t"
"cmpb $0,-1(%%eax)\n\t"
"jne 1b\n\t"
"xorl %%eax,%%eax\n\t"
"2:"
:"=a" (__res):"0" (0),"c" (0xffffffff),"S" (cs),"g" (ct)
:"cx","dx","di","si");
return __res;
}
#define __HAVE_ARCH_STRLEN
extern inline size_t strlen(const char * s)
{
register int __res;
__asm__ __volatile__(
"cld\n\t"
"repne\n\t"
"scasb\n\t"
"notl %0\n\t"
"decl %0"
:"=c" (__res):"D" (s),"a" (0),"0" (0xffffffff):"di");
return __res;
}
#define __HAVE_ARCH_STRTOK
extern inline char * strtok(char * s,const char * ct)
{
register char * __res;
__asm__ __volatile__(
"testl %1,%1\n\t"
"jne 1f\n\t"
"testl %0,%0\n\t"
"je 8f\n\t"
"movl %0,%1\n"
"1:\txorl %0,%0\n\t"
"movl $-1,%%ecx\n\t"
"xorl %%eax,%%eax\n\t"
"cld\n\t"
"movl %4,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
"notl %%ecx\n\t"
"decl %%ecx\n\t"
"je 7f\n\t" /* empty delimiter-string */
"movl %%ecx,%%edx\n"
"2:\tlodsb\n\t"
"testb %%al,%%al\n\t"
"je 7f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasb\n\t"
"je 2b\n\t"
"decl %1\n\t"
"cmpb $0,(%1)\n\t"
"je 7f\n\t"
"movl %1,%0\n"
"3:\tlodsb\n\t"
"testb %%al,%%al\n\t"
"je 5f\n\t"
"movl %4,%%edi\n\t"
"movl %%edx,%%ecx\n\t"
"repne\n\t"
"scasb\n\t"
"jne 3b\n\t"
"decl %1\n\t"
"cmpb $0,(%1)\n\t"
"je 5f\n\t"
"movb $0,(%1)\n\t"
"incl %1\n\t"
"jmp 6f\n"
"5:\txorl %1,%1\n"
"6:\tcmpb $0,(%0)\n\t"
"jne 7f\n\t"
"xorl %0,%0\n"
"7:\ttestl %0,%0\n\t"
"jne 8f\n\t"
"movl %0,%1\n"
"8:"
:"=b" (__res),"=S" (___strtok)
:"0" (___strtok),"1" (s),"g" (ct)
:"ax","cx","dx","di","memory");
return __res;
}
#define __HAVE_ARCH_STRICMP
extern inline int stricmp(const char* cs,const char * ct)
{
register int __res;
__asm__ __volatile__(
"cld\n"
"1:\tmovb (%%esi), %%eax\n\t"
"movb (%%edi), %%dl \n\t"
"cmpb $0x5A, %%al\n\t"
"ja 2f\t\n"
"cmpb $0x40, %%al\t\n"
"jbe 2f\t\n"
"addb $0x20, %%al\t\n"
"2:\t cmpb $0x5A, %%dl\t\n"
"ja 3f\t\n"
"cmpb $0x40, %%dl\t\n"
"jbe 3f\t\n"
"addb $0x20, %%dl\t\n"
"3:\t inc %%esi\t\n"
"inc %%edi\t\n"
"cmpb %%al, %%dl\t\n"
"jne 4f\n\t"
"cmpb $00, %%al\n\t"
"jne 1b\n\t"
"xorl %%eax,%%eax\n\t"
"jmp 5f\n"
"4:\tsbbl %%eax,%%eax\n\t"
"orb $1,%%eax\n"
"5:"
:"=a" (__res):"S" (cs),"D" (ct):"si","di");
return __res;
}
#define __HAVE_ARCH_STRNICMP
extern inline int strnicmp(const char* cs,const char * ct, size_t count)
{
register int __res;
__asm__ __volatile__(
"cld\n"
"1:\t decl %3\n\t"
"js 6f\n\t"
"movb (%%esi), %%al\n\t"
"movb (%%edi), %%dl \n\t"
"cmpb $0x5A, %%al\n\t"
"ja 2f\t\n"
"cmpb $0x40, %%al\t\n"
"jbe 2f\t\n"
"addb $0x20, %%al\t\n"
"2:\t cmpb $0x5A, %%dl\t\n"
"ja 3f\t\n"
"cmpb $0x40, %%dl\t\n"
"jbe 3f\t\n"
"addb $0x20, %%dl\t\n"
"3:\t inc %%esi\t\n"
"inc %%edi\t\n"
"cmpb %%al, %%dl\t\n"
"jne 4f\n\t"
"cmpb $00, %%al\n\t"
"jne 1b\n\t"
"6:xorl %%eax,%%eax\n\t"
"jmp 5f\n"
"4:\tsbbl %%eax,%%eax\n\t"
"orb $1,%%eax\n"
"5:"
:"=a" (__res):"S" (cs),"D" (ct), "c" (count):"si","di", "cx");
return __res;
}
extern inline void * __memcpy(void * to, const void * from, size_t n)
{
__asm__ __volatile__(
"cld\n\t"
"rep ; movsl\n\t"
"testb $2,%b1\n\t"
"je 1f\n\t"
"movsw\n"
"1:\ttestb $1,%b1\n\t"
"je 2f\n\t"
"movsb\n"
"2:"
: /* no output */
:"c" (n/4), "q" (n),"D" ((long) to),"S" ((long) from)
: "cx","di","si","memory");
return (to);
}
/*
* This looks horribly ugly, but the compiler can optimize it totally,
* as the count is constant.
*/
extern inline void * __constant_memcpy(void * to, const void * from, size_t n)
{
switch (n) {
case 0:
return to;
case 1:
*(unsigned char *)to = *(const unsigned char *)from;
return to;
case 2:
*(unsigned short *)to = *(const unsigned short *)from;
return to;
case 3:
*(unsigned short *)to = *(const unsigned short *)from;
*(2+(unsigned char *)to) = *(2+(const unsigned char *)from);
return to;
case 4:
*(unsigned long *)to = *(const unsigned long *)from;
return to;
case 8:
*(unsigned long *)to = *(const unsigned long *)from;
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
return to;
case 12:
*(unsigned long *)to = *(const unsigned long *)from;
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
*(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
return to;
case 16:
*(unsigned long *)to = *(const unsigned long *)from;
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
*(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
*(3+(unsigned long *)to) = *(3+(const unsigned long *)from);
return to;
case 20:
*(unsigned long *)to = *(const unsigned long *)from;
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
*(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
*(3+(unsigned long *)to) = *(3+(const unsigned long *)from);
*(4+(unsigned long *)to) = *(4+(const unsigned long *)from);
return to;
}
#define COMMON(x) \
__asm__("cld\n\t" \
"rep ; movsl" \
x \
: /* no outputs */ \
: "c" (n/4),"D" ((long) to),"S" ((long) from) \
: "cx","di","si","memory");
switch (n % 4) {
case 0: COMMON(""); return to;
case 1: COMMON("\n\tmovsb"); return to;
case 2: COMMON("\n\tmovsw"); return to;
case 3: COMMON("\n\tmovsw\n\tmovsb"); return to;
}
#undef COMMON
}
#define __HAVE_ARCH_MEMCPY
#define memcpy(t, f, n) \
(__builtin_constant_p(n) ? \
__constant_memcpy((t),(f),(n)) : \
__memcpy((t),(f),(n)))
#define __HAVE_ARCH_MEMMOVE
extern inline void * memmove(void * dest,const void * src, size_t n)
{
if (dest<src)
__asm__ __volatile__(
"cld\n\t"
"rep\n\t"
"movsb"
: /* no output */
:"c" (n),"S" (src),"D" (dest)
:"cx","si","di");
else
__asm__ __volatile__(
"std\n\t"
"rep\n\t"
"movsb\n\t"
"cld"
: /* no output */
:"c" (n),
"S" (n-1+(const char *)src),
"D" (n-1+(char *)dest)
:"cx","si","di","memory");
return dest;
}
#define memcmp __builtin_memcmp
#define __HAVE_ARCH_MEMCHR
extern inline void * memchr(const void * cs,int c,size_t count)
{
register void * __res;
if (!count)
return NULL;
__asm__ __volatile__(
"cld\n\t"
"repne\n\t"
"scasb\n\t"
"je 1f\n\t"
"movl $1,%0\n"
"1:\tdecl %0"
:"=D" (__res):"a" (c),"D" (cs),"c" (count)
:"cx");
return __res;
}
extern inline void * __memset_generic(void * s, char c,size_t count)
{
__asm__ __volatile__(
"cld\n\t"
"rep\n\t"
"stosb"
: /* no output */
:"a" (c),"D" (s),"c" (count)
:"cx","di","memory");
return s;
}
/* we might want to write optimized versions of these later */
#define __constant_count_memset(s,c,count) __memset_generic((s),(c),(count))
/*
* memset(x,0,y) is a reasonably common thing to do, so we want to fill
* things 32 bits at a time even when we don't know the size of the
* area at compile-time..
*/
extern inline void * __constant_c_memset(void * s, unsigned long c, size_t count)
{
__asm__ __volatile__(
"cld\n\t"
"rep ; stosl\n\t"
"testb $2,%b1\n\t"
"je 1f\n\t"
"stosw\n"
"1:\ttestb $1,%b1\n\t"
"je 2f\n\t"
"stosb\n"
"2:"
: /* no output */
:"a" (c), "q" (count), "c" (count/4), "D" ((long) s)
:"cx","di","memory");
return (s);
}
/* Added by Gertjan van Wingerde to make minix and sysv module work */
#define __HAVE_ARCH_STRNLEN
extern inline size_t strnlen(const char * s, size_t count)
{
register int __res;
__asm__ __volatile__(
"movl %1,%0\n\t"
"jmp 2f\n"
"1:\tcmpb $0,(%0)\n\t"
"je 3f\n\t"
"incl %0\n"
"2:\tdecl %2\n\t"
"cmpl $-1,%2\n\t"
"jne 1b\n"
"3:\tsubl %1,%0"
:"=a" (__res)
:"c" (s),"d" (count)
:"dx");
return __res;
}
/* end of additional stuff */
/*
* This looks horribly ugly, but the compiler can optimize it totally,
* as we by now know that both pattern and count is constant..
*/
extern inline void * __constant_c_and_count_memset(void * s, unsigned long pattern, size_t count)
{
switch (count) {
case 0:
return s;
case 1:
*(unsigned char *)s = pattern;
return s;
case 2:
*(unsigned short *)s = pattern;
return s;
case 3:
*(unsigned short *)s = pattern;
*(2+(unsigned char *)s) = pattern;
return s;
case 4:
*(unsigned long *)s = pattern;
return s;
}
#define COMMON(x) \
__asm__("cld\n\t" \
"rep ; stosl" \
x \
: /* no outputs */ \
: "a" (pattern),"c" (count/4),"D" ((long) s) \
: "cx","di","memory")
switch (count % 4) {
case 0: COMMON(""); return s;
case 1: COMMON("\n\tstosb"); return s;
case 2: COMMON("\n\tstosw"); return s;
case 3: COMMON("\n\tstosw\n\tstosb"); return s;
}
#undef COMMON
}
#define __constant_c_x_memset(s, c, count) \
(__builtin_constant_p(count) ? \
__constant_c_and_count_memset((s),(c),(count)) : \
__constant_c_memset((s),(c),(count)))
#define __memset(s, c, count) \
(__builtin_constant_p(count) ? \
__constant_count_memset((s),(c),(count)) : \
__memset_generic((s),(c),(count)))
#define __HAVE_ARCH_MEMSET
#define memset(s, c, count) \
(__builtin_constant_p(c) ? \
__constant_c_x_memset((s),(0x01010101UL*(unsigned char)c),(count)) : \
__memset((s),(c),(count)))
/*
* find the first occurrence of byte 'c', or 1 past the area if none
*/
#define __HAVE_ARCH_MEMSCAN
extern inline void * memscan(void * addr, int c, size_t size)
{
if (!size)
return addr;
__asm__("cld
repnz; scasb
jnz 1f
dec %%edi
1: "
: "=D" (addr), "=c" (size)
: "0" (addr), "1" (size), "a" (c));
return addr;
}
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif /* _LINUX_STRING_H_ */
#endif /* _STRING_H_ */

View file

@ -1,128 +1,119 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef __dj_include_sys_stat_h_
#define __dj_include_sys_stat_h_
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __dj_ENFORCE_ANSI_FREESTANDING
/*
* stat.h
*
* Symbolic constants for opening and creating files, also stat, fstat and
* chmod functions.
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.2 $
* $Author: ariadne $
* $Date: 1999/02/21 13:29:57 $
*
*/
#ifndef __STRICT_ANSI__
#define S_ISBLK(m) (((m) & 0xf000) == 0x1000)
#define S_ISCHR(m) (((m) & 0xf000) == 0x2000)
#define S_ISDIR(m) (((m) & 0xf000) == 0x3000)
#define S_ISFIFO(m) (((m) & 0xf000) == 0x4000)
#define S_ISREG(m) (((m) & 0xf000) == 0x0000)
#define S_ISUID 0x80000000
#define S_ISGID 0x40000000
#define S_IRUSR 00400
#define S_IRGRP 00040
#define S_IROTH 00004
#define S_IWUSR 00200
#define S_IWGRP 00020
#define S_IWOTH 00002
#define S_IXUSR 00100
#define S_IXGRP 00010
#define S_IXOTH 00001
#define S_IRWXU 00700
#define S_IRWXG 00070
#define S_IRWXO 00007
#ifndef _STAT_H_
#define _STAT_H_
#include <sys/types.h>
#include <internal/types.h>
//#include <sys/djtypes.h>
__DJ_time_t
#undef __DJ_time_t
#define __DJ_time_t
struct stat {
time_t st_atime;
time_t st_ctime;
dev_t st_dev;
gid_t st_gid;
ino_t st_ino;
mode_t st_mode;
time_t st_mtime;
nlink_t st_nlink;
off_t st_size;
off_t st_blksize;
uid_t st_uid;
dev_t st_rdev; /* unused */
#ifdef __cplusplus
extern "C" {
#endif
/*
* Constants for the stat st_mode member.
*/
#define S_IFIFO 0x1000 /* FIFO */
#define S_IFCHR 0x2000 /* Character */
#define S_IFBLK 0x3000 /* Block */
#define S_IFDIR 0x4000 /* Directory */
#define S_IFREG 0x8000 /* Regular */
#define S_IFMT 0xF000 /* File type mask */
#define S_IEXEC 0x0040
#define S_IWRITE 0x0080
#define S_IREAD 0x0100
#define _S_IREAD S_IREAD
#define _S_IWRITE S_IWRITE
#define _S_IEXEC S_IEXEC
#define S_ISDIR(m) ((m) & S_IFDIR)
#define S_ISFIFO(m) ((m) & S_IFIFO)
#define S_ISCHR(m) ((m) & S_IFCHR)
#define S_ISBLK(m) ((m) & S_IFBLK)
#define S_ISREG(m) ((m) & S_IFREG)
#define S_IRWXU (S_IREAD | S_IWRITE | S_IEXEC)
#define S_IXUSR S_IEXEC
#define S_IWUSR S_IWRITE
#define S_IRUSR S_IREAD
/*
* The structure manipulated and returned by stat and fstat.
*
* NOTE: If called on a directory the values in the time fields are not only
* invalid, they will cause localtime et. al. to return NULL. And calling
* asctime with a NULL pointer causes an Invalid Page Fault. So watch it!
*/
struct stat
{
short st_dev; /* Equivalent to drive number 0=A 1=B ... */
short st_ino; /* Always zero ? */
short st_mode; /* See above constants */
short st_nlink; /* Number of links. */
int st_uid; /* User: Maybe significant on NT ? */
short st_gid; /* Group: Ditto */
short st_rdev; /* Seems useless (not even filled in) */
long st_size; /* File size in bytes */
time_t st_atime; /* Accessed date (always 00:00 hrs local
* on FAT) */
time_t st_mtime; /* Modified time */
time_t st_ctime; /* Creation time */
};
int chmod(const char *_path, mode_t _mode);
int fstat(int _fildes, struct stat *_buf);
//int mkdir(const char *_path, mode_t _mode);
int mkfifo(const char *_path, mode_t _mode);
int stat(const char *_path, struct stat *_buf);
mode_t umask(mode_t _cmask);
#ifndef _POSIX_SOURCE
int _fstat (int nHandle, struct stat* pstat);
int _chmod (const char* szPath, int nMode);
int _stat (const char* szPath, struct stat* pstat);
/* POSIX.1 doesn't mention these at all */
#define S_IFMT 0xf000
#ifndef _NO_OLDNAMES
#define S_IFREG 0x0000
#define S_IFBLK 0x1000
#define S_IFCHR 0x2000
#define S_IFDIR 0x3000
#define S_IFIFO 0x4000
#define S_IFFIFO S_IFIFO
/* These functions live in liboldnames.a. */
int fstat (int nHandle, struct stat* pstat);
int chmod (const char* szPath, int nMode);
int stat (const char* szPath, struct stat* pstat);
#define S_IFLABEL 0x5000
#define S_ISLABEL(m) (((m) & 0xf000) == 0x5000)
#endif /* Not _NO_OLDNAMES */
void _fixpath(const char *, char *);
unsigned short _get_magic(const char *, int);
int _is_executable(const char *, int, const char *);
int mknod(const char *_path, mode_t _mode, dev_t _dev);
char * _truename(const char *, char *);
/* Bit-mapped variable _djstat_flags describes what expensive
f?stat() features our application needs. If you don't need a
feature, set its bit in the variable. By default, all the
bits are cleared (i.e., you get the most expensive code). */
#define _STAT_INODE 1 /* should we bother getting inode numbers? */
#define _STAT_EXEC_EXT 2 /* get execute bits from file extension? */
#define _STAT_EXEC_MAGIC 4 /* get execute bits from magic signature? */
#define _STAT_DIRSIZE 8 /* compute directory size? */
#define _STAT_ROOT_TIME 0x10 /* try to get root dir time stamp? */
#define _STAT_WRITEBIT 0x20 /* fstat() needs write bit? */
extern unsigned short _djstat_flags;
/* Bit-mapped variable _djstat_fail_bits describes which individual
undocumented features f?stat() failed to use. To get a human-
readable description of the bits, call _djstat_describe_lossage(). */
#define _STFAIL_SDA 1 /* Get SDA call failed */
#define _STFAIL_OSVER 2 /* Unsupported DOS version */
#define _STFAIL_BADSDA 4 /* Bad pointer to SDA */
#define _STFAIL_TRUENAME 8 /* _truename() failed */
#define _STFAIL_HASH 0x10 /* inode defaults to hashing */
#define _STFAIL_LABEL 0x20 /* Root dir, but no volume label */
#define _STFAIL_DCOUNT 0x40 /* dirent_count ridiculously large */
#define _STFAIL_WRITEBIT 0x80 /* fstat() failed to get write access bit */
#define _STFAIL_DEVNO 0x100 /* fstat() failed to get device number */
#define _STFAIL_BADSFT 0x200 /* SFT entry found, but can't be trusted */
#define _STFAIL_SFTIDX 0x400 /* bad SFT index in JFT */
#define _STFAIL_SFTNF 0x800 /* file entry not found in SFT array */
extern unsigned short _djstat_fail_bits;
#endif /* !_POSIX_SOURCE */
#endif /* !__STRICT_ANSI__ */
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
#ifndef __dj_ENFORCE_FUNCTION_CALLS
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */
#ifdef __cplusplus
#ifdef __cplusplus
}
#endif
#endif /* !__dj_include_sys_stat_h_ */
#endif /* Not _STAT_H_ */
#endif /* Not __STRICT_ANSI__ */

View file

@ -1,67 +1,112 @@
/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef __dj_include_sys_types_h_
#define __dj_include_sys_types_h_
/*
* types.h
*
* The definition of constants, data types and global variables.
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
* Lots of types supplied by Pedro A. Aranda <paag@tid.es>
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAMED. This includes but is not limited to warrenties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.2 $
* $Author: ariadne $
* $Date: 1999/02/21 13:29:57 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
#ifdef __cplusplus
extern "C" {
#ifndef _TYPES_H_
#define _TYPES_H_
#define __need_wchar_t
#define __need_size_t
#define __need_ptrdiff_t
#include <stddef.h>
#ifndef RC_INVOKED
#ifndef _TIME_T_
#define _TIME_T_
typedef long time_t;
#endif
#ifndef __dj_ENFORCE_ANSI_FREESTANDING
#ifndef __STRICT_ANSI__
#ifndef __STRICT_ANSI__
#include <sys/djtypes.h>
typedef int dev_t;
typedef int ino_t;
typedef int mode_t;
typedef int nlink_t;
#ifndef _OFF_T_
#define _OFF_T_
typedef long _off_t;
__DJ_gid_t
#undef __DJ_gid_t
#define __DJ_gid_t
__DJ_off_t
#undef __DJ_off_t
#define __DJ_off_t
__DJ_pid_t
#undef __DJ_pid_t
#define __DJ_pid_t
//__DJ_size_t
#undef __DJ_size_t
#define __DJ_size_t
__DJ_ssize_t
#undef __DJ_ssize_t
#define __DJ_ssize_t
__DJ_uid_t
#undef __DJ_uid_t
#define __DJ_uid_t
#ifndef _POSIX_SOURCE
/* Allow including program to override. */
#ifndef FD_SETSIZE
#define FD_SETSIZE 256
#ifndef _NO_OLDNAMES
typedef _off_t off_t;
#endif
#endif /* Not _OFF_T_ */
typedef struct fd_set {
unsigned char fd_bits [((FD_SETSIZE) + 7) / 8];
} fd_set;
#define FD_SET(n, p) ((p)->fd_bits[(n) / 8] |= (1 << ((n) & 7)))
#define FD_CLR(n, p) ((p)->fd_bits[(n) / 8] &= ~(1 << ((n) & 7)))
#define FD_ISSET(n, p) ((p)->fd_bits[(n) / 8] & (1 << ((n) & 7)))
#define FD_ZERO(p) memset ((void *)(p), 0, sizeof (*(p)))
#ifndef _DEV_T_
#define _DEV_T_
typedef short _dev_t;
#endif /* !_POSIX_SOURCE */
#endif /* !__STRICT_ANSI__ */
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
#ifndef __dj_ENFORCE_FUNCTION_CALLS
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */
#ifdef __cplusplus
}
#ifndef _NO_OLDNAMES
typedef _dev_t dev_t;
#endif
#endif /* Not _DEV_T_ */
#endif /* !__dj_include_sys_types_h_ */
#ifndef _INO_T_
#define _INO_T_
typedef short _ino_t;
#ifndef _NO_OLDNAMES
typedef _ino_t ino_t;
#endif
#endif /* Not _INO_T_ */
#ifndef _PID_T_
#define _PID_T_
typedef int _pid_t;
#ifndef _NO_OLDNAMES
typedef _pid_t pid_t;
#endif
#endif /* Not _PID_T_ */
#ifndef _MODE_T_
#define _MODE_T_
typedef unsigned short _mode_t;
#ifndef _NO_OLDNAMES
typedef _mode_t mode_t;
#endif
#endif /* Not _MODE_T_ */
#ifndef _SIGSET_T_
#define _SIGSET_T_
typedef int _sigset_t;
#ifndef _NO_OLDNAMES
typedef _sigset_t sigset_t;
#endif
#endif /* Not _SIGSET_T_ */
#endif /* Not __STRICT_ANSI__ */
#endif /* Not RC_INVOKED */
#endif /* Not _TYPES_H_ */

View file

@ -1,35 +1,74 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef __dj_include_time_h_
#define __dj_include_time_h_
/*
* time.h
*
* Date and time functions and types.
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.2 $
* $Author: ariadne $
* $Date: 1999/02/21 13:29:57 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
#ifndef _TIME_H_
#define _TIME_H_
#ifdef __cplusplus
#define __need_wchar_t
#define __need_size_t
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __dj_ENFORCE_ANSI_FREESTANDING
/*
* Number of clock ticks per second. A clock tick is the unit by which
* processor time is measured and is returned by 'clock'.
*/
#define CLOCKS_PER_SEC 1000.0
#define CLK_TICK CLOCKS_PER_SEC
/* 65536(tics/hour) / 3600(sec/hour) * 5(scale) = 91.02
The 5 is to make it a whole number (18.2*5=91) so that
floating point ops aren't required to use it. */
#define CLOCKS_PER_SEC 91
#include <sys/djtypes.h>
#include <internal/types.h>
#ifndef NULL
#define NULL 0
/*
* A type for measuring processor time (in clock ticks).
*/
#ifndef _CLOCK_T_
#define _CLOCK_T_
typedef long clock_t;
#endif
__DJ_clock_t
#undef __DJ_clock_t
#define __DJ_clock_t
//__DJ_size_t
#undef __DJ_size_t
#define __DJ_size_t
__DJ_time_t
#undef __DJ_time_t
#define __DJ_time_t
/*
* Need a definition of time_t.
*/
#include <sys/types.h>
#ifndef _TM_DEFINED
/*
* A type for storing the current time and date. This is the number of
* seconds since midnight Jan 1, 1970.
* NOTE: Normally this is defined by the above include of sys/types.h
*/
#ifndef _TIME_T_
#define _TIME_T_
typedef long time_t;
#endif
/*
* A structure for storing all kinds of useful information about the
* current (or another) time.
*/
struct tm {
int tm_sec;
int tm_min;
@ -43,62 +82,38 @@ struct tm {
char *tm_zone;
int tm_gmtoff;
};
#define _TM_DEFINED
#endif
char * asctime(const struct tm *_tptr);
clock_t clock(void);
char * ctime(const time_t *_cal);
double difftime(time_t _t1, time_t _t0);
struct tm * gmtime(const time_t *_tod);
struct tm * localtime(const time_t *_tod);
time_t mktime(struct tm *_tptr);
size_t strftime(char *_s, size_t _n, const char *_format, const struct tm *_tptr);
time_t time(time_t *_tod);
#ifndef __STRICT_ANSI__
#define CLK_TCK CLOCKS_PER_SEC
clock_t clock (void);
time_t time (time_t* tp);
double difftime (time_t t2, time_t t1);
time_t mktime (struct tm* tmsp);
extern char *tzname[2];
/*
* These functions write to and return pointers to static buffers that may
* be overwritten by other function calls. Yikes!
*
* NOTE: localtime, and perhaps the others of the four functions grouped
* below may return NULL if their argument is not 'acceptable'. Also note
* that calling asctime with a NULL pointer will produce an Invalid Page
* Fault and crap out your program. Guess how I know. Hint: stat called on
* a directory gives 'invalid' times in st_atime etc...
*/
char* asctime (const struct tm* tmsp);
char* ctime (const time_t* tp);
struct tm* gmtime (const time_t* tm);
struct tm* localtime (const time_t* tm);
void tzset(void);
#ifndef _POSIX_SOURCE
size_t strftime (char* caBuffer, size_t sizeMax, const char* szFormat,
const struct tm* tpPrint);
//#define tm_zone __tm_zone
//#define tm_gmtoff __tm_gmtoff
size_t wcsftime (wchar_t* wcaBuffer, size_t sizeMax,
const wchar_t* wsFormat, const struct tm* tpPrint);
struct timeval {
time_t tv_sec;
long tv_usec;
};
struct timezone {
int tz_minuteswest;
int tz_dsttime;
};
#include <sys/types.h>
typedef long long uclock_t;
#define UCLOCKS_PER_SEC 1193180
int gettimeofday(struct timeval *_tp, struct timezone *_tzp);
unsigned long rawclock(void);
int select(int _nfds, fd_set *_readfds, fd_set *_writefds, fd_set *_exceptfds, struct timeval *_timeout);
int settimeofday(struct timeval *_tp, ...);
uclock_t uclock(void);
#endif /* !_POSIX_SOURCE */
#endif /* !__STRICT_ANSI__ */
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
#ifndef __dj_ENFORCE_FUNCTION_CALLS
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */
#ifdef __cplusplus
#ifdef __cplusplus
}
#endif
#endif /* !__dj_include_time_h_ */
#endif

View file

@ -1,81 +1,32 @@
/*
* Adapted from linux for the reactos kernel, march 1998 -- David Welch
* Added wide character string functions, june 1998 -- Boudewijn Dekker
* Removed extern specifier from ___wcstok, june 1998 -- Boudewijn Dekker
* Added wcsicmp and wcsnicmp -- Boudewijn Dekker
* wchar.h
*
* Defines of all functions for supporting wide characters. Actually it
* just includes all those headers, which is not a good thing to do from a
* processing time point of view, but it does mean that everything will be
* in sync.
*
* This file is part of the Mingw32 package.
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.2 $
* $Author: ariadne $
* $Date: 1999/02/21 13:29:57 $
*
*/
#include <internal/types.h>
#ifndef _LINUX_WSTRING_H_
#define _LINUX_WSTRING_H_
#ifndef _WCHAR_T_
#define _WCHAR_T_
#define _WCHAR_T
typedef unsigned short wchar_t;
#endif
#define Aa_Difference (L'A'-L'a')
#define towupper(c) (((c>=L'a') && (c<=L'z')) ? c+Aa_Difference : c)
#define towlower(c) (((c>=L'A') && (c<=L'Z')) ? c-Aa_Difference : c)
//obsolete
wchar_t wtolower(wchar_t c );
wchar_t wtoupper(wchar_t c );
#define iswlower(c) ((c) >= L'a' && (c) <= L'z')
#define iswupper(c) ((c) >= L'A' && (c) <= L'Z')
#define iswdigit(c) ((c) >= L'0' && (c) <= L'9')
#define iswxdigit(c) (((c) >= L'0' && (c) <= L'9') || ((c) >= L'A' && (c) <= L'F') || ((c) >= L'a' && (c) <= L'f') )
#ifndef NULL
#define NULL ((void *) 0)
#endif
#ifdef __cplusplus
extern "C" {
#endif
//wchar_t * ___wcstok = NULL;
wchar_t * wcscpy(wchar_t *,const wchar_t *);
wchar_t * wcsncpy(wchar_t *,const wchar_t *, size_t);
wchar_t * wcscat(wchar_t *, const wchar_t *);
wchar_t * wcsncat(wchar_t *, const wchar_t *, size_t);
int wcscmp(const wchar_t *,const wchar_t *);
int wcsncmp(const wchar_t *,const wchar_t *,size_t);
wchar_t* wcschr(const wchar_t* str, wchar_t ch);
wchar_t * wcsrchr(const wchar_t *,wchar_t);
wchar_t * wcspbrk(const wchar_t *,const wchar_t *);
wchar_t * wcstok(wchar_t *,const wchar_t *);
wchar_t * wcsstr(const wchar_t *,const wchar_t *);
size_t wcslen(const wchar_t * s);
size_t wcsnlen(const wchar_t * s, size_t count);
int wcsicmp(const wchar_t* cs,const wchar_t * ct);
int wcsnicmp(const wchar_t* cs,const wchar_t * ct, size_t count);
size_t wcsspn(const wchar_t *str,const wchar_t *accept);
size_t wcscspn(const wchar_t *str,const wchar_t *reject);
wchar_t *wcsrev(wchar_t *s);
wchar_t *wcsstr(const wchar_t *s,const wchar_t *b);
wchar_t *wcsdup(const wchar_t *ptr);
wchar_t *wcsupr(wchar_t *x);
wchar_t * wcslwr(wchar_t *x);
//obsolete
size_t wstrlen(const wchar_t * s);
int wcscmpi (const wchar_t* ws1, const wchar_t* ws2);
#ifdef __cplusplus
}
#endif
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>