(2006-08-06) rescue-bootcd

This commit is contained in:
2006-08-06 00:00:00 +02:00
parent 2f796b816a
commit decb062d20
21091 changed files with 7076462 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
/*
* bits32/limits.h
*/
#ifndef _BITSIZE_LIMITS_H
#define _BITSIZE_LIMITS_H
#define LONG_BIT 32
#define LONG_MIN (-2147483647L-1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
#endif /* _BITSIZE_LIMITS_H */

View File

@@ -0,0 +1,18 @@
/*
* bits32/stddef.h
*/
#ifndef _BITSIZE_STDDEF_H
#define _BITSIZE_STDDEF_H
#define _SIZE_T
#if defined(__s390__) || defined(__hppa__) || defined(__cris__)
typedef unsigned long size_t;
#else
typedef unsigned int size_t;
#endif
#define _PTRDIFF_T
typedef signed int ptrdiff_t;
#endif /* _BITSIZE_STDDEF_H */

View File

@@ -0,0 +1,34 @@
/*
* bits32/stdint.h
*/
#ifndef _BITSIZE_STDINT_H
#define _BITSIZE_STDINT_H
typedef signed char int8_t;
typedef short int int16_t;
typedef int int32_t;
typedef long long int int64_t;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t;
typedef int int_fast16_t;
typedef int int_fast32_t;
typedef unsigned int uint_fast16_t;
typedef unsigned int uint_fast32_t;
typedef int intptr_t;
typedef unsigned int uintptr_t;
#define __INT64_C(c) c ## LL
#define __UINT64_C(c) c ## ULL
#define __PRI64_RANK "ll"
#define __PRIFAST_RANK ""
#define __PRIPTR_RANK ""
#endif /* _BITSIZE_STDINT_H */

View File

@@ -0,0 +1,18 @@
/*
* bits32/stdintconst.h
*/
#ifndef _BITSIZE_STDINTCONST_H
#define _BITSIZE_STDINTCONST_H
#define INT_FAST16_C(c) INT32_C(c)
#define INT_FAST32_C(c) INT32_C(c)
#define UINT_FAST16_C(c) UINT32_C(c)
#define UINT_FAST32_C(c) UINT32_C(c)
#define INTPTR_C(c) INT32_C(c)
#define UINTPTR_C(c) UINT32_C(c)
#define PTRDIFF_C(c) INT32_C(c)
#endif /* _BITSIZE_STDINTCONST_H */

View File

@@ -0,0 +1,22 @@
/*
* bits32/stdintlimits.h
*/
#ifndef _BITSIZE_STDINTLIMITS_H
#define _BITSIZE_STDINTLIMITS_H
#define INT_FAST16_MIN INT32_MIN
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST16_MAX INT32_MAX
#define INT_FAST32_MAX INT32_MAX
#define UINT_FAST16_MAX UINT32_MAX
#define UINT_FAST32_MAX UINT32_MAX
#define INTPTR_MIN INT32_MIN
#define INTPTR_MAX INT32_MAX
#define UINTPTR_MAX UINT32_MAX
#define PTRDIFF_MIN INT32_MIN
#define PTRDIFF_MAX INT32_MAX
#endif /* _BITSIZE_STDINTLIMITS_H */

View File

@@ -0,0 +1,117 @@
/* ----------------------------------------------------------------------- *
* Not Copyright 2002 H. Peter Anvin
* This file is in the public domain.
* ----------------------------------------------------------------------- */
/*
* com32.h
*
* Common declarations for com32 programs.
*/
#ifndef _COM32_H
#define _COM32_H
#include <stdint.h>
#include <klibc/compiler.h> /* For __cdecl */
/*
* This structure defines the register frame used by the
* system call interface.
*
* The syscall interface is:
*
* __intcall(interrupt_#, source_regs, return_regs)
* __farcall(seg, offs, source_regs, return_regs)
*/
typedef union {
uint32_t l;
uint16_t w[2];
uint8_t b[4];
} reg32_t;
typedef struct {
uint16_t gs; /* Offset 0 */
uint16_t fs; /* Offset 2 */
uint16_t es; /* Offset 4 */
uint16_t ds; /* Offset 6 */
reg32_t edi; /* Offset 8 */
reg32_t esi; /* Offset 12 */
reg32_t ebp; /* Offset 16 */
reg32_t _unused; /* Offset 20 */
reg32_t ebx; /* Offset 24 */
reg32_t edx; /* Offset 28 */
reg32_t ecx; /* Offset 32 */
reg32_t eax; /* Offset 36 */
reg32_t eflags; /* Offset 40 */
} com32sys_t;
/* EFLAGS definitions */
#define EFLAGS_CF 0x00000001
#define EFLAGS_PF 0x00000004
#define EFLAGS_AF 0x00000010
#define EFLAGS_ZF 0x00000040
#define EFLAGS_SF 0x00000080
#define EFLAGS_TF 0x00000100
#define EFLAGS_IF 0x00000200
#define EFLAGS_DF 0x00000400
#define EFLAGS_OF 0x00000800
#define EFLAGS_IOPL 0x00003000
#define EFLAGS_NT 0x00004000
#define EFLAGS_RF 0x00010000
#define EFLAGS_VM 0x00020000
#define EFLAGS_AC 0x00040000
#define EFLAGS_VIF 0x00080000
#define EFLAGS_VIP 0x00100000
#define EFLAGS_ID 0x00200000
extern struct com32_sys_args {
uint32_t cs_sysargs;
char *cs_cmdline;
void __cdecl (*cs_intcall)(uint8_t, const com32sys_t *, com32sys_t *);
void *cs_bounce;
uint32_t cs_bounce_size;
void __cdecl (*cs_farcall)(uint32_t, const com32sys_t *, com32sys_t *);
} __com32;
/*
* System call macros
*/
static inline void
__intcall(uint8_t __i, const com32sys_t *__sr, com32sys_t *__dr)
{
__com32.cs_intcall(__i, __sr, __dr);
}
static inline void
__farcall(uint16_t __es, uint16_t __eo,
const com32sys_t *__sr, com32sys_t *__dr)
{
__com32.cs_farcall((__es << 16) + __eo, __sr, __dr);
}
/*
* These functions convert between linear pointers in the range
* 0..0xFFFFF and real-mode style SEG:OFFS pointers. Note that a
* 32-bit linear pointer is not compatible with a SEG:OFFS pointer
* stored in two consecutive 16-bit words.
*/
static inline uint16_t SEG(void *__p)
{
return (uint16_t)(((uintptr_t)__p) >> 4);
}
static inline uint16_t OFFS(void *__p)
{
/* The double cast here is to shut up gcc */
return (uint16_t)(uintptr_t)__p & 0x000F;
}
static inline void *MK_PTR(uint16_t __seg, uint16_t __offs)
{
return (void *)((__seg << 4) + __offs);
}
#endif /* _COM32_H */

View File

@@ -0,0 +1,60 @@
#ident "$Id: console.h,v 1.4 2004/11/30 22:09:56 hpa Exp $"
/* ----------------------------------------------------------------------- *
*
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall
* be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* ----------------------------------------------------------------------- */
/*
* console.h
*
* Alternative consoles
*/
#ifndef _CONSOLE_H
#define _CONSOLE_H
#include <klibc/extern.h>
#include <dev.h>
__extern int openconsole(const struct input_dev *, const struct output_dev *);
/* Standard line-oriented console */
extern const struct input_dev dev_stdcon_r;
extern const struct output_dev dev_stdcon_w;
/* Raw character-oriented console */
extern const struct input_dev dev_rawcon_r;
extern const struct output_dev dev_rawcon_w;
/* These are output-only consoles; combine with one of the input methods */
/* Serial port only */
extern const struct output_dev dev_serial_w;
/* ANSI console (output only; combine with one of the input methods) */
extern const struct output_dev dev_ansicon_w;
/* ANSI plus serial port */
extern const struct output_dev dev_ansiserial_w;
#endif /* _CONSOLE_H */

