newlib: missing files

git-svn-id: svn://kolibrios.org@2828 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2012-06-27 13:42:25 +00:00
parent b3ffd0487f
commit 98b858c040
6 changed files with 431 additions and 0 deletions

View File

@ -0,0 +1,105 @@
#ifndef _FENV_H_
#define _FENV_H_
/* FPU status word exception flags */
#define FE_INVALID 0x01
#define FE_DENORMAL 0x02
#define FE_DIVBYZERO 0x04
#define FE_OVERFLOW 0x08
#define FE_UNDERFLOW 0x10
#define FE_INEXACT 0x20
#define FE_ALL_EXCEPT (FE_INVALID | FE_DENORMAL | FE_DIVBYZERO \
| FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
/* FPU control word rounding flags */
#define FE_TONEAREST 0x0000
#define FE_DOWNWARD 0x0400
#define FE_UPWARD 0x0800
#define FE_TOWARDZERO 0x0c00
/* The MXCSR exception flags are the same as the
FE flags. */
#define __MXCSR_EXCEPT_FLAG_SHIFT 0
/* How much to shift FE status word exception flags
to get the MXCSR exeptions masks, */
#define __MXCSR_EXCEPT_MASK_SHIFT 7
/* How much to shift FE control word rounding flags
to get MXCSR rounding flags, */
#define __MXCSR_ROUND_FLAG_SHIFT 3
#ifndef RC_INVOKED
/*
For now, support only for the basic abstraction of flags that are
either set or clear. fexcept_t could be structure that holds more
info about the fp environment.
*/
typedef unsigned short fexcept_t;
/* This 32-byte struct represents the entire floating point
environment as stored by fnstenv or fstenv, augmented by
the contents of the MXCSR register, as stored by stmxcsr
(if CPU supports it). */
typedef struct
{
unsigned short __control_word;
unsigned short __unused0;
unsigned short __status_word;
unsigned short __unused1;
unsigned short __tag_word;
unsigned short __unused2;
unsigned int __ip_offset; /* instruction pointer offset */
unsigned short __ip_selector;
unsigned short __opcode;
unsigned int __data_offset;
unsigned short __data_selector;
unsigned short __unused3;
unsigned int __mxcsr; /* contents of the MXCSR register */
} fenv_t;
/*The C99 standard (7.6.9) allows us to define implementation-specific macros for
different fp environments */
/* The default Intel x87 floating point environment (64-bit mantissa) */
#define FE_PC64_ENV ((const fenv_t *)-1)
/* The floating point environment set by MSVCRT _fpreset (53-bit mantissa) */
#define FE_PC53_ENV ((const fenv_t *)-2)
/* The FE_DFL_ENV macro is required by standard.
fesetenv will use the environment set at app startup.*/
#define FE_DFL_ENV ((const fenv_t *) 0)
#ifdef __cplusplus
extern "C" {
#endif
/*TODO: Some of these could be inlined */
/* 7.6.2 Exception */
extern int __cdecl feclearexcept (int);
extern int __cdecl fegetexceptflag (fexcept_t * flagp, int excepts);
extern int __cdecl feraiseexcept (int excepts );
extern int __cdecl fesetexceptflag (const fexcept_t *, int);
extern int __cdecl fetestexcept (int excepts);
/* 7.6.3 Rounding */
extern int __cdecl fegetround (void);
extern int __cdecl fesetround (int mode);
/* 7.6.4 Environment */
extern int __cdecl fegetenv (fenv_t * envp);
extern int __cdecl fesetenv (const fenv_t * );
extern int __cdecl feupdateenv (const fenv_t *);
extern int __cdecl feholdexcept (fenv_t *);
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* ndef _FENV_H */

View File

@ -0,0 +1,22 @@
/*
* stdio_ext.h
*
* Definitions for I/O internal operations, originally from Solaris.
*/
#ifndef _STDIO_EXT_H_
#define _STDIO_EXT_H_
#ifdef __rtems__
#error "<stdio_ext.h> not supported"
#endif
#include <stdio.h>
_BEGIN_STD_C
void _EXFUN(__fpurge,(FILE *));
_END_STD_C
#endif /* _STDIO_EXT_H_ */

View File

@ -0,0 +1,111 @@
/* Default linker script, for normal executables */
OUTPUT_FORMAT("kos32")
OUTPUT_ARCH("")
ENTRY(_start)
SECTIONS
{
.text 0x000000:
{
LONG(0x554e454D);
LONG(0x32305445);
LONG(1);
LONG(_start);
LONG(___iend);
LONG(___memsize);
LONG(___stacktop);
LONG(___cmdline);
LONG(___pgmname); /* full path */
LONG(0); /*FIXME tls data */
*(.init)
*(.text)
*(SORT(.textkos32))
*(.text.*)
*(.glue_7t)
*(.glue_7)
___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0);
___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0);
*(.fini)
/* ??? Why is .gcc_exc here? */
*(.gcc_exc)
PROVIDE (etext = .);
*(.gcc_except_table)
}
.rdata ALIGN(16) :
{
*(.rdata)
*(SORT(.rdatakos32))
___RUNTIME_PSEUDO_RELOC_LIST__ = .;
__RUNTIME_PSEUDO_RELOC_LIST__ = .;
*(.rdata_runtime_pseudo_reloc)
___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;
__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;
}
.CRT ALIGN(16) :
{
___crt_xc_start__ = . ;
*(SORT(.CRT*)) /* C initialization */
___crt_xc_end__ = . ;
___crt_xi_start__ = . ;
*(SORT(.CRT*)) /* C++ initialization */
___crt_xi_end__ = . ;
___crt_xl_start__ = . ;
*(SORT(.CRT*)) /* TLS callbacks */
/* ___crt_xl_end__ is defined in the TLS Directory support code */
___crt_xp_start__ = . ;
*(SORT(.CRT*)) /* Pre-termination */
___crt_xp_end__ = . ;
___crt_xt_start__ = . ;
*(SORT(.CRT*)) /* Termination */
___crt_xt_end__ = . ;
}
.data ALIGN(16) :
{
__data_start__ = . ;
*(.data)
*(.data2)
*(SORT(.datakos32))
*(.jcr)
__CRT_MT = .;
LONG(0);
__data_end__ = . ;
*(.data_cygwin_nocopy)
}
.eh_frame ALIGN(16) :
{
*(.eh_frame)
___iend = . ;
}
bss ALIGN(16):
{
*(.bss)
*(COMMON)
. = ALIGN(16);
___cmdline = .;
. = . + 256;
___pgmname = .;
___menuet__app_path_area = .;
. = . + 1024 + 16;
___stacktop = .;
___memsize = . ;
}
/DISCARD/ :
{
*(.debug)
*(.debug)
*(.debug)
*(.drectve)
*(.note.GNU-stack)
*(.comment)
*(.debug_abbrev)
*(.debug_info)
*(.debug_line)
*(.debug_frame)
*(.debug_loc)
*(.debug_pubnames)
*(.debug_aranges)
*(.debug_ranges)
}
}