View File

@@ -0,0 +1,119 @@
/*
* ctype.h
*
* This assumes ISO 8859-1, being a reasonable superset of ASCII.
*/
#ifndef _CTYPE_H
#define _CTYPE_H
#ifndef __CTYPE_NO_INLINE
# define __ctype_inline extern __inline__
#else
# define __ctype_inline
#endif
/*
* This relies on the following definitions:
*
* cntrl = !print
* alpha = upper|lower
* graph = punct|alpha|digit
* blank = '\t' || ' ' (per POSIX requirement)
*/
enum {
__ctype_upper = (1 << 0),
__ctype_lower = (1 << 1),
__ctype_digit = (1 << 2),
__ctype_xdigit = (1 << 3),
__ctype_space = (1 << 4),
__ctype_print = (1 << 5),
__ctype_punct = (1 << 6),
__ctype_cntrl = (1 << 7),
};
extern const unsigned char __ctypes[];
__ctype_inline int isalnum(int __c)
{
return __ctypes[__c+1] &
(__ctype_upper|__ctype_lower|__ctype_digit);
}
__ctype_inline int isalpha(int __c)
{
return __ctypes[__c+1] &
(__ctype_upper|__ctype_lower);
}
__ctype_inline int isascii(int __c)
{
return !(__c & ~0x7f);
}
__ctype_inline int isblank(int __c)
{
return (__c == '\t') || (__c == ' ');
}
__ctype_inline int iscntrl(int __c)
{
return __ctypes[__c+1] & __ctype_cntrl;
}
__ctype_inline int isdigit(int __c)
{
return ((unsigned)__c - '0') <= 9;
}
__ctype_inline int isgraph(int __c)
{
return __ctypes[__c+1] &
(__ctype_upper|__ctype_lower|__ctype_digit|__ctype_punct);
}
__ctype_inline int islower(int __c)
{
return __ctypes[__c+1] & __ctype_lower;
}
__ctype_inline int isprint(int __c)
{
return __ctypes[__c+1] & __ctype_print;
}
__ctype_inline int ispunct(int __c)
{
return __ctypes[__c+1] & __ctype_punct;
}
__ctype_inline int isspace(int __c)
{
return __ctypes[__c+1] & __ctype_space;
}
__ctype_inline int isupper(int __c)
{
return __ctypes[__c+1] & __ctype_upper;
}
__ctype_inline int isxdigit(int __c)
{
return __ctypes[__c+1] & __ctype_xdigit;
}
/* Note: this is decimal, not hex, to avoid accidental promotion to unsigned */
#define _toupper(__c) ((__c) & ~32)
#define _tolower(__c) ((__c) | 32)
__ctype_inline int toupper(int __c)
{
return islower(__c) ? _toupper(__c) : __c;
}
__ctype_inline int tolower(int __c)
{
return isupper(__c) ? _tolower(__c) : __c;
}
#endif /* _CTYPE_H */

View File

@@ -0,0 +1,57 @@
#ident "$Id: dev.h,v 1.2 2004/11/30 22:09:56 hpa Exp $"
/* ----------------------------------------------------------------------- *
*
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall
* be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* ----------------------------------------------------------------------- */
/*
* console.h
*
* Alternative consoles
*/
#ifndef _DEV_H
#define _DEV_H
#include <klibc/extern.h>
#include <stdint.h>
struct input_dev;
struct output_dev;
__extern int opendev(const struct input_dev *, const struct output_dev *, int);
/* Common generic devices */
/* Null device */
extern const struct input_dev dev_null_r;
extern const struct output_dev dev_null_w;
/* Error device */
extern const struct input_dev dev_error_r;
extern const struct output_dev dev_error_w;
#endif /* _DEV_H */

View File

@@ -0,0 +1,135 @@
#ifndef _ERRNO_H
#define _ERRNO_H
extern int errno;
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EIO 5 /* I/O error */
#define ENXIO 6 /* No such device or address */
#define E2BIG 7 /* Arg list too long */
#define ENOEXEC 8 /* Exec format error */
#define EBADF 9 /* Bad file number */
#define ECHILD 10 /* No child processes */
#define EAGAIN 11 /* Try again */
#define ENOMEM 12 /* Out of memory */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
#define ENOTBLK 15 /* Block device required */
#define EBUSY 16 /* Device or resource busy */
#define EEXIST 17 /* File exists */
#define EXDEV 18 /* Cross-device link */
#define ENODEV 19 /* No such device */
#define ENOTDIR 20 /* Not a directory */
#define EISDIR 21 /* Is a directory */
#define EINVAL 22 /* Invalid argument */
#define ENFILE 23 /* File table overflow */
#define EMFILE 24 /* Too many open files */
#define ENOTTY 25 /* Not a typewriter */
#define ETXTBSY 26 /* Text file busy */
#define EFBIG 27 /* File too large */
#define ENOSPC 28 /* No space left on device */
#define ESPIPE 29 /* Illegal seek */
#define EROFS 30 /* Read-only file system */
#define EMLINK 31 /* Too many links */
#define EPIPE 32 /* Broken pipe */
#define EDOM 33 /* Math argument out of domain of func */
#define ERANGE 34 /* Math result not representable */
#define EDEADLK 35 /* Resource deadlock would occur */
#define ENAMETOOLONG 36 /* File name too long */
#define ENOLCK 37 /* No record locks available */
#define ENOSYS 38 /* Function not implemented */
#define ENOTEMPTY 39 /* Directory not empty */
#define ELOOP 40 /* Too many symbolic links encountered */
#define EWOULDBLOCK EAGAIN /* Operation would block */
#define ENOMSG 42 /* No message of desired type */
#define EIDRM 43 /* Identifier removed */
#define ECHRNG 44 /* Channel number out of range */
#define EL2NSYNC 45 /* Level 2 not synchronized */
#define EL3HLT 46 /* Level 3 halted */
#define EL3RST 47 /* Level 3 reset */
#define ELNRNG 48 /* Link number out of range */
#define EUNATCH 49 /* Protocol driver not attached */
#define ENOCSI 50 /* No CSI structure available */
#define EL2HLT 51 /* Level 2 halted */
#define EBADE 52 /* Invalid exchange */
#define EBADR 53 /* Invalid request descriptor */
#define EXFULL 54 /* Exchange full */
#define ENOANO 55 /* No anode */
#define EBADRQC 56 /* Invalid request code */
#define EBADSLT 57 /* Invalid slot */
#define EDEADLOCK EDEADLK
#define EBFONT 59 /* Bad font file format */
#define ENOSTR 60 /* Device not a stream */
#define ENODATA 61 /* No data available */
#define ETIME 62 /* Timer expired */
#define ENOSR 63 /* Out of streams resources */
#define ENONET 64 /* Machine is not on the network */
#define ENOPKG 65 /* Package not installed */
#define EREMOTE 66 /* Object is remote */
#define ENOLINK 67 /* Link has been severed */
#define EADV 68 /* Advertise error */
#define ESRMNT 69 /* Srmount error */
#define ECOMM 70 /* Communication error on send */
#define EPROTO 71 /* Protocol error */
#define EMULTIHOP 72 /* Multihop attempted */
#define EDOTDOT 73 /* RFS specific error */
#define EBADMSG 74 /* Not a data message */
#define EOVERFLOW 75 /* Value too large for defined data type */
#define ENOTUNIQ 76 /* Name not unique on network */
#define EBADFD 77 /* File descriptor in bad state */
#define EREMCHG 78 /* Remote address changed */
#define ELIBACC 79 /* Can not access a needed shared library */
#define ELIBBAD 80 /* Accessing a corrupted shared library */
#define ELIBSCN 81 /* .lib section in a.out corrupted */
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
#define ELIBEXEC 83 /* Cannot exec a shared library directly */
#define EILSEQ 84 /* Illegal byte sequence */
#define ERESTART 85 /* Interrupted system call should be restarted */
#define ESTRPIPE 86 /* Streams pipe error */
#define EUSERS 87 /* Too many users */
#define ENOTSOCK 88 /* Socket operation on non-socket */
#define EDESTADDRREQ 89 /* Destination address required */
#define EMSGSIZE 90 /* Message too long */
#define EPROTOTYPE 91 /* Protocol wrong type for socket */
#define ENOPROTOOPT 92 /* Protocol not available */
#define EPROTONOSUPPORT 93 /* Protocol not supported */
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
#define EPFNOSUPPORT 96 /* Protocol family not supported */
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
#define EADDRINUSE 98 /* Address already in use */
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
#define ENETDOWN 100 /* Network is down */
#define ENETUNREACH 101 /* Network is unreachable */
#define ENETRESET 102 /* Network dropped connection because of reset */
#define ECONNABORTED 103 /* Software caused connection abort */
#define ECONNRESET 104 /* Connection reset by peer */
#define ENOBUFS 105 /* No buffer space available */
#define EISCONN 106 /* Transport endpoint is already connected */
#define ENOTCONN 107 /* Transport endpoint is not connected */
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
#define ETOOMANYREFS 109 /* Too many references: cannot splice */
#define ETIMEDOUT 110 /* Connection timed out */
#define ECONNREFUSED 111 /* Connection refused */
#define EHOSTDOWN 112 /* Host is down */
#define EHOSTUNREACH 113 /* No route to host */
#define EALREADY 114 /* Operation already in progress */
#define EINPROGRESS 115 /* Operation now in progress */
#define ESTALE 116 /* Stale NFS file handle */
#define EUCLEAN 117 /* Structure needs cleaning */
#define ENOTNAM 118 /* Not a XENIX named type file */
#define ENAVAIL 119 /* No XENIX semaphores available */
#define EISNAM 120 /* Is a named type file */
#define EREMOTEIO 121 /* Remote I/O error */
#define EDQUOT 122 /* Quota exceeded */
#define ENOMEDIUM 123 /* No medium found */
#define EMEDIUMTYPE 124 /* Wrong medium type */
#endif /* _ERRNO_H */

View File

@@ -0,0 +1,24 @@
/*
* fcntl.h
*/
#ifndef _FCNTL_H
#define _FCNTL_H
#include <klibc/extern.h>
#include <klibc/compiler.h>
#include <sys/types.h>
/* None of these are actually supported, although O_RDONLY works */
/* Note this is different from the classical Unix way of doing it */
#define O_RDONLY 1
#define O_WRONLY 2
#define O_RDWR 3
#define O_CREAT 0100
#define O_EXCL 0200
#define O_TRUNC 01000
#define O_APPEND 02000
__extern int open(const char *, int, ...);
#endif /* _FCNTL_H */

View File

@@ -0,0 +1,226 @@
/*
* inttypes.h
*/
#ifndef _INTTYPES_H
#define _INTTYPES_H
#include <klibc/extern.h>
#include <stdint.h>
#include <stddef.h>
static __inline__ intmax_t imaxabs(intmax_t __n)
{
return (__n < (intmax_t)0) ? -__n : __n;
}
__extern intmax_t strtoimax(const char *, char **, int);
__extern uintmax_t strtoumax(const char *, char **, int);
/* extensions */
__extern intmax_t strntoimax(const char *, char **, int, size_t);
__extern uintmax_t strntoumax(const char *, char **, int, size_t);
#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
#define PRId8 "d"
#define PRId16 "d"
#define PRId32 "d"
#define PRId64 __PRI64_RANK "d"
#define PRIdLEAST8 "d"
#define PRIdLEAST16 "d"
#define PRIdLEAST32 "d"
#define PRIdLEAST64 __PRI64_RANK "d"
#define PRIdFAST8 "d"
#define PRIdFAST16 __PRIFAST_RANK "d"
#define PRIdFAST32 __PRIFAST_RANK "d"
#define PRIdFAST64 __PRI64_RANK "d"
#define PRIdMAX __PRI64_RANK "d"
#define PRIdPTR __PRIPTR_RANK "d"
#define PRIi8 "i"
#define PRIi16 "i"
#define PRIi32 "i"
#define PRIi64 __PRI64_RANK "i"
#define PRIiLEAST8 "i"
#define PRIiLEAST16 "i"
#define PRIiLEAST32 "i"
#define PRIiLEAST64 __PRI64_RANK "i"
#define PRIiFAST8 "i"
#define PRIiFAST16 __PRIFAST_RANK "i"
#define PRIiFAST32 __PRIFAST_RANK "i"
#define PRIiFAST64 __PRI64_RANK "i"
#define PRIiMAX __PRI64_RANK "i"
#define PRIiPTR __PRIPTR_RANK "i"
#define PRIo8 "o"
#define PRIo16 "o"
#define PRIo32 "o"
#define PRIo64 __PRI64_RANK "o"
#define PRIoLEAST8 "o"
#define PRIoLEAST16 "o"
#define PRIoLEAST32 "o"
#define PRIoLEAST64 __PRI64_RANK "o"
#define PRIoFAST8 "o"
#define PRIoFAST16 __PRIFAST_RANK "o"
#define PRIoFAST32 __PRIFAST_RANK "o"
#define PRIoFAST64 __PRI64_RANK "o"
#define PRIoMAX __PRI64_RANK "o"
#define PRIoPTR __PRIPTR_RANK "o"
#define PRIu8 "u"
#define PRIu16 "u"
#define PRIu32 "u"
#define PRIu64 __PRI64_RANK "u"
#define PRIuLEAST8 "u"
#define PRIuLEAST16 "u"
#define PRIuLEAST32 "u"
#define PRIuLEAST64 __PRI64_RANK "u"
#define PRIuFAST8 "u"
#define PRIuFAST16 __PRIFAST_RANK "u"
#define PRIuFAST32 __PRIFAST_RANK "u"
#define PRIuFAST64 __PRI64_RANK "u"
#define PRIuMAX __PRI64_RANK "u"
#define PRIuPTR __PRIPTR_RANK "u"
#define PRIx8 "x"
#define PRIx16 "x"
#define PRIx32 "x"
#define PRIx64 __PRI64_RANK "x"
#define PRIxLEAST8 "x"
#define PRIxLEAST16 "x"
#define PRIxLEAST32 "x"
#define PRIxLEAST64 __PRI64_RANK "x"
#define PRIxFAST8 "x"
#define PRIxFAST16 __PRIFAST_RANK "x"
#define PRIxFAST32 __PRIFAST_RANK "x"
#define PRIxFAST64 __PRI64_RANK "x"
#define PRIxMAX __PRI64_RANK "x"
#define PRIxPTR __PRIPTR_RANK "x"
#define PRIX8 "X"
#define PRIX16 "X"
#define PRIX32 "X"
#define PRIX64 __PRI64_RANK "X"
#define PRIXLEAST8 "X"
#define PRIXLEAST16 "X"
#define PRIXLEAST32 "X"
#define PRIXLEAST64 __PRI64_RANK "X"
#define PRIXFAST8 "X"
#define PRIXFAST16 __PRIFAST_RANK "X"
#define PRIXFAST32 __PRIFAST_RANK "X"
#define PRIXFAST64 __PRI64_RANK "X"
#define PRIXMAX __PRI64_RANK "X"
#define PRIXPTR __PRIPTR_RANK "X"
#define SCNd8 "hhd"
#define SCNd16 "hd"
#define SCNd32 "d"
#define SCNd64 __PRI64_RANK "d"
#define SCNdLEAST8 "hhd"
#define SCNdLEAST16 "hd"
#define SCNdLEAST32 "d"
#define SCNdLEAST64 __PRI64_RANK "d"
#define SCNdFAST8 "hhd"
#define SCNdFAST16 __PRIFAST_RANK "d"
#define SCNdFAST32 __PRIFAST_RANK "d"
#define SCNdFAST64 __PRI64_RANK "d"
#define SCNdMAX __PRI64_RANK "d"
#define SCNdPTR __PRIPTR_RANK "d"
#define SCNi8 "hhi"
#define SCNi16 "hi"
#define SCNi32 "i"
#define SCNi64 __PRI64_RANK "i"
#define SCNiLEAST8 "hhi"
#define SCNiLEAST16 "hi"
#define SCNiLEAST32 "i"
#define SCNiLEAST64 __PRI64_RANK "i"
#define SCNiFAST8 "hhi"
#define SCNiFAST16 __PRIFAST_RANK "i"
#define SCNiFAST32 __PRIFAST_RANK "i"
#define SCNiFAST64 __PRI64_RANK "i"
#define SCNiMAX __PRI64_RANK "i"
#define SCNiPTR __PRIPTR_RANK "i"
#define SCNo8 "hho"
#define SCNo16 "ho"
#define SCNo32 "o"
#define SCNo64 __PRI64_RANK "o"
#define SCNoLEAST8 "hho"
#define SCNoLEAST16 "ho"
#define SCNoLEAST32 "o"
#define SCNoLEAST64 __PRI64_RANK "o"
#define SCNoFAST8 "hho"
#define SCNoFAST16 __PRIFAST_RANK "o"
#define SCNoFAST32 __PRIFAST_RANK "o"
#define SCNoFAST64 __PRI64_RANK "o"
#define SCNoMAX __PRI64_RANK "o"
#define SCNoPTR __PRIPTR_RANK "o"
#define SCNu8 "hhu"
#define SCNu16 "hu"
#define SCNu32 "u"
#define SCNu64 __PRI64_RANK "u"
#define SCNuLEAST8 "hhu"
#define SCNuLEAST16 "hu"
#define SCNuLEAST32 "u"
#define SCNuLEAST64 __PRI64_RANK "u"
#define SCNuFAST8 "hhu"
#define SCNuFAST16 __PRIFAST_RANK "u"
#define SCNuFAST32 __PRIFAST_RANK "u"
#define SCNuFAST64 __PRI64_RANK "u"
#define SCNuMAX __PRI64_RANK "u"
#define SCNuPTR __PRIPTR_RANK "u"
#define SCNx8 "hhx"
#define SCNx16 "hx"
#define SCNx32 "x"
#define SCNx64 __PRI64_RANK "x"
#define SCNxLEAST8 "hhx"
#define SCNxLEAST16 "hx"
#define SCNxLEAST32 "x"
#define SCNxLEAST64 __PRI64_RANK "x"
#define SCNxFAST8 "hhx"
#define SCNxFAST16 __PRIFAST_RANK "x"
#define SCNxFAST32 __PRIFAST_RANK "x"
#define SCNxFAST64 __PRI64_RANK "x"
#define SCNxMAX __PRI64_RANK "x"
#define SCNxPTR __PRIPTR_RANK "x"
#endif
#endif /* _INTTYPES_H */