View File

@ -0,0 +1,48 @@
/*
* ====================================================
* Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved.
*
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#if !defined(_SOFT_FLOAT)
/*
Fast version of frexp using Intel float instructions.
double _f_frexp (double x, int *exp);
Function splits x into y * 2 ** z. It then
returns the value of y and updates *exp with z.
There is no error checking or setting of errno.
*/
#include "i386mach.h"
.global SYM (_f_frexp)
SOTYPE_FUNCTION(_f_frexp)
SYM (_f_frexp):
pushl ebp
movl esp,ebp
fldl 8(ebp)
movl 16(ebp),eax
fxtract
fld1
fchs
fxch
fscale
fstp st1
fxch
fld1
faddp
fistpl 0(eax)
leave
ret
#endif

View File

@ -0,0 +1,83 @@
/* This file was based on the modified setjmp.S performed by
* Joel Sherill (joel@OARcorp.com) which specified the use
* of the __USER_LABEL_PREFIX__ and __REGISTER_PREFIX__ macros.
**
** This file is distributed WITHOUT ANY WARRANTY; without even the implied
** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/* These are predefined by new versions of GNU cpp. */
#ifndef __USER_LABEL_PREFIX__
#define __USER_LABEL_PREFIX__ _
#endif
#define __REG_PREFIX__ %
/* ANSI concatenation macros. */
#define CONCAT1(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a##b
/* Use the right prefix for global labels. */
#define SYM(x) CONCAT1(__USER_LABEL_PREFIX__, x)
/* Use the right prefix for registers. */
#define REG(x) CONCAT1(__REG_PREFIX__, x)
#define eax REG(eax)
#define ebx REG(ebx)
#define ecx REG(ecx)
#define edx REG(edx)
#define esi REG(esi)
#define edi REG(edi)
#define ebp REG(ebp)
#define esp REG(esp)
#define st0 REG(st)
#define st1 REG(st(1))
#define st2 REG(st(2))
#define st3 REG(st(3))
#define st4 REG(st(4))
#define st5 REG(st(5))
#define st6 REG(st(6))
#define st7 REG(st(7))
#define ax REG(ax)
#define bx REG(bx)
#define cx REG(cx)
#define dx REG(dx)
#define ah REG(ah)
#define bh REG(bh)
#define ch REG(ch)
#define dh REG(dh)
#define al REG(al)
#define bl REG(bl)
#define cl REG(cl)
#define dl REG(dl)
#define mm1 REG(mm1)
#define mm2 REG(mm2)
#define mm3 REG(mm3)
#define mm4 REG(mm4)
#define mm5 REG(mm5)
#define mm6 REG(mm6)
#define mm7 REG(mm7)
#ifdef _I386MACH_NEED_SOTYPE_FUNCTION
#define SOTYPE_FUNCTION(sym) .type SYM(sym),@function
#else
#define SOTYPE_FUNCTION(sym)
#endif
#ifdef _I386MACH_ALLOW_HW_INTERRUPTS
#define __CLI
#define __STI
#else
#define __CLI cli
#define __STI sti
#endif

View File

@ -0,0 +1,62 @@
/*
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/*
FUNCTION
<<fileno>>---return file descriptor associated with stream
INDEX
fileno
ANSI_SYNOPSIS
#include <stdio.h>
int fileno(FILE *<[fp]>);
TRAD_SYNOPSIS
#include <stdio.h>
int fileno(<[fp]>)
FILE *<[fp]>;
DESCRIPTION
You can use <<fileno>> to return the file descriptor identified by <[fp]>.
RETURNS
<<fileno>> returns a non-negative integer when successful.
If <[fp]> is not an open stream, <<fileno>> returns -1.
PORTABILITY
<<fileno>> is not part of ANSI C.
POSIX requires <<fileno>>.
Supporting OS subroutines required: none.
*/
#include <_ansi.h>
#include <stdio.h>
#include "local.h"
int
_DEFUN(fileno, (f),
FILE * f)
{
int result;
CHECK_INIT (_REENT, f);
_flockfile (f);
result = __sfileno (f);
_funlockfile (f);
return result;
}