View File

@@ -0,0 +1,115 @@
/*
* klibc/compiler.h
*
* Various compiler features
*/
#ifndef _KLIBC_COMPILER_H
#define _KLIBC_COMPILER_H
#define __user
/* Specific calling conventions */
/* __cdecl is used when we want varadic and non-varadic functions to have
the same binary calling convention. */
#ifdef __i386__
# ifdef __GNUC__
# define __cdecl __attribute__((cdecl,regparm(0)))
# else
/* Most other C compilers have __cdecl as a keyword */
# endif
#else
# define __cdecl /* Meaningless on non-i386 */
#endif
/* How to declare a function that *must* be inlined */
#ifdef __GNUC__
# if __GNUC_MAJOR__ >= 3
# define __must_inline static __inline__ __attribute__((always_inline))
# else
# define __must_inline extern __inline__
# endif
#else
# define __must_inline inline /* Just hope this works... */
#endif
/* How to declare a function that does not return */
#ifdef __GNUC__
# define __noreturn void __attribute__((noreturn))
#else
# define __noreturn void
#endif
/* "const" function:
Many functions do not examine any values except their arguments,
and have no effects except the return value. Basically this is
just slightly more strict class than the `pure' attribute above,
since function is not allowed to read global memory.
Note that a function that has pointer arguments and examines the
data pointed to must _not_ be declared `const'. Likewise, a
function that calls a non-`const' function usually must not be
`const'. It does not make sense for a `const' function to return
`void'.
*/
#ifdef __GNUC__
# define __constfunc __attribute__((const))
#else
# define __constfunc
#endif
#undef __attribute_const__
#define __attribute_const__ __constfunc
/* "pure" function:
Many functions have no effects except the return value and their
return value depends only on the parameters and/or global
variables. Such a function can be subject to common subexpression
elimination and loop optimization just as an arithmetic operator
would be. These functions should be declared with the attribute
`pure'.
*/
#ifdef __GNUC__
# define __purefunc __attribute__((pure))
#else
# define __purefunc
#endif
#undef __attribute_pure__
#define __attribute_pure__ __purefunc
/* Format attribute */
#ifdef __GNUC__
# define __formatfunc(t,f,a) __attribute__((format(t,f,a)))
#else
# define __formatfunc(t,f,a)
#endif
/* malloc() function (returns unaliased pointer) */
#if defined(__GNUC__) && (__GNUC_MAJOR__ >= 3)
# define __mallocfunc __attribute__((malloc))
#else
# define __mallocfunc
#endif
/* likely/unlikely */
#if defined(__GNUC__) && (__GNUC_MAJOR__ > 2 || (__GNUC_MAJOR__ == 2 && __GNUC_MINOR__ >= 95))
# define __likely(x) __builtin_expect((x), 1)
# define __unlikely(x) __builtin_expect((x), 0)
#else
# define __likely(x) (x)
# define __unlikely(x) (x)
#endif
/* Possibly unused function */
#ifdef __GNUC__
# define __unusedfunc __attribute__((unused))
#else
# define __unusedfunc
#endif
/* Constructors and destructors */
#define __constructor __attribute__((constructor))
#define __destructor __attribute__((destructor))
#endif

View File

@@ -0,0 +1,4 @@
static inline void __divide_error(void)
{
asm volatile("int $0"); /* Divide by zero */
}

View File

@@ -0,0 +1,14 @@
/*
* klibc/extern.h
*/
#ifndef _KLIBC_EXTERN_H
#define _KLIBC_EXTERN_H
#ifdef __cplusplus
#define __extern extern "C"
#else
#define __extern extern
#endif
#endif /* _KLIBC_EXTERN_H */

View File

@@ -0,0 +1,34 @@
/*
* klibc/sysconfig.h
*
* Allows for definitions of some things which may be system-dependent
*/
#ifndef _KLIBC_SYSCONFIG_H
#define _KLIBC_SYSCONFIG_H
/*
* Define this to obtain memory using sbrk() instead
* of mmap(). This should make it friendlier on
* non-MMU architectures. This should become a
* per-architecture configurable.
*/
#define MALLOC_USING_SBRK
/*
* This is the minimum chunk size we will ask the kernel for using
* malloc(); this should be a multiple of the page size on all
* architectures.
*/
#define MALLOC_CHUNK_SIZE 4096
#define MALLOC_CHUNK_MASK (MALLOC_CHUNK_SIZE-1)
/*
* This is the minimum alignment for the memory returned by sbrk().
* It must be a power of 2. If MALLOC_USING_SBRK is defined it should
* be no smaller than the size of struct arena_header in malloc.h (4
* pointers.)
*/
#define SBRK_ALIGNMENT 32
#endif /* _KLIBC_SYSCONFIG_H */

View File

@@ -0,0 +1,39 @@
/*
* limits.h
*/
#ifndef _LIMITS_H
#define _LIMITS_H
#define CHAR_BIT 8
#define SHRT_BIT 16
#define INT_BIT 32
#define LONGLONG_BIT 64
#define SCHAR_MIN (-128)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
#ifdef __CHAR_UNSIGNED__
# define CHAR_MIN 0
# define CHAR_MAX UCHAR_MAX
#else
# define CHAR_MIN SCHAR_MIN
# define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define INT_MIN (-2147483647-1)
#define INT_MAX 2147483647
#define UINT_MAX 4294967295U
#define LONGLONG_MIN (-9223372036854775807LL-1)
#define LONGLONG_MAX 9223372036854775807LL
#define ULONGLONG_MAX 18446744073709551615ULL
#include <bitsize/limits.h>
#endif /* _LIMITS_H */

View File

@@ -0,0 +1,44 @@
#ident "$Id: minmax.h,v 1.1 2004/11/10 22:31:50 hpa Exp $"
/* ----------------------------------------------------------------------- *
*
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall
* be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* ----------------------------------------------------------------------- */
#ifndef _MINMAX_H
#define _MINMAX_H
/*
* minmax.h: Type-independent safe min/max macros
*/
#define min(x,y) ({ __typeof(x) xx = (x); \
__typeof(y) yy = (y); \
xx < yy ? xx : yy; })
#define max(x,y) ({ __typeof(x) xx = (x); \
__typeof(y) yy = (y); \
xx > yy ? xx : yy; })
#endif /* _MINMAX_H */

View File

@@ -0,0 +1,43 @@
#ifndef _NETINET_IN_H
#define _NETINET_IN_H
/* COM32 will be running on an i386 platform */
#include <stdint.h>
static inline uint16_t __htons(uint16_t v)
{
return ((v) << 8) | ((v) >> 8);
}
#define htons(x) __htons(x)
#define ntohs(x) __htons(x)
static inline uint32_t __htonl(uint32_t v)
{
if ( __builtin_constant_p(v) ) {
return (((v) & 0x000000ff) << 24) |
(((v) & 0x0000ff00) << 8) |
(((v) & 0x00ff0000) >> 8) |
(((v) & 0xff000000) >> 24);
} else {
asm("xchgb %h0,%b0 ; roll $16,%0 ; xchgb %h0,%b0" : "+abcd" (v));
return v;
}
}
#define htonl(x) __htonl(x)
#define ntohl(x) __htonl(x)
static inline uint64_t __htonq(uint64_t v)
{
return ((uint64_t) __htonl(v) << 32) | __htonl(v >> 32);
}
#define htonq(x) __htonq(x)
#define ntohq(x) __htonq(x)
#endif /* _NETINET_IN_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
/*
* stdarg.h
*
* This is just a wrapper for the gcc one, but defines va_copy()
* even if gcc doesn't.
*/
/* Note: the _STDARG_H macro belongs to the gcc header... */
#include_next <stdarg.h>
/* Older gcc considers this an extension, so it's double underbar only */
#ifndef va_copy
#define va_copy(d,s) __va_copy(d,s)
#endif

View File

@@ -0,0 +1,33 @@
/*
* $Id: stdbool.h,v 1.1 2003/04/16 06:32:31 hpa Exp $
*
* stdbool.h
*/
#ifndef _STDBOOL_H
#define _STDBOOL_H
#ifndef __cplusplus
#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
# if !defined(__GNUC__) ||(__GNUC__ < 3)
typedef char _Bool; /* For C compilers without _Bool */
# endif
#endif
#define bool _Bool
#define true 1
#define false 0
#else
/* C++ */
#define bool bool
#define true true
#define false false
#endif
#define __bool_true_false_are_defined 1
#endif /* _STDBOOL_H */

View File

@@ -0,0 +1,24 @@
/*
* stddef.h
*/
#ifndef _STDDEF_H
#define _STDDEF_H
#ifndef __KLIBC__
# define __KLIBC__ 1
#endif
#include <bitsize/stddef.h>
#undef NULL
#ifdef __cplusplus
# define NULL 0
#else
# define NULL ((void *)0)
#endif
#undef offsetof
#define offsetof(t,m) ((size_t)&((t *)0)->m)
#endif /* _STDDEF_H */

View File

@@ -0,0 +1,146 @@
/*
* stdint.h
*/
#ifndef _STDINT_H
#define _STDINT_H
/* Exact types */
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef signed long long int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
/* Small types */
typedef signed char int_least8_t;
typedef signed short int_least16_t;
typedef signed int int_least32_t;
typedef signed long long int_least64_t;
typedef unsigned char uint_least8_t;
typedef unsigned short uint_least16_t;
typedef unsigned int uint_least32_t;
typedef unsigned long long uint_least64_t;
/* Fast types */
typedef signed char int_fast8_t;
typedef signed short int_fast16_t;
typedef signed int int_fast32_t;
typedef signed long long int_fast64_t;
typedef unsigned char uint_fast8_t;
typedef unsigned short uint_fast16_t;
typedef unsigned int uint_fast32_t;
typedef unsigned long long uint_fast64_t;
/* Pointer types */
typedef int32_t intptr_t;
typedef uint32_t uintptr_t;
/* Maximal types */
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
/*
* To be strictly correct...
*/
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
# define INT8_MIN (-128)
# define INT16_MIN (-32767-1)
# define INT32_MIN (-2147483647-1)
# define INT64_MIN (-9223372036854775807LL-1)
# define INT8_MAX (127)
# define INT16_MAX (32767)
# define INT32_MAX (2147483647)
# define INT64_MAX (9223372036854775807LL)
# define UINT8_MAX (255U)
# define UINT16_MAX (65535U)
# define UINT32_MAX (4294967295U)
# define UINT64_MAX (18446744073709551615ULL)
# define INT_LEAST8_MIN (-128)
# define INT_LEAST16_MIN (-32767-1)
# define INT_LEAST32_MIN (-2147483647-1)
# define INT_LEAST64_MIN (-9223372036854775807LL-1)
# define INT_LEAST8_MAX (127)
# define INT_LEAST16_MAX (32767)
# define INT_LEAST32_MAX (2147483647)
# define INT_LEAST64_MAX (9223372036854775807LL)
# define UINT_LEAST8_MAX (255U)
# define UINT_LEAST16_MAX (65535U)
# define UINT_LEAST32_MAX (4294967295U)
# define UINT_LEAST64_MAX (18446744073709551615ULL)
# define INT_FAST8_MIN (-128)
# define INT_FAST16_MIN (-32767-1)
# define INT_FAST32_MIN (-2147483647-1)
# define INT_FAST64_MIN (-9223372036854775807LL-1)
# define INT_FAST8_MAX (127)
# define INT_FAST16_MAX (32767)
# define INT_FAST32_MAX (2147483647)
# define INT_FAST64_MAX (9223372036854775807LL)
# define UINT_FAST8_MAX (255U)
# define UINT_FAST16_MAX (65535U)
# define UINT_FAST32_MAX (4294967295U)
# define UINT_FAST64_MAX (18446744073709551615ULL)
# define INTPTR_MIN (-2147483647-1)
# define INTPTR_MAX (2147483647)
# define UINTPTR_MAX (4294967295U)
# define INTMAX_MIN (-9223372036854775807LL-1)
# define INTMAX_MAX (9223372036854775807LL)
# define UINTMAX_MAX (18446744073709551615ULL)
/* ptrdiff_t limit */
# define PTRDIFF_MIN (-2147483647-1)
# define PTRDIFF_MAX (2147483647)
/* sig_atomic_t limit */
# define SIG_ATOMIC_MIN (-2147483647-1)
# define SIG_ATOMIC_MAX (2147483647)
/* size_t limit */
# define SIZE_MAX (4294967295U)
#endif /* STDC_LIMIT_MACROS */
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
# define INT8_C(n) n
# define INT16_C(n) n
# define INT32_C(n) n
# define INT64_C(n) n ## LL
# define UINT8_C(n) n ## U
# define UINT16_C(n) n ## U
# define UINT32_C(n) n ## U
# define UINT64_C(n) n ## ULL
# define INTMAX_C(n) n ## LL
# define UINTMAX_C(n) n ## ULL
#endif /* STDC_CONSTANT_MACROS */
#endif /* _STDINT_H */

View File

@@ -0,0 +1,120 @@
/*
* stdio.h
*/
#ifndef _STDIO_H
#define _STDIO_H
#include <klibc/extern.h>
#include <stdarg.h>
#include <stddef.h>
/* This structure doesn't really exist, but it gives us something
to define FILE * with */
struct _IO_file;
typedef struct _IO_file FILE;
#ifndef EOF
# define EOF (-1)
#endif
#ifndef BUFSIZ
# define BUFSIZ 4096
#endif
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
/*
* Convert between a FILE * and a file descriptor. We don't actually
* have any in-memory data, so we just abuse the pointer itself to
* hold the data. Note, however, that for file descriptors, -1 is
* error and 0 is a valid value; for FILE *, NULL (0) is error and
* non-NULL are valid.
*/
static __inline__ int fileno(FILE *__f)
{
/* This should really be intptr_t, but size_t should be the same size */
return (int)(size_t)__f - 1;
}
/* This is a macro so it can be used as initializer */
#define __create_file(__fd) ((FILE *)(size_t)((__fd) + 1))
#define stdin __create_file(0)
#define stdout __create_file(1)
#define stderr __create_file(2)
__extern FILE *fopen(const char *, const char *);
struct dev_info;
__extern FILE *fopendev(const struct dev_info *, const char *);
static __inline__ FILE *fdopen(int __fd, const char *__m)
{
(void)__m; return __create_file(__fd);
}
static __inline__ int fclose(FILE *__f)
{
extern int close(int);
return close(fileno(__f));
}
__extern int fputs(const char *, FILE *);
__extern int puts(const char *);
__extern int fputc(int, FILE *);
#define putc(c,f) fputc((c),(f))
#define putchar(c) fputc((c),stdout)
__extern int fgetc(FILE *);
__extern char * fgets(char *, int, FILE *);
#define getc(f) fgetc(f)
__extern size_t _fread(void *, size_t, FILE *);
__extern size_t _fwrite(const void *, size_t, FILE *);
#ifndef __NO_FREAD_FWRITE_INLINES
extern __inline__ size_t
fread(void *__p, size_t __s, size_t __n, FILE *__f)
{
return _fread(__p, __s*__n, __f)/__s;
}
extern __inline__ size_t
fwrite(void *__p, size_t __s, size_t __n, FILE *__f)
{
return _fwrite(__p, __s*__n, __f)/__s;
}
#endif
/* No seek, but we can tell */
__extern long ftell(FILE *);
__extern int printf(const char *, ...);
__extern int vprintf(const char *, va_list);
__extern int fprintf(FILE *, const char *, ...);
__extern int vfprintf(FILE *, const char *, va_list);
__extern int sprintf(char *, const char *, ...);
__extern int vsprintf(char *, const char *, va_list);
__extern int snprintf(char *, size_t n, const char *, ...);
__extern int vsnprintf(char *, size_t n, const char *, va_list);
__extern int asprintf(char **, const char *, ...);
__extern int vasprintf(char **, const char *, va_list);
/* No buffering, so no flushing needed */
extern __inline__ int
fflush(FILE *__f)
{
(void)__f;
return 0;
}
__extern int sscanf(const char *, const char *, ...);
__extern int vsscanf(const char *, const char *, va_list);
__extern void perror(const char *);
__extern int rename(const char *, const char *);
#endif /* _STDIO_H */

View File

@@ -0,0 +1,90 @@
/*
* stdlib.h
*/
#ifndef _STDLIB_H
#define _STDLIB_H
#include <klibc/extern.h>
#include <klibc/compiler.h>
#include <stddef.h>
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
static __inline__ __noreturn _Exit(int __n) {
__extern __noreturn _exit(int);
_exit(__n);
for(;;); /* Some gcc versions are stupid */
}
__extern __noreturn abort(void);
static __inline__ int abs(int __n) {
return (__n < 0) ? -__n : __n;
}
__extern int atexit(void (*)(void));
__extern int on_exit(void (*)(int, void *), void *);
__extern int atoi(const char *);
__extern long atol(const char *);
__extern long long atoll(const char *);
__extern __noreturn exit(int);
__extern void free(void *);
static __inline__ long labs(long __n) {
return (__n < 0L) ? -__n : __n;
}
static __inline__ long long llabs(long long __n) {
return (__n < 0LL) ? -__n : __n;
}
__extern __mallocfunc void *malloc(size_t);
__extern __mallocfunc void *calloc(size_t, size_t);
__extern __mallocfunc void *realloc(void *, size_t);
__extern long strtol(const char *, char **, int);
__extern long long strtoll(const char *, char **, int);
__extern unsigned long strtoul(const char *, char **, int);
__extern unsigned long long strtoull(const char *, char **, int);
__extern char *getenv(const char *);
__extern int putenv(const char *);
__extern int setenv(const char *, const char *, int);
__extern int unsetenv(const char *);
__extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
__extern long jrand48(unsigned short *);
__extern long mrand48(void);
__extern long nrand48(unsigned short *);
__extern long lrand48(void);
__extern unsigned short *seed48(const unsigned short *);
__extern void srand48(long);
#define RAND_MAX 0x7fffffff
static __inline__ int rand(void) {
return (int)lrand48();
}
static __inline__ void srand(unsigned int __s) {
srand48(__s);
}
static __inline__ long random(void)
{
return lrand48();
}
static __inline__ void srandom(unsigned int __s)
{
srand48(__s);
}
/* Basic PTY functions. These only work if devpts is mounted! */
__extern int unlockpt(int);
__extern char *ptsname(int);
__extern int getpt(void);
static __inline__ int grantpt(int __fd)
{
(void)__fd;
return 0; /* devpts does this all for us! */
}
#endif /* _STDLIB_H */

View File

@@ -0,0 +1,43 @@
/*
* string.h
*/
#ifndef _STRING_H
#define _STRING_H
#include <klibc/extern.h>
#include <stddef.h>
__extern void *memccpy(void *, const void *, int, size_t);
__extern void *memchr(const void *, int, size_t);
__extern int memcmp(const void *, const void *, size_t);
__extern void *memcpy(void *, const void *, size_t);
__extern void *memmove(void *, const void *, size_t);
__extern void *memset(void *, int, size_t);
__extern void *memmem(const void *, size_t, const void *, size_t);
__extern void memswap(void *, void *, size_t);
__extern int strcasecmp(const char *, const char *);
__extern int strncasecmp(const char *, const char *, size_t);
__extern char *strcat(char *, const char *);
__extern char *strchr(const char *, int);
__extern int strcmp(const char *, const char *);
__extern char *strcpy(char *, const char *);
__extern size_t strcspn(const char *, const char *);
__extern char *strdup(const char *);
__extern char *strndup(const char *, size_t);
__extern char *strerror(int);
__extern size_t strlen(const char *);
__extern size_t strnlen(const char *, size_t);
__extern char *strncat(char *, const char *, size_t);
__extern size_t strlcat(char *, const char *, size_t);
__extern int strncmp(const char *, const char *, size_t);
__extern char *strncpy(char *, const char *, size_t);
__extern size_t strlcpy(char *, const char *, size_t);
__extern char *strpbrk(const char *, const char *);
__extern char *strrchr(const char *, int);
__extern char *strsep(char **, const char *);
__extern size_t strspn(const char *, const char *);
__extern char *strstr(const char *, const char *);
__extern char *strtok(char *, const char *);
#endif /* _STRING_H */

View File

@@ -0,0 +1,78 @@
#ifndef _CPU_H
#define _CPU_H
#include <inttypes.h>
static inline uint64_t rdtsc(void)
{
uint64_t v;
asm volatile("rdtsc" : "=A" (v));
return v;
}
static inline uint32_t rdtscl(void)
{
uint32_t v;
asm volatile("rdtsc" : "=a" (v) : : "edx");
return v;
}
static inline uint32_t cpuid_eax(uint32_t level)
{
uint32_t v;
asm("cpuid" : "=a" (v) : "a" (level) : "ebx", "ecx", "edx");
return v;
}
static inline uint32_t cpuid_ebx(uint32_t level)
{
uint32_t v;
asm("cpuid" : "=b" (v), "+a" (level) : : "ecx", "edx");
return v;
}
static inline uint32_t cpuid_ecx(uint32_t level)
{
uint32_t v;
asm("cpuid" : "=c" (v), "+a" (level) : : "ebx", "edx");
return v;
}
static inline uint32_t cpuid_edx(uint32_t level)
{
uint32_t v;
asm("cpuid" : "=d" (v), "+a" (level) : : "ebx", "ecx");
return v;
}
static inline uint64_t rdmsr(uint32_t msr)
{
uint64_t v;
asm volatile("rdmsr" : "=A" (v) : "c" (msr));
return v;
}
static inline void wrmsr(uint64_t v, uint32_t msr)
{
asm volatile("wrmsr" : : "A" (v), "c" (msr));
}
static inline void cpu_relax(void)
{
asm volatile("rep ; nop");
}
/* These are local cli/sti; not SMP-safe!!! */
static inline void cli(void)
{
asm volatile("cli");
}
static inline void sti(void)
{
asm volatile("sti");
}
#endif

View File

@@ -0,0 +1,42 @@
#ifndef _SYS_IO_H
#define _SYS_IO_H
#include <inttypes.h>
static inline uint8_t inb(uint16_t p)
{
uint8_t v;
asm volatile("inb %1,%0" : "=a" (v) : "Nd" (p));
return v;
}
static inline uint16_t inw(uint16_t p)
{
uint16_t v;
asm volatile("inw %1,%0" : "=a" (v) : "Nd" (p));
return v;
}
static inline uint32_t inl(uint16_t p)
{
uint32_t v;
asm volatile("inl %1,%0" : "=a" (v) : "Nd" (p));
return v;
}
static inline void outb(uint8_t v, uint16_t p)
{
asm volatile("outb %0,%1" : : "a" (v), "Nd" (p));
}
static inline void outw(uint16_t v, uint16_t p)
{
asm volatile("outw %0,%1" : : "a" (v), "Nd" (p));
}
static inline void outl(uint32_t v, uint16_t p)
{
asm volatile("outl %0,%1" : : "a" (v), "Nd" (p));
}
#endif /* _SYS_IO_H */

View File

@@ -0,0 +1,31 @@
#ifndef _SYS_PCI_H
#define _SYS_PCI_H
#include <inttypes.h>
#include <sys/io.h>
typedef uint32_t pciaddr_t;
static inline pciaddr_t pci_mkaddr(uint32_t bus, uint32_t dev,
uint32_t func, uint32_t reg)
{
return 0x80000000 | ((bus & 0xff) << 16) | ((dev & 0x1f) << 11) |
((func & 0x07) << 8) | (reg & 0xff);
}
enum pci_config_type {
PCI_CFG_AUTO = 0, /* autodetect */
PCI_CFG_TYPE1 = 1,
PCI_CFG_TYPE2 = 2,
};
void pci_set_config_type(enum pci_config_type);
uint8_t pci_readb(pciaddr_t);
uint16_t pci_readw(pciaddr_t);
uint32_t pci_readl(pciaddr_t);
void pci_writeb(uint8_t, pciaddr_t);
void pci_writew(uint16_t, pciaddr_t);
void pci_writel(uint32_t, pciaddr_t);
#endif /* _SYS_PCI_H */

View File

@@ -0,0 +1,43 @@
/*
* sys/stat.h
*/
#ifndef _SYS_STAT_H
#define _SYS_STAT_H
#include <sys/types.h>
/* We don't use this, but it's there for compatibility */
#define S_IFMT 00170000
#define S_IFSOCK 0140000
#define S_IFLNK 0120000
#define S_IFREG 0100000
#define S_IFBLK 0060000
#define S_IFDIR 0040000
#define S_IFCHR 0020000
#define S_IFIFO 0010000
#define S_ISUID 0004000
#define S_ISGID 0002000
#define S_ISVTX 0001000
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
#define S_IRWXU 00700
#define S_IRUSR 00400
#define S_IWUSR 00200
#define S_IXUSR 00100
#define S_IRWXG 00070
#define S_IRGRP 00040
#define S_IWGRP 00020
#define S_IXGRP 00010
#define S_IRWXO 00007
#define S_IROTH 00004
#define S_IWOTH 00002
#define S_IXOTH 00001
#endif /* _SYS_STAT_H */

View File

@@ -0,0 +1,21 @@
/*
* sys/times.h
*/
#ifndef _SYS_TIMES_H
#define _SYS_TIMES_H
#include <stdint.h>
struct tms {
/* Empty */
};
#define HZ 18 /* Piddly resolution... */
#define CLK_TCK HZ
typedef uint16_t clock_t;
clock_t times(struct tms *);
#endif /* _SYS_TIMES_H */

View File

@@ -0,0 +1,16 @@
/*
* sys/types.h
*/
#ifndef _SYS_TYPES_H
#define _SYS_TYPES_H
#include <klibc/compiler.h>
#include <stddef.h>
#include <stdint.h>
typedef ptrdiff_t ssize_t;
typedef int mode_t;
typedef int64_t off_t;
#endif

View File

@@ -0,0 +1,40 @@
#ident "$Id: syslinux.h,v 1.1 2005/01/20 18:41:12 hpa Exp $"
/* ----------------------------------------------------------------------- *
*
* Copyright 2005 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall
* be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* ----------------------------------------------------------------------- */
/*
* syslinux.h
*
* SYSLINUX-specific functions
*/
#ifndef _SYSLINUX_H
#define _SYSLINUX_H
void syslinux_idle(void);
#endif

View File

View File

@@ -0,0 +1,29 @@
/*
* unistd.h
*/
#ifndef _UNISTD_H
#define _UNISTD_H
#include <klibc/extern.h>
#include <klibc/compiler.h>
#include <stddef.h>
#include <sys/types.h>
__extern __noreturn _exit(int);
__extern int open(const char *, int, ...);
__extern int close(int);
__extern ssize_t read(int, void *, size_t);
__extern ssize_t write(int, const void *, size_t);
__extern int isatty(int);
/* Standard file descriptor numbers. */
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
#endif /* _UNISTD_H */

View File

@@ -0,0 +1,323 @@
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2003 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id: zconf.h,v 1.1 2005/01/12 04:56:23 hpa Exp $ */
#ifndef ZCONF_H
#define ZCONF_H
/*
* If you *really* need a unique prefix for all types and library functions,
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
*/
#ifdef Z_PREFIX
# define deflateInit_ z_deflateInit_
# define deflate z_deflate
# define deflateEnd z_deflateEnd
# define inflateInit_ z_inflateInit_
# define inflate z_inflate
# define inflateEnd z_inflateEnd
# define deflateInit2_ z_deflateInit2_
# define deflateSetDictionary z_deflateSetDictionary
# define deflateCopy z_deflateCopy
# define deflateReset z_deflateReset
# define deflatePrime z_deflatePrime
# define deflateParams z_deflateParams
# define deflateBound z_deflateBound
# define inflateInit2_ z_inflateInit2_
# define inflateSetDictionary z_inflateSetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateCopy z_inflateCopy
# define inflateReset z_inflateReset
# define compress z_compress
# define compress2 z_compress2
# define compressBound z_compressBound
# define uncompress z_uncompress
# define adler32 z_adler32
# define crc32 z_crc32
# define get_crc_table z_get_crc_table
# define Byte z_Byte
# define uInt z_uInt
# define uLong z_uLong
# define Bytef z_Bytef
# define charf z_charf
# define intf z_intf
# define uIntf z_uIntf
# define uLongf z_uLongf
# define voidpf z_voidpf
# define voidp z_voidp
#endif
#if defined(__MSDOS__) && !defined(MSDOS)
# define MSDOS
#endif
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
# define OS2
#endif
#if defined(_WINDOWS) && !defined(WINDOWS)
# define WINDOWS
#endif
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
# define WIN32
#endif
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
# ifndef SYS16BIT
# define SYS16BIT
# endif
# endif
#endif
/*
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
* than 64k bytes at a time (needed on systems with 16-bit int).
*/
#ifdef SYS16BIT
# define MAXSEG_64K
#endif
#ifdef MSDOS
# define UNALIGNED_OK
#endif
#ifdef __STDC_VERSION__
# ifndef STDC
# define STDC
# endif
# if __STDC_VERSION__ >= 199901L
# ifndef STDC99
# define STDC99
# endif
# endif
#endif
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
# define STDC
#endif
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
# define STDC
#endif
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
# define STDC
#endif
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
# define STDC
#endif
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
# define STDC
#endif
#ifndef STDC
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
# define const /* note: need a more gentle solution here */
# endif
#endif
/* Some Mac compilers merge all .h files incorrectly: */
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
# define NO_DUMMY_DECL
#endif
/* Maximum value for memLevel in deflateInit2 */
#ifndef MAX_MEM_LEVEL
# ifdef MAXSEG_64K
# define MAX_MEM_LEVEL 8
# else
# define MAX_MEM_LEVEL 9
# endif
#endif
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
* created by gzip. (Files created by minigzip can still be extracted by
* gzip.)
*/
#ifndef MAX_WBITS
# define MAX_WBITS 15 /* 32K LZ77 window */
#endif
/* The memory requirements for deflate are (in bytes):
(1 << (windowBits+2)) + (1 << (memLevel+9))
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
plus a few kilobytes for small objects. For example, if you want to reduce
the default memory requirements from 256K to 128K, compile with
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
Of course this will generally degrade compression (there's no free lunch).
The memory requirements for inflate are (in bytes) 1 << windowBits
that is, 32K for windowBits=15 (default value) plus a few kilobytes
for small objects.
*/
/* Type declarations */
#ifndef OF /* function prototypes */
# ifdef STDC
# define OF(args) args
# else
# define OF(args) ()
# endif
#endif
/* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
* just define FAR to be empty.
*/
#ifdef SYS16BIT
# if defined(M_I86SM) || defined(M_I86MM)
/* MSC small or medium model */
# define SMALL_MEDIUM
# ifdef _MSC_VER
# define FAR _far
# else
# define FAR far
# endif
# endif
# if (defined(__SMALL__) || defined(__MEDIUM__))
/* Turbo C small or medium model */
# define SMALL_MEDIUM
# ifdef __BORLANDC__
# define FAR _far
# else
# define FAR far
# endif
# endif
#endif
#if defined(WINDOWS) || defined(WIN32)
/* If building or using zlib as a DLL, define ZLIB_DLL.
* This is not mandatory, but it offers a little performance increase.
*/
# ifdef ZLIB_DLL
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
# ifdef ZLIB_INTERNAL
# define ZEXTERN extern __declspec(dllexport)
# else
# define ZEXTERN extern __declspec(dllimport)
# endif
# endif
# endif /* ZLIB_DLL */
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
* define ZLIB_WINAPI.
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
*/
# ifdef ZLIB_WINAPI
# ifdef FAR
# undef FAR
# endif
# include <windows.h>
/* No need for _export, use ZLIB.DEF instead. */
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
# define ZEXPORT WINAPI
# ifdef WIN32
# define ZEXPORTVA WINAPIV
# else
# define ZEXPORTVA FAR CDECL
# endif
# endif
#endif
#if defined (__BEOS__)
# ifdef ZLIB_DLL
# ifdef ZLIB_INTERNAL
# define ZEXPORT __declspec(dllexport)
# define ZEXPORTVA __declspec(dllexport)
# else
# define ZEXPORT __declspec(dllimport)
# define ZEXPORTVA __declspec(dllimport)
# endif
# endif
#endif
#ifndef ZEXTERN
# define ZEXTERN extern
#endif
#ifndef ZEXPORT
# define ZEXPORT
#endif
#ifndef ZEXPORTVA
# define ZEXPORTVA
#endif
#ifndef FAR
# define FAR
#endif
#if !defined(__MACTYPES__)
typedef unsigned char Byte; /* 8 bits */
#endif
typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */
#ifdef SMALL_MEDIUM
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
# define Bytef Byte FAR
#else
typedef Byte FAR Bytef;
#endif
typedef char FAR charf;
typedef int FAR intf;
typedef uInt FAR uIntf;
typedef uLong FAR uLongf;
#ifdef STDC
typedef void const *voidpc;
typedef void FAR *voidpf;
typedef void *voidp;
#else
typedef Byte const *voidpc;
typedef Byte FAR *voidpf;
typedef Byte *voidp;
#endif
#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
# include <sys/types.h> /* for off_t */
# include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS
# include <unixio.h> /* for off_t */
# endif
# define z_off_t off_t
#endif
#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
#ifndef z_off_t
# define z_off_t long
#endif
#if defined(__OS400__)
#define NO_vsnprintf
#endif
#if defined(__MVS__)
# define NO_vsnprintf
# ifdef FAR
# undef FAR
# endif
#endif
/* MVS linker does not support external names larger than 8 bytes */
#if defined(__MVS__)
# pragma map(deflateInit_,"DEIN")
# pragma map(deflateInit2_,"DEIN2")
# pragma map(deflateEnd,"DEEND")
# pragma map(deflateBound,"DEBND")
# pragma map(inflateInit_,"ININ")
# pragma map(inflateInit2_,"ININ2")
# pragma map(inflateEnd,"INEND")
# pragma map(inflateSync,"INSY")
# pragma map(inflateSetDictionary,"INSEDI")
# pragma map(compressBound,"CMBND")
# pragma map(inflate_table,"INTABL")
# pragma map(inflate_fast,"INFA")
# pragma map(inflate_copyright,"INCOPY")
#endif
#endif /* ZCONF_H */

File diff suppressed because it is too large Load Diff