RosBE-PPC package. Needed for building ReactOS for PPC.

Install it by running './install.sh $HOME/rosbe-ppc' and then run 
'$HOME/rosbe-ppc/rosbe' to get a shell with the right environment to build.
You can just do 'make -k install' (not everything builds) to get enough to help
porting.

A big endian registry maker (pyhive) and nls swapper (pynls) are provided to 
seed registry hives and nls files.

svn path=/trunk/tools/RosBE/; revision=542
This commit is contained in:
Art Yerkes 2007-11-15 22:38:36 +00:00
parent e3314a1fbd
commit 6e7529a7b5
81 changed files with 9877 additions and 0 deletions

7
RosBE-PPC/elfpe/Makefile Normal file
View File

@ -0,0 +1,7 @@
elfpe: argparse.cpp argparse.h header.cpp header.h \
objectfile.cpp objectfile.h util.cpp util.h pedef.h \
elfpe.cpp
g++ -g -o $@ $^ -lelf
clean:
rm -rf *.o elfpe

View File

@ -0,0 +1,83 @@
#include "argparse.h"
void expandLinkerArg(std::string input, std::vector<std::string> &result)
{
size_t comma;
while((comma = input.find(',')) != std::string::npos)
{
result.push_back(input.substr(0,comma));
input = input.substr(comma+1);
}
if(input.size() > 0)
result.push_back(input);
}
bool getarg
(const std::string &shortName,
const std::string &longName,
bool remove,
std::vector<std::string> &arguments,
std::string &result,
bool novar)
{
for(size_t i = 0; i < arguments.size(); i++)
{
const std::string arg = arguments[i];
// Find -Wl and parse
if (arg.size() > 3 && arg.substr(0,3) == "-Wl")
{
std::vector<std::string> expanded;
expandLinkerArg(arg.substr(4), expanded);
if (getarg(shortName, longName, false, expanded, result))
{
if( remove ) arguments.erase(arguments.begin()+i);
return true;
}
}
// Catch -e etc
else if (arg == shortName)
{
if (arguments.size() > i+1)
{
result = arguments[i+1];
if( remove )
{
arguments.erase(arguments.begin()+i);
if (!novar)
arguments.erase(arguments.begin()+i);
}
}
return true;
}
// Catch --entry foo@12
else if (longName.length())
{
if(arg == longName)
{
if (arguments.size() > i+1)
{
result = arguments[i+1];
if(remove)
{
arguments.erase(arguments.begin()+i);
if (!novar)
arguments.erase(arguments.begin()+i);
}
}
return true;
}
// Catch --entry=foo@12
else if (arg.size() > longName.size() &&
arg.substr(0,longName.size()) == longName &&
arg[longName.size()] == '=')
{
result = arg.substr(longName.size()+1);
if( remove ) arguments.erase(arguments.begin()+i);
return true;
}
}
}
return false;
}

View File

@ -0,0 +1,15 @@
#ifndef ELFPE_ARGPARSE_H
#define ELFPE_ARGPARSE_H
#include <vector>
#include <string>
bool getarg
(const std::string &shortName,
const std::string &longName,
bool remove,
std::vector<std::string> &arguments,
std::string &result,
bool novar = false);
#endif//ELFPE_ARGPARSE_H

View File

@ -0,0 +1,25 @@
#include <stdio.h>
#include "argparse.h"
int main( int argc, char **argv )
{
std::vector<std::string> args;
std::string result;
if (argc <= 3) return 1;
for( int i = 3; i < argc; i++ )
{
args.push_back(argv[i]);
}
if (getarg(argv[1], argv[2], true, args, result))
{
printf("%s\n", result.c_str());
for( int i = 0; i < args.size(); i++ )
{
printf("%s\n", args[i].c_str());
}
return 0;
}
else return 1;
}

190
RosBE-PPC/elfpe/elfpe.cpp Normal file
View File

@ -0,0 +1,190 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <list>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include "objectfile.h"
#include "header.h"
#include "argparse.h"
#define TYPE_PEHEADER (SHT_LOOS + 1)
int execute_command( bool verbose, const std::vector<std::string> &args )
{
std::vector<const char *> argvect;
pid_t pid;
int status = 1;
for( size_t i = 0; i < args.size(); i++ )
{
argvect.push_back(args[i].c_str());
}
argvect.push_back(NULL);
if (!(pid = vfork()))
{
execv((const char *)argvect[0], (char *const*)&argvect[0]);
}
else
{
waitpid(pid, &status, 0);
}
return status;
}
void possibly_define
(std::vector<std::string> &args,
std::string label,
std::string body = "1")
{
std::string the_definition = std::string("-D") + label;
for (size_t i = 0; i < args.size(); i++)
{
if (the_definition.size() <= args[i].size())
{
if (the_definition == args[i].substr(0,the_definition.size()))
{
// Already defined
return;
}
}
}
args.insert(args.begin(), the_definition + "=" + body);
}
int main( int argc, char **argv ) {
bool verbose = false, nostdlib = false,
nostartfiles = false, compile_only = false, is_dll = false, entry,
mkheader = true;
int status = 0;
std::string gcc_name, gcc_hash_output, gcc_line,
mingw_lib_dir, output_file, entry_point = "",
image_base = "0x400000",
section_align = "0x1000", file_align = "0x1000", subsystem = "cui",
result;
std::vector<std::string> gcc_args_str;
const char *installdir = getenv("INSTALLDIR");
installdir = installdir ? installdir : ".";
for( int i = 1; i < argc; i++ )
gcc_args_str.push_back(argv[i]);
gcc_name = std::string(installdir) + "/bin/powerpc-unknown-elf-gcc";
mingw_lib_dir = std::string(installdir) + "/lib";
getarg("-gcc-name", "", true, gcc_args_str, gcc_name);
getarg("-o", "", false, gcc_args_str, output_file);
mkheader = !getarg("-N", "", false, gcc_args_str, result);
compile_only = getarg("-c", "", false, gcc_args_str, result) ||
getarg("-E", "", false, gcc_args_str, result);
getarg("-mingw-lib-dir", "", true, gcc_args_str, mingw_lib_dir);
verbose = getarg("-v", "", false, gcc_args_str, result);
nostdlib = getarg("-nostdlib", "", false, gcc_args_str, result);
nostartfiles = getarg("-nostartfiles", "", false, gcc_args_str, result);
getarg("", "--subsystem", true, gcc_args_str, result);
entry = getarg("-e", "--entry", true, gcc_args_str, entry_point);
getarg("", "--image-base", true, gcc_args_str, image_base);
getarg("", "--section-alignment", true, gcc_args_str, section_align);
getarg("", "--file-alignment", true, gcc_args_str, file_align);
is_dll = getarg("-shared", "", true, gcc_args_str, result, true);
if (output_file.find(".gch") != std::string::npos)
compile_only = true;
if( entry )
{
if(entry_point.size() && entry_point[0] == '_')
{
entry_point = entry_point.substr(1);
}
if( !compile_only )
{
gcc_args_str.push_back(std::string("-Wl,--entry=") + entry_point);
gcc_args_str.push_back(std::string("-Wl,--undefined=") + entry_point);
}
}
// Nostdlib
if( !nostdlib && !compile_only ) {
gcc_args_str.push_back(std::string("-L") + mingw_lib_dir);
gcc_args_str.push_back("-lcrtdll");
gcc_args_str.push_back("-lmingw32");
gcc_args_str.push_back("-lkernel32");
}
// We never use the system start files or standard libs
gcc_args_str.insert(gcc_args_str.begin(),"-nostdlib");
gcc_args_str.insert(gcc_args_str.begin(),"-nostartfiles");
gcc_args_str.insert(gcc_args_str.begin(),"include/crt");
gcc_args_str.insert(gcc_args_str.begin(),"-isystem");
// Add necessary definitions but allow overrides
possibly_define(gcc_args_str,"_M_PPC");
possibly_define(gcc_args_str,"_PPC_");
possibly_define(gcc_args_str,"__PowerPC__");
possibly_define(gcc_args_str,"stdcall","");
possibly_define(gcc_args_str,"__stdcall__","");
possibly_define(gcc_args_str,"cdecl","");
possibly_define(gcc_args_str,"__cdecl__","");
possibly_define(gcc_args_str,"fastcall","");
possibly_define(gcc_args_str,"__fastcall__","");
possibly_define(gcc_args_str,"WORDS_BIGENDIAN");
possibly_define(gcc_args_str,"__MINGW_IMPORT","extern");
possibly_define(gcc_args_str,"_CRTIMP","");
possibly_define(gcc_args_str,"__NO_CTYPE_INLINES");
possibly_define(gcc_args_str,"__declspec(x)","");
/*if (!compile_only) gcc_args_str.push_back(mingw_lib_dir + "/libgcc.a"); */
// Stack on driver name and dump commands flag
if( verbose ) gcc_args_str.insert(gcc_args_str.begin(),"-v");
if (!compile_only)
{
if( is_dll ) gcc_args_str.insert(gcc_args_str.begin(), "-Wl,-r");
gcc_args_str.insert(gcc_args_str.begin(), "-Wl,-q");
gcc_args_str.insert(gcc_args_str.begin(), "-Wl,-d");
gcc_args_str.insert(gcc_args_str.begin(), "-Wl,--start-group");
gcc_args_str.insert(gcc_args_str.begin(), std::string("-Wl,-T,") + mingw_lib_dir + "/ldscript");
//gcc_args_str.insert(gcc_args_str.begin(), "-Wl,-shared,-Bsymbolic,-z,defs");
}
gcc_args_str.insert(gcc_args_str.begin(),gcc_name);
if( verbose ) {
fprintf( stderr, "#" );
for( size_t i = 0; i < gcc_args_str.size(); i++ ) {
fprintf( stderr, " \"%s\"", gcc_args_str[i].c_str() );
}
fprintf( stderr, "\n" );
}
if (!compile_only) gcc_args_str.insert(gcc_args_str.end(), "-Wl,--end-group");
if ( !(status = execute_command( verbose, gcc_args_str )) && !compile_only && mkheader )
{
/* Ok fixup the elf object file */
ElfObjectFile eof(output_file);
const ElfObjectFile::Symbol *entry_sym;
if(!eof) exit(1);
entry_sym = eof.getNamedSymbol(entry_point);
ElfPeHeader header
(strtoul(image_base.c_str(), 0, 0),
strtoul(section_align.c_str(), 0, 0),
strtoul(file_align.c_str(), 0, 0),
entry_sym,
0x10000,
0x100000,
0x10000,
0x100000,
atoi(subsystem.c_str()),
is_dll,
&eof);
eof.addSection(".peheader", header.getData(), TYPE_PEHEADER);
}
return status;
}

236
RosBE-PPC/elfpe/header.cpp Normal file
View File

@ -0,0 +1,236 @@
#include <time.h>
#include "util.h"
#include "header.h"
ElfPeHeader::ElfPeHeader
(uint32_t imagebase,
uint32_t filealign,
uint32_t sectionalign,
const ElfObjectFile::Symbol *entry,
uint32_t stackreserve,
uint32_t stackcommit,
uint32_t heapreserve,
uint32_t heapcommit,
int subsysid,
bool dll,
ElfObjectFile *eof) :
imagebase(imagebase),
sectionalign(sectionalign),
stackreserve(stackreserve),
stackcommit(stackcommit),
heapreserve(heapreserve),
heapcommit(heapcommit),
subsysid(subsysid),
entry(entry),
eof(eof)
{
data.resize(computeSize());
createHeaderSection();
}
int ElfPeHeader::computeSize() const
{
return sectionalign; /* We'll compute it for real later */
}
void ElfPeHeader::createHeaderSection()
{
std::vector<section_mapping_t> sectionRvaSet;
uint32_t imageSize = getSectionRvas(sectionRvaSet);
data[0] = 'M'; data[1] = 'Z';
uint8_t *dataptr = &data[0x3c];
uint32_t coffHeaderSize, optHeaderSizeMember;
le32write_postinc(dataptr, 0x80);
dataptr = &data[0x80];
le32write_postinc(dataptr, 0x4550);
le16write_postinc(dataptr, getPeArch());
le16write_postinc(dataptr, sectionRvaSet.size());
le32write_postinc(dataptr, time(NULL));
le32write_postinc(dataptr, 0);
le32write_postinc(dataptr, 0);
optHeaderSizeMember = dataptr - &data[0];
le16write_postinc(dataptr, 0); // Will fixup sizeof opt header
le16write_postinc(dataptr, getExeFlags());
coffHeaderSize = dataptr - &data[0];
le16write_postinc(dataptr, 0);
le16write_postinc(dataptr, 0x100);
le32write_postinc(dataptr, 0);
le32write_postinc(dataptr, 0);
le32write_postinc(dataptr, 0);
le32write_postinc(dataptr, getEntryPoint(sectionRvaSet, entry));
le32write_postinc(dataptr, 0);
le32write_postinc(dataptr, 0);
le32write_postinc(dataptr, imagebase);
le32write_postinc(dataptr, sectionalign);
le32write_postinc(dataptr, filealign);
le16write_postinc(dataptr, 4);
le16write_postinc(dataptr, 0);
le16write_postinc(dataptr, 1);
le16write_postinc(dataptr, 0);
le16write_postinc(dataptr, 4);
le16write_postinc(dataptr, 0);
le32write_postinc(dataptr, 0);
le32write_postinc(dataptr, imageSize);
le32write_postinc(dataptr, computeSize());
le32write_postinc(dataptr, 0); // No checksum yet
le16write_postinc(dataptr, subsysid);
le16write_postinc(dataptr, getDllFlags());
le32write_postinc(dataptr, stackreserve);
le32write_postinc(dataptr, stackcommit);
le32write_postinc(dataptr, heapreserve);
le32write_postinc(dataptr, heapcommit);
le32write_postinc(dataptr, 0);
le32write_postinc(dataptr, 10); // # Directories
// "Directories"
le32pwrite_postinc(dataptr, getExportInfo(sectionRvaSet));
le32pwrite_postinc(dataptr, getImportInfo(sectionRvaSet));
le32pwrite_postinc(dataptr, getResourceInfo(sectionRvaSet));
le32pwrite_postinc(dataptr, getExceptionInfo());
le32pwrite_postinc(dataptr, getSecurityInfo());
le32pwrite_postinc(dataptr, getRelocInfo());
le32pwrite_postinc(dataptr, getDebugInfo());
le32pwrite_postinc(dataptr, getDescrInfo());
le32pwrite_postinc(dataptr, getMachInfo());
le32pwrite_postinc(dataptr, getTlsInfo());
// Fixup size of optional header
le16write
(&data[0] + optHeaderSizeMember,
(dataptr - &data[0]) - coffHeaderSize);
// Here, we store references to the sections, filling in the RVA and
// size, but leaving out the other info. We write the section name
// truncated into the name field and leave the section id in the
// physical address bit
for (int i = 0; i < sectionRvaSet.size(); i++)
{
section_mapping_t mapping = sectionRvaSet[i];
const ElfObjectFile::Section *section = mapping.section;
std::string name = section->getName();
uint32_t size = section->logicalSize();
uint32_t rva = mapping.rva;
for (int j = 0; j < 8; j++)
{
*dataptr++ = j < name.size() ? name[j] : '\000';
}
le32write_postinc(dataptr, size);
le32write_postinc(dataptr, rva);
le32write_postinc(dataptr, size);
// Note: we put the index in the offset slot so we can find the
// real offset later in the loader
le32write_postinc(dataptr, sectionRvaSet[i].index);
le32write_postinc(dataptr, 0);
le32write_postinc(dataptr, 0);
le32write_postinc(dataptr, 0);
// XXX Figure out the real flags
le32write_postinc(dataptr, IMAGE_SCN_CNT_CODE);
}
}
const std::vector<uint8_t> &ElfPeHeader::getData() const { return data; }
uint32_t ElfPeHeader::getSectionRvas(std::vector<section_mapping_t> &rvas) const
{
uint32_t start = computeSize();
uint32_t limit = start;
for(int i = 0; i < eof->getNumSections(); i++) {
{
const ElfObjectFile::Section &sect = eof->getSection(i);
if(sect.getFlags() & SHF_ALLOC) {
limit = roundup(start + sect.logicalSize(), sectionalign);
#if 0
fprintf(stderr, "rva[%02d:%s] = (%x %x %d)\n",
rvas.size(), sect.getName().c_str(), &sect, start, i);
#endif
rvas.push_back(section_mapping_t(&sect, start, i));
}
}
start = limit;
}
return limit;
}
uint16_t ElfPeHeader::getPeArch() const
{
return IMAGE_FILE_MACHINE_POWERPCBE; /* for now */
}
u32pair_t getNamedSectionInfo(ElfObjectFile *eof, const std::vector<section_mapping_t> &mapping, const std::string &name)
{
const ElfObjectFile::Section *sect = eof->getNamedSection(name);
uint32_t sectaddr;
int i;
if(sect)
{
for(i = 0; i < mapping.size(); i++)
if(mapping[i].index == sect->getNumber())
{
return std::make_pair
(mapping[i].rva, sect->logicalSize());
}
}
return std::make_pair(0,0);
}
u32pair_t ElfPeHeader::getExportInfo(const std::vector<section_mapping_t> &mapping) const
{
return getNamedSectionInfo(eof, mapping, ".edata");
}
u32pair_t ElfPeHeader::getImportInfo(const std::vector<section_mapping_t> &mapping) const
{
return getNamedSectionInfo(eof, mapping, ".idata");
}
u32pair_t ElfPeHeader::getResourceInfo(const std::vector<section_mapping_t> &mapping) const
{
return getNamedSectionInfo(eof, mapping, ".rsrc");
}
u32pair_t ElfPeHeader::getExceptionInfo() const
{
return std::make_pair(0,0);
}
u32pair_t ElfPeHeader::getSecurityInfo() const
{
return std::make_pair(0,0);
}
u32pair_t ElfPeHeader::getRelocInfo() const
{
return std::make_pair(0,0);
}
u32pair_t ElfPeHeader::getDebugInfo() const
{
return std::make_pair(0,0);
}
u32pair_t ElfPeHeader::getDescrInfo() const
{
return std::make_pair(0,0);
}
u32pair_t ElfPeHeader::getTlsInfo() const
{
return std::make_pair(0,0);
}
u32pair_t ElfPeHeader::getMachInfo() const
{
return std::make_pair(0,0);
}
uint32_t ElfPeHeader::getEntryPoint
(const std::vector<section_mapping_t> &secmap,
const ElfObjectFile::Symbol *entry) const
{
if(entry == NULL) return computeSize();
for(int i = 0; i < secmap.size(); i++) {
if(secmap[i].index == entry->section)
return secmap[i].rva + entry->offset;
}
return computeSize();
}

71
RosBE-PPC/elfpe/header.h Normal file
View File

@ -0,0 +1,71 @@
#ifndef COMPDVR_ELFHEADER_H
#define COMPDVR_ELFHEADER_H
#include <vector>
#include <utility>
#include "pedef.h"
#include "util.h"
#include "objectfile.h"
typedef struct section_mapping_t {
const ElfObjectFile::Section *section;
uint32_t rva;
int index;
section_mapping_t
(const ElfObjectFile::Section *sect, uint32_t rva, int index) :
section(sect), rva(rva), index(index) { }
section_mapping_t(const section_mapping_t &other) :
section(other.section), rva(other.rva), index(other.index) { }
} section_mapping_t;
class ElfPeHeader {
public:
ElfPeHeader
(uint32_t imagebase,
uint32_t imagealign,
uint32_t filealign,
const ElfObjectFile::Symbol *entry,
uint32_t stackreserve,
uint32_t stackcommit,
uint32_t heapreserve,
uint32_t heapcommit,
int subsysid,
bool dll,
ElfObjectFile *eof);
const ElfObjectFile::secdata_t &getData() const;
private:
void createHeaderSection();
uint32_t getSectionRvas(std::vector<section_mapping_t> &rvas) const;
uint32_t getEntryPoint(const std::vector<section_mapping_t> &rvas, const ElfObjectFile::Symbol *entry) const;
int computeSize() const;
int getExeFlags() const { return 0; }
int getDllFlags() const { return dll ? IMAGE_FILE_DLL : 0; }
u32pair_t getExportInfo(const std::vector<section_mapping_t> &rvas) const;
u32pair_t getImportInfo(const std::vector<section_mapping_t> &rvas) const;
u32pair_t getResourceInfo(const std::vector<section_mapping_t> &rvas) const;
u32pair_t getExceptionInfo() const;
u32pair_t getSecurityInfo() const;
u32pair_t getRelocInfo() const;
u32pair_t getDebugInfo() const;
u32pair_t getDescrInfo() const;
u32pair_t getMachInfo() const;
u32pair_t getTlsInfo() const;
uint16_t getPeArch() const;
uint32_t saToRva(int section, uint32_t offset) const;
uint32_t vaToRva(uint32_t source_addr) const;
uint32_t
imagebase, filealign, sectionalign,
stackreserve, stackcommit,
heapreserve, heapcommit;
bool dll;
int subsysid;
const ElfObjectFile::Symbol *entry;
ElfObjectFile *eof;
std::vector<uint8_t> data;
static const char *mzHeader;
};
#endif//COMPDVR_ELFHEADER_H

View File

@ -0,0 +1,127 @@
#include <libelf/libelf.h>
#include <fcntl.h>
#include "util.h"
#include "objectfile.h"
ElfObjectFile::ElfObjectFile(const std::string &filename) : fd(-1)
{
Elf_Scn *s = 0;
Elf32_Ehdr *ehdr;
Section *sect;
elfHeader = NULL;
fd = open(filename.c_str(), O_RDWR, 0);
if(fd >= 0) {
if(elf_version(EV_CURRENT) == EV_NONE) {
// Old version
return;
}
elfHeader = elf_begin(fd, ELF_C_RDWR, (Elf*)0);
if(elf_kind(elfHeader) != ELF_K_ELF) {
// Didn't get an elf object file
elfHeader = NULL;
return;
}
ehdr = elf32_getehdr(elfHeader);
shnum = ehdr->e_shnum;
phnum = ehdr->e_phnum;
shstrndx = ehdr->e_shstrndx;
/* Populate section table */
for(size_t i = 0; i < shnum; i++)
{
s = elf_nextscn(elfHeader, s);
if(!s) break;
sect = new Section(*this, i, s);
sections.push_back(sect);
sections_by_name.insert(std::make_pair(sect->getName(), sect));
}
populateSymbolTable();
}
}
ElfObjectFile::~ElfObjectFile()
{
if(elfHeader) elf_end(elfHeader);
if(fd >= 0) close(fd);
}
void ElfObjectFile::populateSymbolTable()
{
int i = 0, j;
int type, link, flags, section;
uint32_t offset;
std::string name;
uint8_t *data, *symptr;
Elf32_Sym *sym;
Symbol *ourSym;
for( i = 0; i < getNumSections(); i++ ) {
type = getSection(i).getType();
link = getSection(i).getLink();
if( (type == SHT_SYMTAB) || (type == SHT_DYNSYM) ) {
/* Read a symbol */
sym = (Elf32_Sym*)getSection(i).getSectionData();
for (j = 0; j < getSection(i).logicalSize() / sizeof(Elf32_Sym); j++) {
name = elf_strptr(elfHeader, link, sym[j].st_name);
ourSym = new Symbol(name, sym[j].st_value, sym[j].st_shndx, sym[j].st_info);
symbols.push_back(ourSym);
symbols_by_name.insert(std::make_pair(name, ourSym));
}
}
}
}
uint32_t ElfObjectFile::getEntryPoint() const
{
Elf32_Ehdr *elf32ehdr = elf32_getehdr(elfHeader);
return elf32ehdr->e_entry;
}
void ElfObjectFile::addSection(const std::string &name, const secdata_t &data, int type)
{
Elf_Scn *newsect = elf_newscn(elfHeader),
*strsect = elf_getscn(elfHeader, shstrndx);
Elf32_Shdr *shdr = elf32_getshdr(newsect);
/* Create data for the new section */
Elf_Data *edata = elf_newdata(newsect), *strdata = elf_getdata(strsect, 0),
*newstrdata = elf_newdata(strsect);
edata->d_align = 0x1000;
edata->d_size = data.size();
edata->d_off = 0;
edata->d_type = ELF_T_BYTE;
edata->d_version = EV_CURRENT;
edata->d_buf = malloc(edata->d_size);
memcpy(edata->d_buf, &data[0], edata->d_size);
/* Add the name of the new section to the string table */
newstrdata->d_off = strdata->d_off + strdata->d_size;
newstrdata->d_size = name.size() + 1;
newstrdata->d_align = 1;
newstrdata->d_buf = (void *)name.c_str();
/* Finish the section */
shdr->sh_name = newstrdata->d_off;
shdr->sh_type = type;
shdr->sh_flags = SHF_ALLOC;
shdr->sh_addr = 0;
shdr->sh_link = 0;
shdr->sh_info = 0;
elf_update(elfHeader, ELF_C_WRITE);
}
const ElfObjectFile::Section *ElfObjectFile::getNamedSection(const std::string &name) const
{
std::map<std::string, const ElfObjectFile::Section *>::const_iterator i =
sections_by_name.find(name);
if(i != sections_by_name.end())
return i->second;
else return NULL;
}
const ElfObjectFile::Symbol *ElfObjectFile::getNamedSymbol(const std::string &name) const
{
std::map<std::string, const ElfObjectFile::Symbol *>::const_iterator i =
symbols_by_name.find(name);
if(i != symbols_by_name.end())
return i->second;
else return NULL;
}

View File

@ -0,0 +1,126 @@
#ifndef COMPDVR_ELFOBJECT_H
#define COMPDVR_ELFOBJECT_H
#include <string>
#include <vector>
#include <map>
#include <libelf/libelf.h>
class ElfObjectFile {
public:
typedef std::vector<uint8_t> secdata_t;
class Symbol {
public:
Symbol(const std::string &name, uint32_t offset,
int section, int flags) :
name(name), offset(offset), section(section), flags(flags) { }
std::string name;
uint32_t offset;
int section;
int flags;
};
class Section {
public:
Section(const Section &other) :
obj(other.obj), section(other.section), have_data(false),
number(other.number) {
e32shdr = elf32_getshdr(section);
}
Section(ElfObjectFile &obj, int number, Elf_Scn *sechdr) :
obj(&obj), section(sechdr), have_data(false), number(number) {
e32shdr = elf32_getshdr(section);
}
Section &operator = (const Section &other) {
obj = other.obj;
have_data = false;
section = other.section;
e32shdr = other.e32shdr;
number = other.number;
}
operator bool () { return !!section; }
std::string getName() const {
return obj->getString(e32shdr->sh_name);
}
int getType() const {
return e32shdr->sh_type;
}
int getNumber() const {
return number;
}
int getLink() const {
return e32shdr->sh_link;
}
int getInfo() const {
return e32shdr->sh_info;
}
int getFlags() const {
return e32shdr->sh_flags;
}
int logicalSize() const {
return e32shdr->sh_size;
}
uint32_t getStartRva() const {
return e32shdr->sh_addr;
}
uint32_t getFileOffset() const {
return e32shdr->sh_offset;
}
uint8_t *getSectionData() const {
if(!have_data) {
data = *elf_getdata(section, NULL);
have_data = true;
}
return (uint8_t *)data.d_buf;
}
private:
const ElfObjectFile *obj;
int number;
Elf_Scn *section;
Elf32_Shdr *e32shdr;
mutable bool have_data;
mutable Elf_Data data;
};
ElfObjectFile(const std::string &filename);
~ElfObjectFile();
Elf *operator -> () { return fd >= 0 ? elfHeader : 0; }
bool operator ! () const { return fd == -1 ? true : false; }
int getNumSections() const { return sections.size(); }
uint32_t getEntryPoint() const;
std::string getString(int offset) const {
return elf_strptr(elfHeader, shstrndx, offset);
}
void addSection
(const std::string &name, const secdata_t &data, int type = SHT_PROGBITS);
const Section &getSection(int sect) const { return *sections[sect]; }
const Section *getNamedSection(const std::string &name) const;
const Symbol &getSymbol(int n) const { return *symbols[n]; }
const Symbol *getNamedSymbol(const std::string &symname) const;
private:
int fd;
int shnum, phnum;
int shstrndx;
Elf *elfHeader;
std::vector<Section*> sections;
std::map<std::string, const Section *> sections_by_name;
std::vector<Symbol*> symbols;
std::map<std::string, const Symbol *> symbols_by_name;
void populateSymbolTable();
};
#endif//COMPDVR_ELFOBJECT_H

44
RosBE-PPC/elfpe/pedef.h Normal file
View File

@ -0,0 +1,44 @@
#ifndef COMPDVR_PEDEF_H
#define COMPDVR_PEDEF_H
// Definitions from bernd.luevelsmeyer@iplan.heitec.net 's pe.txt reference
#define IMAGE_FILE_MACHINE_I386 (0x14c)
#define IMAGE_FILE_MACHINE_I486 (0x14d)
#define IMAGE_FILE_MACHINE_I586 (0x14e)
#define IMAGE_FILE_MACHINE_R3000BE (0x160)
#define IMAGE_FILE_MACHINE_R3000 (0x162)
#define IMAGE_FILE_MACHINE_R4000 (0x166)
#define IMAGE_FILE_MACHINE_R10000 (0x168)
#define IMAGE_FILE_MACHINE_ALPHA (0x184)
#define IMAGE_FILE_MACHINE_POWERPC (0x1F0)
// Recognize BE PowerPC by a coff BE style arch magic
#define IMAGE_FILE_MACHINE_POWERPCBE (0xF001)
#define IMAGE_FILE_RELOCS_STRIPPED 0x0001
#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
#define IMAGE_FILE_AGGRESSIVE_WS_TRIM 0x0010
#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
#define IMAGE_FILE_32BIT_MACHINE 0x0100
#define IMAGE_FILE_DEBUG_STRIPPED 0x0200
#define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
#define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
#define IMAGE_FILE_SYSTEM 0x1000
#define IMAGE_FILE_DLL 0x2000
#define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
#define IMAGE_SCN_CNT_CODE 0x00000020
#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
#define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
#define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
#define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
#define IMAGE_SCN_MEM_SHARED 0x10000000
#define IMAGE_SCN_MEM_EXECUTE 0x20000000
#define IMAGE_SCN_MEM_READ 0x40000000
#define IMAGE_SCN_MEM_WRITE 0x80000000
#endif//COMPDVR_PEDEF_H

59
RosBE-PPC/elfpe/util.cpp Normal file
View File

@ -0,0 +1,59 @@
#include "util.h"
uint32_t roundup(uint32_t value, int round)
{
round--;
return (value + round) & ~round;
}
void le16write(uint8_t *dataptr, uint16_t value)
{
dataptr[0] = value;
dataptr[1] = value >> 8;
}
void le16write_postinc(uint8_t *&dataptr, uint16_t value)
{
le16write(dataptr, value); dataptr += 2;
}
void le32write(uint8_t *dataptr, uint32_t value)
{
le16write(dataptr, value);
le16write(dataptr + 2, value >> 16);
}
void le32write_postinc(uint8_t *&dataptr, uint32_t value)
{
le32write(dataptr, value); dataptr += 4;
}
void le32pwrite_postinc(uint8_t *&dataptr, const u32pair_t &value)
{
le32write_postinc(dataptr, value.first);
le32write_postinc(dataptr, value.second);
}
uint16_t be16read(uint8_t *dataptr)
{
return dataptr[0] << 8 | dataptr[1];
}
uint16_t be16read_postinc(uint8_t *&dataptr)
{
uint16_t res = be16read(dataptr);
dataptr += 2;
return res;
}
uint32_t be32read(uint8_t *dataptr)
{
return be16read(dataptr) << 16 | be16read(dataptr+2);
}
uint32_t be32read_postinc(uint8_t *&dataptr)
{
uint32_t res = be32read(dataptr);
dataptr += 4;
return res;
}

24
RosBE-PPC/elfpe/util.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef COMPDVR_UTIL_H
#define COMPDVR_UTIL_H
#include <utility>
#include <stdint.h>
void le16write(uint8_t *dataptr, uint16_t value);
void le16write_postinc(uint8_t *&dataptr, uint16_t value);
void le32write(uint8_t *dataptr, uint32_t value);
void le32write_postinc(uint8_t *&dataptr, uint32_t value);
uint16_t le16read(uint8_t *dataptr);
uint16_t le16read_postinc(uint8_t *&dataptr);
uint32_t le32read(uint8_t *dataptr);
uint32_t le32read_postinc(uint8_t *&dataptr);
uint16_t be16read(uint8_t *dataptr);
uint16_t be16read_postinc(uint8_t *&dataptr);
uint32_t be32read(uint8_t *dataptr);
uint32_t be32read_postinc(uint8_t *&dataptr);
typedef std::pair<uint32_t, uint32_t> u32pair_t;
void le32pwrite_postinc(uint8_t *&dataptr, const u32pair_t &pair);
void le32pwrite(uint8_t *dataptr, const u32pair_t &pair);
uint32_t roundup(uint32_t value, int round);
#endif//COMPDVR_UTIL_H

View File

@ -0,0 +1,683 @@
Only in binutils-2.16.1/bfd: bfd.i
Only in binutils-2.16.1/bfd: bfd_wrap.c
Only in clean/binutils-2.16.1/bfd/doc: bfd.info-1
Only in clean/binutils-2.16.1/bfd/doc: bfd.info-2
diff -x '*.1' -x '*.info' -ur clean/binutils-2.16.1/bfd/elf.c binutils-2.16.1/bfd/elf.c
--- clean/binutils-2.16.1/bfd/elf.c 2005-05-29 15:00:10.000000000 -0700
+++ binutils-2.16.1/bfd/elf.c 2007-09-12 23:53:42.000000000 -0700
@@ -4744,7 +4744,7 @@
if (bfd_seek (abfd, i_shdrp[count]->sh_offset, SEEK_SET) != 0
|| bfd_bwrite (i_shdrp[count]->contents, amt, abfd) != amt)
return FALSE;
- }
+ }
if (count == SHN_LORESERVE - 1)
count += SHN_HIRESERVE + 1 - SHN_LORESERVE;
}
@@ -6539,7 +6539,6 @@
_bfd_elf_validate_reloc (bfd *abfd, arelent *areloc)
{
/* Check whether we really have an ELF howto. */
-
if ((*areloc->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec)
{
bfd_reloc_code_real_type code;
diff -x '*.1' -x '*.info' -ur clean/binutils-2.16.1/bfd/elf32-ppc.c binutils-2.16.1/bfd/elf32-ppc.c
--- clean/binutils-2.16.1/bfd/elf32-ppc.c 2005-04-19 10:09:30.000000000 -0700
+++ binutils-2.16.1/bfd/elf32-ppc.c 2007-09-12 23:53:43.000000000 -0700
@@ -2053,6 +2053,7 @@
case BFD_RELOC_LO16_PLTOFF: r = R_PPC_PLT16_LO; break;
case BFD_RELOC_HI16_PLTOFF: r = R_PPC_PLT16_HI; break;
case BFD_RELOC_HI16_S_PLTOFF: r = R_PPC_PLT16_HA; break;
+ case BFD_RELOC_RVA: r = R_PPC_UADDR32; break;
case BFD_RELOC_GPREL16: r = R_PPC_SDAREL16; break;
case BFD_RELOC_16_BASEREL: r = R_PPC_SECTOFF; break;
case BFD_RELOC_LO16_BASEREL: r = R_PPC_SECTOFF_LO; break;
Only in binutils-2.16.1/bfd: elf32-ppc.c~
Only in binutils-2.16.1/binutils: dlltool
diff -x '*.1' -x '*.info' -ur clean/binutils-2.16.1/binutils/dlltool.c binutils-2.16.1/binutils/dlltool.c
--- clean/binutils-2.16.1/binutils/dlltool.c 2005-02-23 04:25:57.000000000 -0800
+++ binutils-2.16.1/binutils/dlltool.c 2007-09-14 23:01:31.000000000 -0700
@@ -382,7 +382,7 @@
extern char * program_name;
static int machine;
-static int killat;
+static int killat = 1;
static int add_stdcall_alias;
static const char *ext_prefix_alias;
static int verbose;
@@ -417,11 +417,12 @@
static const char * mname = "mcore-le";
#endif
+static char * elf_linker = NULL;
+static char * elf_linker_flags = NULL;
+
#ifdef DLLTOOL_MCORE_ELF
static const char * mname = "mcore-elf";
static char * mcore_elf_out_file = NULL;
-static char * mcore_elf_linker = NULL;
-static char * mcore_elf_linker_flags = NULL;
#define DRECTVE_SECTION_NAME ((machine == MMCORE_ELF || machine == MMCORE_ELF_LE) ? ".exports" : ".drectve")
#endif
@@ -507,13 +508,23 @@
the glue. */
static const unsigned char ppc_jtab[] =
{
- 0x00, 0x00, 0x62, 0x81, /* lwz r11,0(r2) */
- /* Reloc TOCREL16 __imp_xxx */
- 0x00, 0x00, 0x8B, 0x81, /* lwz r12,0(r11) */
- 0x04, 0x00, 0x41, 0x90, /* stw r2,4(r1) */
- 0xA6, 0x03, 0x89, 0x7D, /* mtctr r12 */
- 0x04, 0x00, 0x4B, 0x80, /* lwz r2,4(r11) */
- 0x20, 0x04, 0x80, 0x4E /* bctr */
+ 0x38, 0x21, 0xff, 0xf0, /* addi 1,1,-16 */
+ 0x7c, 0x08, 0x02, 0xa6, /* mflr 0 */
+ 0x90, 0x01, 0x00, 0x00, /* stw 0,0(1) */
+ 0x90, 0x61, 0x00, 0x04, /* stw 3,4(1) */
+ 0x48, 0x00, 0x00, 0x05, /* bl next */
+ 0x7c, 0x68, 0x02, 0xa6, /* mflr 3 */
+ 0x38, 0x63, 0x00, 0x2c, /* addi 3,3,44 */
+ 0x80, 0x63, 0x00, 0x00, /* lwz 3,0(3) */
+ 0x80, 0x03, 0x00, 0x00, /* lwz 0,0(3) */
+ 0x80, 0x61, 0x00, 0x04, /* lwz 3,4(1) */
+ 0x7c, 0x08, 0x03, 0xa6, /* mtlr 0 */
+ 0x4e, 0x80, 0x00, 0x21, /* blrl */
+ 0x80, 0x01, 0x00, 0x00, /* lwz 0,0,1 */
+ 0x7c, 0x08, 0x03, 0xa6, /* mtlr 0 */
+ 0x38, 0x21, 0x00, 0x10, /* addi 1,1,16 */
+ 0x4e, 0x80, 0x00, 0x20, /* blr */
+ 0x00, 0x00, 0x00, 0x00, /* ; receives address of table entry */
};
#ifdef DLLTOOL_PPC
@@ -567,8 +578,8 @@
#define MPPC 2
"ppc", ".byte", ".short", ".long", ".asciz", "#",
"jmp *", ".global", ".space", ".align\t2",".align\t4", "",
- "pe-powerpcle",bfd_arch_powerpc,
- ppc_jtab, sizeof (ppc_jtab), 0
+ "powerpc-unknown-linux-gnu", bfd_arch_powerpc,
+ ppc_jtab, sizeof (ppc_jtab), 0x40
}
,
{
@@ -1351,6 +1362,7 @@
sprintf (new_exclude->string, "%s", exclude_string);
else
sprintf (new_exclude->string, "_%s", exclude_string);
+
new_exclude->next = excludes;
excludes = new_exclude;
@@ -1538,7 +1550,7 @@
fprintf (f, "\n");
for (i = 0, exp = d_exports; exp; i++, exp = exp->next)
{
- fprintf (f, "%s %d = %s %s @ %d %s%s%s%s\n",
+ fprintf (f, "%s - %d = %s %s @ %d %s%s%s%s\n",
ASM_C,
i,
exp->name,
@@ -1778,7 +1790,7 @@
if (d_exports)
{
- fprintf (f, "\t.section .edata\n\n");
+ fprintf (f, "\t.section .edata,\"ax\"\n\n");
fprintf (f, "\t%s 0 %s Allways 0\n", ASM_LONG, ASM_C);
fprintf (f, "\t%s 0x%lx %s Time and date\n", ASM_LONG, (long) time(0),
ASM_C);
@@ -1821,13 +1833,31 @@
if (exp->forward == 0)
{
+ int i, lead_at;
+ char *function_name = xmalloc(strlen(exp->internal_name)+1);
+ char *nameptr = function_name;
+ char *last_at;
+
+ lead_at = exp->internal_name[0] == '@';
+ last_at = strrchr(exp->internal_name + lead_at, '@');
+
+ if( !last_at || last_at == exp->internal_name )
+ last_at = exp->internal_name + strlen(exp->internal_name);
+
+ for( i = 0; i + exp->internal_name < last_at; i++ )
+ if( exp->internal_name[i] != '@' )
+ *nameptr++ = exp->internal_name[i];
+ *nameptr = 0;
+
if (exp->internal_name[0] == '@')
fprintf (f, "\t%s%s%s\t%s %d\n", ASM_RVA_BEFORE,
- exp->internal_name, ASM_RVA_AFTER, ASM_C, exp->ordinal);
+ function_name, ASM_RVA_AFTER, ASM_C, exp->ordinal);
else
fprintf (f, "\t%s%s%s%s\t%s %d\n", ASM_RVA_BEFORE,
ASM_PREFIX (exp->internal_name),
- exp->internal_name, ASM_RVA_AFTER, ASM_C, exp->ordinal);
+ function_name, ASM_RVA_AFTER, ASM_C, exp->ordinal);
+
+ free(function_name);
}
else
fprintf (f, "\t%sf%d%s\t%s %d\n", ASM_RVA_BEFORE,
@@ -2002,7 +2032,7 @@
{
int lead_at = (*name == '@');
- if (add_underscore && !lead_at)
+ if (add_underscore && !lead_at)
{
char *copy = xmalloc (strlen (name) + 2);
@@ -2036,8 +2066,6 @@
unsigned char *data;
} sinfo;
-#ifndef DLLTOOL_PPC
-
#define TEXT 0
#define DATA 1
#define BSS 2
@@ -2045,8 +2073,16 @@
#define IDATA5 4
#define IDATA4 5
#define IDATA6 6
+#ifdef DLLTOOL_PPC
+#define RDATA 7
+#define PDATA 8
+#endif
+#ifdef DLLTOOL_PPC
+#define NSECS 9
+#else
#define NSECS 7
+#endif
#define TEXT_SEC_FLAGS \
(SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY | SEC_HAS_CONTENTS)
@@ -2057,45 +2093,18 @@
{ id, name, flags, align, NULL, NULL, NULL, 0, NULL }
static sinfo secdata[NSECS] =
{
- INIT_SEC_DATA (TEXT, ".text", TEXT_SEC_FLAGS, 2),
+ INIT_SEC_DATA (TEXT, ".text", TEXT_SEC_FLAGS | SEC_RELOC, 2),
INIT_SEC_DATA (DATA, ".data", DATA_SEC_FLAGS, 2),
INIT_SEC_DATA (BSS, ".bss", BSS_SEC_FLAGS, 2),
INIT_SEC_DATA (IDATA7, ".idata$7", SEC_HAS_CONTENTS, 2),
- INIT_SEC_DATA (IDATA5, ".idata$5", SEC_HAS_CONTENTS, 2),
- INIT_SEC_DATA (IDATA4, ".idata$4", SEC_HAS_CONTENTS, 2),
- INIT_SEC_DATA (IDATA6, ".idata$6", SEC_HAS_CONTENTS, 1)
-};
-
-#else
-
-/* Sections numbered to make the order the same as other PowerPC NT
- compilers. This also keeps funny alignment thingies from happening. */
-#define TEXT 0
-#define PDATA 1
-#define RDATA 2
-#define IDATA5 3
-#define IDATA4 4
-#define IDATA6 5
-#define IDATA7 6
-#define DATA 7
-#define BSS 8
-
-#define NSECS 9
-
-static sinfo secdata[NSECS] =
-{
- { TEXT, ".text", SEC_CODE | SEC_HAS_CONTENTS, 3},
- { PDATA, ".pdata", SEC_HAS_CONTENTS, 2},
- { RDATA, ".reldata", SEC_HAS_CONTENTS, 2},
- { IDATA5, ".idata$5", SEC_HAS_CONTENTS, 2},
- { IDATA4, ".idata$4", SEC_HAS_CONTENTS, 2},
- { IDATA6, ".idata$6", SEC_HAS_CONTENTS, 1},
- { IDATA7, ".idata$7", SEC_HAS_CONTENTS, 2},
- { DATA, ".data", SEC_DATA, 2},
- { BSS, ".bss", 0, 2}
-};
-
+ INIT_SEC_DATA (IDATA5, ".idata$5", SEC_HAS_CONTENTS | SEC_RELOC, 2),
+ INIT_SEC_DATA (IDATA4, ".idata$4", SEC_HAS_CONTENTS | SEC_RELOC, 2),
+ INIT_SEC_DATA (IDATA6, ".idata$6", SEC_HAS_CONTENTS, 1),
+#ifdef DLLTOOL_PPC
+ INIT_SEC_DATA (RDATA, ".rdata", SEC_HAS_CONTENTS, 2),
+ INIT_SEC_DATA (PDATA, ".pdata", SEC_HAS_CONTENTS, 2),
#endif
+};
/* This is what we're trying to make. We generate the imp symbols with
both single and double underscores, for compatibility.
@@ -2143,6 +2152,7 @@
strcpy (copy, ASM_PREFIX (name));
strcat (copy, prefix);
strcat (copy, name);
+
return copy;
}
@@ -2150,14 +2160,14 @@
make_imp_label (const char *prefix, const char *name)
{
int len;
- char *copy;
+ char *copy, *xname;
if (name[0] == '@')
{
len = strlen (prefix) + strlen (name);
copy = xmalloc (len + 1);
strcpy (copy, prefix);
- strcat (copy, name);
+ strcat (copy, name+1);
}
else
{
@@ -2167,13 +2177,21 @@
strcat (copy, ASM_PREFIX (name));
strcat (copy, name);
}
+
+ xname = strchr (copy+1,'@');
+ if (xname)
+ {
+ *xname = 0;
+ }
+
return copy;
}
-static bfd *
-make_one_lib_file (export_type *exp, int i)
+static bfd *make_one_lib_file (export_type *exp, int i)
{
bfd * abfd;
+ asymbol * hint_name;
+ asymbol * oft_sym;
asymbol * exp_label;
asymbol * iname = 0;
asymbol * iname2;
@@ -2188,12 +2206,11 @@
#ifndef EXTRA
#define EXTRA 0
#endif
- asymbol * ptrs[NSECS + 4 + EXTRA + 1];
+ asymbol * ptrs[NSECS + 4 + EXTRA + 3];
flagword applicable;
char * outname = xmalloc (strlen (TMP_STUB) + 10);
int oidx = 0;
-
sprintf (outname, "%s%05d.o", TMP_STUB, i);
abfd = bfd_openw (outname, HOW_BFD_WRITE_TARGET);
@@ -2245,19 +2262,8 @@
if (! exp->data)
{
exp_label = bfd_make_empty_symbol (abfd);
- exp_label->name = make_imp_label ("", exp->name);
-
- /* On PowerPC, the function name points to a descriptor in
- the rdata section, the first element of which is a
- pointer to the code (..function_name), and the second
- points to the .toc. */
-#ifdef DLLTOOL_PPC
- if (machine == MPPC)
- exp_label->section = secdata[RDATA].sec;
- else
-#endif
- exp_label->section = secdata[TEXT].sec;
-
+ exp_label->name = make_imp_label ("..", exp->name);
+ exp_label->section = secdata[TEXT].sec;
exp_label->flags = BSF_GLOBAL;
exp_label->value = 0;
@@ -2289,6 +2295,7 @@
iname_lab = bfd_make_empty_symbol (abfd);
iname_lab->name = head_label;
+
iname_lab->section = (asection *) &bfd_und_section;
iname_lab->flags = 0;
iname_lab->value = 0;
@@ -2305,17 +2312,48 @@
/* The symbol referring to the code (.text). */
{
asymbol *function_name;
+ char *at;
+ int lead_at;
+ char hint_name_buf[0x100];
function_name = bfd_make_empty_symbol(abfd);
- function_name->name = make_label ("..", exp->name);
+ lead_at = exp->name[0] == '@';
+ function_name->name = make_label ("", exp->name+lead_at);
+ at = strchr(function_name->name + lead_at, '@');
+ if(at) *at = 0;
function_name->section = secdata[TEXT].sec;
function_name->flags = BSF_GLOBAL;
function_name->value = 0;
fn_pp = ptrs + oidx;
ptrs[oidx++] = function_name;
+
+ sprintf( hint_name_buf, "_sym_%s_%s", head_label, function_name->name );
+ at = strchr(hint_name_buf, '@');
+ if (at) *at = 0;
+
+ hint_name = bfd_make_empty_symbol(abfd);
+ hint_name->name = make_label ("", hint_name_buf);
+ hint_name->section = secdata[IDATA6].sec;
+ hint_name->flags = BSF_GLOBAL;
+ hint_name->value = 0;
+
+ ptrs[oidx++] = hint_name;
+
+ sprintf( hint_name_buf, "_idata4_%s_%s", head_label, function_name->name );
+ at = strchr(hint_name_buf, '@');
+ if (at) *at = 0;
+
+ oft_sym = bfd_make_empty_symbol(abfd);
+ oft_sym->name = make_label ("", hint_name_buf);
+ oft_sym->section = secdata[IDATA5].sec;
+ oft_sym->flags = BSF_GLOBAL;
+ oft_sym->value = 0;
+
+ ptrs[oidx++] = oft_sym;
}
+#if 0
/* The .toc symbol. */
{
asymbol *toc_symbol;
@@ -2330,6 +2368,7 @@
ptrs[oidx++] = toc_symbol;
}
#endif
+#endif
ptrs[oidx] = 0;
@@ -2358,18 +2397,8 @@
rel->address = HOW_JTAB_ROFF;
rel->addend = 0;
-
- if (machine == MPPC)
- {
- rel->howto = bfd_reloc_type_lookup (abfd,
- BFD_RELOC_16_GOTOFF);
- rel->sym_ptr_ptr = iname_pp;
- }
- else
- {
- rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32);
- rel->sym_ptr_ptr = secdata[IDATA5].sympp;
- }
+ rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32);
+ rel->sym_ptr_ptr = &oft_sym;
sec->orelocation = rpp;
sec->reloc_count = 1;
}
@@ -2400,7 +2429,7 @@
rel->address = 0;
rel->addend = 0;
rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_RVA);
- rel->sym_ptr_ptr = secdata[IDATA6].sympp;
+ rel->sym_ptr_ptr = &hint_name;
sec->orelocation = rpp;
}
@@ -2435,6 +2464,7 @@
sec->reloc_count = 1;
break;
+#if 0
#ifdef DLLTOOL_PPC
case PDATA:
{
@@ -2542,6 +2572,7 @@
sec->reloc_count = 2;
break;
#endif /* DLLTOOL_PPC */
+#endif
}
}
@@ -2556,6 +2587,9 @@
bfd_set_section_vma (abfd, si->sec, vma);
}
}
+
+ bfd_set_symtab (abfd, ptrs, oidx);
+
/* Write them out. */
for (i = 0; i < NSECS; i++)
{
@@ -2572,7 +2606,6 @@
si->size);
}
- bfd_set_symtab (abfd, ptrs, oidx);
bfd_close (abfd);
abfd = bfd_openr (outname, HOW_BFD_READ_TARGET);
return abfd;
@@ -2592,7 +2625,7 @@
fprintf (f, "%s IMAGE_IMPORT_DESCRIPTOR\n", ASM_C);
fprintf (f, "\t.section .idata$2\n");
- fprintf(f,"\t%s\t%s\n", ASM_GLOBAL,head_label);
+ fprintf (f,"\t%s\t%s\n", ASM_GLOBAL,head_label);
fprintf (f, "%s:\n", head_label);
@@ -2617,16 +2650,12 @@
if (!no_idata5)
{
fprintf (f, "\t.section\t.idata$5\n");
- fprintf (f, "\t%s\t0\n", ASM_LONG);
fprintf (f, "fthunk:\n");
}
if (!no_idata4)
{
fprintf (f, "\t.section\t.idata$4\n");
-
- fprintf (f, "\t%s\t0\n", ASM_LONG);
- fprintf (f, "\t.section .idata$4\n");
fprintf (f, "hname:\n");
}
@@ -2729,9 +2758,11 @@
for (i = 0; (exp = d_exports_lexically[i]); i++)
{
bfd *n;
+
/* Don't add PRIVATE entries to import lib. */
if (exp->private)
continue;
+
n = make_one_lib_file (exp, i);
n->next = head;
head = n;
@@ -3091,10 +3122,10 @@
fprintf (file, _(" -v --verbose Be verbose.\n"));
fprintf (file, _(" -V --version Display the program version.\n"));
fprintf (file, _(" -h --help Display this information.\n"));
-#ifdef DLLTOOL_MCORE_ELF
- fprintf (file, _(" -M --mcore-elf <outname> Process mcore-elf object files into <outname>.\n"));
fprintf (file, _(" -L --linker <name> Use <name> as the linker.\n"));
fprintf (file, _(" -F --linker-flags <flags> Pass <flags> to the linker.\n"));
+#ifdef DLLTOOL_MCORE_ELF
+ fprintf (file, _(" -M --mcore-elf <outname> Process mcore-elf object files into <outname>.\n"));
#endif
exit (status);
}
@@ -3131,6 +3162,7 @@
{"base-file", required_argument, NULL, 'b'},
{"as", required_argument, NULL, 'S'},
{"as-flags", required_argument, NULL, 'f'},
+ {"ld", required_argument, NULL, 'L'},
{"mcore-elf", required_argument, NULL, 'M'},
{"compat-implib", no_argument, NULL, 'C'},
{"temp-prefix", required_argument, NULL, 't'},
@@ -3161,7 +3193,7 @@
#ifdef DLLTOOL_MCORE_ELF
"m:e:l:aD:d:z:b:xp:cCuUkAS:f:nvVHhM:L:F:",
#else
- "m:e:l:aD:d:z:b:xp:cCuUkAS:f:nvVHh",
+ "m:e:l:aD:d:z:b:xp:cCuUkAS:f:nvVHhL:F:",
#endif
long_options, 0))
!= EOF)
@@ -3256,15 +3288,15 @@
fatal (_("Unable to open base-file: %s"), optarg);
break;
-#ifdef DLLTOOL_MCORE_ELF
- case 'M':
- mcore_elf_out_file = optarg;
- break;
case 'L':
- mcore_elf_linker = optarg;
+ elf_linker = optarg;
break;
case 'F':
- mcore_elf_linker_flags = optarg;
+ elf_linker_flags = optarg;
+ break;
+#ifdef DLLTOOL_MCORE_ELF
+ case 'M':
+ mcore_elf_out_file = optarg;
break;
#endif
case 'C':
@@ -3304,6 +3336,9 @@
if (as_name == NULL)
as_name = deduce_name ("as");
+ if (elf_linker == NULL)
+ elf_linker = deduce_name ("ld");
+
/* Don't use the default exclude list if we're reading only the
symbols in the .drectve section. The default excludes are meant
to avoid exporting DLL entry point and Cygwin32 impure_ptr. */
@@ -3517,8 +3552,8 @@
ds = dyn_string_new (100);
dyn_string_append_cstr (ds, "-r ");
- if (mcore_elf_linker_flags != NULL)
- dyn_string_append_cstr (ds, mcore_elf_linker_flags);
+ if (elf_linker_flags != NULL)
+ dyn_string_append_cstr (ds, elf_linker_flags);
while (ptr->next != NULL)
{
@@ -3531,10 +3566,7 @@
dyn_string_append_cstr (ds, "-o ");
dyn_string_append_cstr (ds, MCORE_ELF_TMP_OBJ);
- if (mcore_elf_linker == NULL)
- mcore_elf_linker = deduce_name ("ld");
-
- run (mcore_elf_linker, ds->s);
+ run (elf_linker, ds->s);
dyn_string_delete (ds);
@@ -3573,8 +3605,8 @@
dyn_string_append_cstr (ds, "-shared ");
- if (mcore_elf_linker_flags)
- dyn_string_append_cstr (ds, mcore_elf_linker_flags);
+ if (elf_linker_flags)
+ dyn_string_append_cstr (ds, elf_linker_flags);
dyn_string_append_cstr (ds, " ");
dyn_string_append_cstr (ds, MCORE_ELF_TMP_EXP);
@@ -3583,7 +3615,7 @@
dyn_string_append_cstr (ds, " -o ");
dyn_string_append_cstr (ds, mcore_elf_out_file);
- run (mcore_elf_linker, ds->s);
+ run (elf_linker, ds->s);
dyn_string_delete (ds);
Only in binutils-2.16.1/binutils: dlltool.c~
Only in binutils-2.16.1/binutils/po: Makefile
Files clean/binutils-2.16.1/binutils/po/ro.gmo and binutils-2.16.1/binutils/po/ro.gmo differ
diff -x '*.1' -x '*.info' -ur clean/binutils-2.16.1/binutils/rescoff.c binutils-2.16.1/binutils/rescoff.c
--- clean/binutils-2.16.1/binutils/rescoff.c 2003-09-14 05:20:16.000000000 -0700
+++ binutils-2.16.1/binutils/rescoff.c 2007-09-12 23:53:33.000000000 -0700
@@ -442,6 +442,9 @@
#elif defined DLLTOOL_ARM
if (! bfd_set_arch_mach (abfd, bfd_arch_arm, 0))
bfd_fatal ("bfd_set_arch_mach(arm)");
+#elif defined DLLTOOL_PPC
+ if (! bfd_set_arch_mach (abfd, bfd_arch_powerpc, 0))
+ bfd_fatal ("bfd_set_arch_mach(ppc)");
#else
/* FIXME: This is obviously i386 specific. */
if (! bfd_set_arch_mach (abfd, bfd_arch_i386, 0))
diff -x '*.1' -x '*.info' -ur clean/binutils-2.16.1/binutils/resres.c binutils-2.16.1/binutils/resres.c
--- clean/binutils-2.16.1/binutils/resres.c 2005-03-03 03:46:12.000000000 -0800
+++ binutils-2.16.1/binutils/resres.c 2007-10-30 13:07:31.000000000 -0700
@@ -30,6 +30,13 @@
#include <assert.h>
#include <time.h>
+#include <endian.h>
+
+#if __BYTE_ORDER != __LITTLE_ENDIAN
+#define FLIP(x) (((x) << 24) | (((x) & 0xff00) << 8) | (((x) >> 8) & 0xff00) | (((x) >> 24) & 0xff))
+#else
+#define FLIP(x) (x)
+#endif
struct res_hdr
{
@@ -157,6 +164,9 @@
if (fread (&reshdr, sizeof (reshdr), 1, fres) != 1)
return 0;
+ reshdr.data_size = FLIP(reshdr.data_size);
+ reshdr.header_size = FLIP(reshdr.header_size);
+
/* read resource type */
read_res_id (&type);
/* read resource id */
@@ -531,6 +541,8 @@
struct res_hdr reshdr =
{0, 0};
read_res_data (&reshdr, sizeof (reshdr), 1);
+ reshdr.data_size = FLIP(reshdr.data_size);
+ reshdr.header_size = FLIP(reshdr.header_size);
if ((reshdr.data_size != 0) || (reshdr.header_size != 0x20))
goto skip_err;
Only in binutils-2.16.1/binutils: windres
Only in clean/binutils-2.16.1/gas/doc: as.info-1
Only in clean/binutils-2.16.1/gas/doc: as.info-2
Only in clean/binutils-2.16.1/gas/doc: as.info-3
Only in binutils-2.16.1/gprof: Makefile
Only in binutils-2.16.1/gprof: config.log
Only in binutils-2.16.1/gprof: config.status
Only in binutils-2.16.1/gprof: gconfig.h
Only in binutils-2.16.1/gprof: libtool
Only in binutils-2.16.1/gprof/po: Makefile
Only in binutils-2.16.1/gprof/po: Makefile.in
Only in binutils-2.16.1/gprof/po: POTFILES
Only in binutils-2.16.1/gprof: stamp-h1
Only in binutils-2.16.1/intl: config.cache
Only in binutils-2.16.1/intl: config.h
Only in binutils-2.16.1/intl: config.status
Only in binutils-2.16.1/intl: stamp-h
Only in binutils-2.16.1/ld/emulparams: .elf32mcore.sh.swp

View File

@ -0,0 +1,210 @@
diff -ur clean/gcc-4.1.0/Makefile.in gcc-4.1.0/Makefile.in
--- clean/gcc-4.1.0/Makefile.in 2005-12-15 06:02:02.000000000 -0800
+++ gcc-4.1.0/Makefile.in 2007-09-23 20:11:22.000000000 -0700
@@ -1,4 +1,4 @@
-
+#
# Makefile.in is generated from Makefile.tpl by 'autogen Makefile.def'.
#
# Makefile for directory with subdirs to build.
@@ -726,6 +726,7 @@
maybe-all-utils \
maybe-all-gnattools
.PHONY: all-target
+# maybe-all-target-libiberty
all-target: \
maybe-all-target-libstdc++-v3 \
maybe-all-target-libmudflap \
@@ -2108,6 +2109,7 @@
maybe-install-gnattools
.PHONY: install-target
+# maybe-install-target-libiberty
install-target: \
maybe-install-target-libstdc++-v3 \
maybe-install-target-libmudflap \
@@ -2118,7 +2120,6 @@
maybe-install-target-libtermcap \
maybe-install-target-winsup \
maybe-install-target-libgloss \
- maybe-install-target-libiberty \
maybe-install-target-gperf \
maybe-install-target-examples \
maybe-install-target-libffi \
Only in gcc-4.1.0: Makefile.in~
diff -ur clean/gcc-4.1.0/libssp/Makefile.in gcc-4.1.0/libssp/Makefile.in
--- clean/gcc-4.1.0/libssp/Makefile.in 2006-02-27 16:29:00.000000000 -0800
+++ gcc-4.1.0/libssp/Makefile.in 2007-09-21 00:27:01.000000000 -0700
@@ -71,10 +71,11 @@
"$(DESTDIR)$(libsubincludedir)"
toolexeclibLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(toolexeclib_LTLIBRARIES)
-am_libssp_la_OBJECTS = ssp.lo gets-chk.lo memcpy-chk.lo memmove-chk.lo \
- mempcpy-chk.lo memset-chk.lo snprintf-chk.lo sprintf-chk.lo \
- stpcpy-chk.lo strcat-chk.lo strcpy-chk.lo strncat-chk.lo \
- strncpy-chk.lo vsnprintf-chk.lo vsprintf-chk.lo
+am_libssp_la_OBJECTS =
+#am_libssp_la_OBJECTS = ssp.lo gets-chk.lo memcpy-chk.lo memmove-chk.lo \
+# mempcpy-chk.lo memset-chk.lo snprintf-chk.lo sprintf-chk.lo \
+# stpcpy-chk.lo strcat-chk.lo strcpy-chk.lo strncat-chk.lo \
+# strncpy-chk.lo vsnprintf-chk.lo vsprintf-chk.lo
libssp_la_OBJECTS = $(am_libssp_la_OBJECTS)
am_libssp_nonshared_la_OBJECTS = libssp_nonshared_la-ssp-local.lo
libssp_nonshared_la_OBJECTS = $(am_libssp_nonshared_la_OBJECTS)
Only in gcc-4.1.0/libssp: Makefile.in~
diff -ur clean/gcc-4.1.0/libssp/gets-chk.c gcc-4.1.0/libssp/gets-chk.c
--- clean/gcc-4.1.0/libssp/gets-chk.c 2005-08-16 20:26:45.000000000 -0700
+++ gcc-4.1.0/libssp/gets-chk.c 2007-09-21 00:06:58.000000000 -0700
@@ -52,6 +52,7 @@
# include <string.h>
#endif
+#if 0
extern void __chk_fail (void) __attribute__((__noreturn__));
char *
@@ -86,3 +87,4 @@
free (buf);
return ret;
}
+#endif
Only in gcc-4.1.0/libssp: gets-chk.c~
diff -ur clean/gcc-4.1.0/libssp/memcpy-chk.c gcc-4.1.0/libssp/memcpy-chk.c
--- clean/gcc-4.1.0/libssp/memcpy-chk.c 2005-08-16 20:26:45.000000000 -0700
+++ gcc-4.1.0/libssp/memcpy-chk.c 2007-09-21 00:09:45.000000000 -0700
@@ -39,6 +39,7 @@
# include <string.h>
#endif
+#if 0
extern void __chk_fail (void) __attribute__((__noreturn__));
void *
@@ -49,3 +50,4 @@
__chk_fail ();
return memcpy (dest, src, len);
}
+#endif
Only in gcc-4.1.0/libssp: memcpy-chk.c~
diff -ur clean/gcc-4.1.0/libssp/memset-chk.c gcc-4.1.0/libssp/memset-chk.c
--- clean/gcc-4.1.0/libssp/memset-chk.c 2005-08-16 20:26:45.000000000 -0700
+++ gcc-4.1.0/libssp/memset-chk.c 2007-09-21 00:25:06.000000000 -0700
@@ -41,6 +41,7 @@
extern void __chk_fail (void) __attribute__((__noreturn__));
+#if 0
void *
__memset_chk (void *dest, int val, size_t len, size_t slen)
{
@@ -48,3 +49,4 @@
__chk_fail ();
return memset (dest, val, len);
}
+#endif
Only in gcc-4.1.0/libssp: memset-chk.c~
diff -ur clean/gcc-4.1.0/libssp/ssp.c gcc-4.1.0/libssp/ssp.c
--- clean/gcc-4.1.0/libssp/ssp.c 2005-08-16 20:26:45.000000000 -0700
+++ gcc-4.1.0/libssp/ssp.c 2007-09-21 00:04:15.000000000 -0700
@@ -58,6 +58,8 @@
void *__stack_chk_guard = 0;
+#if 0
+
static void __attribute__ ((constructor))
__guard_setup (void)
{
@@ -176,3 +178,4 @@
__stack_chk_fail ();
}
#endif
+#endif
Only in gcc-4.1.0/libssp: ssp.c~
diff -ur clean/gcc-4.1.0/libssp/stpcpy-chk.c gcc-4.1.0/libssp/stpcpy-chk.c
--- clean/gcc-4.1.0/libssp/stpcpy-chk.c 2005-08-16 20:26:45.000000000 -0700
+++ gcc-4.1.0/libssp/stpcpy-chk.c 2007-09-21 00:10:38.000000000 -0700
@@ -41,6 +41,7 @@
extern void __chk_fail (void) __attribute__((__noreturn__));
+#if 0
char *
__stpcpy_chk (char *__restrict__ dest, const char *__restrict__ src,
size_t slen)
@@ -50,3 +51,4 @@
__chk_fail ();
return memcpy (dest, src, len + 1) + len;
}
+#endif
Only in gcc-4.1.0/libssp: stpcpy-chk.c~
diff -ur clean/gcc-4.1.0/libssp/strcat-chk.c gcc-4.1.0/libssp/strcat-chk.c
--- clean/gcc-4.1.0/libssp/strcat-chk.c 2005-08-16 20:26:45.000000000 -0700
+++ gcc-4.1.0/libssp/strcat-chk.c 2007-09-21 00:10:55.000000000 -0700
@@ -41,6 +41,7 @@
extern void __chk_fail (void) __attribute__((__noreturn__));
+#if 0
char *
__strcat_chk (char *__restrict__ dest, const char *__restrict__ src,
size_t slen)
@@ -71,3 +72,4 @@
return dest;
}
+#endif
Only in gcc-4.1.0/libssp: strcat-chk.c~
diff -ur clean/gcc-4.1.0/libssp/strcpy-chk.c gcc-4.1.0/libssp/strcpy-chk.c
--- clean/gcc-4.1.0/libssp/strcpy-chk.c 2005-08-16 20:26:45.000000000 -0700
+++ gcc-4.1.0/libssp/strcpy-chk.c 2007-09-21 00:10:01.000000000 -0700
@@ -39,6 +39,7 @@
# include <string.h>
#endif
+#if 0
extern void __chk_fail (void) __attribute__((__noreturn__));
char *
@@ -50,3 +51,4 @@
__chk_fail ();
return memcpy (dest, src, len + 1);
}
+#endif
Only in gcc-4.1.0/libssp: strcpy-chk.c~
diff -ur clean/gcc-4.1.0/libssp/strncat-chk.c gcc-4.1.0/libssp/strncat-chk.c
--- clean/gcc-4.1.0/libssp/strncat-chk.c 2005-08-16 20:26:45.000000000 -0700
+++ gcc-4.1.0/libssp/strncat-chk.c 2007-09-21 00:10:14.000000000 -0700
@@ -41,6 +41,7 @@
extern void __chk_fail (void) __attribute__((__noreturn__));
+#if 0
char *
__strncat_chk (char *__restrict__ dest, const char *__restrict__ src,
size_t n, size_t slen)
@@ -118,3 +119,4 @@
return s;
}
+#endif
Only in gcc-4.1.0/libssp: strncat-chk.c~
diff -ur clean/gcc-4.1.0/libssp/strncpy-chk.c gcc-4.1.0/libssp/strncpy-chk.c
--- clean/gcc-4.1.0/libssp/strncpy-chk.c 2005-08-16 20:26:45.000000000 -0700
+++ gcc-4.1.0/libssp/strncpy-chk.c 2007-09-21 00:10:26.000000000 -0700
@@ -41,6 +41,8 @@
extern void __chk_fail (void) __attribute__((__noreturn__));
+#if 0
+
#ifdef HAVE_STRNCPY
char *
__strncpy_chk (char *__restrict__ dest, const char *__restrict__ src,
@@ -51,3 +53,5 @@
return strncpy (dest, src, len);
}
#endif
+
+#endif
Only in gcc-4.1.0/libssp: strncpy-chk.c~

View File

@ -0,0 +1 @@
Unpack and patch gcc-4.1.0 and binutils-2.16.1 here.

68
RosBE-PPC/install.sh Executable file
View File

@ -0,0 +1,68 @@
#!/bin/sh
EXE=
if [ x`uname -o` = xCygwin ] ; then
EXE=.exe
fi
if [ "x$1" == xclean ] ; then
rm -rf binutils-configure gcc-configure
exit 0
fi
if [ "x$1" == x ] ; then
echo usage: "$0" [install-dir]
exit 1
fi
idir="$1"
libdir="$idir"/lib
# Build and install binutils
if [ ! -d build/binutils-configure ] ; then
mkdir -p build/binutils-configure || exit 1
fi
cd build/binutils-configure || exit 1
sh ../../gnu/binutils-2.16.1/configure \
--prefix="$idir" \
--target=powerpc-unknown-elf && \
make && \
make -C binutils CFLAGS="-g -DDLLTOOL_PPC" dlltool$EXE && \
make -C binutils CFLAGS="-g -DDLLTOOL_PPC" windres$EXE && \
make install && \
cp binutils/dlltool "$idir"/bin/powerpc-unknown-elf-dlltool && \
cp binutils/windres "$idir"/bin/powerpc-unknown-elf-windres || exit 1
cd ../..
# Copy extra files
cp -r ldscript mingw-crt-headers "$libdir" || exit 1
# Build and install gcc
if [ ! -d build/gcc-configure ] ; then
mkdir build/gcc-configure || exit 1
fi
export PATH="$idir/bin":$PATH
cd build/gcc-configure || exit 1
sh ../../gnu/gcc-4.1.0/configure \
--prefix="$idir" \
--target=powerpc-unknown-elf \
--disable-ssp \
--disable-threads \
--enable-languages=c || exit 1
make
make install || exit 1
cd ../..
# Make elfpe
make -C elfpe && cp elfpe/elfpe ovr/powerpc-unknown-elf-gcc || exit 1
# Make env script
echo '#!/bin/sh' > "$idir"/rosbe
echo 'THISDIR=`dirname $0`' >> "$idir"/rosbe
echo export PATH='"$THISDIR/ovr:$THISDIR/bin:$PATH"' >> "$idir"/rosbe
echo export 'INSTALLDIR="$THISDIR"' >> "$idir"/rosbe
echo export OLDMAKE=`which make` >> "$idir"/rosbe
echo echo "\"Run make in your reactos dir to build\"" >> "$idir"/rosbe
echo exec $SHELL >> "$idir"/rosbe
chmod +x "$idir"/rosbe
echo Run "\"$idir/rosbe\"" to get a shell with the right settings
# Make wrappers
cp -r ovr "$idir"

69
RosBE-PPC/ldscript Normal file
View File

@ -0,0 +1,69 @@
/* Default linker script, for normal executables */
OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc",
"elf32-powerpc")
OUTPUT_ARCH(powerpc:common)
SECTIONS
{
.text :
{
__text_start__ = .;
*(.text)
*(init)
*(INIT)
__text_end__ = .;
}
.data :
{
*(.data)
*(.data2)
*(.rdata)
*(.sdata)
*(.pdata)
}
.rodata :
{
*(.rodata)
*(.got2)
*(.eh_frame)
}
.idata :
{
*(.idata$2)
SORT(*)(.idata$3)
LONG(0); LONG(0); LONG(0); LONG(0); LONG(0);
SORT(*)(.idata$4)
SORT(*)(.idata$5)
SORT(*)(.idata$6)
SORT(*)(.idata$7)
}
.edata :
{
*(.edata)
}
.bss :
{
*(.sbss)
*(.bss)
*(COMMON)
}
.rsrc :
{
*(.rsrc)
}
.rela.text :
{
*(.rela.text)
}
.rela.data :
{
*(.rela.data)
}
.rela.rodata :
{
*(.rela.rodata)
}
.rela.got2 :
{
*(.rela.got2)
}
}

View File

@ -0,0 +1,174 @@
/*
* _mingw.h
*
* Mingw specific macros included by ALL include files.
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Mumit Khan <khan@xraylith.wisc.edu>
*
* 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
* DISCLAIMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#ifndef __MINGW_H
#define __MINGW_H
#define __PowerPC__
#define __MINGW_IMPORT extern
#define __DECLSPEC_SUPPORTED
/* These are defined by the user (or the compiler)
to specify how identifiers are imported from a DLL.
__DECLSPEC_SUPPORTED Defined if dllimport attribute is supported.
__MINGW_IMPORT The attribute definition to specify imported
variables/functions.
_CRTIMP As above. For MS compatibility.
__MINGW32_VERSION Runtime version.
__MINGW32_MAJOR_VERSION Runtime major version.
__MINGW32_MINOR_VERSION Runtime minor version.
__MINGW32_BUILD_DATE Runtime build date.
Other macros:
__int64 define to be long long. Using a typedef doesn't
work for "unsigned __int64"
All headers should include this first, and then use __DECLSPEC_SUPPORTED
to choose between the old ``__imp__name'' style or __MINGW_IMPORT
style declarations. */
/* Try to avoid problems with outdated checks for GCC __attribute__ support. */
#undef __attribute__
#ifndef __GNUC__
# ifndef __MINGW_IMPORT
# define __MINGW_IMPORT __declspec(dllimport)
# endif
# ifndef _CRTIMP
# define _CRTIMP __declspec(dllimport)
# endif
# define __DECLSPEC_SUPPORTED
# define __attribute__(x) /* nothing */
#else /* __GNUC__ */
# ifdef __declspec
# ifndef __MINGW_IMPORT
/* Note the extern. This is needed to work around GCC's
limitations in handling dllimport attribute. */
# define __MINGW_IMPORT extern __attribute__ ((dllimport))
# endif
# ifndef _CRTIMP
# ifdef __USE_CRTIMP
# define _CRTIMP __attribute__ ((dllimport))
# else
# define _CRTIMP
# endif
# endif
# define __DECLSPEC_SUPPORTED
# else /* __declspec */
# ifndef __PowerPC__
# undef __DECLSPEC_SUPPORTED
# undef __MINGW_IMPORT
# ifndef _CRTIMP
# define _CRTIMP
# endif
# else /* __PowerPC__ */
# define __declspec(x)
# define _CRTIMP
# endif /* __PowerPC__ */
# endif /* __declspec */
# ifndef __cdecl
# define __cdecl __attribute__ ((__cdecl__))
# endif
# ifndef __stdcall
# define __stdcall __attribute__ ((__stdcall__))
# endif
# ifndef __int64
# define __int64 long long
# endif
# ifndef __int32
# define __int32 long
# endif
# ifndef __int16
# define __int16 short
# endif
# ifndef __int8
# define __int8 char
# endif
# ifndef __small
# define __small char
# endif
# ifndef __hyper
# define __hyper long long
# endif
#endif /* __GNUC__ */
#ifdef __cplusplus
#define __CRT_INLINE inline
#else
#define __CRT_INLINE extern __inline__
#endif
#if defined (__GNUC__) && defined (__GNUC_MINOR__)
#define __MINGW_GNUC_PREREQ(major, minor) \
(__GNUC__ > (major) \
|| (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
#else
#define __MINGW_GNUC_PREREQ(major, minor) 0
#endif
#ifdef __cplusplus
# define __UNUSED_PARAM(x)
#else
# ifdef __GNUC__
# define __UNUSED_PARAM(x) x __attribute__ ((__unused__))
# else
# define __UNUSED_PARAM(x) x
# endif
#endif
#ifdef __GNUC__
#define __MINGW_ATTRIB_NORETURN __attribute__ ((__noreturn__))
#define __MINGW_ATTRIB_CONST __attribute__ ((__const__))
#else
#define __MINGW_ATTRIB_NORETURN
#define __MINGW_ATTRIB_CONST
#endif
#if __MINGW_GNUC_PREREQ (3, 0)
#define __MINGW_ATTRIB_MALLOC __attribute__ ((__malloc__))
#define __MINGW_ATTRIB_PURE __attribute__ ((__pure__))
#else
#define __MINGW_ATTRIB_MALLOC
#define __MINGW_ATTRIB_PURE
#endif
/* Attribute `nonnull' was valid as of gcc 3.3. We don't use GCC's
variadiac macro facility, because variadic macros cause syntax
errors with --traditional-cpp. */
#if __MINGW_GNUC_PREREQ (3, 3)
#define __MINGW_ATTRIB_NONNULL(arg) __attribute__ ((__nonnull__ (arg)))
#else
#define __MINGW_ATTRIB_NONNULL(arg)
#endif /* GNUC >= 3.3 */
#ifndef __MSVCRT_VERSION__
/* High byte is the major version, low byte is the minor. */
# define __MSVCRT_VERSION__ 0x0600
#endif
#define __MINGW32_VERSION 3.10
#define __MINGW32_MAJOR_VERSION 3
#define __MINGW32_MINOR_VERSION 10
#endif /* __MINGW_H */

View File

@ -0,0 +1,55 @@
/*
* assert.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Define the assert macro for debug output.
*
*/
#ifndef _ASSERT_H_
#define _ASSERT_H_
/* All the headers include this file. */
#include <_mingw.h>
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
#ifdef NDEBUG
/*
* If not debugging, assert does nothing.
*/
#define assert(x) ((void)0)
#else /* debugging enabled */
/*
* CRTDLL nicely supplies a function which does the actual output and
* call to abort.
*/
_CRTIMP void __cdecl _assert (const char*, const char*, int)
#ifdef __GNUC__
__attribute__ ((noreturn))
#endif
;
/*
* Definition of the assert macro.
*/
#define assert(e) ((e) ? (void)0 : _assert(#e, __FILE__, __LINE__))
#endif /* NDEBUG */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _ASSERT_H_ */

View File

@ -0,0 +1,160 @@
/*
* complex.h
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Danny Smith <dannysmith@users.sourceforge.net>
*
* 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
* DISCLAIMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#ifndef _COMPLEX_H_
#define _COMPLEX_H_
/* All the headers include this file. */
#include <_mingw.h>
#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
|| !defined __STRICT_ANSI__
/* These macros are specified by C99 standard */
#ifndef __cplusplus
#define complex _Complex
#endif
#define _Complex_I (0.0F + 1.0iF)
/* GCC doesn't support _Imaginary type yet, so we don't
define _Imaginary_I */
#define I _Complex_I
#ifdef __cplusplus
extern "C" {
#endif
#ifndef RC_INVOKED
/* TODO: long double versions */
double __MINGW_ATTRIB_CONST creal (double _Complex);
double __MINGW_ATTRIB_CONST cimag (double _Complex);
double __MINGW_ATTRIB_CONST carg (double _Complex);
double __MINGW_ATTRIB_CONST cabs (double _Complex);
double _Complex __MINGW_ATTRIB_CONST conj (double _Complex);
double _Complex cacos (double _Complex);
double _Complex casin (double _Complex);
double _Complex catan (double _Complex);
double _Complex ccos (double _Complex);
double _Complex csin (double _Complex);
double _Complex ctan (double _Complex);
double _Complex cacosh (double _Complex);
double _Complex casinh (double _Complex);
double _Complex catanh (double _Complex);
double _Complex ccosh (double _Complex);
double _Complex csinh (double _Complex);
double _Complex ctanh (double _Complex);
double _Complex cexp (double _Complex);
double _Complex clog (double _Complex);
double _Complex cpow (double _Complex, double _Complex);
double _Complex csqrt (double _Complex);
double _Complex __MINGW_ATTRIB_CONST cproj (double _Complex);
float __MINGW_ATTRIB_CONST crealf (float _Complex);
float __MINGW_ATTRIB_CONST cimagf (float _Complex);
float __MINGW_ATTRIB_CONST cargf (float _Complex);
float __MINGW_ATTRIB_CONST cabsf (float _Complex);
float _Complex __MINGW_ATTRIB_CONST conjf (float _Complex);
float _Complex cacosf (float _Complex);
float _Complex casinf (float _Complex);
float _Complex catanf (float _Complex);
float _Complex ccosf (float _Complex);
float _Complex csinf (float _Complex);
float _Complex ctanf (float _Complex);
float _Complex cacoshf (float _Complex);
float _Complex casinhf (float _Complex);
float _Complex catanhf (float _Complex);
float _Complex ccoshf (float _Complex);
float _Complex csinhf (float _Complex);
float _Complex ctanhf (float _Complex);
float _Complex cexpf (float _Complex);
float _Complex clogf (float _Complex);
float _Complex cpowf (float _Complex, float _Complex);
float _Complex csqrtf (float _Complex);
float _Complex __MINGW_ATTRIB_CONST cprojf (float _Complex);
#ifdef __GNUC__
__CRT_INLINE double __MINGW_ATTRIB_CONST creal (double _Complex _Z)
{
return __real__ _Z;
}
__CRT_INLINE double __MINGW_ATTRIB_CONST cimag (double _Complex _Z)
{
return __imag__ _Z;
}
__CRT_INLINE double _Complex __MINGW_ATTRIB_CONST conj (double _Complex _Z)
{
return __extension__ ~_Z;
}
__CRT_INLINE double __MINGW_ATTRIB_CONST carg (double _Complex _Z)
{
double res;
#ifdef _M_IX86
__asm__ ("fpatan;"
: "=t" (res) : "0" (__real__ _Z), "u" (__imag__ _Z) : "st(1)");
#endif
return res;
}
__CRT_INLINE float __MINGW_ATTRIB_CONST crealf (float _Complex _Z)
{
return __real__ _Z;
}
__CRT_INLINE float __MINGW_ATTRIB_CONST cimagf (float _Complex _Z)
{
return __imag__ _Z;
}
__CRT_INLINE float _Complex __MINGW_ATTRIB_CONST conjf (float _Complex _Z)
{
return __extension__ ~_Z;
}
__CRT_INLINE float __MINGW_ATTRIB_CONST cargf (float _Complex _Z)
{
float res;
#ifdef _M_IX86
__asm__ ("fpatan;"
: "=t" (res) : "0" (__real__ _Z), "u" (__imag__ _Z) : "st(1)");
#endif
return res;
}
#endif /* __GNUC__ */
#endif /* RC_INVOKED */
#ifdef __cplusplus
}
#endif
#endif /* __STDC_VERSION__ >= 199901L */
#endif /* _COMPLEX_H */

View File

@ -0,0 +1,53 @@
/*
* conio.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Low level console I/O functions. Pretty please try to use the ANSI
* standard ones if you are writing new code.
*
*/
#ifndef _CONIO_H_
#define _CONIO_H_
/* All the headers include this file. */
#include <_mingw.h>
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
_CRTIMP char* __cdecl _cgets (char*);
_CRTIMP int __cdecl _cprintf (const char*, ...);
_CRTIMP int __cdecl _cputs (const char*);
_CRTIMP int __cdecl _cscanf (char*, ...);
_CRTIMP int __cdecl _getch (void);
_CRTIMP int __cdecl _getche (void);
_CRTIMP int __cdecl _kbhit (void);
_CRTIMP int __cdecl _putch (int);
_CRTIMP int __cdecl _ungetch (int);
#ifndef _NO_OLDNAMES
_CRTIMP int __cdecl getch (void);
_CRTIMP int __cdecl getche (void);
_CRTIMP int __cdecl kbhit (void);
_CRTIMP int __cdecl putch (int);
_CRTIMP int __cdecl ungetch (int);
#endif /* Not _NO_OLDNAMES */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _CONIO_H_ */

View File

@ -0,0 +1,247 @@
/*
* ctype.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Functions for testing character types and converting characters.
*
*/
#ifndef _CTYPE_H_
#define _CTYPE_H_
/* All the headers include this file. */
#include <_mingw.h>
#define __need_wchar_t
#define __need_wint_t
#ifndef RC_INVOKED
#include <stddef.h>
#endif /* Not RC_INVOKED */
/*
* The following flags are used to tell iswctype and _isctype what character
* types you are looking for.
*/
#define _UPPER 0x0001
#define _LOWER 0x0002
#define _DIGIT 0x0004
#define _SPACE 0x0008 /* HT LF VT FF CR SP */
#define _PUNCT 0x0010
#define _CONTROL 0x0020
#define _BLANK 0x0040 /* this is SP only, not SP and HT as in C99 */
#define _HEX 0x0080
#define _LEADBYTE 0x8000
#define _ALPHA 0x0103
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
_CRTIMP int __cdecl isalnum(int);
_CRTIMP int __cdecl isalpha(int);
_CRTIMP int __cdecl iscntrl(int);
_CRTIMP int __cdecl isdigit(int);
_CRTIMP int __cdecl isgraph(int);
_CRTIMP int __cdecl islower(int);
_CRTIMP int __cdecl isprint(int);
_CRTIMP int __cdecl ispunct(int);
_CRTIMP int __cdecl isspace(int);
_CRTIMP int __cdecl isupper(int);
_CRTIMP int __cdecl isxdigit(int);
#ifndef __STRICT_ANSI__
_CRTIMP int __cdecl _isctype (int, int);
#endif
/* These are the ANSI versions, with correct checking of argument */
_CRTIMP int __cdecl tolower(int);
_CRTIMP int __cdecl toupper(int);
/*
* NOTE: The above are not old name type wrappers, but functions exported
* explicitly by MSVCRT/CRTDLL. However, underscored versions are also
* exported.
*/
#ifndef __STRICT_ANSI__
/*
* These are the cheap non-std versions: The return values are undefined
* if the argument is not ASCII char or is not of appropriate case
*/
_CRTIMP int __cdecl _tolower(int);
_CRTIMP int __cdecl _toupper(int);
#endif
/* Also defined in stdlib.h */
#ifndef MB_CUR_MAX
#ifdef __DECLSPEC_SUPPORTED
# ifdef __MSVCRT__
# define MB_CUR_MAX __mb_cur_max
__MINGW_IMPORT int __mb_cur_max;
# else /* not __MSVCRT */
# define MB_CUR_MAX __mb_cur_max_dll
__MINGW_IMPORT int __mb_cur_max_dll;
# endif /* not __MSVCRT */
#else /* ! __DECLSPEC_SUPPORTED */
# ifdef __MSVCRT__
extern int* _imp____mbcur_max;
# define MB_CUR_MAX (*_imp____mb_cur_max)
# else /* not __MSVCRT */
extern int* _imp____mbcur_max_dll;
# define MB_CUR_MAX (*_imp____mb_cur_max_dll)
# endif /* not __MSVCRT */
#endif /* __DECLSPEC_SUPPORTED */
#endif /* MB_CUR_MAX */
#ifdef __DECLSPEC_SUPPORTED
__MINGW_IMPORT unsigned short _ctype[];
# ifdef __MSVCRT__
__MINGW_IMPORT unsigned short* _pctype;
# else /* CRTDLL */
__MINGW_IMPORT unsigned short* _pctype_dll;
# define _pctype _pctype_dll
# endif
#else /* __DECLSPEC_SUPPORTED */
extern unsigned short** _imp___ctype;
#define _ctype (*_imp___ctype)
# ifdef __MSVCRT__
extern unsigned short** _imp___pctype;
# define _pctype (*_imp___pctype)
# else /* CRTDLL */
extern unsigned short** _imp___pctype_dll;
# define _pctype (*_imp___pctype_dll)
# endif /* CRTDLL */
#endif /* __DECLSPEC_SUPPORTED */
/*
* Use inlines here rather than macros, because macros will upset
* C++ usage (eg, ::isalnum), and so usually get undefined
*
* According to standard for SB chars, these function are defined only
* for input values representable by unsigned char or EOF.
* Thus, there is no range test.
* This reproduces behaviour of MSVCRT.dll lib implemention for SB chars.
*
* If no MB char support is needed, these can be simplified even
* more by command line define -DMB_CUR_MAX=1. The compiler will then
* optimise away the constant condition.
*/
#if ! (defined (__NO_INLINE__) || defined (__NO_CTYPE_INLINES) \
|| defined (__STRICT_ANSI__ ))
/* use simple lookup if SB locale, else _isctype() */
#define __ISCTYPE(c, mask) (MB_CUR_MAX == 1 ? (_pctype[c] & mask) : _isctype(c, mask))
__CRT_INLINE int __cdecl isalnum(int c) {return __ISCTYPE(c, (_ALPHA|_DIGIT));}
__CRT_INLINE int __cdecl isalpha(int c) {return __ISCTYPE(c, _ALPHA);}
__CRT_INLINE int __cdecl iscntrl(int c) {return __ISCTYPE(c, _CONTROL);}
__CRT_INLINE int __cdecl isdigit(int c) {return __ISCTYPE(c, _DIGIT);}
__CRT_INLINE int __cdecl isgraph(int c) {return __ISCTYPE(c, (_PUNCT|_ALPHA|_DIGIT));}
__CRT_INLINE int __cdecl islower(int c) {return __ISCTYPE(c, _LOWER);}
__CRT_INLINE int __cdecl isprint(int c) {return __ISCTYPE(c, (_BLANK|_PUNCT|_ALPHA|_DIGIT));}
__CRT_INLINE int __cdecl ispunct(int c) {return __ISCTYPE(c, _PUNCT);}
__CRT_INLINE int __cdecl isspace(int c) {return __ISCTYPE(c, _SPACE);}
__CRT_INLINE int __cdecl isupper(int c) {return __ISCTYPE(c, _UPPER);}
__CRT_INLINE int __cdecl isxdigit(int c) {return __ISCTYPE(c, _HEX);}
/* these reproduce behaviour of lib underscored versions */
__CRT_INLINE int __cdecl _tolower(int c) {return ( c -'A'+'a');}
__CRT_INLINE int __cdecl _toupper(int c) {return ( c -'a'+'A');}
/* TODO? Is it worth inlining ANSI tolower, toupper? Probably only
if we only want C-locale. */
#endif /* _NO_CTYPE_INLINES */
/* Wide character equivalents */
#ifndef WEOF
#define WEOF (wchar_t)(0xFFFF)
#endif
#ifndef _WCTYPE_T_DEFINED
typedef wchar_t wctype_t;
#define _WCTYPE_T_DEFINED
#endif
_CRTIMP int __cdecl iswalnum(wint_t);
_CRTIMP int __cdecl iswalpha(wint_t);
_CRTIMP int __cdecl iswascii(wint_t);
_CRTIMP int __cdecl iswcntrl(wint_t);
_CRTIMP int __cdecl iswctype(wint_t, wctype_t);
_CRTIMP int __cdecl is_wctype(wint_t, wctype_t); /* Obsolete! */
_CRTIMP int __cdecl iswdigit(wint_t);
_CRTIMP int __cdecl iswgraph(wint_t);
_CRTIMP int __cdecl iswlower(wint_t);
_CRTIMP int __cdecl iswprint(wint_t);
_CRTIMP int __cdecl iswpunct(wint_t);
_CRTIMP int __cdecl iswspace(wint_t);
_CRTIMP int __cdecl iswupper(wint_t);
_CRTIMP int __cdecl iswxdigit(wint_t);
/* Older MS docs uses wchar_t for arg and return type, while newer
online MS docs say arg is wint_t and return is int.
ISO C uses wint_t for both. */
_CRTIMP wint_t __cdecl towlower (wint_t);
_CRTIMP wint_t __cdecl towupper (wint_t);
_CRTIMP int __cdecl isleadbyte (int);
/* Also in wctype.h */
#if ! (defined (__NO_INLINE__) || defined(__NO_CTYPE_INLINES) \
|| defined(__WCTYPE_INLINES_DEFINED))
#define __WCTYPE_INLINES_DEFINED
__CRT_INLINE int __cdecl iswalnum(wint_t wc) {return (iswctype(wc,_ALPHA|_DIGIT));}
__CRT_INLINE int __cdecl iswalpha(wint_t wc) {return (iswctype(wc,_ALPHA));}
__CRT_INLINE int __cdecl iswascii(wint_t wc) {return ((wc & ~0x7F) ==0);}
__CRT_INLINE int __cdecl iswcntrl(wint_t wc) {return (iswctype(wc,_CONTROL));}
__CRT_INLINE int __cdecl iswdigit(wint_t wc) {return (iswctype(wc,_DIGIT));}
__CRT_INLINE int __cdecl iswgraph(wint_t wc) {return (iswctype(wc,_PUNCT|_ALPHA|_DIGIT));}
__CRT_INLINE int __cdecl iswlower(wint_t wc) {return (iswctype(wc,_LOWER));}
__CRT_INLINE int __cdecl iswprint(wint_t wc) {return (iswctype(wc,_BLANK|_PUNCT|_ALPHA|_DIGIT));}
__CRT_INLINE int __cdecl iswpunct(wint_t wc) {return (iswctype(wc,_PUNCT));}
__CRT_INLINE int __cdecl iswspace(wint_t wc) {return (iswctype(wc,_SPACE));}
__CRT_INLINE int __cdecl iswupper(wint_t wc) {return (iswctype(wc,_UPPER));}
__CRT_INLINE int __cdecl iswxdigit(wint_t wc) {return (iswctype(wc,_HEX));}
__CRT_INLINE int __cdecl isleadbyte(int c) {return (_pctype[(unsigned char)(c)] & _LEADBYTE);}
#endif /* !(defined(__NO_CTYPE_INLINES) || defined(__WCTYPE_INLINES_DEFINED)) */
#ifndef __STRICT_ANSI__
int __cdecl __isascii (int);
int __cdecl __toascii (int);
int __cdecl __iscsymf (int); /* Valid first character in C symbol */
int __cdecl __iscsym (int); /* Valid character in C symbol (after first) */
#if !(defined (__NO_INLINE__) || defined (__NO_CTYPE_INLINES))
__CRT_INLINE int __cdecl __isascii(int c) {return ((c & ~0x7F) == 0);}
__CRT_INLINE int __cdecl __toascii(int c) {return (c & 0x7F);}
__CRT_INLINE int __cdecl __iscsymf(int c) {return (isalpha(c) || (c == '_'));}
__CRT_INLINE int __cdecl __iscsym(int c) {return (isalnum(c) || (c == '_'));}
#endif /* __NO_CTYPE_INLINES */
#ifndef _NO_OLDNAMES
/* Not _CRTIMP */
int __cdecl isascii (int);
int __cdecl toascii (int);
int __cdecl iscsymf (int);
int __cdecl iscsym (int);
#endif /* Not _NO_OLDNAMES */
#endif /* Not __STRICT_ANSI__ */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _CTYPE_H_ */

View File

@ -0,0 +1,26 @@
/*
* dir.h
*
* This file OBSOLESCENT and only provided for backward compatibility.
* Please use io.h instead.
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
* Mumit Khan <khan@xraylith.wisc.edu>
*
* 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
* DISCLAIMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#include <io.h>

View File

@ -0,0 +1,73 @@
/*
* direct.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Functions for manipulating paths and directories (included from io.h)
* plus functions for setting the current drive.
*
*/
#ifndef _DIRECT_H_
#define _DIRECT_H_
/* All the headers include this file. */
#include <_mingw.h>
#define __need_wchar_t
#ifndef RC_INVOKED
#include <stddef.h>
#endif /* Not RC_INVOKED */
#include <io.h>
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _DISKFREE_T_DEFINED
/* needed by _getdiskfree (also in dos.h) */
struct _diskfree_t {
unsigned total_clusters;
unsigned avail_clusters;
unsigned sectors_per_cluster;
unsigned bytes_per_sector;
};
#define _DISKFREE_T_DEFINED
#endif
/*
* You really shouldn't be using these. Use the Win32 API functions instead.
* However, it does make it easier to port older code.
*/
_CRTIMP int __cdecl _getdrive (void);
_CRTIMP unsigned long __cdecl _getdrives(void);
_CRTIMP int __cdecl _chdrive (int);
_CRTIMP char* __cdecl _getdcwd (int, char*, int);
_CRTIMP unsigned __cdecl _getdiskfree (unsigned, struct _diskfree_t *);
#ifndef _NO_OLDNAMES
# define diskfree_t _diskfree_t
#endif
#ifndef _WDIRECT_DEFINED
/* wide character versions. Also in wchar.h */
#ifdef __MSVCRT__
_CRTIMP int __cdecl _wchdir(const wchar_t*);
_CRTIMP wchar_t* __cdecl _wgetcwd(wchar_t*, int);
_CRTIMP wchar_t* __cdecl _wgetdcwd(int, wchar_t*, int);
_CRTIMP int __cdecl _wmkdir(const wchar_t*);
_CRTIMP int __cdecl _wrmdir(const wchar_t*);
#endif /* __MSVCRT__ */
#define _WDIRECT_DEFINED
#endif
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _DIRECT_H_ */

View File

@ -0,0 +1,123 @@
/*
* DIRENT.H (formerly DIRLIB.H)
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
*/
#ifndef _DIRENT_H_
#define _DIRENT_H_
/* All the headers include this file. */
#include <_mingw.h>
#include <io.h>
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
struct dirent
{
long d_ino; /* Always zero. */
unsigned short d_reclen; /* Always zero. */
unsigned short d_namlen; /* Length of name in d_name. */
char d_name[FILENAME_MAX]; /* File name. */
};
/*
* This is an internal data structure. Good programmers will not use it
* except as an argument to one of the functions below.
* dd_stat field is now int (was short in older versions).
*/
typedef struct
{
/* disk transfer area for this dir */
struct _finddata_t dd_dta;
/* dirent struct to return from dir (NOTE: this makes this thread
* safe as long as only one thread uses a particular DIR struct at
* a time) */
struct dirent dd_dir;
/* _findnext handle */
long dd_handle;
/*
* Status of search:
* 0 = not started yet (next entry to read is first entry)
* -1 = off the end
* positive = 0 based index of next entry
*/
int dd_stat;
/* given path for dir with search pattern (struct is extended) */
char dd_name[1];
} DIR;
DIR* __cdecl opendir (const char*);
struct dirent* __cdecl readdir (DIR*);
int __cdecl closedir (DIR*);
void __cdecl rewinddir (DIR*);
long __cdecl telldir (DIR*);
void __cdecl seekdir (DIR*, long);
/* wide char versions */
struct _wdirent
{
long d_ino; /* Always zero. */
unsigned short d_reclen; /* Always zero. */
unsigned short d_namlen; /* Length of name in d_name. */
wchar_t d_name[FILENAME_MAX]; /* File name. */
};
/*
* This is an internal data structure. Good programmers will not use it
* except as an argument to one of the functions below.
*/
typedef struct
{
/* disk transfer area for this dir */
struct _wfinddata_t dd_dta;
/* dirent struct to return from dir (NOTE: this makes this thread
* safe as long as only one thread uses a particular DIR struct at
* a time) */
struct _wdirent dd_dir;
/* _findnext handle */
long dd_handle;
/*
* Status of search:
* 0 = not started yet (next entry to read is first entry)
* -1 = off the end
* positive = 0 based index of next entry
*/
int dd_stat;
/* given path for dir with search pattern (struct is extended) */
wchar_t dd_name[1];
} _WDIR;
_WDIR* __cdecl _wopendir (const wchar_t*);
struct _wdirent* __cdecl _wreaddir (_WDIR*);
int __cdecl _wclosedir (_WDIR*);
void __cdecl _wrewinddir (_WDIR*);
long __cdecl _wtelldir (_WDIR*);
void __cdecl _wseekdir (_WDIR*, long);
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _DIRENT_H_ */

View File

@ -0,0 +1,89 @@
/*
* dos.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* DOS-specific functions and structures.
*
*/
#ifndef _DOS_H_
#define _DOS_H_
/* All the headers include this file. */
#include <_mingw.h>
#define __need_wchar_t
#ifndef RC_INVOKED
#include <stddef.h>
#endif /* Not RC_INVOKED */
/* For DOS file attributes */
#include <io.h>
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __MSVCRT__ /* these are in CRTDLL, but not MSVCRT */
#ifndef __DECLSPEC_SUPPORTED
extern unsigned int *_imp___basemajor_dll;
extern unsigned int *_imp___baseminor_dll;
extern unsigned int *_imp___baseversion_dll;
extern unsigned int *_imp___osmajor_dll;
extern unsigned int *_imp___osminor_dll;
extern unsigned int *_imp___osmode_dll;
#define _basemajor (*_imp___basemajor_dll)
#define _baseminor (*_imp___baseminor_dll)
#define _baseversion (*_imp___baseversion_dll)
#define _osmajor (*_imp___osmajor_dll)
#define _osminor (*_imp___osminor_dll)
#define _osmode (*_imp___osmode_dll)
#else /* __DECLSPEC_SUPPORTED */
__MINGW_IMPORT unsigned int _basemajor_dll;
__MINGW_IMPORT unsigned int _baseminor_dll;
__MINGW_IMPORT unsigned int _baseversion_dll;
__MINGW_IMPORT unsigned int _osmajor_dll;
__MINGW_IMPORT unsigned int _osminor_dll;
__MINGW_IMPORT unsigned int _osmode_dll;
#define _basemajor _basemajor_dll
#define _baseminor _baseminor_dll
#define _baseversion _baseversion_dll
#define _osmajor _osmajor_dll
#define _osminor _osminor_dll
#define _osmode _osmode_dll
#endif /* __DECLSPEC_SUPPORTED */
#endif /* ! __MSVCRT__ */
#ifndef _DISKFREE_T_DEFINED
/* needed by _getdiskfree (also in direct.h) */
struct _diskfree_t {
unsigned total_clusters;
unsigned avail_clusters;
unsigned sectors_per_cluster;
unsigned bytes_per_sector;
};
#define _DISKFREE_T_DEFINED
#endif
_CRTIMP unsigned __cdecl _getdiskfree (unsigned, struct _diskfree_t *);
#ifndef _NO_OLDNAMES
# define diskfree_t _diskfree_t
#endif
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _DOS_H_ */

View File

@ -0,0 +1,101 @@
/*
* errno.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Error numbers and access to error reporting.
*
*/
#ifndef _ERRNO_H_
#define _ERRNO_H_
/* All the headers include this file. */
#include <_mingw.h>
/*
* Error numbers.
* TODO: Can't be sure of some of these assignments, I guessed from the
* names given by strerror and the defines in the Cygnus errno.h. A lot
* of the names from the Cygnus errno.h are not represented, and a few
* of the descriptions returned by strerror do not obviously match
* their error naming.
*/
#define EPERM 1 /* Operation not permitted */
#define ENOFILE 2 /* No such file or directory */
#define ENOENT 2
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted function call */
#define EIO 5 /* Input/output 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 descriptor */
#define ECHILD 10 /* No child processes */
#define EAGAIN 11 /* Resource temporarily unavailable */
#define ENOMEM 12 /* Not enough space */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
/* 15 - Unknown Error */
#define EBUSY 16 /* strerror reports "Resource device" */
#define EEXIST 17 /* File exists */
#define EXDEV 18 /* Improper link (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 /* Too many open files in system */
#define EMFILE 24 /* Too many open files */
#define ENOTTY 25 /* Inappropriate I/O control operation */
/* 26 - Unknown Error */
#define EFBIG 27 /* File too large */
#define ENOSPC 28 /* No space left on device */
#define ESPIPE 29 /* Invalid seek (seek on a pipe?) */
#define EROFS 30 /* Read-only file system */
#define EMLINK 31 /* Too many links */
#define EPIPE 32 /* Broken pipe */
#define EDOM 33 /* Domain error (math functions) */
#define ERANGE 34 /* Result too large (possibly too small) */
/* 35 - Unknown Error */
#define EDEADLOCK 36 /* Resource deadlock avoided (non-Cyg) */
#define EDEADLK 36
/* 37 - Unknown Error */
#define ENAMETOOLONG 38 /* Filename too long (91 in Cyg?) */
#define ENOLCK 39 /* No locks available (46 in Cyg?) */
#define ENOSYS 40 /* Function not implemented (88 in Cyg?) */
#define ENOTEMPTY 41 /* Directory not empty (90 in Cyg?) */
#define EILSEQ 42 /* Illegal byte sequence */
/*
* NOTE: ENAMETOOLONG and ENOTEMPTY conflict with definitions in the
* sockets.h header provided with windows32api-0.1.2.
* You should go and put an #if 0 ... #endif around the whole block
* of errors (look at the comment above them).
*/
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
/*
* Definitions of errno. For _doserrno, sys_nerr and * sys_errlist, see
* stdlib.h.
*/
#ifdef _UWIN
#undef errno
extern int errno;
#else
_CRTIMP int* __cdecl _errno(void);
#define errno (*_errno())
#endif
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _ERRNO_H_ */

View File

@ -0,0 +1,102 @@
/*
* excpt.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Support for operating system level structured exception handling.
*
* NOTE: This is very preliminary stuff. I am also pretty sure it is
* completely Intel specific.
*
*/
#ifndef _EXCPT_H_
#define _EXCPT_H_
/* All the headers include this file. */
#include <_mingw.h>
#include <windef.h>
/*
* NOTE: The constants structs and typedefs below should be defined in the
* Win32 API headers.
*/
#define EH_NONCONTINUABLE 0x01
#define EH_UNWINDING 0x02
#define EH_EXIT_UNWIND 0x04
#define EH_STACK_INVALID 0x08
#define EH_NESTED_CALL 0x10
#ifndef RC_INVOKED
typedef enum {
ExceptionContinueExecution,
ExceptionContinueSearch,
ExceptionNestedException,
ExceptionCollidedUnwind
} EXCEPTION_DISPOSITION;
/*
* End of stuff that should be in the Win32 API files.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* The type of function that is expected as an exception handler to be
* installed with _try1.
*/
typedef EXCEPTION_DISPOSITION (*PEXCEPTION_HANDLER)
(struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
/*
* This is not entirely necessary, but it is the structure installed by
* the _try1 primitive below.
*/
typedef struct _EXCEPTION_REGISTRATION
{
struct _EXCEPTION_REGISTRATION* prev;
PEXCEPTION_HANDLER handler;
} EXCEPTION_REGISTRATION, *PEXCEPTION_REGISTRATION;
typedef EXCEPTION_REGISTRATION EXCEPTION_REGISTRATION_RECORD;
typedef PEXCEPTION_REGISTRATION PEXCEPTION_REGISTRATION_RECORD;
/*
* A macro which installs the supplied exception handler.
* Push the pointer to the new handler onto the stack,
* then push the pointer to the old registration structure (at fs:0)
* onto the stack, then put a pointer to the new registration
* structure (i.e. the current stack pointer) at fs:0.
*/
#define __try1(pHandler) \
__asm__ ("pushl %0;pushl %%fs:0;movl %%esp,%%fs:0;" : : "g" (pHandler));
/*
* A macro which (despite its name) *removes* an installed
* exception handler. Should be used only in conjunction with the above
* install routine __try1.
* Move the pointer to the old reg. struct (at the current stack
* position) to fs:0, replacing the pointer we installed above,
* then add 8 to the stack pointer to get rid of the space we
* used when we pushed on our new reg. struct above. Notice that
* the stack must be in the exact state at this point that it was
* after we did _try1 or this will smash things.
*/
#define __except1 \
__asm__ ("movl (%%esp),%%eax;movl %%eax,%%fs:0;addl $8,%%esp;" \
: : : "%eax");
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* _EXCPT_H_ not defined */

View File

@ -0,0 +1,69 @@
/*
* fcntl.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Access constants for _open. Note that the permissions constants are
* in sys/stat.h (ick).
*
*/
#ifndef _FCNTL_H_
#define _FCNTL_H_
/* All the headers include this file. */
#include <_mingw.h>
/*
* It appears that fcntl.h should include io.h for compatibility...
*/
#include <io.h>
/* 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_RANDOM 0x0010
#define _O_SEQUENTIAL 0x0020
#define _O_TEMPORARY 0x0040 /* Make the file dissappear after closing.
* WARNING: Even if not created by _open! */
#define _O_NOINHERIT 0x0080
#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. */
#define _O_SHORT_LIVED 0x1000
/* 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
#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_NOINHERIT _O_NOINHERIT
#define O_SEQUENTIAL _O_SEQUENTIAL
#define O_RANDOM _O_RANDOM
#endif /* Not _NO_OLDNAMES */
#endif /* Not _FCNTL_H_ */

View File

@ -0,0 +1,91 @@
#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
#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 28-byte struct represents the entire floating point
environment as stored by fnstenv or fstenv */
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;
} 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,152 @@
/*
* float.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Constants related to floating point arithmetic.
*
* Also included here are some non-ANSI bits for accessing the floating
* point controller.
*
* NOTE: GCC provides float.h, but it doesn't include the non-standard
* stuff for accessing the fp controller. We include_next the
* GCC-supplied header and just define the MS-specific extensions
* here.
*
*/
#include_next<float.h>
#ifndef _MINGW_FLOAT_H_
#define _MINGW_FLOAT_H_
/* All the headers include this file. */
#include <_mingw.h>
/*
* Functions and definitions for controlling the FPU.
*/
#ifndef __STRICT_ANSI__
/* TODO: These constants are only valid for x86 machines */
/* Control word masks for unMask */
#define _MCW_EM 0x0008001F /* Error masks */
#define _MCW_IC 0x00040000 /* Infinity */
#define _MCW_RC 0x00000300 /* Rounding */
#define _MCW_PC 0x00030000 /* Precision */
/* Control word values for unNew (use with related unMask above) */
#define _EM_INVALID 0x00000010
#define _EM_DENORMAL 0x00080000
#define _EM_ZERODIVIDE 0x00000008
#define _EM_OVERFLOW 0x00000004
#define _EM_UNDERFLOW 0x00000002
#define _EM_INEXACT 0x00000001
#define _IC_AFFINE 0x00040000
#define _IC_PROJECTIVE 0x00000000
#define _RC_CHOP 0x00000300
#define _RC_UP 0x00000200
#define _RC_DOWN 0x00000100
#define _RC_NEAR 0x00000000
#define _PC_24 0x00020000
#define _PC_53 0x00010000
#define _PC_64 0x00000000
/* These are also defined in Mingw math.h, needed to work around
GCC build issues. */
/* Return values for fpclass. */
#ifndef __MINGW_FPCLASS_DEFINED
#define __MINGW_FPCLASS_DEFINED 1
#define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */
#define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */
#define _FPCLASS_NINF 0x0004 /* Negative Infinity */
#define _FPCLASS_NN 0x0008 /* Negative Normal */
#define _FPCLASS_ND 0x0010 /* Negative Denormal */
#define _FPCLASS_NZ 0x0020 /* Negative Zero */
#define _FPCLASS_PZ 0x0040 /* Positive Zero */
#define _FPCLASS_PD 0x0080 /* Positive Denormal */
#define _FPCLASS_PN 0x0100 /* Positive Normal */
#define _FPCLASS_PINF 0x0200 /* Positive Infinity */
#endif /* __MINGW_FPCLASS_DEFINED */
/* invalid subconditions (_SW_INVALID also set) */
#define _SW_UNEMULATED 0x0040 /* unemulated instruction */
#define _SW_SQRTNEG 0x0080 /* square root of a neg number */
#define _SW_STACKOVERFLOW 0x0200 /* FP stack overflow */
#define _SW_STACKUNDERFLOW 0x0400 /* FP stack underflow */
/* Floating point error signals and return codes */
#define _FPE_INVALID 0x81
#define _FPE_DENORMAL 0x82
#define _FPE_ZERODIVIDE 0x83
#define _FPE_OVERFLOW 0x84
#define _FPE_UNDERFLOW 0x85
#define _FPE_INEXACT 0x86
#define _FPE_UNEMULATED 0x87
#define _FPE_SQRTNEG 0x88
#define _FPE_STACKOVERFLOW 0x8a
#define _FPE_STACKUNDERFLOW 0x8b
#define _FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
/* Set the FPU control word as cw = (cw & ~unMask) | (unNew & unMask),
* i.e. change the bits in unMask to have the values they have in unNew,
* leaving other bits unchanged. */
_CRTIMP unsigned int __cdecl _controlfp (unsigned int unNew, unsigned int unMask);
_CRTIMP unsigned int __cdecl _control87 (unsigned int unNew, unsigned int unMask);
_CRTIMP unsigned int __cdecl _clearfp (void); /* Clear the FPU status word */
_CRTIMP unsigned int __cdecl _statusfp (void); /* Report the FPU status word */
#define _clear87 _clearfp
#define _status87 _statusfp
/*
MSVCRT.dll _fpreset initializes the control register to 0x27f,
the status register to zero and the tag word to 0FFFFh.
This differs from asm instruction finit/fninit which set control
word to 0x37f (64 bit mantissa precison rather than 53 bit).
By default, the mingw version of _fpreset sets fp control as
per fninit. To use the MSVCRT.dll _fpreset, include CRT_fp8.o when
building your application.
*/
void __cdecl _fpreset (void);
void __cdecl fpreset (void);
/* Global 'variable' for the current floating point error code. */
_CRTIMP int * __cdecl __fpecode(void);
#define _fpecode (*(__fpecode()))
/*
* IEEE recommended functions. MS puts them in float.h
* but they really belong in math.h.
*/
_CRTIMP double __cdecl _chgsign (double);
_CRTIMP double __cdecl _copysign (double, double);
_CRTIMP double __cdecl _logb (double);
_CRTIMP double __cdecl _nextafter (double, double);
_CRTIMP double __cdecl _scalb (double, long);
_CRTIMP int __cdecl _finite (double);
_CRTIMP int __cdecl _fpclass (double);
_CRTIMP int __cdecl _isnan (double);
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not __STRICT_ANSI__ */
#endif /* _FLOAT_H_ */

View File

@ -0,0 +1,84 @@
/*
* Copyright (c) 1987, 1993, 1994, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef __GETOPT_H__
#define __GETOPT_H__
#ifdef __cplusplus
extern "C" {
#endif
extern int opterr; /* if error message should be printed */
extern int optind; /* index into parent argv vector */
extern int optopt; /* character checked for validity */
extern int optreset; /* reset getopt */
extern char *optarg; /* argument associated with option */
int getopt (int, char * const *, const char *);
#ifdef __cplusplus
}
#endif
#endif /* __GETOPT_H__ */
#ifndef __UNISTD_GETOPT__
#ifndef __GETOPT_LONG_H__
#define __GETOPT_LONG_H__
#ifdef __cplusplus
extern "C" {
#endif
struct option {
const char *name;
int has_arg;
int *flag;
int val;
};
int getopt_long (int, char *const *, const char *, const struct option *, int *);
#ifndef HAVE_DECL_GETOPT
#define HAVE_DECL_GETOPT 1
#endif
#define no_argument 0
#define required_argument 1
#define optional_argument 2
#ifdef __cplusplus
}
#endif
#endif /* __GETOPT_LONG_H__ */
#endif /* __UNISTD_GETOPT__ */

View File

@ -0,0 +1,278 @@
/* 7.8 Format conversion of integer types <inttypes.h> */
#ifndef _INTTYPES_H_
#define _INTTYPES_H_
#include <_mingw.h>
#include <stdint.h>
#define __need_wchar_t
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
intmax_t quot;
intmax_t rem;
} imaxdiv_t;
#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
/* 7.8.1 Macros for format specifiers
*
* MS runtime does not yet understand C9x standard "ll"
* length specifier. It appears to treat "ll" as "l".
* The non-standard I64 length specifier causes warning in GCC,
* but understood by MS runtime functions.
*/
/* fprintf macros for signed types */
#define PRId8 "d"
#define PRId16 "d"
#define PRId32 "d"
#define PRId64 "I64d"
#define PRIdLEAST8 "d"
#define PRIdLEAST16 "d"
#define PRIdLEAST32 "d"
#define PRIdLEAST64 "I64d"
#define PRIdFAST8 "d"
#define PRIdFAST16 "d"
#define PRIdFAST32 "d"
#define PRIdFAST64 "I64d"
#define PRIdMAX "I64d"
#define PRIdPTR "d"
#define PRIi8 "i"
#define PRIi16 "i"
#define PRIi32 "i"
#define PRIi64 "I64i"
#define PRIiLEAST8 "i"
#define PRIiLEAST16 "i"
#define PRIiLEAST32 "i"
#define PRIiLEAST64 "I64i"
#define PRIiFAST8 "i"
#define PRIiFAST16 "i"
#define PRIiFAST32 "i"
#define PRIiFAST64 "I64i"
#define PRIiMAX "I64i"
#define PRIiPTR "i"
#define PRIo8 "o"
#define PRIo16 "o"
#define PRIo32 "o"
#define PRIo64 "I64o"
#define PRIoLEAST8 "o"
#define PRIoLEAST16 "o"
#define PRIoLEAST32 "o"
#define PRIoLEAST64 "I64o"
#define PRIoFAST8 "o"
#define PRIoFAST16 "o"
#define PRIoFAST32 "o"
#define PRIoFAST64 "I64o"
#define PRIoMAX "I64o"
#define PRIoPTR "o"
/* fprintf macros for unsigned types */
#define PRIu8 "u"
#define PRIu16 "u"
#define PRIu32 "u"
#define PRIu64 "I64u"
#define PRIuLEAST8 "u"
#define PRIuLEAST16 "u"
#define PRIuLEAST32 "u"
#define PRIuLEAST64 "I64u"
#define PRIuFAST8 "u"
#define PRIuFAST16 "u"
#define PRIuFAST32 "u"
#define PRIuFAST64 "I64u"
#define PRIuMAX "I64u"
#define PRIuPTR "u"
#define PRIx8 "x"
#define PRIx16 "x"
#define PRIx32 "x"
#define PRIx64 "I64x"
#define PRIxLEAST8 "x"
#define PRIxLEAST16 "x"
#define PRIxLEAST32 "x"
#define PRIxLEAST64 "I64x"
#define PRIxFAST8 "x"
#define PRIxFAST16 "x"
#define PRIxFAST32 "x"
#define PRIxFAST64 "I64x"
#define PRIxMAX "I64x"
#define PRIxPTR "x"
#define PRIX8 "X"
#define PRIX16 "X"
#define PRIX32 "X"
#define PRIX64 "I64X"
#define PRIXLEAST8 "X"
#define PRIXLEAST16 "X"
#define PRIXLEAST32 "X"
#define PRIXLEAST64 "I64X"
#define PRIXFAST8 "X"
#define PRIXFAST16 "X"
#define PRIXFAST32 "X"
#define PRIXFAST64 "I64X"
#define PRIXMAX "I64X"
#define PRIXPTR "X"
/*
* fscanf macros for signed int types
* NOTE: if 32-bit int is used for int_fast8_t and int_fast16_t
* (see stdint.h, 7.18.1.3), FAST8 and FAST16 should have
* no length identifiers
*/
#define SCNd16 "hd"
#define SCNd32 "d"
#define SCNd64 "I64d"
#define SCNdLEAST16 "hd"
#define SCNdLEAST32 "d"
#define SCNdLEAST64 "I64d"
#define SCNdFAST16 "hd"
#define SCNdFAST32 "d"
#define SCNdFAST64 "I64d"
#define SCNdMAX "I64d"
#define SCNdPTR "d"
#define SCNi16 "hi"
#define SCNi32 "i"
#define SCNi64 "I64i"
#define SCNiLEAST16 "hi"
#define SCNiLEAST32 "i"
#define SCNiLEAST64 "I64i"
#define SCNiFAST16 "hi"
#define SCNiFAST32 "i"
#define SCNiFAST64 "I64i"
#define SCNiMAX "I64i"
#define SCNiPTR "i"
#define SCNo16 "ho"
#define SCNo32 "o"
#define SCNo64 "I64o"
#define SCNoLEAST16 "ho"
#define SCNoLEAST32 "o"
#define SCNoLEAST64 "I64o"
#define SCNoFAST16 "ho"
#define SCNoFAST32 "o"
#define SCNoFAST64 "I64o"
#define SCNoMAX "I64o"
#define SCNoPTR "o"
#define SCNx16 "hx"
#define SCNx32 "x"
#define SCNx64 "I64x"
#define SCNxLEAST16 "hx"
#define SCNxLEAST32 "x"
#define SCNxLEAST64 "I64x"
#define SCNxFAST16 "hx"
#define SCNxFAST32 "x"
#define SCNxFAST64 "I64x"
#define SCNxMAX "I64x"
#define SCNxPTR "x"
/* fscanf macros for unsigned int types */
#define SCNu16 "hu"
#define SCNu32 "u"
#define SCNu64 "I64u"
#define SCNuLEAST16 "hu"
#define SCNuLEAST32 "u"
#define SCNuLEAST64 "I64u"
#define SCNuFAST16 "hu"
#define SCNuFAST32 "u"
#define SCNuFAST64 "I64u"
#define SCNuMAX "I64u"
#define SCNuPTR "u"
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/*
* no length modifier for char types prior to C9x
* MS runtime scanf appears to treat "hh" as "h"
*/
/* signed char */
#define SCNd8 "hhd"
#define SCNdLEAST8 "hhd"
#define SCNdFAST8 "hhd"
#define SCNi8 "hhi"
#define SCNiLEAST8 "hhi"
#define SCNiFAST8 "hhi"
#define SCNo8 "hho"
#define SCNoLEAST8 "hho"
#define SCNoFAST8 "hho"
#define SCNx8 "hhx"
#define SCNxLEAST8 "hhx"
#define SCNxFAST8 "hhx"
/* unsigned char */
#define SCNu8 "hhu"
#define SCNuLEAST8 "hhu"
#define SCNuFAST8 "hhu"
#endif /* __STDC_VERSION__ >= 199901 */
#endif /* !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) */
__CRT_INLINE intmax_t __cdecl imaxabs (intmax_t j)
{return (j >= 0 ? j : -j);}
imaxdiv_t __cdecl imaxdiv (intmax_t numer, intmax_t denom);
/* 7.8.2 Conversion functions for greatest-width integer types */
intmax_t __cdecl strtoimax (const char* __restrict__ nptr,
char** __restrict__ endptr, int base);
uintmax_t __cdecl strtoumax (const char* __restrict__ nptr,
char** __restrict__ endptr, int base);
intmax_t __cdecl wcstoimax (const wchar_t* __restrict__ nptr,
wchar_t** __restrict__ endptr, int base);
uintmax_t __cdecl wcstoumax (const wchar_t* __restrict__ nptr,
wchar_t** __restrict__ endptr, int base);
#ifdef __cplusplus
}
#endif
#endif /* ndef _INTTYPES_H */

View File

@ -0,0 +1,313 @@
/*
* io.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* System level I/O functions and types.
*
*/
#ifndef _IO_H_
#define _IO_H_
/* All the headers include this file. */
#include <_mingw.h>
/* 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
* an inclusion of sys/types.h */
#include <sys/types.h> /* To get time_t. */
#include <stdint.h> /* For intptr_t. */
/*
* Attributes of files as returned by _findfirst et al.
*/
#define _A_NORMAL 0x00000000
#define _A_RDONLY 0x00000001
#define _A_HIDDEN 0x00000002
#define _A_SYSTEM 0x00000004
#define _A_VOLID 0x00000008
#define _A_SUBDIR 0x00000010
#define _A_ARCH 0x00000020
#ifndef RC_INVOKED
#ifndef _FSIZE_T_DEFINED
typedef unsigned long _fsize_t;
#define _FSIZE_T_DEFINED
#endif
/*
* The maximum length of a file name. You should use GetVolumeInformation
* instead of this constant. But hey, this works.
* Also defined in stdio.h.
*/
#ifndef FILENAME_MAX
#define FILENAME_MAX (260)
#endif
/*
* The following structure is filled in by _findfirst or _findnext when
* they succeed in finding a match.
*/
struct _finddata_t
{
unsigned attrib; /* Attributes, see constants above. */
time_t time_create;
time_t time_access; /* always midnight local time */
time_t time_write;
_fsize_t size;
char name[FILENAME_MAX]; /* may include spaces. */
};
struct _finddatai64_t {
unsigned attrib;
time_t time_create;
time_t time_access;
time_t time_write;
__int64 size;
char name[FILENAME_MAX];
};
struct __finddata64_t {
unsigned attrib;
__time64_t time_create;
__time64_t time_access;
__time64_t time_write;
_fsize_t size;
char name[FILENAME_MAX];
};
#ifndef _WFINDDATA_T_DEFINED
struct _wfinddata_t {
unsigned attrib;
time_t time_create; /* -1 for FAT file systems */
time_t time_access; /* -1 for FAT file systems */
time_t time_write;
_fsize_t size;
wchar_t name[FILENAME_MAX]; /* may include spaces. */
};
struct _wfinddatai64_t {
unsigned attrib;
time_t time_create;
time_t time_access;
time_t time_write;
__int64 size;
wchar_t name[FILENAME_MAX];
};
struct __wfinddata64_t {
unsigned attrib;
__time64_t time_create;
__time64_t time_access;
__time64_t time_write;
_fsize_t size;
wchar_t name[FILENAME_MAX];
};
#define _WFINDDATA_T_DEFINED
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Functions for searching for files. _findfirst returns -1 if no match
* is found. Otherwise it returns a handle to be used in _findnext and
* _findclose calls. _findnext also returns -1 if no match could be found,
* and 0 if a match was found. Call _findclose when you are finished.
*/
/* FIXME: Should these all use intptr_t, as per recent MSDN docs? */
_CRTIMP long __cdecl _findfirst (const char*, struct _finddata_t*);
_CRTIMP int __cdecl _findnext (long, struct _finddata_t*);
_CRTIMP int __cdecl _findclose (long);
_CRTIMP int __cdecl _chdir (const char*);
_CRTIMP char* __cdecl _getcwd (char*, int);
_CRTIMP int __cdecl _mkdir (const char*);
_CRTIMP char* __cdecl _mktemp (char*);
_CRTIMP int __cdecl _rmdir (const char*);
_CRTIMP int __cdecl _chmod (const char*, int);
#ifdef __MSVCRT__
_CRTIMP __int64 __cdecl _filelengthi64(int);
_CRTIMP long __cdecl _findfirsti64(const char*, struct _finddatai64_t*);
_CRTIMP int __cdecl _findnexti64(long, struct _finddatai64_t*);
_CRTIMP __int64 __cdecl _lseeki64(int, __int64, int);
_CRTIMP __int64 __cdecl _telli64(int);
/* These require newer versions of msvcrt.dll (6.1 or higher). */
#if __MSVCRT_VERSION__ >= 0x0601
_CRTIMP intptr_t __cdecl _findfirst64(const char*, struct __finddata64_t*);
_CRTIMP intptr_t __cdecl _findnext64(intptr_t, struct __finddata64_t*);
#endif /* __MSVCRT_VERSION__ >= 0x0601 */
#ifndef __NO_MINGW_LFS
__CRT_INLINE off64_t lseek64 (int fd, off64_t offset, int whence)
{
return _lseeki64(fd, (__int64) offset, whence);
}
#endif
#endif /* __MSVCRT__ */
#ifndef _NO_OLDNAMES
#ifndef _UWIN
_CRTIMP int __cdecl chdir (const char*);
_CRTIMP char* __cdecl getcwd (char*, int);
_CRTIMP int __cdecl mkdir (const char*);
_CRTIMP char* __cdecl mktemp (char*);
_CRTIMP int __cdecl rmdir (const char*);
_CRTIMP int __cdecl chmod (const char*, int);
#endif /* _UWIN */
#endif /* Not _NO_OLDNAMES */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
/* TODO: Maximum number of open handles has not been tested, I just set
* it the same as FOPEN_MAX. */
#define HANDLE_MAX FOPEN_MAX
/* 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 X_OK 1 /* Check for execute permission. */
#define W_OK 2 /* Check for write permission */
#define R_OK 4 /* Check for read permission */
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
_CRTIMP int __cdecl _access (const char*, int);
_CRTIMP int __cdecl _chsize (int, long);
_CRTIMP int __cdecl _close (int);
_CRTIMP int __cdecl _commit(int);
/* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80),
* the "owner write permission" bit (on FAT). */
_CRTIMP int __cdecl _creat (const char*, int);
_CRTIMP int __cdecl _dup (int);
_CRTIMP int __cdecl _dup2 (int, int);
_CRTIMP long __cdecl _filelength (int);
_CRTIMP long __cdecl _get_osfhandle (int);
_CRTIMP int __cdecl _isatty (int);
/* 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
_CRTIMP int __cdecl _eof (int);
#endif
/* LK_... locking commands defined in sys/locking.h. */
_CRTIMP int __cdecl _locking (int, int, long);
_CRTIMP long __cdecl _lseek (int, long, int);
/* Optional third argument is unsigned unPermissions. */
_CRTIMP int __cdecl _open (const char*, int, ...);
_CRTIMP int __cdecl _open_osfhandle (long, int);
_CRTIMP int __cdecl _pipe (int *, unsigned int, int);
_CRTIMP int __cdecl _read (int, void*, unsigned int);
_CRTIMP int __cdecl _setmode (int, int);
/* SH_... flags for nShFlags defined in share.h
* Optional fourth argument is unsigned unPermissions */
_CRTIMP int __cdecl _sopen (const char*, int, int, ...);
_CRTIMP long __cdecl _tell (int);
/* Should umask be in sys/stat.h and/or sys/types.h instead? */
_CRTIMP int __cdecl _umask (int);
_CRTIMP int __cdecl _unlink (const char*);
_CRTIMP int __cdecl _write (int, const void*, unsigned int);
/* Wide character versions. Also declared in wchar.h. */
/* Not in crtdll.dll */
#if !defined (_WIO_DEFINED)
#if defined (__MSVCRT__)
_CRTIMP int __cdecl _waccess(const wchar_t*, int);
_CRTIMP int __cdecl _wchmod(const wchar_t*, int);
_CRTIMP int __cdecl _wcreat(const wchar_t*, int);
_CRTIMP long __cdecl _wfindfirst(const wchar_t*, struct _wfinddata_t*);
_CRTIMP int __cdecl _wfindnext(long, struct _wfinddata_t *);
_CRTIMP int __cdecl _wunlink(const wchar_t*);
_CRTIMP int __cdecl _wopen(const wchar_t*, int, ...);
_CRTIMP int __cdecl _wsopen(const wchar_t*, int, int, ...);
_CRTIMP wchar_t * __cdecl _wmktemp(wchar_t*);
_CRTIMP long __cdecl _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*);
_CRTIMP int __cdecl _wfindnexti64(long, struct _wfinddatai64_t*);
#if __MSVCRT_VERSION__ >= 0x0601
_CRTIMP intptr_t __cdecl _wfindfirst64(const wchar_t*, struct __wfinddata64_t*);
_CRTIMP intptr_t __cdecl _wfindnext64(intptr_t, struct __wfinddata64_t*);
#endif
#endif /* defined (__MSVCRT__) */
#define _WIO_DEFINED
#endif /* _WIO_DEFINED */
#ifndef _NO_OLDNAMES
/*
* Non-underscored versions of non-ANSI functions to improve portability.
* These functions live in libmoldname.a.
*/
#ifndef _UWIN
_CRTIMP int __cdecl access (const char*, int);
_CRTIMP int __cdecl chsize (int, long );
_CRTIMP int __cdecl close (int);
_CRTIMP int __cdecl creat (const char*, int);
_CRTIMP int __cdecl dup (int);
_CRTIMP int __cdecl dup2 (int, int);
_CRTIMP int __cdecl eof (int);
_CRTIMP long __cdecl filelength (int);
_CRTIMP int __cdecl isatty (int);
_CRTIMP long __cdecl lseek (int, long, int);
_CRTIMP int __cdecl open (const char*, int, ...);
_CRTIMP int __cdecl read (int, void*, unsigned int);
_CRTIMP int __cdecl setmode (int, int);
_CRTIMP int __cdecl sopen (const char*, int, int, ...);
_CRTIMP long __cdecl tell (int);
_CRTIMP int __cdecl umask (int);
_CRTIMP int __cdecl unlink (const char*);
_CRTIMP int __cdecl write (int, const void*, unsigned int);
#endif /* _UWIN */
/* Wide character versions. Also declared in wchar.h. */
/* Where do these live? Not in libmoldname.a nor in libmsvcrt.a */
#if 0
int waccess(const wchar_t *, int);
int wchmod(const wchar_t *, int);
int wcreat(const wchar_t *, int);
long wfindfirst(wchar_t *, struct _wfinddata_t *);
int wfindnext(long, struct _wfinddata_t *);
int wunlink(const wchar_t *);
int wrename(const wchar_t *, const wchar_t *);
int wopen(const wchar_t *, int, ...);
int wsopen(const wchar_t *, int, int, ...);
wchar_t * wmktemp(wchar_t *);
#endif
#endif /* Not _NO_OLDNAMES */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* _IO_H_ not defined */

View File

@ -0,0 +1,107 @@
/*
* limits.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Functions for manipulating paths and directories (included from io.h)
* plus functions for setting the current drive.
*
* Defines constants for the sizes of integral types.
*
* NOTE: GCC should supply a version of this header and it should be safe to
* use that version instead of this one (maybe safer).
*
*/
#ifndef _LIMITS_H_
#define _LIMITS_H_
/* All the headers include this file. */
#include <_mingw.h>
/*
* File system limits
*
* TODO: NAME_MAX and OPEN_MAX are file system limits or not? Are they the
* same as FILENAME_MAX and FOPEN_MAX from stdio.h?
* NOTE: Apparently the actual size of PATH_MAX is 260, but a space is
* required for the NUL. TODO: Test?
*/
#define PATH_MAX (259)
/*
* Characteristics of the char data type.
*
* TODO: Is MB_LEN_MAX correct?
*/
#define CHAR_BIT 8
#define MB_LEN_MAX 2
#define SCHAR_MIN (-128)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
/* TODO: Is this safe? I think it might just be testing the preprocessor,
* not the compiler itself... */
#if ('\x80' < 0)
#define CHAR_MIN SCHAR_MIN
#define CHAR_MAX SCHAR_MAX
#else
#define CHAR_MIN 0
#define CHAR_MAX UCHAR_MAX
#endif
/*
* Maximum and minimum values for ints.
*/
#define INT_MAX 2147483647
#define INT_MIN (-INT_MAX-1)
#define UINT_MAX 0xffffffff
/*
* Maximum and minimum values for shorts.
*/
#define SHRT_MAX 32767
#define SHRT_MIN (-SHRT_MAX-1)
#define USHRT_MAX 0xffff
/*
* Maximum and minimum values for longs and unsigned longs.
*
* TODO: This is not correct for Alphas, which have 64 bit longs.
*/
#define LONG_MAX 2147483647L
#define LONG_MIN (-LONG_MAX-1)
#define ULONG_MAX 0xffffffffUL
/*
* The GNU C compiler also allows 'long long int'
*/
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#define LONG_LONG_MAX 9223372036854775807LL
#define LONG_LONG_MIN (-LONG_LONG_MAX-1)
#define ULONG_LONG_MAX (2ULL * LONG_LONG_MAX + 1)
/* ISO C9x macro names */
#define LLONG_MAX LONG_LONG_MAX
#define LLONG_MIN LONG_LONG_MIN
#define ULLONG_MAX ULONG_LONG_MAX
/* MSVC compatibility */
#define _I64_MIN LONG_LONG_MIN
#define _I64_MAX LONG_LONG_MAX
#define _UI64_MAX ULONG_LONG_MAX
#endif /* Not Strict ANSI and GNU C compiler */
#endif /* not _LIMITS_H_ */

View File

View File

@ -0,0 +1,88 @@
/*
* locale.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Functions and types for localization (ie. changing the appearance of
* output based on the standards of a certain country).
*
*/
#ifndef _LOCALE_H_
#define _LOCALE_H_
/* All the headers include this file. */
#include <_mingw.h>
/*
* NOTE: I have tried to test this, but I am limited by my knowledge of
* locale issues. The structure does not bomb if you look at the
* values, and 'decimal_point' even seems to be correct. But the
* rest of the values are, by default, not particularly useful
* (read meaningless and not related to the international settings
* of the system).
*/
#define LC_ALL 0
#define LC_COLLATE 1
#define LC_CTYPE 2
#define LC_MONETARY 3
#define LC_NUMERIC 4
#define LC_TIME 5
#define LC_MIN LC_ALL
#define LC_MAX LC_TIME
#ifndef RC_INVOKED
/* According to C89 std, NULL is defined in locale.h too. */
#define __need_NULL
#include <stddef.h>
/*
* The structure returned by 'localeconv'.
*/
struct lconv
{
char* decimal_point;
char* thousands_sep;
char* grouping;
char* int_curr_symbol;
char* currency_symbol;
char* mon_decimal_point;
char* mon_thousands_sep;
char* mon_grouping;
char* positive_sign;
char* negative_sign;
char int_frac_digits;
char frac_digits;
char p_cs_precedes;
char p_sep_by_space;
char n_cs_precedes;
char n_sep_by_space;
char p_sign_posn;
char n_sign_posn;
};
#ifdef __cplusplus
extern "C" {
#endif
_CRTIMP char* __cdecl setlocale (int, const char*);
_CRTIMP struct lconv* __cdecl localeconv (void);
#ifndef _WLOCALE_DEFINED /* also declared in wchar.h */
# define __need_wchar_t
# include <stddef.h>
_CRTIMP wchar_t* __cdecl _wsetlocale(int, const wchar_t*);
# define _WLOCALE_DEFINED
#endif /* ndef _WLOCALE_DEFINED */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _LOCALE_H_ */

View File

@ -0,0 +1,90 @@
/*
* malloc.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Support for programs which want to use malloc.h to get memory management
* functions. Unless you absolutely need some of these functions and they are
* not in the ANSI headers you should use the ANSI standard header files
* instead.
*
*/
#ifndef _MALLOC_H_
#define _MALLOC_H_
/* All the headers include this file. */
#include <_mingw.h>
#include <stdlib.h>
#ifndef RC_INVOKED
/*
* The structure used to walk through the heap with _heapwalk.
*/
typedef struct _heapinfo
{
int* _pentry;
size_t _size;
int _useflag;
} _HEAPINFO;
/* Values for _heapinfo.useflag */
#define _USEDENTRY 0
#define _FREEENTRY 1
#ifdef __cplusplus
extern "C" {
#endif
/*
The _heap* memory allocation functions are supported on NT
but not W9x. On latter, they always set errno to ENOSYS.
*/
_CRTIMP int __cdecl _heapwalk (_HEAPINFO*);
#ifdef __GNUC__
#define _alloca(x) __builtin_alloca((x))
#endif
#ifndef _NO_OLDNAMES
_CRTIMP int __cdecl heapwalk (_HEAPINFO*);
#ifdef __GNUC__
#define alloca(x) __builtin_alloca((x))
#endif
#endif /* Not _NO_OLDNAMES */
_CRTIMP int __cdecl _heapchk (void); /* Verify heap integrety. */
_CRTIMP int __cdecl _heapmin (void); /* Return unused heap to the OS. */
_CRTIMP int __cdecl _heapset (unsigned int);
_CRTIMP size_t __cdecl _msize (void*);
_CRTIMP size_t __cdecl _get_sbh_threshold (void);
_CRTIMP int __cdecl _set_sbh_threshold (size_t);
_CRTIMP void* __cdecl _expand (void*, size_t);
/* These require msvcr70.dll or higher. */
#if __MSVCRT_VERSION__ >= 0x0700
_CRTIMP void * __cdecl _aligned_offset_malloc(size_t, size_t, size_t);
_CRTIMP void * __cdecl _aligned_offset_realloc(void*, size_t, size_t, size_t);
_CRTIMP void * __cdecl _aligned_malloc (size_t, size_t);
_CRTIMP void * __cdecl _aligned_realloc (void*, size_t, size_t);
_CRTIMP void __cdecl _aligned_free (void*);
#endif /* __MSVCRT_VERSION__ >= 0x0700 */
/* These require libmingwex.a. */
void * __cdecl __mingw_aligned_offset_malloc (size_t, size_t, size_t);
void * __cdecl __mingw_aligned_offset_realloc (void*, size_t, size_t, size_t);
void * __cdecl __mingw_aligned_malloc (size_t, size_t);
void * __cdecl __mingw_aligned_realloc (void*, size_t, size_t);
void __cdecl __mingw_aligned_free (void*);
#ifdef __cplusplus
}
#endif
#endif /* RC_INVOKED */
#endif /* Not _MALLOC_H_ */

View File

@ -0,0 +1,831 @@
/*
* math.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Mathematical functions.
*
*/
#ifndef _MATH_H_
#define _MATH_H_
#if __GNUC__ >= 3
#pragma GCC system_header
#endif
/* All the headers include this file. */
#include <_mingw.h>
/*
* Types for the _exception structure.
*/
#define _DOMAIN 1 /* domain error in argument */
#define _SING 2 /* singularity */
#define _OVERFLOW 3 /* range overflow */
#define _UNDERFLOW 4 /* range underflow */
#define _TLOSS 5 /* total loss of precision */
#define _PLOSS 6 /* partial loss of precision */
/*
* Exception types with non-ANSI names for compatibility.
*/
#ifndef __STRICT_ANSI__
#ifndef _NO_OLDNAMES
#define DOMAIN _DOMAIN
#define SING _SING
#define OVERFLOW _OVERFLOW
#define UNDERFLOW _UNDERFLOW
#define TLOSS _TLOSS
#define PLOSS _PLOSS
#endif /* Not _NO_OLDNAMES */
#endif /* Not __STRICT_ANSI__ */
/* Traditional/XOPEN math constants (double precison) */
#ifndef __STRICT_ANSI__
#define M_E 2.7182818284590452354
#define M_LOG2E 1.4426950408889634074
#define M_LOG10E 0.43429448190325182765
#define M_LN2 0.69314718055994530942
#define M_LN10 2.30258509299404568402
#define M_PI 3.14159265358979323846
#define M_PI_2 1.57079632679489661923
#define M_PI_4 0.78539816339744830962
#define M_1_PI 0.31830988618379067154
#define M_2_PI 0.63661977236758134308
#define M_2_SQRTPI 1.12837916709551257390
#define M_SQRT2 1.41421356237309504880
#define M_SQRT1_2 0.70710678118654752440
#endif
/* These are also defined in Mingw float.h; needed here as well to work
around GCC build issues. */
#ifndef __STRICT_ANSI__
#ifndef __MINGW_FPCLASS_DEFINED
#define __MINGW_FPCLASS_DEFINED 1
/* IEEE 754 classication */
#define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */
#define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */
#define _FPCLASS_NINF 0x0004 /* Negative Infinity */
#define _FPCLASS_NN 0x0008 /* Negative Normal */
#define _FPCLASS_ND 0x0010 /* Negative Denormal */
#define _FPCLASS_NZ 0x0020 /* Negative Zero */
#define _FPCLASS_PZ 0x0040 /* Positive Zero */
#define _FPCLASS_PD 0x0080 /* Positive Denormal */
#define _FPCLASS_PN 0x0100 /* Positive Normal */
#define _FPCLASS_PINF 0x0200 /* Positive Infinity */
#endif /* __MINGW_FPCLASS_DEFINED */
#endif /* Not __STRICT_ANSI__ */
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
/*
* HUGE_VAL is returned by strtod when the value would overflow the
* representation of 'double'. There are other uses as well.
*
* __imp__HUGE is a pointer to the actual variable _HUGE in
* MSVCRT.DLL. If we used _HUGE directly we would get a pointer
* to a thunk function.
*
* NOTE: The CRTDLL version uses _HUGE_dll instead.
*/
#ifndef __DECLSPEC_SUPPORTED
#ifdef __MSVCRT__
extern double* _imp___HUGE;
#define HUGE_VAL (*_imp___HUGE)
#else
/* CRTDLL */
extern double* _imp___HUGE_dll;
#define HUGE_VAL (*_imp___HUGE_dll)
#endif
#else /* __DECLSPEC_SUPPORTED */
#ifdef __MSVCRT__
__MINGW_IMPORT double _HUGE;
#define HUGE_VAL _HUGE
#else
/* CRTDLL */
__MINGW_IMPORT double _HUGE_dll;
#define HUGE_VAL _HUGE_dll
#endif
#endif /* __DECLSPEC_SUPPORTED */
struct _exception
{
int type;
char *name;
double arg1;
double arg2;
double retval;
};
_CRTIMP double __cdecl sin (double);
_CRTIMP double __cdecl cos (double);
_CRTIMP double __cdecl tan (double);
_CRTIMP double __cdecl sinh (double);
_CRTIMP double __cdecl cosh (double);
_CRTIMP double __cdecl tanh (double);
_CRTIMP double __cdecl asin (double);
_CRTIMP double __cdecl acos (double);
_CRTIMP double __cdecl atan (double);
_CRTIMP double __cdecl atan2 (double, double);
_CRTIMP double __cdecl exp (double);
_CRTIMP double __cdecl log (double);
_CRTIMP double __cdecl log10 (double);
_CRTIMP double __cdecl pow (double, double);
_CRTIMP double __cdecl sqrt (double);
_CRTIMP double __cdecl ceil (double);
_CRTIMP double __cdecl floor (double);
_CRTIMP double __cdecl fabs (double);
_CRTIMP double __cdecl ldexp (double, int);
_CRTIMP double __cdecl frexp (double, int*);
_CRTIMP double __cdecl modf (double, double*);
_CRTIMP double __cdecl fmod (double, double);
/* Excess precision when using a 64-bit mantissa for FPU math ops can
cause unexpected results with some of the MSVCRT math functions. For
example, unless the function return value is stored (truncating to
53-bit mantissa), calls to pow with both x and y as integral values
sometimes produce a non-integral result.
One workaround is to reset the FPU env to 53-bit mantissa
by a call to fesetenv (FE_PC53_ENV). Amother is to force storage
of the return value of individual math functions using wrappers.
NB, using these wrappers will disable builtin math functions and
hence disable the folding of function results at compile time when
arguments are constant. */
#if 0
#define __DEFINE_FLOAT_STORE_MATHFN_D1(fn1) \
static __inline__ double \
__float_store_ ## fn1 (double x) \
{ \
__volatile__ double res = (fn1) (x); \
return res; \
}
#define __DEFINE_FLOAT_STORE_MATHFN_D2(fn2) \
static __inline__ double \
__float_store_ ## fn2 (double x, double y) \
{ \
__volatile__ double res = (fn2) (x, y); \
return res; \
}
#endif
/* For example, here is how to force the result of the pow function
to be stored: */
#if 0
#undef pow
/* Define the ___float_store_pow function and use it instead of pow(). */
__DEFINE_FLOAT_STORE_MATHFN_D2 (pow)
#define pow __float_store_pow
#endif
#ifndef __STRICT_ANSI__
/* Complex number (for _cabs). This is the MS version. The ISO
C99 counterpart _Complex is an intrinsic type in GCC and
'complex' is defined as a macro. See complex.h */
struct _complex
{
double x; /* Real part */
double y; /* Imaginary part */
};
_CRTIMP double __cdecl _cabs (struct _complex);
_CRTIMP double __cdecl _hypot (double, double);
_CRTIMP double __cdecl _j0 (double);
_CRTIMP double __cdecl _j1 (double);
_CRTIMP double __cdecl _jn (int, double);
_CRTIMP double __cdecl _y0 (double);
_CRTIMP double __cdecl _y1 (double);
_CRTIMP double __cdecl _yn (int, double);
_CRTIMP int __cdecl _matherr (struct _exception *);
/* These are also declared in Mingw float.h; needed here as well to work
around GCC build issues. */
/* BEGIN FLOAT.H COPY */
/*
* IEEE recommended functions
*/
_CRTIMP double __cdecl _chgsign (double);
_CRTIMP double __cdecl _copysign (double, double);
_CRTIMP double __cdecl _logb (double);
_CRTIMP double __cdecl _nextafter (double, double);
_CRTIMP double __cdecl _scalb (double, long);
_CRTIMP int __cdecl _finite (double);
_CRTIMP int __cdecl _fpclass (double);
_CRTIMP int __cdecl _isnan (double);
/* END FLOAT.H COPY */
/*
* Non-underscored versions of non-ANSI functions.
* These reside in liboldnames.a.
*/
#if !defined (_NO_OLDNAMES)
_CRTIMP double __cdecl j0 (double);
_CRTIMP double __cdecl j1 (double);
_CRTIMP double __cdecl jn (int, double);
_CRTIMP double __cdecl y0 (double);
_CRTIMP double __cdecl y1 (double);
_CRTIMP double __cdecl yn (int, double);
_CRTIMP double __cdecl chgsign (double);
_CRTIMP double __cdecl scalb (double, long);
_CRTIMP int __cdecl finite (double);
_CRTIMP int __cdecl fpclass (double);
#define FP_SNAN _FPCLASS_SNAN
#define FP_QNAN _FPCLASS_QNAN
#define FP_NINF _FPCLASS_NINF
#define FP_PINF _FPCLASS_PINF
#define FP_NDENORM _FPCLASS_ND
#define FP_PDENORM _FPCLASS_PD
#define FP_NZERO _FPCLASS_NZ
#define FP_PZERO _FPCLASS_PZ
#define FP_NNORM _FPCLASS_NN
#define FP_PNORM _FPCLASS_PN
#endif /* Not _NO_OLDNAMES */
/* This require msvcr70.dll or higher. */
#if __MSVCRT_VERSION__ >= 0x0700
_CRTIMP int __cdecl _set_SSE2_enable (int);
#endif /* __MSVCRT_VERSION__ >= 0x0700 */
#endif /* __STRICT_ANSI__ */
#ifndef __NO_ISOCEXT
#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
|| !defined __STRICT_ANSI__ || defined __cplusplus
#define NAN (0.0F/0.0F)
#define HUGE_VALF (1.0F/0.0F)
#define HUGE_VALL (1.0L/0.0L)
#define INFINITY (1.0F/0.0F)
/* 7.12.3.1 */
/*
Return values for fpclassify.
These are based on Intel x87 fpu condition codes
in the high byte of status word and differ from
the return values for MS IEEE 754 extension _fpclass()
*/
#define FP_NAN 0x0100
#define FP_NORMAL 0x0400
#define FP_INFINITE (FP_NAN | FP_NORMAL)
#define FP_ZERO 0x4000
#define FP_SUBNORMAL (FP_NORMAL | FP_ZERO)
/* 0x0200 is signbit mask */
/*
We can't inline float or double, because we want to ensure truncation
to semantic type before classification.
(A normal long double value might become subnormal when
converted to double, and zero when converted to float.)
*/
extern int __cdecl __fpclassifyf (float);
extern int __cdecl __fpclassify (double);
__CRT_INLINE int __cdecl __fpclassifyl (long double x){
unsigned short sw;
__asm__ ("fxam; fstsw %%ax;" : "=a" (sw): "t" (x));
return sw & (FP_NAN | FP_NORMAL | FP_ZERO );
}
#define fpclassify(x) (sizeof (x) == sizeof (float) ? __fpclassifyf (x) \
: sizeof (x) == sizeof (double) ? __fpclassify (x) \
: __fpclassifyl (x))
/* 7.12.3.2 */
#define isfinite(x) ((fpclassify(x) & FP_NAN) == 0)
/* 7.12.3.3 */
#define isinf(x) (fpclassify(x) == FP_INFINITE)
/* 7.12.3.4 */
/* We don't need to worry about trucation here:
A NaN stays a NaN. */
__CRT_INLINE int __cdecl __isnan (double _x)
{
unsigned short sw;
#ifdef _M_IX86
__asm__ ("fxam;"
"fstsw %%ax": "=a" (sw) : "t" (_x));
return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
== FP_NAN;
#else
return 0;
#endif
}
__CRT_INLINE int __cdecl __isnanf (float _x)
{
unsigned short sw;
#ifdef _M_IX86
__asm__ ("fxam;"
"fstsw %%ax": "=a" (sw) : "t" (_x));
return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
== FP_NAN;
#else
return 0;
#endif
}
__CRT_INLINE int __cdecl __isnanl (long double _x)
{
unsigned short sw;
#ifdef _M_IX86
__asm__ ("fxam;"
"fstsw %%ax": "=a" (sw) : "t" (_x));
return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
== FP_NAN;
#else
return 0;
#endif
}
#define isnan(x) (sizeof (x) == sizeof (float) ? __isnanf (x) \
: sizeof (x) == sizeof (double) ? __isnan (x) \
: __isnanl (x))
/* 7.12.3.5 */
#define isnormal(x) (fpclassify(x) == FP_NORMAL)
/* 7.12.3.6 The signbit macro */
__CRT_INLINE int __cdecl __signbit (double x) {
unsigned short stw;
#ifdef _M_IX86
__asm__ ( "fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
#endif
return stw & 0x0200;
}
__CRT_INLINE int __cdecl __signbitf (float x) {
unsigned short stw;
#ifdef _M_IX86
__asm__ ("fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
#endif
return stw & 0x0200;
}
__CRT_INLINE int __cdecl __signbitl (long double x) {
unsigned short stw;
#ifdef _M_IX86
__asm__ ("fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
#endif
return stw & 0x0200;
}
#define signbit(x) (sizeof (x) == sizeof (float) ? __signbitf (x) \
: sizeof (x) == sizeof (double) ? __signbit (x) \
: __signbitl (x))
/* 7.12.4 Trigonometric functions: Double in C89 */
extern float __cdecl sinf (float);
extern long double __cdecl sinl (long double);
extern float __cdecl cosf (float);
extern long double __cdecl cosl (long double);
extern float __cdecl tanf (float);
extern long double __cdecl tanl (long double);
extern float __cdecl asinf (float);
extern long double __cdecl asinl (long double);
extern float __cdecl acosf (float);
extern long double __cdecl acosl (long double);
extern float __cdecl atanf (float);
extern long double __cdecl atanl (long double);
extern float __cdecl atan2f (float, float);
extern long double __cdecl atan2l (long double, long double);
/* 7.12.5 Hyperbolic functions: Double in C89 */
__CRT_INLINE float __cdecl sinhf (float x)
{return (float) sinh (x);}
extern long double __cdecl sinhl (long double);
__CRT_INLINE float __cdecl coshf (float x)
{return (float) cosh (x);}
extern long double __cdecl coshl (long double);
__CRT_INLINE float __cdecl tanhf (float x)
{return (float) tanh (x);}
extern long double __cdecl tanhl (long double);
/* Inverse hyperbolic trig functions */
/* 7.12.5.1 */
extern double __cdecl acosh (double);
extern float __cdecl acoshf (float);
extern long double __cdecl acoshl (long double);
/* 7.12.5.2 */
extern double __cdecl asinh (double);
extern float __cdecl asinhf (float);
extern long double __cdecl asinhl (long double);
/* 7.12.5.3 */
extern double __cdecl atanh (double);
extern float __cdecl atanf (float);
extern long double __cdecl atanhl (long double);
/* Exponentials and logarithms */
/* 7.12.6.1 Double in C89 */
__CRT_INLINE float __cdecl expf (float x)
{return (float) exp (x);}
extern long double __cdecl expl (long double);
/* 7.12.6.2 */
extern double __cdecl exp2(double);
extern float __cdecl exp2f(float);
extern long double __cdecl exp2l(long double);
/* 7.12.6.3 The expm1 functions: TODO */
/* 7.12.6.4 Double in C89 */
__CRT_INLINE float __cdecl frexpf (float x, int* expn)
{return (float) frexp (x, expn);}
extern long double __cdecl frexpl (long double, int*);
/* 7.12.6.5 */
#define FP_ILOGB0 ((int)0x80000000)
#define FP_ILOGBNAN ((int)0x80000000)
extern int __cdecl ilogb (double);
extern int __cdecl ilogbf (float);
extern int __cdecl ilogbl (long double);
/* 7.12.6.6 Double in C89 */
__CRT_INLINE float __cdecl ldexpf (float x, int expn)
{return (float) ldexp (x, expn);}
extern long double __cdecl ldexpl (long double, int);
/* 7.12.6.7 Double in C89 */
extern float __cdecl logf (float);
extern long double __cdecl logl (long double);
/* 7.12.6.8 Double in C89 */
extern float __cdecl log10f (float);
extern long double __cdecl log10l (long double);
/* 7.12.6.9 */
extern double __cdecl log1p(double);
extern float __cdecl log1pf(float);
extern long double __cdecl log1pl(long double);
/* 7.12.6.10 */
extern double __cdecl log2 (double);
extern float __cdecl log2f (float);
extern long double __cdecl log2l (long double);
/* 7.12.6.11 */
extern double __cdecl logb (double);
extern float __cdecl logbf (float);
extern long double __cdecl logbl (long double);
__CRT_INLINE double __cdecl logb (double x)
{
double res;
__asm__ ("fxtract\n\t"
"fstp %%st" : "=t" (res) : "0" (x));
return res;
}
__CRT_INLINE float __cdecl logbf (float x)
{
float res;
__asm__ ("fxtract\n\t"
"fstp %%st" : "=t" (res) : "0" (x));
return res;
}
__CRT_INLINE long double __cdecl logbl (long double x)
{
long double res;
#ifdef _M_IX86
__asm__ ("fxtract\n\t"
"fstp %%st" : "=t" (res) : "0" (x));
#endif
return res;
}
/* 7.12.6.12 Double in C89 */
extern float __cdecl modff (float, float*);
extern long double __cdecl modfl (long double, long double*);
/* 7.12.6.13 */
extern double __cdecl scalbn (double, int);
extern float __cdecl scalbnf (float, int);
extern long double __cdecl scalbnl (long double, int);
extern double __cdecl scalbln (double, long);
extern float __cdecl scalblnf (float, long);
extern long double __cdecl scalblnl (long double, long);
/* 7.12.7.1 */
/* Implementations adapted from Cephes versions */
extern double __cdecl cbrt (double);
extern float __cdecl cbrtf (float);
extern long double __cdecl cbrtl (long double);
/* 7.12.7.2 The fabs functions: Double in C89 */
extern float __cdecl fabsf (float x);
extern long double __cdecl fabsl (long double x);
/* 7.12.7.3 */
extern double __cdecl hypot (double, double); /* in libmoldname.a */
__CRT_INLINE float __cdecl hypotf (float x, float y)
{ return (float) hypot (x, y);}
extern long double __cdecl hypotl (long double, long double);
/* 7.12.7.4 The pow functions. Double in C89 */
__CRT_INLINE float __cdecl powf (float x, float y)
{return (float) pow (x, y);}
extern long double __cdecl powl (long double, long double);
/* 7.12.7.5 The sqrt functions. Double in C89. */
extern float __cdecl sqrtf (float);
extern long double __cdecl sqrtl (long double);
/* 7.12.8.1 The erf functions */
extern double __cdecl erf (double);
extern float __cdecl erff (float);
/* TODO
extern long double __cdecl erfl (long double);
*/
/* 7.12.8.2 The erfc functions */
extern double __cdecl erfc (double);
extern float __cdecl erfcf (float);
/* TODO
extern long double __cdecl erfcl (long double);
*/
/* 7.12.8.3 The lgamma functions */
extern double __cdecl lgamma (double);
extern float __cdecl lgammaf (float);
extern long double __cdecl lgammal (long double);
/* 7.12.8.4 The tgamma functions */
extern double __cdecl tgamma (double);
extern float __cdecl tgammaf (float);
extern long double __cdecl tgammal (long double);
/* 7.12.9.1 Double in C89 */
extern float __cdecl ceilf (float);
extern long double __cdecl ceill (long double);
/* 7.12.9.2 Double in C89 */
extern float __cdecl floorf (float);
extern long double __cdecl floorl (long double);
/* 7.12.9.3 */
extern double __cdecl nearbyint ( double);
extern float __cdecl nearbyintf (float);
extern long double __cdecl nearbyintl (long double);
/* 7.12.9.4 */
/* round, using fpu control word settings */
__CRT_INLINE double __cdecl rint (double x)
{
double retval;
__asm__ ("frndint;": "=t" (retval) : "0" (x));
return retval;
}
__CRT_INLINE float __cdecl rintf (float x)
{
float retval;
__asm__ ("frndint;" : "=t" (retval) : "0" (x) );
return retval;
}
__CRT_INLINE long double __cdecl rintl (long double x)
{
long double retval;
__asm__ ("frndint;" : "=t" (retval) : "0" (x) );
return retval;
}
/* 7.12.9.5 */
__CRT_INLINE long __cdecl lrint (double x)
{
long retval;
__asm__ __volatile__ \
("fistpl %0" : "=m" (retval) : "t" (x) : "st"); \
return retval;
}
__CRT_INLINE long __cdecl lrintf (float x)
{
long retval;
__asm__ __volatile__ \
("fistpl %0" : "=m" (retval) : "t" (x) : "st"); \
return retval;
}
__CRT_INLINE long __cdecl lrintl (long double x)
{
long retval;
__asm__ __volatile__ \
("fistpl %0" : "=m" (retval) : "t" (x) : "st"); \
return retval;
}
__CRT_INLINE long long __cdecl llrint (double x)
{
long long retval;
__asm__ __volatile__ \
("fistpll %0" : "=m" (retval) : "t" (x) : "st"); \
return retval;
}
__CRT_INLINE long long __cdecl llrintf (float x)
{
long long retval;
__asm__ __volatile__ \
("fistpll %0" : "=m" (retval) : "t" (x) : "st"); \
return retval;
}
__CRT_INLINE long long __cdecl llrintl (long double x)
{
long long retval;
__asm__ __volatile__ \
("fistpll %0" : "=m" (retval) : "t" (x) : "st"); \
return retval;
}
/* 7.12.9.6 */
/* round away from zero, regardless of fpu control word settings */
extern double __cdecl round (double);
extern float __cdecl roundf (float);
extern long double __cdecl roundl (long double);
/* 7.12.9.7 */
extern long __cdecl lround (double);
extern long __cdecl lroundf (float);
extern long __cdecl lroundl (long double);
extern long long __cdecl llround (double);
extern long long __cdecl llroundf (float);
extern long long __cdecl llroundl (long double);
/* 7.12.9.8 */
/* round towards zero, regardless of fpu control word settings */
extern double __cdecl trunc (double);
extern float __cdecl truncf (float);
extern long double __cdecl truncl (long double);
/* 7.12.10.1 Double in C89 */
extern float __cdecl fmodf (float, float);
extern long double __cdecl fmodl (long double, long double);
/* 7.12.10.2 */
extern double __cdecl remainder (double, double);
extern float __cdecl remainderf (float, float);
extern long double __cdecl remainderl (long double, long double);
/* 7.12.10.3 */
extern double __cdecl remquo(double, double, int *);
extern float __cdecl remquof(float, float, int *);
extern long double __cdecl remquol(long double, long double, int *);
/* 7.12.11.1 */
extern double __cdecl copysign (double, double); /* in libmoldname.a */
extern float __cdecl copysignf (float, float);
extern long double __cdecl copysignl (long double, long double);
/* 7.12.11.2 Return a NaN */
extern double __cdecl nan(const char *tagp);
extern float __cdecl nanf(const char *tagp);
extern long double __cdecl nanl(const char *tagp);
#ifndef __STRICT_ANSI__
#define _nan() nan("")
#define _nanf() nanf("")
#define _nanl() nanl("")
#endif
/* 7.12.11.3 */
extern double __cdecl nextafter (double, double); /* in libmoldname.a */
extern float __cdecl nextafterf (float, float);
/* TODO: Not yet implemented */
/* extern long double __cdecl nextafterl (long double, long double); */
/* 7.12.11.4 The nexttoward functions: TODO */
/* 7.12.12.1 */
/* x > y ? (x - y) : 0.0 */
extern double __cdecl fdim (double x, double y);
extern float __cdecl fdimf (float x, float y);
extern long double __cdecl fdiml (long double x, long double y);
/* fmax and fmin.
NaN arguments are treated as missing data: if one argument is a NaN
and the other numeric, then these functions choose the numeric
value. */
/* 7.12.12.2 */
extern double __cdecl fmax (double, double);
extern float __cdecl fmaxf (float, float);
extern long double __cdecl fmaxl (long double, long double);
/* 7.12.12.3 */
extern double __cdecl fmin (double, double);
extern float __cdecl fminf (float, float);
extern long double __cdecl fminl (long double, long double);
/* 7.12.13.1 */
/* return x * y + z as a ternary op */
extern double __cdecl fma (double, double, double);
extern float __cdecl fmaf (float, float, float);
extern long double __cdecl fmal (long double, long double, long double);
/* 7.12.14 */
/*
* With these functions, comparisons involving quiet NaNs set the FP
* condition code to "unordered". The IEEE floating-point spec
* dictates that the result of floating-point comparisons should be
* false whenever a NaN is involved, with the exception of the != op,
* which always returns true: yes, (NaN != NaN) is true).
*/
#if __GNUC__ >= 3
#define isgreater(x, y) __builtin_isgreater(x, y)
#define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
#define isless(x, y) __builtin_isless(x, y)
#define islessequal(x, y) __builtin_islessequal(x, y)
#define islessgreater(x, y) __builtin_islessgreater(x, y)
#define isunordered(x, y) __builtin_isunordered(x, y)
#else
/* helper */
__CRT_INLINE int __cdecl
__fp_unordered_compare (long double x, long double y){
unsigned short retval;
__asm__ ("fucom %%st(1);"
"fnstsw;": "=a" (retval) : "t" (x), "u" (y));
return retval;
}
#define isgreater(x, y) ((__fp_unordered_compare(x, y) \
& 0x4500) == 0)
#define isless(x, y) ((__fp_unordered_compare (y, x) \
& 0x4500) == 0)
#define isgreaterequal(x, y) ((__fp_unordered_compare (x, y) \
& FP_INFINITE) == 0)
#define islessequal(x, y) ((__fp_unordered_compare(y, x) \
& FP_INFINITE) == 0)
#define islessgreater(x, y) ((__fp_unordered_compare(x, y) \
& FP_SUBNORMAL) == 0)
#define isunordered(x, y) ((__fp_unordered_compare(x, y) \
& 0x4500) == 0x4500)
#endif
#endif /* __STDC_VERSION__ >= 199901L */
#endif /* __NO_ISOCEXT */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _MATH_H_ */

View File

@ -0,0 +1,97 @@
/*
* mbctype.h
*
* Functions for testing multibyte character types and converting characters.
*
* 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
* DISCLAIMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#ifndef _MBCTYPE_H_
#define _MBCTYPE_H_
/* All the headers include this file. */
#include <_mingw.h>
/* return values for _mbsbtype and _mbbtype in mbstring.h */
#define _MBC_SINGLE 0
#define _MBC_LEAD 1
#define _MBC_TRAIL 2
#define _MBC_ILLEGAL (-1)
/* args for setmbcp (in lieu of actual codepage) */
#define _MB_CP_SBCS 0
#define _MB_CP_OEM (-2)
#define _MB_CP_ANSI (-3)
#define _MB_CP_LOCALE (-4)
/* TODO: bit masks */
/*
#define _MS
#define _MP
#define _M1
#define _M2
#define _SBUP
#define _SBLOW
*/
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __STRICT_ANSI__
_CRTIMP int __cdecl _setmbcp (int);
_CRTIMP int __cdecl _getmbcp (void);
/* byte classification */
/* NB: Corresponding _ismbc* functions are in mbstring.h */
_CRTIMP int __cdecl _ismbbalpha (unsigned int);
_CRTIMP int __cdecl _ismbbalnum (unsigned int);
_CRTIMP int __cdecl _ismbbgraph (unsigned int);
_CRTIMP int __cdecl _ismbbprint (unsigned int);
_CRTIMP int __cdecl _ismbbpunct (unsigned int);
_CRTIMP int __cdecl _ismbbkana (unsigned int);
_CRTIMP int __cdecl _ismbbkalnum (unsigned int);
_CRTIMP int __cdecl _ismbbkprint (unsigned int);
_CRTIMP int __cdecl _ismbbkpunct (unsigned int);
/* these are also in mbstring.h */
_CRTIMP int __cdecl _ismbblead (unsigned int);
_CRTIMP int __cdecl _ismbbtrail (unsigned int);
_CRTIMP int __cdecl _ismbslead (const unsigned char*, const unsigned char*);
_CRTIMP int __cdecl _ismbstrail (const unsigned char*, const unsigned char*);
#ifdef __DECLSPEC_SUPPORTED
__MINGW_IMPORT unsigned char _mbctype[];
__MINGW_IMPORT unsigned char _mbcasemap[];
#endif
/* TODO : _MBCS_ mappings go in tchar.h */
#endif /* Not strict ANSI */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _MCTYPE_H_ */

View File

@ -0,0 +1,132 @@
/*
* mbstring.h
*
* Protototypes for string functions supporting multibyte characters.
*
* 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
* DISCLAIMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#ifndef _MBSTRING_H_
#define _MBSTRING_H_
/* All the headers include this file. */
#include <_mingw.h>
#ifndef RC_INVOKED
#define __need_size_t
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __STRICT_ANSI__
/* character classification */
_CRTIMP int __cdecl _ismbcalnum (unsigned int);
_CRTIMP int __cdecl _ismbcalpha (unsigned int);
_CRTIMP int __cdecl _ismbcdigit (unsigned int);
_CRTIMP int __cdecl _ismbcgraph (unsigned int);
_CRTIMP int __cdecl _ismbcprint (unsigned int);
_CRTIMP int __cdecl _ismbcpunct (unsigned int);
_CRTIMP int __cdecl _ismbcspace (unsigned int);
_CRTIMP int __cdecl _ismbclower (unsigned int);
_CRTIMP int __cdecl _ismbcupper (unsigned int);
_CRTIMP int __cdecl _ismbclegal (unsigned int);
_CRTIMP int __cdecl _ismbcsymbol (unsigned int);
/* also in mbctype.h */
_CRTIMP int __cdecl _ismbblead (unsigned int );
_CRTIMP int __cdecl _ismbbtrail (unsigned int );
_CRTIMP int __cdecl _ismbslead ( const unsigned char*, const unsigned char*);
_CRTIMP int __cdecl _ismbstrail ( const unsigned char*, const unsigned char*);
_CRTIMP unsigned int __cdecl _mbctolower (unsigned int);
_CRTIMP unsigned int __cdecl _mbctoupper (unsigned int);
_CRTIMP void __cdecl _mbccpy (unsigned char*, const unsigned char*);
_CRTIMP size_t __cdecl _mbclen (const unsigned char*);
_CRTIMP unsigned int __cdecl _mbbtombc (unsigned int);
_CRTIMP unsigned int __cdecl _mbctombb (unsigned int);
/* Return value constants for these are defined in mbctype.h. */
_CRTIMP int __cdecl _mbbtype (unsigned char, int);
_CRTIMP int __cdecl _mbsbtype (const unsigned char*, size_t);
_CRTIMP unsigned char* __cdecl _mbscpy (unsigned char*, const unsigned char*);
_CRTIMP unsigned char* __cdecl _mbsncpy (unsigned char*, const unsigned char*, size_t);
_CRTIMP unsigned char* __cdecl _mbsnbcpy (unsigned char*, const unsigned char*, size_t);
_CRTIMP unsigned char* __cdecl _mbsset (unsigned char*, unsigned int);
_CRTIMP unsigned char* __cdecl _mbsnset (unsigned char*, unsigned int, size_t);
_CRTIMP unsigned char* __cdecl _mbsnbset (unsigned char*, unsigned int, size_t);
_CRTIMP unsigned char* __cdecl _mbsdup (const unsigned char*);
_CRTIMP unsigned char* __cdecl _mbsrev (unsigned char*);
_CRTIMP unsigned char* __cdecl _mbscat (unsigned char*, const unsigned char*);
_CRTIMP unsigned char* __cdecl _mbsncat (unsigned char*, const unsigned char*, size_t);
_CRTIMP unsigned char* __cdecl _mbsnbcat (unsigned char*, const unsigned char*, size_t);
_CRTIMP size_t __cdecl _mbslen (const unsigned char*);
_CRTIMP size_t __cdecl _mbsnbcnt (const unsigned char*, size_t);
_CRTIMP size_t __cdecl _mbsnccnt (const unsigned char*, size_t);
_CRTIMP unsigned char* __cdecl _mbschr (const unsigned char*, unsigned int);
_CRTIMP unsigned char* __cdecl _mbsrchr (const unsigned char*, unsigned int);
_CRTIMP size_t __cdecl _mbsspn (const unsigned char*, const unsigned char*);
_CRTIMP size_t __cdecl _mbscspn (const unsigned char*, const unsigned char*);
_CRTIMP unsigned char* __cdecl _mbsspnp (const unsigned char*, const unsigned char*);
_CRTIMP unsigned char* __cdecl _mbspbrk (const unsigned char*, const unsigned char*);
_CRTIMP int __cdecl _mbscmp (const unsigned char*, const unsigned char*);
_CRTIMP int __cdecl _mbsicmp (const unsigned char*, const unsigned char*);
_CRTIMP int __cdecl _mbsncmp (const unsigned char*, const unsigned char*, size_t);
_CRTIMP int __cdecl _mbsnicmp (const unsigned char*, const unsigned char*, size_t);
_CRTIMP int __cdecl _mbsnbcmp (const unsigned char*, const unsigned char*, size_t);
_CRTIMP int __cdecl _mbsnbicmp (const unsigned char*, const unsigned char*, size_t);
_CRTIMP int __cdecl _mbscoll (const unsigned char*, const unsigned char*);
_CRTIMP int __cdecl _mbsicoll (const unsigned char*, const unsigned char*);
_CRTIMP int __cdecl _mbsncoll (const unsigned char*, const unsigned char*, size_t);
_CRTIMP int __cdecl _mbsnicoll (const unsigned char*, const unsigned char*, size_t);
_CRTIMP int __cdecl _mbsnbcoll (const unsigned char*, const unsigned char*, size_t);
_CRTIMP int __cdecl _mbsnbicoll (const unsigned char*, const unsigned char*, size_t);
_CRTIMP unsigned char* __cdecl _mbsinc (const unsigned char*);
_CRTIMP unsigned char* __cdecl _mbsninc (const unsigned char*, size_t);
_CRTIMP unsigned char* __cdecl _mbsdec (const unsigned char*, const unsigned char*);
_CRTIMP unsigned int __cdecl _mbsnextc (const unsigned char*);
_CRTIMP unsigned char* __cdecl _mbslwr (unsigned char*);
_CRTIMP unsigned char* __cdecl _mbsupr (unsigned char*);
_CRTIMP unsigned char* __cdecl _mbstok (unsigned char*, const unsigned char*);
/* Kanji */
_CRTIMP int __cdecl _ismbchira (unsigned int);
_CRTIMP int __cdecl _ismbckata (unsigned int);
_CRTIMP int __cdecl _ismbcl0 (unsigned int);
_CRTIMP int __cdecl _ismbcl1 (unsigned int);
_CRTIMP int __cdecl _ismbcl2 (unsigned int);
_CRTIMP unsigned int __cdecl _mbcjistojms (unsigned int);
_CRTIMP unsigned int __cdecl _mbcjmstojis (unsigned int);
_CRTIMP unsigned int __cdecl _mbctohira (unsigned int);
_CRTIMP unsigned int __cdecl _mbctokata (unsigned int);
#endif /* Not strict ANSI */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _MBSTRING_H_ */

View File

@ -0,0 +1,6 @@
/*
* This file is part of the Mingw32 package.
*
* mem.h maps to string.h
*/
#include <string.h>

View File

@ -0,0 +1,7 @@
/*
* This file is part of the Mingw32 package.
*
* memory.h maps to the standard string.h header.
*/
#include <string.h>

View File

@ -0,0 +1,138 @@
/*
* process.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Function calls for spawning child processes.
*
*/
#ifndef _PROCESS_H_
#define _PROCESS_H_
/* All the headers include this file. */
#include <_mingw.h>
/* Includes a definition of _pid_t and pid_t */
#include <sys/types.h>
/*
* Constants for cwait actions.
* Obsolete for Win32.
*/
#define _WAIT_CHILD 0
#define _WAIT_GRANDCHILD 1
#ifndef _NO_OLDNAMES
#define WAIT_CHILD _WAIT_CHILD
#define WAIT_GRANDCHILD _WAIT_GRANDCHILD
#endif /* Not _NO_OLDNAMES */
/*
* 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
#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 */
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
_CRTIMP void __cdecl _cexit(void);
_CRTIMP void __cdecl _c_exit(void);
_CRTIMP int __cdecl _cwait (int*, _pid_t, int);
_CRTIMP _pid_t __cdecl _getpid(void);
_CRTIMP int __cdecl _execl (const char*, const char*, ...);
_CRTIMP int __cdecl _execle (const char*, const char*, ...);
_CRTIMP int __cdecl _execlp (const char*, const char*, ...);
_CRTIMP int __cdecl _execlpe (const char*, const char*, ...);
_CRTIMP int __cdecl _execv (const char*, const char* const*);
_CRTIMP int __cdecl _execve (const char*, const char* const*, const char* const*);
_CRTIMP int __cdecl _execvp (const char*, const char* const*);
_CRTIMP int __cdecl _execvpe (const char*, const char* const*, const char* const*);
_CRTIMP int __cdecl _spawnl (int, const char*, const char*, ...);
_CRTIMP int __cdecl _spawnle (int, const char*, const char*, ...);
_CRTIMP int __cdecl _spawnlp (int, const char*, const char*, ...);
_CRTIMP int __cdecl _spawnlpe (int, const char*, const char*, ...);
_CRTIMP int __cdecl _spawnv (int, const char*, const char* const*);
_CRTIMP int __cdecl _spawnve (int, const char*, const char* const*, const char* const*);
_CRTIMP int __cdecl _spawnvp (int, const char*, const char* const*);
_CRTIMP int __cdecl _spawnvpe (int, const char*, const char* const*, const char* const*);
/*
* 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.
*/
_CRTIMP unsigned long __cdecl
_beginthread (void (*)(void *), unsigned, void*);
_CRTIMP void __cdecl _endthread (void);
#ifdef __MSVCRT__
_CRTIMP unsigned long __cdecl
_beginthreadex (void *, unsigned, unsigned (__stdcall *) (void *),
void*, unsigned, unsigned*);
_CRTIMP void __cdecl _endthreadex (unsigned);
#endif
#ifndef _NO_OLDNAMES
/*
* Functions without the leading underscore, for portability. These functions
* live in liboldnames.a.
*/
_CRTIMP int __cdecl cwait (int*, pid_t, int);
_CRTIMP pid_t __cdecl getpid (void);
_CRTIMP int __cdecl execl (const char*, const char*, ...);
_CRTIMP int __cdecl execle (const char*, const char*, ...);
_CRTIMP int __cdecl execlp (const char*, const char*, ...);
_CRTIMP int __cdecl execlpe (const char*, const char*, ...);
_CRTIMP int __cdecl execv (const char*, const char* const*);
_CRTIMP int __cdecl execve (const char*, const char* const*, const char* const*);
_CRTIMP int __cdecl execvp (const char*, const char* const*);
_CRTIMP int __cdecl execvpe (const char*, const char* const*, const char* const*);
_CRTIMP int __cdecl spawnl (int, const char*, const char*, ...);
_CRTIMP int __cdecl spawnle (int, const char*, const char*, ...);
_CRTIMP int __cdecl spawnlp (int, const char*, const char*, ...);
_CRTIMP int __cdecl spawnlpe (int, const char*, const char*, ...);
_CRTIMP int __cdecl spawnv (int, const char*, const char* const*);
_CRTIMP int __cdecl spawnve (int, const char*, const char* const*, const char* const*);
_CRTIMP int __cdecl spawnvp (int, const char*, const char* const*);
_CRTIMP int __cdecl spawnvpe (int, const char*, const char* const*, const char* const*);
#endif /* Not _NO_OLDNAMES */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* _PROCESS_H_ not defined */

View File

@ -0,0 +1,64 @@
/*
* search.h
*
* Functions for searching and sorting.
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Danny Smith <dannysmith@users.sourceforge.net>
*
* 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
* DISCLAIMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#ifndef _SEARCH_H_
#define _SEARCH_H_
/* All the headers include this file. */
#include <_mingw.h>
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _SIZE_T_DEFINED
typedef unsigned int size_t;
#define _SIZE_T_DEFINED
#endif
/* bsearch and qsort are also declared in stdlib.h */
_CRTIMP void* __cdecl bsearch (const void*, const void*, size_t, size_t,
int (*)(const void*, const void*));
_CRTIMP void __cdecl qsort (void*, size_t, size_t,
int (*)(const void*, const void*));
_CRTIMP void* __cdecl _lfind (const void*, const void*, unsigned int*,
unsigned int, int (*)(const void*, const void*));
_CRTIMP void* __cdecl _lsearch (const void*, void*, unsigned int*, unsigned int,
int (*)(const void*, const void*));
#ifndef _NO_OLDNAMES
_CRTIMP void* __cdecl lfind (const void*, const void*, unsigned int*,
unsigned int, int (*)(const void*, const void*));
_CRTIMP void* __cdecl lsearch (const void*, void*, unsigned int*, unsigned int,
int (*)(const void*, const void*));
#endif
#ifdef __cplusplus
}
#endif
#endif /* RC_INVOKED */
#endif /* _SEARCH_H_ */

View File

@ -0,0 +1,56 @@
/*
* setjmp.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Declarations supporting setjmp and longjump, a method for avoiding
* the normal function call return sequence. (Bleah!)
*
*/
#ifndef _SETJMP_H_
#define _SETJMP_H_
/* All the headers include this file. */
#include <_mingw.h>
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
/*
* The buffer used by setjmp to store the information used by longjmp
* to perform it's evil goto-like work. The size of this buffer was
* determined through experimentation; it's contents are a mystery.
* NOTE: This was determined on an i386 (actually a Pentium). The
* contents could be different on an Alpha or something else.
*/
#define _JBLEN 16
#define _JBTYPE int
typedef _JBTYPE jmp_buf[_JBLEN];
/*
* The function provided by CRTDLL which appears to do the actual work
* of setjmp.
*/
_CRTIMP int __cdecl _setjmp (jmp_buf);
#define setjmp(x) _setjmp(x)
/*
* Return to the last setjmp call and act as if setjmp had returned
* nVal (which had better be non-zero!).
*/
_CRTIMP void __cdecl longjmp (jmp_buf, int) __MINGW_ATTRIB_NORETURN;
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _SETJMP_H_ */

View File

@ -0,0 +1,33 @@
/*
* share.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Constants for file sharing functions.
*
*/
#ifndef _SHARE_H_
#define _SHARE_H_
/* All the headers include this file. */
#include <_mingw.h>
#define _SH_COMPAT 0x00 /* Compatibility */
#define _SH_DENYRW 0x10 /* Deny read/write */
#define _SH_DENYWR 0x20 /* Deny write */
#define _SH_DENYRD 0x30 /* Deny read */
#define _SH_DENYNO 0x40 /* Deny nothing */
#ifndef _NO_OLDNAMES
/* Non ANSI names */
#define SH_DENYRW _SH_DENYRW
#define SH_DENYWR _SH_DENYWR
#define SH_DENYRD _SH_DENYRD
#define SH_DENYNO _SH_DENYNO
#endif /* Not _NO_OLDNAMES */
#endif /* Not _SHARE_H_ */

View File

@ -0,0 +1,98 @@
/*
* signal.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* A way to set handlers for exceptional conditions (also known as signals).
*
*/
#ifndef _SIGNAL_H_
#define _SIGNAL_H_
/* All the headers include this file. */
#include <_mingw.h>
/*
* The actual signal values. Using other values with signal
* produces a SIG_ERR return value.
*
* NOTE: SIGINT is produced when the user presses Ctrl-C.
* SIGILL has not been tested.
* SIGFPE doesn't seem to work?
* SIGSEGV does not catch writing to a NULL pointer (that shuts down
* your app; can you say "segmentation violation core dump"?).
* SIGTERM comes from what kind of termination request exactly?
* SIGBREAK is indeed produced by pressing Ctrl-Break.
* SIGABRT is produced by calling abort.
* TODO: The above results may be related to not installing an appropriate
* structured exception handling frame. Results may be better if I ever
* manage to get the SEH stuff down.
*/
#define SIGINT 2 /* Interactive attention */
#define SIGILL 4 /* Illegal instruction */
#define SIGFPE 8 /* Floating point error */
#define SIGSEGV 11 /* Segmentation violation */
#define SIGTERM 15 /* Termination request */
#define SIGBREAK 21 /* Control-break */
#define SIGABRT 22 /* Abnormal termination (abort) */
#define NSIG 23 /* maximum signal number + 1 */
#ifndef RC_INVOKED
#ifndef _SIG_ATOMIC_T_DEFINED
typedef int sig_atomic_t;
#define _SIG_ATOMIC_T_DEFINED
#endif
/*
* The prototypes (below) are the easy part. The hard part is figuring
* out what signals are available and what numbers they are assigned
* along with appropriate values of SIG_DFL and SIG_IGN.
*/
/*
* A pointer to a signal handler function. A signal handler takes a
* single int, which is the signal it handles.
*/
typedef void (*__p_sig_fn_t)(int);
/*
* These are special values of signal handler pointers which are
* used to send a signal to the default handler (SIG_DFL), ignore
* the signal (SIG_IGN), indicate an error return (SIG_ERR),
* get an error (SIG_SGE), or acknowledge (SIG_ACK).
*/
#define SIG_DFL ((__p_sig_fn_t) 0)
#define SIG_IGN ((__p_sig_fn_t) 1)
#define SIG_ERR ((__p_sig_fn_t) -1)
#define SIG_SGE ((__p_sig_fn_t) 3)
#define SIG_ACK ((__p_sig_fn_t) 4)
#ifdef __cplusplus
extern "C" {
#endif
/*
* Call signal to set the signal handler for signal sig to the
* function pointed to by handler. Returns a pointer to the
* previous handler, or SIG_ERR if an error occurs. Initially
* unhandled signals defined above will return SIG_DFL.
*/
_CRTIMP __p_sig_fn_t __cdecl signal(int, __p_sig_fn_t);
/*
* Raise the signal indicated by sig. Returns non-zero on success.
*/
_CRTIMP int __cdecl raise (int);
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _SIGNAL_H_ */

View File

@ -0,0 +1,7 @@
/*
* This is just an RC_INVOKED guard for the real stdarg.h
* fixincluded in gcc system dir. One day we will delete this file.
*/
#ifndef RC_INVOKED
#include_next<stdarg.h>
#endif

View File

@ -0,0 +1,7 @@
/*
* This is just an RC_INVOKED guard for the real stddef.h
* fixincluded in gcc system dir. One day we will delete this file.
*/
#ifndef RC_INVOKED
#include_next<stddef.h>
#endif

View File

@ -0,0 +1,184 @@
/* ISO C9x 7.18 Integer types <stdint.h>
* Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794)
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* Contributor: Danny Smith <danny_r_smith_2001@yahoo.co.nz>
*
* 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
* DISCLAIMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* Date: 2000-12-02
*/
#ifndef _STDINT_H
#define _STDINT_H
#define __need_wint_t
#define __need_wchar_t
#include <stddef.h>
/* 7.18.1.1 Exact-width integer types */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned uint32_t;
typedef long long int64_t;
typedef unsigned long long uint64_t;
/* 7.18.1.2 Minimum-width integer types */
typedef signed char int_least8_t;
typedef unsigned char uint_least8_t;
typedef short int_least16_t;
typedef unsigned short uint_least16_t;
typedef int int_least32_t;
typedef unsigned uint_least32_t;
typedef long long int_least64_t;
typedef unsigned long long uint_least64_t;
/* 7.18.1.3 Fastest minimum-width integer types
* Not actually guaranteed to be fastest for all purposes
* Here we use the exact-width types for 8 and 16-bit ints.
*/
typedef char int_fast8_t;
typedef unsigned char uint_fast8_t;
typedef short int_fast16_t;
typedef unsigned short uint_fast16_t;
typedef int int_fast32_t;
typedef unsigned int uint_fast32_t;
typedef long long int_fast64_t;
typedef unsigned long long uint_fast64_t;
/* 7.18.1.4 Integer types capable of holding object pointers */
typedef int intptr_t;
typedef unsigned uintptr_t;
/* 7.18.1.5 Greatest-width integer types */
typedef long long intmax_t;
typedef unsigned long long uintmax_t;
/* 7.18.2 Limits of specified-width integer types */
#if !defined ( __cplusplus) || defined (__STDC_LIMIT_MACROS)
/* 7.18.2.1 Limits of exact-width integer types */
#define INT8_MIN (-128)
#define INT16_MIN (-32768)
#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 0xff /* 255U */
#define UINT16_MAX 0xffff /* 65535U */
#define UINT32_MAX 0xffffffff /* 4294967295U */
#define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */
/* 7.18.2.2 Limits of minimum-width integer types */
#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST64_MIN INT64_MIN
#define INT_LEAST8_MAX INT8_MAX
#define INT_LEAST16_MAX INT16_MAX
#define INT_LEAST32_MAX INT32_MAX
#define INT_LEAST64_MAX INT64_MAX
#define UINT_LEAST8_MAX UINT8_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#define UINT_LEAST64_MAX UINT64_MAX
/* 7.18.2.3 Limits of fastest minimum-width integer types */
#define INT_FAST8_MIN INT8_MIN
#define INT_FAST16_MIN INT16_MIN
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST64_MIN INT64_MIN
#define INT_FAST8_MAX INT8_MAX
#define INT_FAST16_MAX INT16_MAX
#define INT_FAST32_MAX INT32_MAX
#define INT_FAST64_MAX INT64_MAX
#define UINT_FAST8_MAX UINT8_MAX
#define UINT_FAST16_MAX UINT16_MAX
#define UINT_FAST32_MAX UINT32_MAX
#define UINT_FAST64_MAX UINT64_MAX
/* 7.18.2.4 Limits of integer types capable of holding
object pointers */
#define INTPTR_MIN INT32_MIN
#define INTPTR_MAX INT32_MAX
#define UINTPTR_MAX UINT32_MAX
/* 7.18.2.5 Limits of greatest-width integer types */
#define INTMAX_MIN INT64_MIN
#define INTMAX_MAX INT64_MAX
#define UINTMAX_MAX UINT64_MAX
/* 7.18.3 Limits of other integer types */
#define PTRDIFF_MIN INT32_MIN
#define PTRDIFF_MAX INT32_MAX
#define SIG_ATOMIC_MIN INT32_MIN
#define SIG_ATOMIC_MAX INT32_MAX
#define SIZE_MAX UINT32_MAX
#ifndef WCHAR_MIN /* also in wchar.h */
#define WCHAR_MIN 0
#define WCHAR_MAX ((wchar_t)-1) /* UINT16_MAX */
#endif
/*
* wint_t is unsigned short for compatibility with MS runtime
*/
#define WINT_MIN 0
#define WINT_MAX ((wint_t)-1) /* UINT16_MAX */
#endif /* !defined ( __cplusplus) || defined __STDC_LIMIT_MACROS */
/* 7.18.4 Macros for integer constants */
#if !defined ( __cplusplus) || defined (__STDC_CONSTANT_MACROS)
/* 7.18.4.1 Macros for minimum-width integer constants
Accoding to Douglas Gwyn <gwyn@arl.mil>:
"This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC
9899:1999 as initially published, the expansion was required
to be an integer constant of precisely matching type, which
is impossible to accomplish for the shorter types on most
platforms, because C99 provides no standard way to designate
an integer constant with width less than that of type int.
TC1 changed this to require just an integer constant
*expression* with *promoted* type."
*/
#define INT8_C(val) ((int8_t) + (val))
#define UINT8_C(val) ((uint8_t) + (val##U))
#define INT16_C(val) ((int16_t) + (val))
#define UINT16_C(val) ((uint16_t) + (val##U))
#define INT32_C(val) val##L
#define UINT32_C(val) val##UL
#define INT64_C(val) val##LL
#define UINT64_C(val) val##ULL
/* 7.18.4.2 Macros for greatest-width integer constants */
#define INTMAX_C(val) INT64_C(val)
#define UINTMAX_C(val) UINT64_C(val)
#endif /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */
#endif

View File

@ -0,0 +1,506 @@
/*
* stdio.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* 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 directory separator.
*
*/
#ifndef _STDIO_H_
#define _STDIO_H_
/* All the headers include this file. */
#include <_mingw.h>
#ifndef RC_INVOKED
#define __need_size_t
#define __need_NULL
#define __need_wchar_t
#define __need_wint_t
#include <stddef.h>
#define __need___va_list
#include <stdarg.h>
#endif /* Not RC_INVOKED */
/* Flags for the iobuf structure */
#define _IOREAD 1 /* currently reading */
#define _IOWRT 2 /* currently writing */
#define _IORW 0x0080 /* opened as "r+w" */
/*
* The three standard file pointers provided by the run time library.
* NOTE: These will go to the bit-bucket silently in GUI applications!
*/
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
/* 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.
* Also defined in io.h.
*/
#ifndef FILENAME_MAX
#define FILENAME_MAX (260)
#endif
/*
* 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)
/* After creating this many names, tmpnam and tmpfile return NULL */
#define TMP_MAX 32767
/*
* Tmpnam, tmpfile and, sometimes, _tempnam try to create
* temp files in the root directory of the current drive
* (not in pwd, as suggested by some older MS doc's).
* Redefining these macros does not effect the CRT functions.
*/
#define _P_tmpdir "\\"
#define _wP_tmpdir L"\\"
/*
* The maximum size of name (including NUL) that will be put in the user
* supplied buffer caName for tmpnam.
* Inferred from the size of the static buffer returned by tmpnam
* when passed a NULL argument. May actually be smaller.
*/
#define L_tmpnam (16)
#define _IOFBF 0x0000 /* full buffered */
#define _IOLBF 0x0040 /* line buffered */
#define _IONBF 0x0004 /* not buffered */
#define _IOMYBUF 0x0008 /* stdio malloc()'d buffer */
#define _IOEOF 0x0010 /* EOF reached on read */
#define _IOERR 0x0020 /* I/O error from system */
#define _IOSTRG 0x0040 /* Strange or no file descriptor */
#ifdef _POSIX_SOURCE
# define _IOAPPEND 0x0200
#endif
/*
* The buffer size as used by setbuf such that it is equivalent to
* (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ).
*/
#define BUFSIZ 512
/* 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
#ifndef RC_INVOKED
#ifndef __VALIST
#ifdef __GNUC__
#define __VALIST __gnuc_va_list
#else
#define __VALIST char*
#endif
#endif /* defined __VALIST */
/*
* The structure underlying the FILE type.
*
* Some believe that nobody in their right mind should make use of the
* internals of this structure. Provided by Pedro A. Aranda Gutiirrez
* <paag@tid.es>.
*/
#ifndef _FILE_DEFINED
#define _FILE_DEFINED
typedef struct _iobuf
{
char* _ptr;
int _cnt;
char* _base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char* _tmpfname;
} FILE;
#endif /* Not _FILE_DEFINED */
/*
* The standard file handles
*/
#ifndef __DECLSPEC_SUPPORTED
extern FILE (*_imp___iob)[1]; /* A pointer to an array of FILE */
#define _iob (*_imp___iob) /* An array of FILE */
#else /* __DECLSPEC_SUPPORTED */
__MINGW_IMPORT FILE _iob[1]; /* An array of FILE imported from DLL. */
#endif /* __DECLSPEC_SUPPORTED */
#define stdin (&_iob[STDIN_FILENO])
#define stdout (&_iob[STDOUT_FILENO])
#define stderr (&_iob[STDERR_FILENO])
#ifdef __cplusplus
extern "C" {
#endif
/*
* File Operations
*/
_CRTIMP FILE* __cdecl fopen (const char*, const char*);
_CRTIMP FILE* __cdecl freopen (const char*, const char*, FILE*);
_CRTIMP int __cdecl fflush (FILE*);
_CRTIMP int __cdecl fclose (FILE*);
/* MS puts remove & rename (but not wide versions) in io.h also */
_CRTIMP int __cdecl remove (const char*);
_CRTIMP int __cdecl rename (const char*, const char*);
_CRTIMP FILE* __cdecl tmpfile (void);
_CRTIMP char* __cdecl tmpnam (char*);
#ifndef __STRICT_ANSI__
_CRTIMP char* __cdecl _tempnam (const char*, const char*);
_CRTIMP int __cdecl _rmtmp(void);
#ifndef NO_OLDNAMES
_CRTIMP char* __cdecl tempnam (const char*, const char*);
_CRTIMP int __cdecl rmtmp(void);
#endif
#endif /* __STRICT_ANSI__ */
_CRTIMP int __cdecl setvbuf (FILE*, char*, int, size_t);
_CRTIMP void __cdecl setbuf (FILE*, char*);
/*
* Formatted Output
*/
_CRTIMP int __cdecl fprintf (FILE*, const char*, ...);
_CRTIMP int __cdecl printf (const char*, ...);
_CRTIMP int __cdecl sprintf (char*, const char*, ...);
_CRTIMP int __cdecl _snprintf (char*, size_t, const char*, ...);
_CRTIMP int __cdecl vfprintf (FILE*, const char*, __VALIST);
_CRTIMP int __cdecl vprintf (const char*, __VALIST);
_CRTIMP int __cdecl vsprintf (char*, const char*, __VALIST);
_CRTIMP int __cdecl _vsnprintf (char*, size_t, const char*, __VALIST);
#ifndef __NO_ISOCEXT /* externs in libmingwex.a */
int __cdecl snprintf(char* s, size_t n, const char* format, ...);
__CRT_INLINE int __cdecl
vsnprintf (char* s, size_t n, const char* format, __VALIST arg)
{ return _vsnprintf ( s, n, format, arg); }
int __cdecl vscanf (const char * __restrict__, __VALIST);
int __cdecl vfscanf (FILE * __restrict__, const char * __restrict__,
__VALIST);
int __cdecl vsscanf (const char * __restrict__,
const char * __restrict__, __VALIST);
#endif
/*
* Formatted Input
*/
_CRTIMP int __cdecl fscanf (FILE*, const char*, ...);
_CRTIMP int __cdecl scanf (const char*, ...);
_CRTIMP int __cdecl sscanf (const char*, const char*, ...);
/*
* Character Input and Output Functions
*/
_CRTIMP int __cdecl fgetc (FILE*);
_CRTIMP char* __cdecl fgets (char*, int, FILE*);
_CRTIMP int __cdecl fputc (int, FILE*);
_CRTIMP int __cdecl fputs (const char*, FILE*);
_CRTIMP char* __cdecl gets (char*);
_CRTIMP int __cdecl puts (const char*);
_CRTIMP int __cdecl ungetc (int, FILE*);
/* Traditionally, getc and putc are defined as macros. but the
standard doesn't say that they must be macros.
We use inline functions here to allow the fast versions
to be used in C++ with namespace qualification, eg., ::getc.
_filbuf and _flsbuf are not thread-safe. */
_CRTIMP int __cdecl _filbuf (FILE*);
_CRTIMP int __cdecl _flsbuf (int, FILE*);
#if !defined _MT
__CRT_INLINE int __cdecl getc (FILE* __F)
{
return (--__F->_cnt >= 0)
? (int) (unsigned char) *__F->_ptr++
: _filbuf (__F);
}
__CRT_INLINE int __cdecl putc (int __c, FILE* __F)
{
return (--__F->_cnt >= 0)
? (int) (unsigned char) (*__F->_ptr++ = (char)__c)
: _flsbuf (__c, __F);
}
__CRT_INLINE int __cdecl getchar (void)
{
return (--stdin->_cnt >= 0)
? (int) (unsigned char) *stdin->_ptr++
: _filbuf (stdin);
}
__CRT_INLINE int __cdecl putchar(int __c)
{
return (--stdout->_cnt >= 0)
? (int) (unsigned char) (*stdout->_ptr++ = (char)__c)
: _flsbuf (__c, stdout);}
#else /* Use library functions. */
_CRTIMP int __cdecl getc (FILE*);
_CRTIMP int __cdecl putc (int, FILE*);
_CRTIMP int __cdecl getchar (void);
_CRTIMP int __cdecl putchar (int);
#endif
/*
* Direct Input and Output Functions
*/
_CRTIMP size_t __cdecl fread (void*, size_t, size_t, FILE*);
_CRTIMP size_t __cdecl fwrite (const void*, size_t, size_t, FILE*);
/*
* File Positioning Functions
*/
_CRTIMP int __cdecl fseek (FILE*, long, int);
_CRTIMP long __cdecl ftell (FILE*);
_CRTIMP void __cdecl rewind (FILE*);
#ifdef __USE_MINGW_FSEEK /* These are in libmingwex.a */
/*
* Workaround for limitations on win9x where a file contents are
* not zero'd out if you seek past the end and then write.
*/
int __cdecl __mingw_fseek (FILE *, long, int);
int __cdecl __mingw_fwrite (const void*, size_t, size_t, FILE*);
#define fseek(fp, offset, whence) __mingw_fseek(fp, offset, whence)
#define fwrite(buffer, size, count, fp) __mingw_fwrite(buffer, size, count, fp)
#endif /* __USE_MINGW_FSEEK */
/*
* 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? It's definitely a 64-bit number in
* MSVCRT however, and for now `long long' will do.
*/
#ifdef __MSVCRT__
typedef long long fpos_t;
#else
typedef long fpos_t;
#endif
_CRTIMP int __cdecl fgetpos (FILE*, fpos_t*);
_CRTIMP int __cdecl fsetpos (FILE*, const fpos_t*);
/*
* Error Functions
*/
_CRTIMP int __cdecl feof (FILE*);
_CRTIMP int __cdecl ferror (FILE*);
#ifdef __cplusplus
inline int __cdecl feof (FILE* __F)
{ return __F->_flag & _IOEOF; }
inline int __cdecl ferror (FILE* __F)
{ return __F->_flag & _IOERR; }
#else
#define feof(__F) ((__F)->_flag & _IOEOF)
#define ferror(__F) ((__F)->_flag & _IOERR)
#endif
_CRTIMP void __cdecl clearerr (FILE*);
_CRTIMP void __cdecl perror (const char*);
#ifndef __STRICT_ANSI__
/*
* Pipes
*/
_CRTIMP FILE* __cdecl _popen (const char*, const char*);
_CRTIMP int __cdecl _pclose (FILE*);
#ifndef NO_OLDNAMES
_CRTIMP FILE* __cdecl popen (const char*, const char*);
_CRTIMP int __cdecl pclose (FILE*);
#endif
/*
* Other Non ANSI functions
*/
_CRTIMP int __cdecl _flushall (void);
_CRTIMP int __cdecl _fgetchar (void);
_CRTIMP int __cdecl _fputchar (int);
_CRTIMP FILE* __cdecl _fdopen (int, const char*);
_CRTIMP int __cdecl _fileno (FILE*);
_CRTIMP int __cdecl _fcloseall(void);
_CRTIMP FILE* __cdecl _fsopen(const char*, const char*, int);
#ifdef __MSVCRT__
_CRTIMP int __cdecl _getmaxstdio(void);
_CRTIMP int __cdecl _setmaxstdio(int);
#endif
#ifndef _NO_OLDNAMES
_CRTIMP int __cdecl fgetchar (void);
_CRTIMP int __cdecl fputchar (int);
_CRTIMP FILE* __cdecl fdopen (int, const char*);
_CRTIMP int __cdecl fileno (FILE*);
#endif /* Not _NO_OLDNAMES */
#define _fileno(__F) ((__F)->_file)
#ifndef _NO_OLDNAMES
#define fileno(__F) ((__F)->_file)
#endif
#if defined (__MSVCRT__) && !defined (__NO_MINGW_LFS)
#include <sys/types.h>
__CRT_INLINE FILE* __cdecl fopen64 (const char* filename, const char* mode)
{
return fopen (filename, mode);
}
int __cdecl fseeko64 (FILE*, off64_t, int);
#ifdef __USE_MINGW_FSEEK
int __cdecl __mingw_fseeko64 (FILE *, off64_t, int);
#define fseeko64(fp, offset, whence) __mingw_fseeko64(fp, offset, whence)
#endif
__CRT_INLINE off64_t __cdecl ftello64 (FILE * stream)
{
fpos_t pos;
if (fgetpos(stream, &pos))
return -1LL;
else
return ((off64_t) pos);
}
#endif /* __NO_MINGW_LFS */
#endif /* Not __STRICT_ANSI__ */
/* Wide versions */
#ifndef _WSTDIO_DEFINED
/* also in wchar.h - keep in sync */
_CRTIMP int __cdecl fwprintf (FILE*, const wchar_t*, ...);
_CRTIMP int __cdecl wprintf (const wchar_t*, ...);
_CRTIMP int __cdecl swprintf (wchar_t*, const wchar_t*, ...);
_CRTIMP int __cdecl _snwprintf (wchar_t*, size_t, const wchar_t*, ...);
_CRTIMP int __cdecl vfwprintf (FILE*, const wchar_t*, __VALIST);
_CRTIMP int __cdecl vwprintf (const wchar_t*, __VALIST);
_CRTIMP int __cdecl vswprintf (wchar_t*, const wchar_t*, __VALIST);
_CRTIMP int __cdecl _vsnwprintf (wchar_t*, size_t, const wchar_t*, __VALIST);
_CRTIMP int __cdecl fwscanf (FILE*, const wchar_t*, ...);
_CRTIMP int __cdecl wscanf (const wchar_t*, ...);
_CRTIMP int __cdecl swscanf (const wchar_t*, const wchar_t*, ...);
_CRTIMP wint_t __cdecl fgetwc (FILE*);
_CRTIMP wint_t __cdecl fputwc (wchar_t, FILE*);
_CRTIMP wint_t __cdecl ungetwc (wchar_t, FILE*);
#ifdef __MSVCRT__
_CRTIMP wchar_t* __cdecl fgetws (wchar_t*, int, FILE*);
_CRTIMP int __cdecl fputws (const wchar_t*, FILE*);
_CRTIMP wint_t __cdecl getwc (FILE*);
_CRTIMP wint_t __cdecl getwchar (void);
_CRTIMP wchar_t* __cdecl _getws (wchar_t*);
_CRTIMP wint_t __cdecl putwc (wint_t, FILE*);
_CRTIMP int __cdecl _putws (const wchar_t*);
_CRTIMP wint_t __cdecl putwchar (wint_t);
_CRTIMP FILE* __cdecl _wfdopen(int, wchar_t *);
_CRTIMP FILE* __cdecl _wfopen (const wchar_t*, const wchar_t*);
_CRTIMP FILE* __cdecl _wfreopen (const wchar_t*, const wchar_t*, FILE*);
_CRTIMP FILE* __cdecl _wfsopen (const wchar_t*, const wchar_t*, int);
_CRTIMP wchar_t* __cdecl _wtmpnam (wchar_t*);
_CRTIMP wchar_t* __cdecl _wtempnam (const wchar_t*, const wchar_t*);
_CRTIMP int __cdecl _wrename (const wchar_t*, const wchar_t*);
_CRTIMP int __cdecl _wremove (const wchar_t*);
_CRTIMP void __cdecl _wperror (const wchar_t*);
_CRTIMP FILE* __cdecl _wpopen (const wchar_t*, const wchar_t*);
#endif /* __MSVCRT__ */
#ifndef __NO_ISOCEXT /* externs in libmingwex.a */
int __cdecl snwprintf (wchar_t* s, size_t n, const wchar_t* format, ...);
__CRT_INLINE int __cdecl
vsnwprintf (wchar_t* s, size_t n, const wchar_t* format, __VALIST arg)
{ return _vsnwprintf ( s, n, format, arg);}
int __cdecl vwscanf (const wchar_t * __restrict__, __VALIST);
int __cdecl vfwscanf (FILE * __restrict__,
const wchar_t * __restrict__, __VALIST);
int __cdecl vswscanf (const wchar_t * __restrict__,
const wchar_t * __restrict__, __VALIST);
#endif
#define _WSTDIO_DEFINED
#endif /* _WSTDIO_DEFINED */
#ifndef __STRICT_ANSI__
#ifdef __MSVCRT__
#ifndef NO_OLDNAMES
_CRTIMP FILE* __cdecl wpopen (const wchar_t*, const wchar_t*);
#endif /* not NO_OLDNAMES */
#endif /* MSVCRT runtime */
/*
* Other Non ANSI wide functions
*/
_CRTIMP wint_t __cdecl _fgetwchar (void);
_CRTIMP wint_t __cdecl _fputwchar (wint_t);
_CRTIMP int __cdecl _getw (FILE*);
_CRTIMP int __cdecl _putw (int, FILE*);
#ifndef _NO_OLDNAMES
_CRTIMP wint_t __cdecl fgetwchar (void);
_CRTIMP wint_t __cdecl fputwchar (wint_t);
_CRTIMP int __cdecl getw (FILE*);
_CRTIMP int __cdecl putw (int, FILE*);
#endif /* Not _NO_OLDNAMES */
#endif /* __STRICT_ANSI */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* _STDIO_H_ */

View File

@ -0,0 +1,514 @@
/*
* stdlib.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Definitions for common types, variables, and functions.
*
*/
#ifndef _STDLIB_H_
#define _STDLIB_H_
/* All the headers include this file. */
#include <_mingw.h>
#define __need_size_t
#define __need_wchar_t
#define __need_NULL
#ifndef RC_INVOKED
#include <stddef.h>
#endif /* RC_INVOKED */
/*
* RAND_MAX is the maximum value that may be returned by rand.
* The minimum is zero.
*/
#define RAND_MAX 0x7FFF
/*
* These values may be used as exit status codes.
*/
#define EXIT_SUCCESS 0
#define EXIT_FAILURE 1
/*
* Definitions for path name functions.
* NOTE: All of these values have simply been chosen to be conservatively high.
* Remember that with long file names we can no longer depend on
* extensions being short.
*/
#ifndef __STRICT_ANSI__
#ifndef MAX_PATH
#define MAX_PATH (260)
#endif
#define _MAX_PATH MAX_PATH
#define _MAX_DRIVE (3)
#define _MAX_DIR 256
#define _MAX_FNAME 256
#define _MAX_EXT 256
#endif /* Not __STRICT_ANSI__ */
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
#if !defined (__STRICT_ANSI__)
/*
* 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;
/* imports from runtime dll of the above variables */
#ifdef __MSVCRT__
extern int* __cdecl __p___argc(void);
extern char*** __cdecl __p___argv(void);
extern wchar_t*** __cdecl __p___wargv(void);
#define __argc (*__p___argc())
#define __argv (*__p___argv())
#define __wargv (*__p___wargv())
#else /* !MSVCRT */
#ifndef __DECLSPEC_SUPPORTED
extern int* _imp____argc_dll;
extern char*** _imp____argv_dll;
#define __argc (*_imp____argc_dll)
#define __argv (*_imp____argv_dll)
#else /* __DECLSPEC_SUPPORTED */
__MINGW_IMPORT int __argc_dll;
__MINGW_IMPORT char** __argv_dll;
#define __argc __argc_dll
#define __argv __argv_dll
#endif /* __DECLSPEC_SUPPORTED */
#endif /* __MSVCRT */
#endif /* __STRICT_ANSI__ */
/*
* Also defined in ctype.h.
*/
#ifndef MB_CUR_MAX
#ifdef __DECLSPEC_SUPPORTED
# ifdef __MSVCRT__
# define MB_CUR_MAX __mb_cur_max
__MINGW_IMPORT int __mb_cur_max;
# else /* not __MSVCRT */
# define MB_CUR_MAX __mb_cur_max_dll
__MINGW_IMPORT int __mb_cur_max_dll;
# endif /* not __MSVCRT */
#else /* ! __DECLSPEC_SUPPORTED */
# ifdef __MSVCRT__
extern int* _imp____mbcur_max;
# define MB_CUR_MAX (*_imp____mb_cur_max)
# else /* not __MSVCRT */
extern int* _imp____mbcur_max_dll;
# define MB_CUR_MAX (*_imp____mb_cur_max_dll)
# endif /* not __MSVCRT */
#endif /* __DECLSPEC_SUPPORTED */
#endif /* MB_CUR_MAX */
/*
* MS likes to declare errno in stdlib.h as well.
*/
#ifdef _UWIN
#undef errno
extern int errno;
#else
_CRTIMP int* __cdecl _errno(void);
#define errno (*_errno())
#endif
_CRTIMP int* __cdecl __doserrno(void);
#define _doserrno (*__doserrno())
#if !defined (__STRICT_ANSI__)
/*
* Use environ from the DLL, not as a global.
*/
#ifdef __MSVCRT__
extern _CRTIMP char *** __cdecl __p__environ(void);
extern _CRTIMP wchar_t *** __cdecl __p__wenviron(void);
# define _environ (*__p__environ())
# define _wenviron (*__p__wenviron())
#else /* ! __MSVCRT__ */
# ifndef __DECLSPEC_SUPPORTED
extern char *** _imp___environ_dll;
# define _environ (*_imp___environ_dll)
# else /* __DECLSPEC_SUPPORTED */
__MINGW_IMPORT char ** _environ_dll;
# define _environ _environ_dll
# endif /* __DECLSPEC_SUPPORTED */
#endif /* ! __MSVCRT__ */
#define environ _environ
#ifdef __MSVCRT__
/* One of the MSVCRTxx libraries */
#ifndef __DECLSPEC_SUPPORTED
extern int* _imp___sys_nerr;
# define sys_nerr (*_imp___sys_nerr)
#else /* __DECLSPEC_SUPPORTED */
__MINGW_IMPORT int _sys_nerr;
# ifndef _UWIN
# define sys_nerr _sys_nerr
# endif /* _UWIN */
#endif /* __DECLSPEC_SUPPORTED */
#else /* ! __MSVCRT__ */
/* CRTDLL run time library */
#ifndef __DECLSPEC_SUPPORTED
extern int* _imp___sys_nerr_dll;
# define sys_nerr (*_imp___sys_nerr_dll)
#else /* __DECLSPEC_SUPPORTED */
__MINGW_IMPORT int _sys_nerr_dll;
# define sys_nerr _sys_nerr_dll
#endif /* __DECLSPEC_SUPPORTED */
#endif /* ! __MSVCRT__ */
#ifndef __DECLSPEC_SUPPORTED
extern char*** _imp__sys_errlist;
#define sys_errlist (*_imp___sys_errlist)
#else /* __DECLSPEC_SUPPORTED */
__MINGW_IMPORT char* _sys_errlist[];
#ifndef _UWIN
#define sys_errlist _sys_errlist
#endif /* _UWIN */
#endif /* __DECLSPEC_SUPPORTED */
/*
* OS version and such constants.
*/
#ifdef __MSVCRT__
/* msvcrtxx.dll */
extern _CRTIMP unsigned __cdecl int* __p__osver(void);
extern _CRTIMP unsigned __cdecl int* __p__winver(void);
extern _CRTIMP unsigned __cdecl int* __p__winmajor(void);
extern _CRTIMP unsigned __cdecl int* __p__winminor(void);
#ifndef __DECLSPEC_SUPPORTED
# define _osver (*__p__osver())
# define _winver (*__p__winver())
# define _winmajor (*__p__winmajor())
# define _winminor (*__p__winminor())
#else
__MINGW_IMPORT unsigned int _osver;
__MINGW_IMPORT unsigned int _winver;
__MINGW_IMPORT unsigned int _winmajor;
__MINGW_IMPORT unsigned int _winminor;
#endif /* __DECLSPEC_SUPPORTED */
#else
/* Not msvcrtxx.dll, thus crtdll.dll */
#ifndef __DECLSPEC_SUPPORTED
extern unsigned int* _imp___osver_dll;
extern unsigned int* _imp___winver_dll;
extern unsigned int* _imp___winmajor_dll;
extern unsigned int* _imp___winminor_dll;
#define _osver (*_imp___osver_dll)
#define _winver (*_imp___winver_dll)
#define _winmajor (*_imp___winmajor_dll)
#define _winminor (*_imp___winminor_dll)
#else /* __DECLSPEC_SUPPORTED */
__MINGW_IMPORT unsigned int _osver_dll;
__MINGW_IMPORT unsigned int _winver_dll;
__MINGW_IMPORT unsigned int _winmajor_dll;
__MINGW_IMPORT unsigned int _winminor_dll;
#define _osver _osver_dll
#define _winver _winver_dll
#define _winmajor _winmajor_dll
#define _winminor _winminor_dll
#endif /* __DECLSPEC_SUPPORTED */
#endif
#if defined __MSVCRT__
/* although the _pgmptr is exported as DATA,
* be safe and use the access function __p__pgmptr() to get it. */
_CRTIMP char** __cdecl __p__pgmptr(void);
#define _pgmptr (*__p__pgmptr())
_CRTIMP wchar_t** __cdecl __p__wpgmptr(void);
#define _wpgmptr (*__p__wpgmptr())
#else /* ! __MSVCRT__ */
# ifndef __DECLSPEC_SUPPORTED
extern char** __imp__pgmptr_dll;
# define _pgmptr (*_imp___pgmptr_dll)
# else /* __DECLSPEC_SUPPORTED */
__MINGW_IMPORT char* _pgmptr_dll;
# define _pgmptr _pgmptr_dll
# endif /* __DECLSPEC_SUPPORTED */
/* no wide version in CRTDLL */
#endif /* __MSVCRT__ */
/*
* This variable determines the default file mode.
* TODO: Which flags work?
*/
#if !defined (__DECLSPEC_SUPPORTED) || defined (__IN_MINGW_RUNTIME)
#ifdef __MSVCRT__
extern int* _imp___fmode;
#define _fmode (*_imp___fmode)
#else
/* CRTDLL */
extern int* _imp___fmode_dll;
#define _fmode (*_imp___fmode_dll)
#endif
#else /* __DECLSPEC_SUPPORTED */
#ifdef __MSVCRT__
__MINGW_IMPORT int _fmode;
#else /* ! __MSVCRT__ */
__MINGW_IMPORT int _fmode_dll;
#define _fmode _fmode_dll
#endif /* ! __MSVCRT__ */
#endif /* __DECLSPEC_SUPPORTED */
#endif /* Not __STRICT_ANSI__ */
_CRTIMP double __cdecl atof (const char*);
_CRTIMP int __cdecl atoi (const char*);
_CRTIMP long __cdecl atol (const char*);
#if !defined (__STRICT_ANSI__)
_CRTIMP int __cdecl _wtoi (const wchar_t *);
_CRTIMP long __cdecl _wtol (const wchar_t *);
#endif
_CRTIMP double __cdecl strtod (const char*, char**);
#if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */
__CRT_INLINE float __cdecl strtof (const char *nptr, char **endptr)
{ return (strtod (nptr, endptr));}
long double __cdecl strtold (const char * __restrict__, char ** __restrict__);
#endif /* __NO_ISOCEXT */
_CRTIMP long __cdecl strtol (const char*, char**, int);
_CRTIMP unsigned long __cdecl strtoul (const char*, char**, int);
#ifndef _WSTDLIB_DEFINED
/* also declared in wchar.h */
_CRTIMP double __cdecl wcstod (const wchar_t*, wchar_t**);
#if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */
__CRT_INLINE float __cdecl wcstof( const wchar_t *nptr, wchar_t **endptr)
{ return (wcstod(nptr, endptr)); }
long double __cdecl wcstold (const wchar_t * __restrict__, wchar_t ** __restrict__);
#endif /* __NO_ISOCEXT */
_CRTIMP long __cdecl wcstol (const wchar_t*, wchar_t**, int);
_CRTIMP unsigned long __cdecl wcstoul (const wchar_t*, wchar_t**, int);
#define _WSTDLIB_DEFINED
#endif
_CRTIMP size_t __cdecl wcstombs (char*, const wchar_t*, size_t);
_CRTIMP int __cdecl wctomb (char*, wchar_t);
_CRTIMP int __cdecl mblen (const char*, size_t);
_CRTIMP size_t __cdecl mbstowcs (wchar_t*, const char*, size_t);
_CRTIMP int __cdecl mbtowc (wchar_t*, const char*, size_t);
_CRTIMP int __cdecl rand (void);
_CRTIMP void __cdecl srand (unsigned int);
_CRTIMP void* __cdecl calloc (size_t, size_t) __MINGW_ATTRIB_MALLOC;
_CRTIMP void* __cdecl malloc (size_t) __MINGW_ATTRIB_MALLOC;
_CRTIMP void* __cdecl realloc (void*, size_t);
_CRTIMP void __cdecl free (void*);
_CRTIMP void __cdecl abort (void) __MINGW_ATTRIB_NORETURN;
_CRTIMP void __cdecl exit (int) __MINGW_ATTRIB_NORETURN;
/* Note: This is in startup code, not imported directly from dll */
int __cdecl atexit (void (*)(void));
_CRTIMP int __cdecl system (const char*);
_CRTIMP char* __cdecl getenv (const char*);
/* bsearch and qsort are also in non-ANSI header search.h */
_CRTIMP void* __cdecl bsearch (const void*, const void*, size_t, size_t,
int (*)(const void*, const void*));
_CRTIMP void __cdecl qsort (void*, size_t, size_t,
int (*)(const void*, const void*));
_CRTIMP int __cdecl abs (int) __MINGW_ATTRIB_CONST;
_CRTIMP long __cdecl labs (long) __MINGW_ATTRIB_CONST;
/*
* 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;
_CRTIMP div_t __cdecl div (int, int) __MINGW_ATTRIB_CONST;
_CRTIMP ldiv_t __cdecl ldiv (long, long) __MINGW_ATTRIB_CONST;
#if !defined (__STRICT_ANSI__)
/*
* NOTE: Officially the three following functions are obsolete. The Win32 API
* functions SetErrorMode, Beep and Sleep are their replacements.
*/
_CRTIMP void __cdecl _beep (unsigned int, unsigned int);
_CRTIMP void __cdecl _seterrormode (int);
_CRTIMP void __cdecl _sleep (unsigned long);
_CRTIMP void __cdecl _exit (int) __MINGW_ATTRIB_NORETURN;
/* _onexit is MS extension. Use atexit for portability. */
/* Note: This is in startup code, not imported directly from dll */
typedef int (* _onexit_t)(void);
_onexit_t __cdecl _onexit( _onexit_t );
_CRTIMP int __cdecl _putenv (const char*);
_CRTIMP void __cdecl _searchenv (const char*, const char*, char*);
_CRTIMP char* __cdecl _ecvt (double, int, int*, int*);
_CRTIMP char* __cdecl _fcvt (double, int, int*, int*);
_CRTIMP char* __cdecl _gcvt (double, int, char*);
_CRTIMP void __cdecl _makepath (char*, const char*, const char*, const char*, const char*);
_CRTIMP void __cdecl _splitpath (const char*, char*, char*, char*, char*);
_CRTIMP char* __cdecl _fullpath (char*, const char*, size_t);
_CRTIMP char* __cdecl _itoa (int, char*, int);
_CRTIMP char* __cdecl _ltoa (long, char*, int);
_CRTIMP char* __cdecl _ultoa(unsigned long, char*, int);
_CRTIMP wchar_t* __cdecl _itow (int, wchar_t*, int);
_CRTIMP wchar_t* __cdecl _ltow (long, wchar_t*, int);
_CRTIMP wchar_t* __cdecl _ultow (unsigned long, wchar_t*, int);
#ifdef __MSVCRT__
_CRTIMP __int64 __cdecl _atoi64(const char *);
_CRTIMP char* __cdecl _i64toa(__int64, char *, int);
_CRTIMP char* __cdecl _ui64toa(unsigned __int64, char *, int);
_CRTIMP __int64 __cdecl _wtoi64(const wchar_t *);
_CRTIMP wchar_t* __cdecl _i64tow(__int64, wchar_t *, int);
_CRTIMP wchar_t* __cdecl _ui64tow(unsigned __int64, wchar_t *, int);
_CRTIMP wchar_t* __cdecl _wgetenv(const wchar_t*);
_CRTIMP int __cdecl _wputenv(const wchar_t*);
_CRTIMP void __cdecl _wsearchenv(const wchar_t*, const wchar_t*, wchar_t*);
_CRTIMP void __cdecl _wmakepath(wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*);
_CRTIMP void __cdecl _wsplitpath (const wchar_t*, wchar_t*, wchar_t*, wchar_t*, wchar_t*);
_CRTIMP wchar_t* __cdecl _wfullpath (wchar_t*, const wchar_t*, size_t);
_CRTIMP unsigned int __cdecl _rotl(unsigned int, int) __MINGW_ATTRIB_CONST;
_CRTIMP unsigned int __cdecl _rotr(unsigned int, int) __MINGW_ATTRIB_CONST;
_CRTIMP unsigned long __cdecl _lrotl(unsigned long, int) __MINGW_ATTRIB_CONST;
_CRTIMP unsigned long __cdecl _lrotr(unsigned long, int) __MINGW_ATTRIB_CONST;
#endif
#ifndef _NO_OLDNAMES
_CRTIMP int __cdecl putenv (const char*);
_CRTIMP void __cdecl searchenv (const char*, const char*, char*);
_CRTIMP char* __cdecl itoa (int, char*, int);
_CRTIMP char* __cdecl ltoa (long, char*, int);
#ifndef _UWIN
_CRTIMP char* __cdecl ecvt (double, int, int*, int*);
_CRTIMP char* __cdecl fcvt (double, int, int*, int*);
_CRTIMP char* __cdecl gcvt (double, int, char*);
#endif /* _UWIN */
#endif /* Not _NO_OLDNAMES */
#endif /* Not __STRICT_ANSI__ */
/* C99 names */
#if !defined __NO_ISOCEXT /* externs in static libmingwex.a */
/* C99 name for _exit */
void __cdecl _Exit(int) __MINGW_ATTRIB_NORETURN;
#ifndef __STRICT_ANSI__ /* inline using non-ansi functions */
__CRT_INLINE void __cdecl _Exit(int status)
{ _exit(status); }
#endif
typedef struct { long long quot, rem; } lldiv_t;
lldiv_t __cdecl lldiv (long long, long long) __MINGW_ATTRIB_CONST;
__CRT_INLINE long long __cdecl llabs(long long _j)
{return (_j >= 0 ? _j : -_j);}
long long __cdecl strtoll (const char* __restrict__, char** __restrict, int);
unsigned long long __cdecl strtoull (const char* __restrict__, char** __restrict__, int);
#if defined (__MSVCRT__) /* these are stubs for MS _i64 versions */
long long __cdecl atoll (const char *);
#if !defined (__STRICT_ANSI__)
long long __cdecl wtoll (const wchar_t *);
char* __cdecl lltoa (long long, char *, int);
char* __cdecl ulltoa (unsigned long long , char *, int);
wchar_t* __cdecl lltow (long long, wchar_t *, int);
wchar_t* __cdecl ulltow (unsigned long long, wchar_t *, int);
/* inline using non-ansi functions */
__CRT_INLINE long long __cdecl atoll (const char * _c)
{ return _atoi64 (_c); }
__CRT_INLINE char* __cdecl lltoa (long long _n, char * _c, int _i)
{ return _i64toa (_n, _c, _i); }
__CRT_INLINE char* __cdecl ulltoa (unsigned long long _n, char * _c, int _i)
{ return _ui64toa (_n, _c, _i); }
__CRT_INLINE long long __cdecl wtoll (const wchar_t * _w)
{ return _wtoi64 (_w); }
__CRT_INLINE wchar_t* __cdecl lltow (long long _n, wchar_t * _w, int _i)
{ return _i64tow (_n, _w, _i); }
__CRT_INLINE wchar_t* __cdecl ulltow (unsigned long long _n, wchar_t * _w, int _i)
{ return _ui64tow (_n, _w, _i); }
#endif /* (__STRICT_ANSI__) */
#endif /* __MSVCRT__ */
#endif /* !__NO_ISOCEXT */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _STDLIB_H_ */

View File

@ -0,0 +1,193 @@
/*
* string.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Definitions for memory and string functions.
*
*/
#ifndef _STRING_H_
#define _STRING_H_
/* All the headers include this file. */
#include <_mingw.h>
/*
* Define size_t, wchar_t and NULL
*/
#define __need_size_t
#define __need_wchar_t
#define __need_NULL
#ifndef RC_INVOKED
#include <stddef.h>
#endif /* Not RC_INVOKED */
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
/*
* Prototypes of the ANSI Standard C library string functions.
*/
_CRTIMP void* __cdecl memchr (const void*, int, size_t) __MINGW_ATTRIB_PURE;
_CRTIMP int __cdecl memcmp (const void*, const void*, size_t) __MINGW_ATTRIB_PURE;
_CRTIMP void* __cdecl memcpy (void*, const void*, size_t);
_CRTIMP void* __cdecl memmove (void*, const void*, size_t);
_CRTIMP void* __cdecl memset (void*, int, size_t);
_CRTIMP char* __cdecl strcat (char*, const char*);
_CRTIMP char* __cdecl strchr (const char*, int) __MINGW_ATTRIB_PURE;
_CRTIMP int __cdecl strcmp (const char*, const char*) __MINGW_ATTRIB_PURE;
_CRTIMP int __cdecl strcoll (const char*, const char*); /* Compare using locale */
_CRTIMP char* __cdecl strcpy (char*, const char*);
_CRTIMP size_t __cdecl strcspn (const char*, const char*) __MINGW_ATTRIB_PURE;
_CRTIMP char* __cdecl strerror (int); /* NOTE: NOT an old name wrapper. */
_CRTIMP size_t __cdecl strlen (const char*) __MINGW_ATTRIB_PURE;
_CRTIMP char* __cdecl strncat (char*, const char*, size_t);
_CRTIMP int __cdecl strncmp (const char*, const char*, size_t) __MINGW_ATTRIB_PURE;
_CRTIMP char* __cdecl strncpy (char*, const char*, size_t);
_CRTIMP char* __cdecl strpbrk (const char*, const char*) __MINGW_ATTRIB_PURE;
_CRTIMP char* __cdecl strrchr (const char*, int) __MINGW_ATTRIB_PURE;
_CRTIMP size_t __cdecl strspn (const char*, const char*) __MINGW_ATTRIB_PURE;
_CRTIMP char* __cdecl strstr (const char*, const char*) __MINGW_ATTRIB_PURE;
_CRTIMP char* __cdecl strtok (char*, const char*);
_CRTIMP size_t __cdecl strxfrm (char*, const char*, size_t);
#ifndef __STRICT_ANSI__
/*
* Extra non-ANSI functions provided by the CRTDLL library
*/
_CRTIMP char* __cdecl _strerror (const char *);
_CRTIMP void* __cdecl _memccpy (void*, const void*, int, size_t);
_CRTIMP int __cdecl _memicmp (const void*, const void*, size_t);
_CRTIMP char* __cdecl _strdup (const char*) __MINGW_ATTRIB_MALLOC;
_CRTIMP int __cdecl _strcmpi (const char*, const char*);
_CRTIMP int __cdecl _stricmp (const char*, const char*);
_CRTIMP int __cdecl _stricoll (const char*, const char*);
_CRTIMP char* __cdecl _strlwr (char*);
_CRTIMP int __cdecl _strnicmp (const char*, const char*, size_t);
_CRTIMP char* __cdecl _strnset (char*, int, size_t);
_CRTIMP char* __cdecl _strrev (char*);
_CRTIMP char* __cdecl _strset (char*, int);
_CRTIMP char* __cdecl _strupr (char*);
_CRTIMP void __cdecl _swab (const char*, char*, size_t);
#ifdef __MSVCRT__
_CRTIMP int __cdecl _strncoll(const char*, const char*, size_t);
_CRTIMP int __cdecl _strnicoll(const char*, const char*, size_t);
#endif
#ifndef _NO_OLDNAMES
/*
* 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.
*/
_CRTIMP void* __cdecl memccpy (void*, const void*, int, size_t);
_CRTIMP int __cdecl memicmp (const void*, const void*, size_t);
_CRTIMP char* __cdecl strdup (const char*) __MINGW_ATTRIB_MALLOC;
_CRTIMP int __cdecl strcmpi (const char*, const char*);
_CRTIMP int __cdecl stricmp (const char*, const char*);
__CRT_INLINE int __cdecl
strcasecmp (const char * __sz1, const char * __sz2)
{return _stricmp (__sz1, __sz2);}
_CRTIMP int __cdecl stricoll (const char*, const char*);
_CRTIMP char* __cdecl strlwr (char*);
_CRTIMP int __cdecl strnicmp (const char*, const char*, size_t);
__CRT_INLINE int __cdecl
strncasecmp (const char * __sz1, const char * __sz2, size_t __sizeMaxCompare)
{return _strnicmp (__sz1, __sz2, __sizeMaxCompare);}
_CRTIMP char* __cdecl strnset (char*, int, size_t);
_CRTIMP char* __cdecl strrev (char*);
_CRTIMP char* __cdecl strset (char*, int);
_CRTIMP char* __cdecl strupr (char*);
#ifndef _UWIN
_CRTIMP void __cdecl swab (const char*, char*, size_t);
#endif /* _UWIN */
#endif /* _NO_OLDNAMES */
#endif /* Not __STRICT_ANSI__ */
#ifndef _WSTRING_DEFINED
/*
* Unicode versions of the standard calls.
* Also in wchar.h, where they belong according to ISO standard.
*/
_CRTIMP wchar_t* __cdecl wcscat (wchar_t*, const wchar_t*);
_CRTIMP wchar_t* __cdecl wcschr (const wchar_t*, wchar_t);
_CRTIMP int __cdecl wcscmp (const wchar_t*, const wchar_t*);
_CRTIMP int __cdecl wcscoll (const wchar_t*, const wchar_t*);
_CRTIMP wchar_t* __cdecl wcscpy (wchar_t*, const wchar_t*);
_CRTIMP size_t __cdecl wcscspn (const wchar_t*, const wchar_t*);
/* Note: _wcserror requires __MSVCRT_VERSION__ >= 0x0700. */
_CRTIMP size_t __cdecl wcslen (const wchar_t*);
_CRTIMP wchar_t* __cdecl wcsncat (wchar_t*, const wchar_t*, size_t);
_CRTIMP int __cdecl wcsncmp(const wchar_t*, const wchar_t*, size_t);
_CRTIMP wchar_t* __cdecl wcsncpy(wchar_t*, const wchar_t*, size_t);
_CRTIMP wchar_t* __cdecl wcspbrk(const wchar_t*, const wchar_t*);
_CRTIMP wchar_t* __cdecl wcsrchr(const wchar_t*, wchar_t);
_CRTIMP size_t __cdecl wcsspn(const wchar_t*, const wchar_t*);
_CRTIMP wchar_t* __cdecl wcsstr(const wchar_t*, const wchar_t*);
_CRTIMP wchar_t* __cdecl wcstok(wchar_t*, const wchar_t*);
_CRTIMP size_t __cdecl wcsxfrm(wchar_t*, const wchar_t*, size_t);
#ifndef __STRICT_ANSI__
/*
* Unicode versions of non-ANSI string functions provided by CRTDLL.
*/
/* NOTE: _wcscmpi not provided by CRTDLL, this define is for portability */
#define _wcscmpi _wcsicmp
_CRTIMP wchar_t* __cdecl _wcsdup (const wchar_t*);
_CRTIMP int __cdecl _wcsicmp (const wchar_t*, const wchar_t*);
_CRTIMP int __cdecl _wcsicoll (const wchar_t*, const wchar_t*);
_CRTIMP wchar_t* __cdecl _wcslwr (wchar_t*);
_CRTIMP int __cdecl _wcsnicmp (const wchar_t*, const wchar_t*, size_t);
_CRTIMP wchar_t* __cdecl _wcsnset (wchar_t*, wchar_t, size_t);
_CRTIMP wchar_t* __cdecl _wcsrev (wchar_t*);
_CRTIMP wchar_t* __cdecl _wcsset (wchar_t*, wchar_t);
_CRTIMP wchar_t* __cdecl _wcsupr (wchar_t*);
#ifdef __MSVCRT__
_CRTIMP int __cdecl _wcsncoll(const wchar_t*, const wchar_t*, size_t);
_CRTIMP int __cdecl _wcsnicoll(const wchar_t*, const wchar_t*, size_t);
#if __MSVCRT_VERSION__ >= 0x0700
_CRTIMP wchar_t* __cdecl _wcserror(int);
_CRTIMP wchar_t* __cdecl __wcserror(const wchar_t*);
#endif
#endif
#ifndef _NO_OLDNAMES
/* NOTE: There is no _wcscmpi, but this is for compatibility. */
int __cdecl wcscmpi (const wchar_t * __ws1, const wchar_t * __ws2);
__CRT_INLINE int __cdecl
wcscmpi (const wchar_t * __ws1, const wchar_t * __ws2)
{return _wcsicmp (__ws1, __ws2);}
_CRTIMP wchar_t* __cdecl wcsdup (const wchar_t*);
_CRTIMP int __cdecl wcsicmp (const wchar_t*, const wchar_t*);
_CRTIMP int __cdecl wcsicoll (const wchar_t*, const wchar_t*);
_CRTIMP wchar_t* __cdecl wcslwr (wchar_t*);
_CRTIMP int __cdecl wcsnicmp (const wchar_t*, const wchar_t*, size_t);
_CRTIMP wchar_t* __cdecl wcsnset (wchar_t*, wchar_t, size_t);
_CRTIMP wchar_t* __cdecl wcsrev (wchar_t*);
_CRTIMP wchar_t* __cdecl wcsset (wchar_t*, wchar_t);
_CRTIMP wchar_t* __cdecl wcsupr (wchar_t*);
#endif /* Not _NO_OLDNAMES */
#endif /* Not strict ANSI */
#define _WSTRING_DEFINED
#endif /* _WSTRING_DEFINED */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _STRING_H_ */

View File

@ -0,0 +1,12 @@
/*
File: strings.h
Copyright: Public Domain
This file is provided because non ANSI fuctions are described in string.h
that belong in strings.h. These functions are provided for in the OLDNAME
libraries.
*/
#if !defined(_STRINGS_H_)
# define _STRINGS_H_ 1
# include <string.h>
#endif

View File

@ -0,0 +1,7 @@
/*
* This file is part of the Mingw32 package.
*
* This fcntl.h maps to the root fcntl.h
*/
#include <fcntl.h>

View File

@ -0,0 +1,7 @@
/*
* This file is part of the Mingw32 package.
*
* This file.h maps to the root fcntl.h
* TODO?
*/
#include <fcntl.h>

View File

@ -0,0 +1,31 @@
/*
* locking.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Constants for the mode parameter of the locking function.
*
*/
#ifndef _LOCKING_H_
#define _LOCKING_H_
/* All the headers include this file. */
#include <_mingw.h>
#define _LK_UNLCK 0 /* Unlock */
#define _LK_LOCK 1 /* Lock */
#define _LK_NBLCK 2 /* Non-blocking lock */
#define _LK_RLCK 3 /* Lock for read only */
#define _LK_NBRLCK 4 /* Non-blocking lock for read only */
#ifndef NO_OLDNAMES
#define LK_UNLCK _LK_UNLCK
#define LK_LOCK _LK_LOCK
#define LK_NBLCK _LK_NBLCK
#define LK_RLCK _LK_RLCK
#define LK_NBRLCK _LK_NBRLCK
#endif /* Not NO_OLDNAMES */
#endif /* Not _LOCKING_H_ */

View File

@ -0,0 +1,22 @@
/*
* param.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
*/
#ifndef _SYS_PARAM_H
#define _SYS_PARAM_H
#include <sys/types.h>
#include <limits.h>
/* These are useful for cross-compiling */
#define BIG_ENDIAN 4321
#define LITTLE_ENDIAN 1234
#define BYTE_ORDER LITTLE_ENDIAN
#define MAXPATHLEN PATH_MAX
#endif

View File

@ -0,0 +1,198 @@
/*
* stat.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Symbolic constants for opening and creating files, also stat, fstat and
* chmod functions.
*
*/
#ifndef _STAT_H_
#define _STAT_H_
/* All the headers include this file. */
#include <_mingw.h>
#define __need_size_t
#define __need_wchar_t
#ifndef RC_INVOKED
#include <stddef.h>
#endif /* Not RC_INVOKED */
#include <sys/types.h>
/*
* Constants for the stat st_mode member.
*/
#define _S_IFLNK 0xF000 /* Pretend */
#define _S_IFIFO 0x1000 /* FIFO */
#define _S_IFCHR 0x2000 /* Character */
#define _S_IFBLK 0x3000 /* Block: Is this ever set under w32? */
#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_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
#define _S_IXUSR _S_IEXEC
#define _S_IWUSR _S_IWRITE
#define _S_IRUSR _S_IREAD
#define _S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
#define _S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
#define _S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR)
#define _S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK)
#define _S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
#define _S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK) /* Should always be zero.*/
#ifndef _NO_OLDNAMES
#define S_IFLNK _S_IFLNK
#define S_IFIFO _S_IFIFO
#define S_IFCHR _S_IFCHR
#define S_IFBLK _S_IFBLK
#define S_IFDIR _S_IFDIR
#define S_IFREG _S_IFREG
#define S_IFMT _S_IFMT
#define S_IEXEC _S_IEXEC
#define S_IWRITE _S_IWRITE
#define S_IREAD _S_IREAD
#define S_IRWXU _S_IRWXU
#define S_IXUSR _S_IXUSR
#define S_IWUSR _S_IWUSR
#define S_IRUSR _S_IRUSR
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) /* Should always be zero.*/
#endif /* Not _NO_OLDNAMES */
#ifndef RC_INVOKED
#ifndef _STAT_DEFINED
/*
* 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
{
_dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
_ino_t st_ino; /* Always zero ? */
_mode_t st_mode; /* See above constants */
short st_nlink; /* Number of links. */
short st_uid; /* User: Maybe significant on NT ? */
short st_gid; /* Group: Ditto */
_dev_t st_rdev; /* Seems useless (not even filled in) */
_off_t 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 */
};
struct stat
{
_dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
_ino_t st_ino; /* Always zero ? */
_mode_t st_mode; /* See above constants */
short st_nlink; /* Number of links. */
short st_uid; /* User: Maybe significant on NT ? */
short st_gid; /* Group: Ditto */
_dev_t st_rdev; /* Seems useless (not even filled in) */
_off_t 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 */
};
#if defined (__MSVCRT__)
struct _stati64 {
_dev_t st_dev;
_ino_t st_ino;
unsigned short st_mode;
short st_nlink;
short st_uid;
short st_gid;
_dev_t st_rdev;
__int64 st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
struct __stat64
{
_dev_t st_dev;
_ino_t st_ino;
_mode_t st_mode;
short st_nlink;
short st_uid;
short st_gid;
_dev_t st_rdev;
_off_t st_size;
__time64_t st_atime;
__time64_t st_mtime;
__time64_t st_ctime;
};
#endif /* __MSVCRT__ */
#define _STAT_DEFINED
#endif /* _STAT_DEFINED */
#ifdef __cplusplus
extern "C" {
#endif
_CRTIMP int __cdecl _fstat (int, struct _stat*);
_CRTIMP int __cdecl _chmod (const char*, int);
_CRTIMP int __cdecl _stat (const char*, struct _stat*);
#define _lstat _stat
#ifndef _NO_OLDNAMES
/* These functions live in liboldnames.a. */
_CRTIMP int __cdecl fstat (int, struct stat*);
_CRTIMP int __cdecl chmod (const char*, int);
_CRTIMP int __cdecl stat (const char*, struct stat*);
#define lstat stat
#endif /* Not _NO_OLDNAMES */
#if defined (__MSVCRT__)
_CRTIMP int __cdecl _fstati64(int, struct _stati64 *);
_CRTIMP int __cdecl _stati64(const char *, struct _stati64 *);
/* These require newer versions of msvcrt.dll (6.10 or higher). */
#if __MSVCRT_VERSION__ >= 0x0601
_CRTIMP int __cdecl _fstat64 (int, struct __stat64*);
_CRTIMP int __cdecl _stat64 (const char*, struct __stat64*);
#endif /* __MSVCRT_VERSION__ >= 0x0601 */
#if !defined ( _WSTAT_DEFINED) /* also declared in wchar.h */
_CRTIMP int __cdecl _wstat(const wchar_t*, struct _stat*);
_CRTIMP int __cdecl _wstati64 (const wchar_t*, struct _stati64*);
#if __MSVCRT_VERSION__ >= 0x0601
_CRTIMP int __cdecl _wstat64 (const wchar_t*, struct __stat64*);
#endif /* __MSVCRT_VERSION__ >= 0x0601 */
#define _WSTAT_DEFINED
#endif /* _WSTAT_DEFIND */
#endif /* __MSVCRT__ */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _STAT_H_ */

View File

@ -0,0 +1,16 @@
#include <time.h>
#ifndef _TIMEVAL_DEFINED /* also in winsock[2].h */
#define _TIMEVAL_DEFINED
struct timeval {
long tv_sec;
long tv_usec;
};
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
#define timercmp(tvp, uvp, cmp) \
(((tvp)->tv_sec != (uvp)->tv_sec) ? \
((tvp)->tv_sec cmp (uvp)->tv_sec) : \
((tvp)->tv_usec cmp (uvp)->tv_usec))
#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
#endif /* _TIMEVAL_DEFINED */

View File

@ -0,0 +1,74 @@
/*
* timeb.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Support for the UNIX System V ftime system call.
*
*/
#ifndef _TIMEB_H_
#define _TIMEB_H_
/* All the headers include this file. */
#include <_mingw.h>
#include <sys/types.h>
#ifndef RC_INVOKED
/*
* TODO: Structure not tested.
*/
struct _timeb
{
long time;
short millitm;
short timezone;
short dstflag;
};
#ifndef _NO_OLDNAMES
/*
* TODO: Structure not tested.
*/
struct timeb
{
long time;
short millitm;
short timezone;
short dstflag;
};
#endif
struct __timeb64
{
__time64_t time;
short millitm;
short timezone;
short dstflag;
};
#ifdef __cplusplus
extern "C" {
#endif
/* TODO: Not tested. */
_CRTIMP void __cdecl _ftime (struct _timeb*);
#ifndef _NO_OLDNAMES
_CRTIMP void __cdecl ftime (struct timeb*);
#endif /* Not _NO_OLDNAMES */
/* This requires newer versions of msvcrt.dll (6.10 or higher). */
#if __MSVCRT_VERSION__ >= 0x0601
_CRTIMP void __cdecl _ftime64 (struct __timeb64*);
#endif /* __MSVCRT_VERSION__ >= 0x0601 */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _TIMEB_H_ */

View File

@ -0,0 +1,120 @@
/*
* types.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* The definition of constants, data types and global variables.
*
*/
#ifndef _TYPES_H_
#define _TYPES_H_
/* All the headers include this file. */
#include <_mingw.h>
#define __need_wchar_t
#define __need_size_t
#define __need_ptrdiff_t
#ifndef RC_INVOKED
#include <stddef.h>
#endif /* Not RC_INVOKED */
#ifndef RC_INVOKED
#ifndef _TIME_T_DEFINED
typedef long time_t;
#define _TIME_T_DEFINED
#endif
#ifndef _TIME64_T_DEFINED
typedef __int64 __time64_t;
#define _TIME64_T_DEFINED
#endif
#ifndef _OFF_T_
#define _OFF_T_
typedef long _off_t;
#ifndef _NO_OLDNAMES
typedef _off_t off_t;
#endif
#endif /* Not _OFF_T_ */
#ifndef _DEV_T_
#define _DEV_T_
#ifdef __MSVCRT__
typedef unsigned int _dev_t;
#else
typedef short _dev_t;
#endif
#ifndef _NO_OLDNAMES
typedef _dev_t dev_t;
#endif
#endif /* Not _DEV_T_ */
#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_ */
#ifndef _SSIZE_T_
#define _SSIZE_T_
typedef long _ssize_t;
#ifndef _NO_OLDNAMES
typedef _ssize_t ssize_t;
#endif
#endif /* Not _SSIZE_T_ */
#ifndef _FPOS64_T_
#define _FPOS64_T_
typedef long long fpos64_t;
#endif
#ifndef _OFF64_T_
#define _OFF64_T_
typedef long long off64_t;
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _TYPES_H_ */

View File

@ -0,0 +1,6 @@
/*
* This file is part of the Mingw32 package.
*
* unistd.h maps (roughly) to io.h
*/
#include <io.h>

View File

@ -0,0 +1,82 @@
/*
* utime.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Support for the utime function.
*
*/
#ifndef _UTIME_H_
#define _UTIME_H_
/* All the headers include this file. */
#include <_mingw.h>
#define __need_wchar_t
#define __need_size_t
#ifndef RC_INVOKED
#include <stddef.h>
#endif /* Not RC_INVOKED */
#include <sys/types.h>
#ifndef RC_INVOKED
/*
* Structure used by _utime function.
*/
struct _utimbuf
{
time_t actime; /* Access time */
time_t modtime; /* Modification time */
};
#ifndef _NO_OLDNAMES
/* NOTE: Must be the same as _utimbuf above. */
struct utimbuf
{
time_t actime;
time_t modtime;
};
#endif /* Not _NO_OLDNAMES */
struct __utimbuf64
{
__time64_t actime;
__time64_t modtime;
};
#ifdef __cplusplus
extern "C" {
#endif
_CRTIMP int __cdecl _utime (const char*, struct _utimbuf*);
#ifndef _NO_OLDNAMES
_CRTIMP int __cdecl utime (const char*, struct utimbuf*);
#endif /* Not _NO_OLDNAMES */
_CRTIMP int __cdecl _futime (int, struct _utimbuf*);
/* The wide character version, only available for MSVCRT versions of the
* C runtime library. */
#ifdef __MSVCRT__
_CRTIMP int __cdecl _wutime (const wchar_t*, struct _utimbuf*);
#endif /* MSVCRT runtime */
/* These require newer versions of msvcrt.dll (6.10 or higher). */
#if __MSVCRT_VERSION__ >= 0x0601
_CRTIMP int __cdecl _utime64 (const char*, struct __utimbuf64*);
_CRTIMP int __cdecl _wutime64 (const wchar_t*, struct __utimbuf64*);
_CRTIMP int __cdecl _futime64 (int, struct __utimbuf64*);
#endif /* __MSVCRT_VERSION__ >= 0x0601 */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _UTIME_H_ */

View File

@ -0,0 +1,397 @@
/*
* tchar.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Unicode mapping layer for the standard C library. By including this
* file and using the 't' names for string functions
* (eg. _tprintf) you can make code which can be easily adapted to both
* Unicode and non-unicode environments. In a unicode enabled compile define
* _UNICODE before including tchar.h, otherwise the standard non-unicode
* library functions will be used.
*
* Note that you still need to include string.h or stdlib.h etc. to define
* the appropriate functions. Also note that there are several defines
* included for non-ANSI functions which are commonly available (but using
* the convention of prepending an underscore to non-ANSI library function
* names).
*
*/
#ifndef _TCHAR_H_
#define _TCHAR_H_
/* All the headers include this file. */
#include <_mingw.h>
/*
* NOTE: This tests _UNICODE, which is different from the UNICODE define
* used to differentiate Win32 API calls.
*/
#ifdef _UNICODE
/*
* Use TCHAR instead of char or wchar_t. It will be appropriately translated
* if _UNICODE is correctly defined (or not).
*/
#ifndef _TCHAR_DEFINED
#ifndef RC_INVOKED
typedef wchar_t TCHAR;
typedef wchar_t _TCHAR;
#endif /* Not RC_INVOKED */
#define _TCHAR_DEFINED
#endif
/*
* __TEXT is a private macro whose specific use is to force the expansion of a
* macro passed as an argument to the macros _T or _TEXT. DO NOT use this
* macro within your programs. It's name and function could change without
* notice.
*/
#define __TEXT(q) L##q
/* for porting from other Windows compilers */
#if 0 /* no wide startup module */
#define _tmain wmain
#define _tWinMain wWinMain
#define _tenviron _wenviron
#define __targv __wargv
#endif
/*
* Unicode functions
*/
#define _tprintf wprintf
#define _ftprintf fwprintf
#define _stprintf swprintf
#define _sntprintf _snwprintf
#define _vtprintf vwprintf
#define _vftprintf vfwprintf
#define _vstprintf vswprintf
#define _vsntprintf _vsnwprintf
#define _tscanf wscanf
#define _ftscanf fwscanf
#define _stscanf swscanf
#define _fgettc fgetwc
#define _fgettchar _fgetwchar
#define _fgetts fgetws
#define _fputtc fputwc
#define _fputtchar _fputwchar
#define _fputts fputws
#define _gettc getwc
#define _getts _getws
#define _puttc putwc
#define _puttchar putwchar
#define _putts _putws
#define _ungettc ungetwc
#define _tcstod wcstod
#define _tcstol wcstol
#define _tcstoul wcstoul
#define _itot _itow
#define _ltot _ltow
#define _ultot _ultow
#define _ttoi _wtoi
#define _ttol _wtol
#define _tcscat wcscat
#define _tcschr wcschr
#define _tcscmp wcscmp
#define _tcscpy wcscpy
#define _tcscspn wcscspn
#define _tcslen wcslen
#define _tcsncat wcsncat
#define _tcsncmp wcsncmp
#define _tcsncpy wcsncpy
#define _tcspbrk wcspbrk
#define _tcsrchr wcsrchr
#define _tcsspn wcsspn
#define _tcsstr wcsstr
#define _tcstok wcstok
#define _tcsdup _wcsdup
#define _tcsicmp _wcsicmp
#define _tcsnicmp _wcsnicmp
#define _tcsnset _wcsnset
#define _tcsrev _wcsrev
#define _tcsset _wcsset
#define _tcslwr _wcslwr
#define _tcsupr _wcsupr
#define _tcsxfrm wcsxfrm
#define _tcscoll wcscoll
#define _tcsicoll _wcsicoll
#define _istalpha iswalpha
#define _istupper iswupper
#define _istlower iswlower
#define _istdigit iswdigit
#define _istxdigit iswxdigit
#define _istspace iswspace
#define _istpunct iswpunct
#define _istalnum iswalnum
#define _istprint iswprint
#define _istgraph iswgraph
#define _istcntrl iswcntrl
#define _istascii iswascii
#define _totupper towupper
#define _totlower towlower
#define _tcsftime wcsftime
/* Macro functions */
#define _tcsdec _wcsdec
#define _tcsinc _wcsinc
#define _tcsnbcnt _wcsncnt
#define _tcsnccnt _wcsncnt
#define _tcsnextc _wcsnextc
#define _tcsninc _wcsninc
#define _tcsspnp _wcsspnp
#define _wcsdec(_wcs1, _wcs2) ((_wcs1)>=(_wcs2) ? NULL : (_wcs2)-1)
#define _wcsinc(_wcs) ((_wcs)+1)
#define _wcsnextc(_wcs) ((unsigned int) *(_wcs))
#define _wcsninc(_wcs, _inc) (((_wcs)+(_inc)))
#define _wcsncnt(_wcs, _cnt) ((wcslen(_wcs)>_cnt) ? _count : wcslen(_wcs))
#define _wcsspnp(_wcs1, _wcs2) ((*((_wcs1)+wcsspn(_wcs1,_wcs2))) ? ((_wcs1)+wcsspn(_wcs1,_wcs2)) : NULL)
#if 1 /* defined __MSVCRT__ */
/*
* These wide functions not in crtdll.dll.
* Define macros anyway so that _wfoo rather than _tfoo is undefined
*/
#define _ttoi64 _wtoi64
#define _i64tot _i64tow
#define _ui64tot _ui64tow
#define _tasctime _wasctime
#define _tctime _wctime
#define _tstrdate _wstrdate
#define _tstrtime _wstrtime
#define _tutime _wutime
#define _tcsnccoll _wcsncoll
#define _tcsncoll _wcsncoll
#define _tcsncicoll _wcsnicoll
#define _tcsnicoll _wcsnicoll
#define _taccess _waccess
#define _tchmod _wchmod
#define _tcreat _wcreat
#define _tfindfirst _wfindfirst
#define _tfindnext _wfindnext
#define _tfdopen _wfdopen
#define _tfopen _wfopen
#define _tfsopen _wfsopen
#define _tgetenv _wgetenv
#define _tputenv _wputenv
#define _tsearchenv _wsearchenv
#define _tmakepath _wmakepath
#define _tsplitpath _wsplitpath
#define _tfullpath _wfullpath
#define _tmktemp _wmktemp
#define _topen _wopen
#define _tremove _wremove
#define _trename _wrename
#define _tsopen _wsopen
#define _tsetlocale _wsetlocale
#define _tunlink _wunlink
#define _tfinddata_t _wfinddata_t
#define _tfindfirsti64 _wfindfirsti64
#define _tfindnexti64 _wfindnexti64
#define _tfinddatai64_t _wfinddatai64_t
#define _tchdir _wchdir
#define _tgetcwd _wgetcwd
#define _tgetdcwd _wgetdcwd
#define _tmkdir _wmkdir
#define _trmdir _wrmdir
#define _tstat _wstat
#endif /* __MSVCRT__ */
/* dirent structures and functions */
#define _tdirent _wdirent
#define _TDIR _WDIR
#define _topendir _wopendir
#define _tclosedir _wclosedir
#define _treaddir _wreaddir
#define _trewinddir _wrewinddir
#define _ttelldir _wtelldir
#define _tseekdir _wseekdir
#else /* Not _UNICODE */
/*
* TCHAR, the type you should use instead of char.
*/
#ifndef _TCHAR_DEFINED
#ifndef RC_INVOKED
typedef char TCHAR;
typedef char _TCHAR;
#endif
#define _TCHAR_DEFINED
#endif
/*
* __TEXT is a private macro whose specific use is to force the expansion of a
* macro passed as an argument to the macros _T or _TEXT. DO NOT use this
* macro within your programs. It's name and function could change without
* notice.
*/
#define __TEXT(q) q
/* for porting from other Windows compilers */
#define _tmain main
#define _tWinMain WinMain
#define _tenviron _environ
#define __targv __argv
/*
* Non-unicode (standard) functions
*/
#define _tprintf printf
#define _ftprintf fprintf
#define _stprintf sprintf
#define _sntprintf _snprintf
#define _vtprintf vprintf
#define _vftprintf vfprintf
#define _vstprintf vsprintf
#define _vsntprintf _vsnprintf
#define _tscanf scanf
#define _ftscanf fscanf
#define _stscanf sscanf
#define _fgettc fgetc
#define _fgettchar _fgetchar
#define _fgetts fgets
#define _fputtc fputc
#define _fputtchar _fputchar
#define _fputts fputs
#define _tfdopen _fdopen
#define _tfopen fopen
#define _tfsopen _fsopen
#define _tgetenv getenv
#define _tputenv _putenv
#define _tsearchenv _searchenv
#define _tmakepath _makepath
#define _tsplitpath _splitpath
#define _tfullpath _fullpath
#define _gettc getc
#define _getts gets
#define _puttc putc
#define _puttchar putchar
#define _putts puts
#define _ungettc ungetc
#define _tcstod strtod
#define _tcstol strtol
#define _tcstoul strtoul
#define _itot _itoa
#define _ltot _ltoa
#define _ultot _ultoa
#define _ttoi atoi
#define _ttol atol
#define _tcscat strcat
#define _tcschr strchr
#define _tcscmp strcmp
#define _tcscpy strcpy
#define _tcscspn strcspn
#define _tcslen strlen
#define _tcsncat strncat
#define _tcsncmp strncmp
#define _tcsncpy strncpy
#define _tcspbrk strpbrk
#define _tcsrchr strrchr
#define _tcsspn strspn
#define _tcsstr strstr
#define _tcstok strtok
#define _tcsdup _strdup
#define _tcsicmp _stricmp
#define _tcsnicmp _strnicmp
#define _tcsnset _strnset
#define _tcsrev _strrev
#define _tcsset _strset
#define _tcslwr _strlwr
#define _tcsupr _strupr
#define _tcsxfrm strxfrm
#define _tcscoll strcoll
#define _tcsicoll _stricoll
#define _istalpha isalpha
#define _istupper isupper
#define _istlower islower
#define _istdigit isdigit
#define _istxdigit isxdigit
#define _istspace isspace
#define _istpunct ispunct
#define _istalnum isalnum
#define _istprint isprint
#define _istgraph isgraph
#define _istcntrl iscntrl
#define _istascii isascii
#define _totupper toupper
#define _totlower tolower
#define _tasctime asctime
#define _tctime ctime
#define _tstrdate _strdate
#define _tstrtime _strtime
#define _tutime _utime
#define _tcsftime strftime
/* Macro functions */
#define _tcsdec _strdec
#define _tcsinc _strinc
#define _tcsnbcnt _strncnt
#define _tcsnccnt _strncnt
#define _tcsnextc _strnextc
#define _tcsninc _strninc
#define _tcsspnp _strspnp
#define _strdec(_str1, _str2) ((_str1)>=(_str2) ? NULL : (_str2)-1)
#define _strinc(_str) ((_str)+1)
#define _strnextc(_str) ((unsigned int) *(_str))
#define _strninc(_str, _inc) (((_str)+(_inc)))
#define _strncnt(_str, _cnt) ((strlen(_str)>_cnt) ? _count : strlen(_str))
#define _strspnp(_str1, _str2) ((*((_str1)+strspn(_str1,_str2))) ? ((_str1)+strspn(_str1,_str2)) : NULL)
#define _tchmod _chmod
#define _tcreat _creat
#define _tfindfirst _findfirst
#define _tfindnext _findnext
#define _tmktemp _mktemp
#define _topen _open
#define _taccess _access
#define _tremove remove
#define _trename rename
#define _tsopen _sopen
#define _tsetlocale setlocale
#define _tunlink _unlink
#define _tfinddata_t _finddata_t
#define _tchdir _chdir
#define _tgetcwd _getcwd
#define _tgetdcwd _getdcwd
#define _tmkdir _mkdir
#define _trmdir _rmdir
#define _tstat _stat
#if 1 /* defined __MSVCRT__ */
/* Not in crtdll.dll. Define macros anyway? */
#define _ttoi64 _atoi64
#define _i64tot _i64toa
#define _ui64tot _ui64toa
#define _tcsnccoll _strncoll
#define _tcsncoll _strncoll
#define _tcsncicoll _strnicoll
#define _tcsnicoll _strnicoll
#define _tfindfirsti64 _findfirsti64
#define _tfindnexti64 _findnexti64
#define _tfinddatai64_t _finddatai64_t
#endif /* __MSVCRT__ */
/* dirent structures and functions */
#define _tdirent dirent
#define _TDIR DIR
#define _topendir opendir
#define _tclosedir closedir
#define _treaddir readdir
#define _trewinddir rewinddir
#define _ttelldir telldir
#define _tseekdir seekdir
#endif /* Not _UNICODE */
/*
* UNICODE a constant string when _UNICODE is defined else returns the string
* unmodified. Also defined in w32api/winnt.h.
*/
#define _TEXT(x) __TEXT(x)
#define _T(x) __TEXT(x)
#endif /* Not _TCHAR_H_ */

View File

@ -0,0 +1,217 @@
/*
* time.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Date and time functions and types.
*
*/
#ifndef _TIME_H_
#define _TIME_H_
/* All the headers include this file. */
#include <_mingw.h>
#define __need_wchar_t
#define __need_size_t
#define __need_NULL
#ifndef RC_INVOKED
#include <stddef.h>
#endif /* Not RC_INVOKED */
/*
* 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 ((clock_t)1000)
#define CLK_TCK CLOCKS_PER_SEC
#ifndef RC_INVOKED
/*
* A type for storing the current time and date. This is the number of
* seconds since midnight Jan 1, 1970.
* NOTE: This is also defined in non-ISO sys/types.h.
*/
#ifndef _TIME_T_DEFINED
typedef long time_t;
#define _TIME_T_DEFINED
#endif
#ifndef __STRICT_ANSI__
/* A 64-bit time_t to get to Y3K */
#ifndef _TIME64_T_DEFINED
typedef __int64 __time64_t;
#define _TIME64_T_DEFINED
#endif
#endif
/*
* A type for measuring processor time (in clock ticks).
*/
#ifndef _CLOCK_T_DEFINED
typedef long clock_t;
#define _CLOCK_T_DEFINED
#endif
#ifndef _TM_DEFINED
/*
* A structure for storing all kinds of useful information about the
* current (or another) time.
*/
struct tm
{
int tm_sec; /* Seconds: 0-59 (K&R says 0-61?) */
int tm_min; /* Minutes: 0-59 */
int tm_hour; /* Hours since midnight: 0-23 */
int tm_mday; /* Day of the month: 1-31 */
int tm_mon; /* Months *since* january: 0-11 */
int tm_year; /* Years since 1900 */
int tm_wday; /* Days since Sunday (0-6) */
int tm_yday; /* Days since Jan. 1: 0-365 */
int tm_isdst; /* +1 Daylight Savings Time, 0 No DST,
* -1 don't know */
};
#define _TM_DEFINED
#endif
#ifdef __cplusplus
extern "C" {
#endif
_CRTIMP clock_t __cdecl clock (void);
_CRTIMP time_t __cdecl time (time_t*);
_CRTIMP double __cdecl difftime (time_t, time_t);
_CRTIMP time_t __cdecl mktime (struct tm*);
/*
* 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...
*/
_CRTIMP char* __cdecl asctime (const struct tm*);
_CRTIMP char* __cdecl ctime (const time_t*);
_CRTIMP struct tm* __cdecl gmtime (const time_t*);
_CRTIMP struct tm* __cdecl localtime (const time_t*);
_CRTIMP size_t __cdecl strftime (char*, size_t, const char*, const struct tm*);
#ifndef __STRICT_ANSI__
extern _CRTIMP void __cdecl _tzset (void);
#ifndef _NO_OLDNAMES
extern _CRTIMP void __cdecl tzset (void);
#endif
_CRTIMP char* __cdecl _strdate(char*);
_CRTIMP char* __cdecl _strtime(char*);
/* These require newer versions of msvcrt.dll (6.10 or higher). */
#if __MSVCRT_VERSION__ >= 0x0601
_CRTIMP __time64_t __cdecl _time64( __time64_t);
_CRTIMP __time64_t __cdecl _mktime64 (struct tm*);
_CRTIMP char* __cdecl _ctime64 (const __time64_t*);
_CRTIMP struct tm* __cdecl _gmtime64 (const __time64_t*);
_CRTIMP struct tm* __cdecl _localtime64 (const __time64_t*);
#endif /* __MSVCRT_VERSION__ >= 0x0601 */
/*
* _daylight: non zero if daylight savings time is used.
* _timezone: difference in seconds between GMT and local time.
* _tzname: standard/daylight savings time zone names (an array with two
* elements).
*/
#ifdef __MSVCRT__
/* These are for compatibility with pre-VC 5.0 suppied MSVCRT. */
extern _CRTIMP int* __cdecl __p__daylight (void);
extern _CRTIMP long* __cdecl __p__timezone (void);
extern _CRTIMP char** __cdecl __p__tzname (void);
__MINGW_IMPORT int _daylight;
__MINGW_IMPORT long _timezone;
__MINGW_IMPORT char *_tzname[2];
#else /* not __MSVCRT (ie. crtdll) */
#ifndef __DECLSPEC_SUPPORTED
extern int* _imp___daylight_dll;
extern long* _imp___timezone_dll;
extern char** _imp___tzname;
#define _daylight (*_imp___daylight_dll)
#define _timezone (*_imp___timezone_dll)
#define _tzname (*_imp___tzname)
#else /* __DECLSPEC_SUPPORTED */
__MINGW_IMPORT int _daylight_dll;
__MINGW_IMPORT long _timezone_dll;
__MINGW_IMPORT char* _tzname[2];
#define _daylight _daylight_dll
#define _timezone _timezone_dll
#endif /* __DECLSPEC_SUPPORTED */
#endif /* not __MSVCRT__ */
#ifndef _NO_OLDNAMES
#ifdef __MSVCRT__
/* These go in the oldnames import library for MSVCRT. */
__MINGW_IMPORT int daylight;
__MINGW_IMPORT long timezone;
__MINGW_IMPORT char *tzname[2];
#else /* not __MSVCRT__ */
/* CRTDLL is royally messed up when it comes to these macros.
TODO: import and alias these via oldnames import library instead
of macros. */
#define daylight _daylight
/* NOTE: timezone not defined because it would conflict with sys/timeb.h.
Also, tzname used to a be macro, but now it's in moldname. */
__MINGW_IMPORT char *tzname[2];
#endif /* not __MSVCRT__ */
#endif /* Not _NO_OLDNAMES */
#endif /* Not __STRICT_ANSI__ */
#ifndef _WTIME_DEFINED
/* wide function prototypes, also declared in wchar.h */
#ifndef __STRICT_ANSI__
#ifdef __MSVCRT__
_CRTIMP wchar_t* __cdecl _wasctime(const struct tm*);
_CRTIMP wchar_t* __cdecl _wctime(const time_t*);
_CRTIMP wchar_t* __cdecl _wstrdate(wchar_t*);
_CRTIMP wchar_t* __cdecl _wstrtime(wchar_t*);
#if __MSVCRT_VERSION__ >= 0x0601
_CRTIMP wchar_t* __cdecl _wctime64 (const __time64_t*);
#endif
#endif /* __MSVCRT__ */
#endif /* __STRICT_ANSI__ */
_CRTIMP size_t __cdecl wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
#define _WTIME_DEFINED
#endif /* _WTIME_DEFINED */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _TIME_H_ */

View File

@ -0,0 +1,33 @@
/*
* This file is part of the Mingw32 package.
*
* unistd.h maps (roughly) to io.h
*/
#ifndef _UNISTD_H
#define _UNISTD_H
#include <io.h>
#include <process.h>
#define __UNISTD_GETOPT__
#include <getopt.h>
#undef __UNISTD_GETOPT__
#ifdef __cplusplus
extern "C" {
#endif
/* This is defined as a real library function to allow autoconf
to verify its existence. */
int ftruncate(int, off_t);
__CRT_INLINE int ftruncate(int __fd, off_t __length)
{
return _chsize (__fd, __length);
}
#ifdef __cplusplus
}
#endif
#endif /* _UNISTD_H */

View File

@ -0,0 +1 @@
#include <sys/utime.h>

View File

@ -0,0 +1,4 @@
/*
* TODO: Nothing here yet. Should provide UNIX compatibility constants
* comparible to those in limits.h and float.h.
*/

View File

@ -0,0 +1,7 @@
/*
* This is just an RC_INVOKED guard for the real varargs.h
* fixincluded in gcc system dir. One day we will delete this file.
*/
#ifndef RC_INVOKED
#include_next<varargs.h>
#endif

View File

@ -0,0 +1,464 @@
/*
* wchar.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* 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.
*
*/
#ifndef _WCHAR_H_
#define _WCHAR_H_
/* All the headers include this file. */
#include <_mingw.h>
#ifndef RC_INVOKED
#define __need_size_t
#define __need_wint_t
#define __need_wchar_t
#define __need_NULL
#include <stddef.h>
#ifndef __VALIST
#if defined __GNUC__ && __GNUC__ >= 3
#define __need___va_list
#include <stdarg.h>
#define __VALIST __builtin_va_list
#else
#define __VALIST char*
#endif
#endif
#endif /* Not RC_INVOKED */
/*
* MSDN says that isw* char classifications are in wchar.h and wctype.h.
* Although the wctype names are ANSI, their exposure in this header is
* not.
*/
#include <wctype.h>
#ifndef __STRICT_ANSI__
/* This is necessary to support the the non-ANSI wchar declarations
here. */
#include <sys/types.h>
#endif /* __STRICT_ANSI__ */
#define WCHAR_MIN 0
#define WCHAR_MAX ((wchar_t)-1)
#ifndef WEOF
#define WEOF (wchar_t)(0xFFFF)
#endif
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _FILE_DEFINED /* Also in stdio.h */
#define _FILE_DEFINED
typedef struct _iobuf
{
char* _ptr;
int _cnt;
char* _base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char* _tmpfname;
} FILE;
#endif /* Not _FILE_DEFINED */
#ifndef _TIME_T_DEFINED /* Also in time.h */
typedef long time_t;
#define _TIME_T_DEFINED
#endif
#ifndef _TM_DEFINED /* Also in time.h */
struct tm {
int tm_sec; /* seconds after the minute - [0,59] */
int tm_min; /* minutes after the hour - [0,59] */
int tm_hour; /* hours since midnight - [0,23] */
int tm_mday; /* day of the month - [1,31] */
int tm_mon; /* months since January - [0,11] */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday - [0,6] */
int tm_yday; /* days since January 1 - [0,365] */
int tm_isdst; /* daylight savings time flag */
};
#define _TM_DEFINED
#endif
#ifndef _WSTDIO_DEFINED
/* Also in stdio.h - keep in sync */
_CRTIMP int __cdecl fwprintf (FILE*, const wchar_t*, ...);
_CRTIMP int __cdecl wprintf (const wchar_t*, ...);
_CRTIMP int __cdecl swprintf (wchar_t*, const wchar_t*, ...);
_CRTIMP int __cdecl _snwprintf (wchar_t*, size_t, const wchar_t*, ...);
_CRTIMP int __cdecl vfwprintf (FILE*, const wchar_t*, __VALIST);
_CRTIMP int __cdecl vwprintf (const wchar_t*, __VALIST);
_CRTIMP int __cdecl vswprintf (wchar_t*, const wchar_t*, __VALIST);
_CRTIMP int __cdecl _vsnwprintf (wchar_t*, size_t, const wchar_t*, __VALIST);
_CRTIMP int __cdecl fwscanf (FILE*, const wchar_t*, ...);
_CRTIMP int __cdecl wscanf (const wchar_t*, ...);
_CRTIMP int __cdecl swscanf (const wchar_t*, const wchar_t*, ...);
_CRTIMP wint_t __cdecl fgetwc (FILE*);
_CRTIMP wint_t __cdecl fputwc (wchar_t, FILE*);
_CRTIMP wint_t __cdecl ungetwc (wchar_t, FILE*);
#ifdef __MSVCRT__
_CRTIMP wchar_t* __cdecl fgetws (wchar_t*, int, FILE*);
_CRTIMP int __cdecl fputws (const wchar_t*, FILE*);
_CRTIMP wint_t __cdecl getwc (FILE*);
_CRTIMP wint_t __cdecl getwchar (void);
_CRTIMP wint_t __cdecl putwc (wint_t, FILE*);
_CRTIMP wint_t __cdecl putwchar (wint_t);
#ifndef __STRICT_ANSI__
_CRTIMP wchar_t* __cdecl _getws (wchar_t*);
_CRTIMP int __cdecl _putws (const wchar_t*);
_CRTIMP FILE* __cdecl _wfdopen(int, wchar_t *);
_CRTIMP FILE* __cdecl _wfopen (const wchar_t*, const wchar_t*);
_CRTIMP FILE* __cdecl _wfreopen (const wchar_t*, const wchar_t*, FILE*);
_CRTIMP FILE* __cdecl _wfsopen (const wchar_t*, const wchar_t*, int);
_CRTIMP wchar_t* __cdecl _wtmpnam (wchar_t*);
_CRTIMP wchar_t* __cdecl _wtempnam (const wchar_t*, const wchar_t*);
_CRTIMP int __cdecl _wrename (const wchar_t*, const wchar_t*);
_CRTIMP int __cdecl _wremove (const wchar_t*);
_CRTIMP void __cdecl _wperror (const wchar_t*);
_CRTIMP FILE* __cdecl _wpopen (const wchar_t*, const wchar_t*);
#endif /* __STRICT_ANSI__ */
#endif /* __MSVCRT__ */
#ifndef __NO_ISOCEXT /* externs in libmingwex.a */
int __cdecl snwprintf (wchar_t* s, size_t n, const wchar_t* format, ...);
__CRT_INLINE int __cdecl
vsnwprintf (wchar_t* s, size_t n, const wchar_t* format, __VALIST arg)
{ return _vsnwprintf ( s, n, format, arg);}
int __cdecl vwscanf (const wchar_t * __restrict__, __VALIST);
int __cdecl vfwscanf (FILE * __restrict__,
const wchar_t * __restrict__, __VALIST);
int __cdecl vswscanf (const wchar_t * __restrict__,
const wchar_t * __restrict__, __VALIST);
#endif
#define _WSTDIO_DEFINED
#endif /* _WSTDIO_DEFINED */
#ifndef _WSTDLIB_DEFINED /* also declared in stdlib.h */
_CRTIMP long __cdecl wcstol (const wchar_t*, wchar_t**, int);
_CRTIMP unsigned long __cdecl wcstoul (const wchar_t*, wchar_t**, int);
_CRTIMP double __cdecl wcstod (const wchar_t*, wchar_t**);
#if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */
__CRT_INLINE float __cdecl wcstof( const wchar_t *nptr, wchar_t **endptr)
{ return (wcstod(nptr, endptr)); }
long double __cdecl wcstold (const wchar_t * __restrict__, wchar_t ** __restrict__);
#endif /* __NO_ISOCEXT */
#define _WSTDLIB_DEFINED
#endif /* _WSTDLIB_DEFINED */
#ifndef _WTIME_DEFINED
#ifndef __STRICT_ANSI__
#ifdef __MSVCRT__
/* wide function prototypes, also declared in time.h */
_CRTIMP wchar_t* __cdecl _wasctime (const struct tm*);
_CRTIMP wchar_t* __cdecl _wctime (const time_t*);
_CRTIMP wchar_t* __cdecl _wstrdate (wchar_t*);
_CRTIMP wchar_t* __cdecl _wstrtime (wchar_t*);
#if __MSVCRT_VERSION__ >= 0x601
_CRTIMP wchar_t* __cdecl _wctime64 (const __time64_t*);
#endif
#endif /* __MSVCRT__ */
#endif /* __STRICT_ANSI__ */
_CRTIMP size_t __cdecl wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
#define _WTIME_DEFINED
#endif /* _WTIME_DEFINED */
#ifndef _WSTRING_DEFINED
/*
* Unicode versions of the standard string calls.
* Also in string.h.
*/
_CRTIMP wchar_t* __cdecl wcscat (wchar_t*, const wchar_t*);
_CRTIMP wchar_t* __cdecl wcschr (const wchar_t*, wchar_t);
_CRTIMP int __cdecl wcscmp (const wchar_t*, const wchar_t*);
_CRTIMP int __cdecl wcscoll (const wchar_t*, const wchar_t*);
_CRTIMP wchar_t* __cdecl wcscpy (wchar_t*, const wchar_t*);
_CRTIMP size_t __cdecl wcscspn (const wchar_t*, const wchar_t*);
/* Note: _wcserror requires __MSVCRT_VERSION__ >= 0x0700. */
_CRTIMP size_t __cdecl wcslen (const wchar_t*);
_CRTIMP wchar_t* __cdecl wcsncat (wchar_t*, const wchar_t*, size_t);
_CRTIMP int __cdecl wcsncmp(const wchar_t*, const wchar_t*, size_t);
_CRTIMP wchar_t* __cdecl wcsncpy(wchar_t*, const wchar_t*, size_t);
_CRTIMP wchar_t* __cdecl wcspbrk(const wchar_t*, const wchar_t*);
_CRTIMP wchar_t* __cdecl wcsrchr(const wchar_t*, wchar_t);
_CRTIMP size_t __cdecl wcsspn(const wchar_t*, const wchar_t*);
_CRTIMP wchar_t* __cdecl wcsstr(const wchar_t*, const wchar_t*);
_CRTIMP wchar_t* __cdecl wcstok(wchar_t*, const wchar_t*);
_CRTIMP size_t __cdecl wcsxfrm(wchar_t*, const wchar_t*, size_t);
#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
_CRTIMP wchar_t* __cdecl _wcsdup (const wchar_t*);
_CRTIMP int __cdecl _wcsicmp (const wchar_t*, const wchar_t*);
_CRTIMP int __cdecl _wcsicoll (const wchar_t*, const wchar_t*);
_CRTIMP wchar_t* __cdecl _wcslwr (wchar_t*);
_CRTIMP int __cdecl _wcsnicmp (const wchar_t*, const wchar_t*, size_t);
_CRTIMP wchar_t* __cdecl _wcsnset (wchar_t*, wchar_t, size_t);
_CRTIMP wchar_t* __cdecl _wcsrev (wchar_t*);
_CRTIMP wchar_t* __cdecl _wcsset (wchar_t*, wchar_t);
_CRTIMP wchar_t* __cdecl _wcsupr (wchar_t*);
#ifdef __MSVCRT__
_CRTIMP int __cdecl _wcsncoll(const wchar_t*, const wchar_t*, size_t);
_CRTIMP int __cdecl _wcsnicoll(const wchar_t*, const wchar_t*, size_t);
#if __MSVCRT_VERSION__ >= 0x0700
_CRTIMP wchar_t* __cdecl _wcserror(int);
_CRTIMP wchar_t* __cdecl __wcserror(const wchar_t*);
#endif
#endif
#ifndef _NO_OLDNAMES
/* NOTE: There is no _wcscmpi, but this is for compatibility. */
__CRT_INLINE int __cdecl
wcscmpi (const wchar_t * __ws1, const wchar_t * __ws2)
{return _wcsicmp (__ws1, __ws2);}
_CRTIMP wchar_t* __cdecl wcsdup (const wchar_t*);
_CRTIMP int __cdecl wcsicmp (const wchar_t*, const wchar_t*);
_CRTIMP int __cdecl wcsicoll (const wchar_t*, const wchar_t*);
_CRTIMP wchar_t* __cdecl wcslwr (wchar_t*);
_CRTIMP int __cdecl wcsnicmp (const wchar_t*, const wchar_t*, size_t);
_CRTIMP wchar_t* __cdecl wcsnset (wchar_t*, wchar_t, size_t);
_CRTIMP wchar_t* __cdecl wcsrev (wchar_t*);
_CRTIMP wchar_t* __cdecl wcsset (wchar_t*, wchar_t);
_CRTIMP wchar_t* __cdecl wcsupr (wchar_t*);
#endif /* Not _NO_OLDNAMES */
#endif /* Not strict ANSI */
#define _WSTRING_DEFINED
#endif /* _WSTRING_DEFINED */
/* These are resolved by -lmsvcp60 */
/* If you don't have msvcp60.dll in your windows system directory, you can
easily obtain it with a search from your favorite search engine. */
#ifndef __STRICT_ANSI__
typedef wchar_t _Wint_t;
#endif
typedef int mbstate_t;
wint_t __cdecl btowc(int);
size_t __cdecl mbrlen(const char *, size_t, mbstate_t *);
size_t __cdecl mbrtowc(wchar_t *, const char *, size_t, mbstate_t *);
size_t __cdecl mbsrtowcs(wchar_t *, const char **, size_t, mbstate_t *);
size_t __cdecl wcrtomb(char *, wchar_t, mbstate_t *);
size_t __cdecl wcsrtombs(char *, const wchar_t **, size_t, mbstate_t *);
int __cdecl wctob(wint_t);
#ifndef __NO_ISOCEXT /* these need static lib libmingwex.a */
__CRT_INLINE int __cdecl fwide(FILE* __UNUSED_PARAM(stream), int __UNUSED_PARAM(mode))
{return -1;} /* limited to byte orientation */
__CRT_INLINE int __cdecl mbsinit(const mbstate_t* __UNUSED_PARAM(ps))
{return 1;}
wchar_t* __cdecl wmemset(wchar_t* s, wchar_t c, size_t n);
wchar_t* __cdecl wmemchr(const wchar_t* s, wchar_t c, size_t n);
int wmemcmp(const wchar_t* s1, const wchar_t * s2, size_t n);
wchar_t* __cdecl wmemcpy(wchar_t* __restrict__ s1, const wchar_t* __restrict__ s2,
size_t n);
wchar_t* __cdecl wmemmove(wchar_t* s1, const wchar_t* s2, size_t n);
long long __cdecl wcstoll(const wchar_t* __restrict__ nptr,
wchar_t** __restrict__ endptr, int base);
unsigned long long __cdecl wcstoull(const wchar_t* __restrict__ nptr,
wchar_t ** __restrict__ endptr, int base);
#endif /* __NO_ISOCEXT */
#ifndef __STRICT_ANSI__
/* non-ANSI wide char functions from io.h, direct.h, sys/stat.h and locale.h. */
#ifndef _FSIZE_T_DEFINED
typedef unsigned long _fsize_t;
#define _FSIZE_T_DEFINED
#endif
#ifndef _WFINDDATA_T_DEFINED
struct _wfinddata_t {
unsigned attrib;
time_t time_create; /* -1 for FAT file systems */
time_t time_access; /* -1 for FAT file systems */
time_t time_write;
_fsize_t size;
wchar_t name[260]; /* may include spaces. */
};
struct _wfinddatai64_t {
unsigned attrib;
time_t time_create;
time_t time_access;
time_t time_write;
__int64 size;
wchar_t name[260];
};
struct __wfinddata64_t {
unsigned attrib;
__time64_t time_create;
__time64_t time_access;
__time64_t time_write;
_fsize_t size;
wchar_t name[260];
};
#define _WFINDDATA_T_DEFINED
#endif
/* Wide character versions. Also defined in io.h. */
/* CHECK: I believe these only exist in MSVCRT, and not in CRTDLL. Also
applies to other wide character versions? */
#if !defined (_WIO_DEFINED)
#if defined (__MSVCRT__)
#include <stdint.h> /* For intptr_t. */
_CRTIMP int __cdecl _waccess (const wchar_t*, int);
_CRTIMP int __cdecl _wchmod (const wchar_t*, int);
_CRTIMP int __cdecl _wcreat (const wchar_t*, int);
_CRTIMP long __cdecl _wfindfirst (const wchar_t*, struct _wfinddata_t *);
_CRTIMP int __cdecl _wfindnext (long, struct _wfinddata_t *);
_CRTIMP int __cdecl _wunlink (const wchar_t*);
_CRTIMP int __cdecl _wopen (const wchar_t*, int, ...);
_CRTIMP int __cdecl _wsopen (const wchar_t*, int, int, ...);
_CRTIMP wchar_t* __cdecl _wmktemp (wchar_t*);
_CRTIMP long __cdecl _wfindfirsti64 (const wchar_t*, struct _wfinddatai64_t*);
_CRTIMP int __cdecl _wfindnexti64 (long, struct _wfinddatai64_t*);
#if __MSVCRT_VERSION__ >= 0x0601
_CRTIMP intptr_t __cdecl _wfindfirst64(const wchar_t*, struct __wfinddata64_t*);
_CRTIMP intptr_t __cdecl _wfindnext64(intptr_t, struct __wfinddata64_t*);
#endif /* __MSVCRT_VERSION__ >= 0x0601 */
#endif /* defined (__MSVCRT__) */
#define _WIO_DEFINED
#endif /* _WIO_DEFINED */
#ifndef _WDIRECT_DEFINED
/* Also in direct.h */
#ifdef __MSVCRT__
_CRTIMP int __cdecl _wchdir (const wchar_t*);
_CRTIMP wchar_t* __cdecl _wgetcwd (wchar_t*, int);
_CRTIMP wchar_t* __cdecl _wgetdcwd (int, wchar_t*, int);
_CRTIMP int __cdecl _wmkdir (const wchar_t*);
_CRTIMP int __cdecl _wrmdir (const wchar_t*);
#endif /* __MSVCRT__ */
#define _WDIRECT_DEFINED
#endif /* _WDIRECT_DEFINED */
#ifndef _STAT_DEFINED
/*
* 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
{
_dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
_ino_t st_ino; /* Always zero ? */
_mode_t st_mode; /* See above constants */
short st_nlink; /* Number of links. */
short st_uid; /* User: Maybe significant on NT ? */
short st_gid; /* Group: Ditto */
_dev_t st_rdev; /* Seems useless (not even filled in) */
_off_t 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 */
};
struct stat
{
_dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
_ino_t st_ino; /* Always zero ? */
_mode_t st_mode; /* See above constants */
short st_nlink; /* Number of links. */
short st_uid; /* User: Maybe significant on NT ? */
short st_gid; /* Group: Ditto */
_dev_t st_rdev; /* Seems useless (not even filled in) */
_off_t 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 */
};
#if defined (__MSVCRT__)
struct _stati64 {
_dev_t st_dev;
_ino_t st_ino;
unsigned short st_mode;
short st_nlink;
short st_uid;
short st_gid;
_dev_t st_rdev;
__int64 st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
struct __stat64
{
_dev_t st_dev;
_ino_t st_ino;
_mode_t st_mode;
short st_nlink;
short st_uid;
short st_gid;
_dev_t st_rdev;
_off_t st_size;
__time64_t st_atime;
__time64_t st_mtime;
__time64_t st_ctime;
};
#endif /* __MSVCRT__ */
#define _STAT_DEFINED
#endif /* _STAT_DEFINED */
#if !defined ( _WSTAT_DEFINED)
/* also declared in sys/stat.h */
#if defined __MSVCRT__
_CRTIMP int __cdecl _wstat (const wchar_t*, struct _stat*);
_CRTIMP int __cdecl _wstati64 (const wchar_t*, struct _stati64*);
#if __MSVCRT_VERSION__ >= 0x0601
_CRTIMP int __cdecl _wstat64 (const wchar_t*, struct __stat64*);
#endif /* __MSVCRT_VERSION__ >= 0x0601 */
#endif /* __MSVCRT__ */
#define _WSTAT_DEFINED
#endif /* ! _WSTAT_DEFIND */
#ifndef _WLOCALE_DEFINED /* also declared in locale.h */
_CRTIMP wchar_t* __cdecl _wsetlocale (int, const wchar_t*);
#define _WLOCALE_DEFINED
#endif
#endif /* not __STRICT_ANSI__ */
#ifdef __cplusplus
} /* end of extern "C" */
#endif
#endif /* Not RC_INVOKED */
#endif /* not _WCHAR_H_ */

View File

@ -0,0 +1,142 @@
/*
* wctype.h
*
* Functions for testing wide character types and converting characters.
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Mumit Khan <khan@xraylith.wisc.edu>
*
* 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
* DISCLAIMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#ifndef _WCTYPE_H_
#define _WCTYPE_H_
/* All the headers include this file. */
#include <_mingw.h>
#define __need_wchar_t
#define __need_wint_t
#ifndef RC_INVOKED
#include <stddef.h>
#endif /* Not RC_INVOKED */
/*
* The following flags are used to tell iswctype and _isctype what character
* types you are looking for.
*/
#define _UPPER 0x0001
#define _LOWER 0x0002
#define _DIGIT 0x0004
#define _SPACE 0x0008
#define _PUNCT 0x0010
#define _CONTROL 0x0020
#define _BLANK 0x0040
#define _HEX 0x0080
#define _LEADBYTE 0x8000
#define _ALPHA 0x0103
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
#ifndef WEOF
#define WEOF (wchar_t)(0xFFFF)
#endif
#ifndef _WCTYPE_T_DEFINED
typedef wchar_t wctype_t;
#define _WCTYPE_T_DEFINED
#endif
/* Wide character equivalents - also in ctype.h */
_CRTIMP int __cdecl iswalnum(wint_t);
_CRTIMP int __cdecl iswalpha(wint_t);
_CRTIMP int __cdecl iswascii(wint_t);
_CRTIMP int __cdecl iswcntrl(wint_t);
_CRTIMP int __cdecl iswctype(wint_t, wctype_t);
_CRTIMP int __cdecl is_wctype(wint_t, wctype_t); /* Obsolete! */
_CRTIMP int __cdecl iswdigit(wint_t);
_CRTIMP int __cdecl iswgraph(wint_t);
_CRTIMP int __cdecl iswlower(wint_t);
_CRTIMP int __cdecl iswprint(wint_t);
_CRTIMP int __cdecl iswpunct(wint_t);
_CRTIMP int __cdecl iswspace(wint_t);
_CRTIMP int __cdecl iswupper(wint_t);
_CRTIMP int __cdecl iswxdigit(wint_t);
_CRTIMP wchar_t __cdecl towlower(wchar_t);
_CRTIMP wchar_t __cdecl towupper(wchar_t);
_CRTIMP int __cdecl isleadbyte (int);
/* Also in ctype.h */
#ifdef __DECLSPEC_SUPPORTED
__MINGW_IMPORT unsigned short _ctype[];
# ifdef __MSVCRT__
__MINGW_IMPORT unsigned short* _pctype;
# else /* CRTDLL */
__MINGW_IMPORT unsigned short* _pctype_dll;
# define _pctype _pctype_dll
# endif
#else /* ! __DECLSPEC_SUPPORTED */
extern unsigned short** _imp___ctype;
#define _ctype (*_imp___ctype)
# ifdef __MSVCRT__
extern unsigned short** _imp___pctype;
# define _pctype (*_imp___pctype)
# else /* CRTDLL */
extern unsigned short** _imp___pctype_dll;
# define _pctype (*_imp___pctype_dll)
# endif /* CRTDLL */
#endif /* __DECLSPEC_SUPPORTED */
#if !(defined (__NO_INLINE__) || defined(__NO_CTYPE_INLINES) \
|| defined(__WCTYPE_INLINES_DEFINED))
#define __WCTYPE_INLINES_DEFINED
__CRT_INLINE int __cdecl iswalnum(wint_t wc) {return (iswctype(wc,_ALPHA|_DIGIT));}
__CRT_INLINE int __cdecl iswalpha(wint_t wc) {return (iswctype(wc,_ALPHA));}
__CRT_INLINE int __cdecl iswascii(wint_t wc) {return ((wc & ~0x7F) ==0);}
__CRT_INLINE int __cdecl iswcntrl(wint_t wc) {return (iswctype(wc,_CONTROL));}
__CRT_INLINE int __cdecl iswdigit(wint_t wc) {return (iswctype(wc,_DIGIT));}
__CRT_INLINE int __cdecl iswgraph(wint_t wc) {return (iswctype(wc,_PUNCT|_ALPHA|_DIGIT));}
__CRT_INLINE int __cdecl iswlower(wint_t wc) {return (iswctype(wc,_LOWER));}
__CRT_INLINE int __cdecl iswprint(wint_t wc) {return (iswctype(wc,_BLANK|_PUNCT|_ALPHA|_DIGIT));}
__CRT_INLINE int __cdecl iswpunct(wint_t wc) {return (iswctype(wc,_PUNCT));}
__CRT_INLINE int __cdecl iswspace(wint_t wc) {return (iswctype(wc,_SPACE));}
__CRT_INLINE int __cdecl iswupper(wint_t wc) {return (iswctype(wc,_UPPER));}
__CRT_INLINE int __cdecl iswxdigit(wint_t wc) {return (iswctype(wc,_HEX));}
__CRT_INLINE int __cdecl isleadbyte(int c) {return (_pctype[(unsigned char)(c)] & _LEADBYTE);}
#endif /* !(defined(__NO_CTYPE_INLINES) || defined(__WCTYPE_INLINES_DEFINED)) */
typedef wchar_t wctrans_t;
_CRTIMP wint_t __cdecl towctrans(wint_t, wctrans_t);
_CRTIMP wctrans_t __cdecl wctrans(const char*);
_CRTIMP wctype_t __cdecl wctype(const char*);
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _WCTYPE_H_ */

19
RosBE-PPC/ovr/bootcd Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
#
# Create an iso that can be booted under qemu.
# For now, this is just to make ofwldr available to qemu. A disk image will
# still be required yet.
#
CD=output-ppc/ppcboot
I=$CD/install
TOOLS=`dirname $0`
mkdir -p $I
cp output-ppc/boot/freeldr/freeldr/ofwldr $I/yaboot
cp $TOOLS/ofboot.b $I
mkisofs -chrp-boot -U -part -hfs -T -r -l -J -A "ReactOS" -sysid PPC \
-V "ReactOS" -volset 1 -volset-size 1 -volset-seqno 1 \
-hfs-volid "ReactOS" -hfs-bless $I -map $TOOLS/hfsmap.lst \
-no-desktop -allow-multidot -o ppcboot.iso $CD

12
RosBE-PPC/ovr/hfsmap.lst Normal file
View File

@ -0,0 +1,12 @@
# ext. xlate creator type comment
.hqx Ascii 'BnHx' 'TEXT' "BinHex file"
.sit Raw 'SIT!' 'SITD' "StuffIT Expander"
.mov Raw 'TVOD' 'MooV' "QuickTime Movie"
.deb Raw 'Debn' 'bina' "Debian package"
.bin Raw 'ddsk' 'DDim' "Floppy or ramdisk image"
.img Raw 'ddsk' 'DDim' "Floppy or ramdisk image"
.b Raw 'UNIX' 'tbxi' "bootstrap"
yaboot Raw 'UNIX' 'boot' "bootstrap"
vmlinux Raw 'UNIX' 'boot' "bootstrap"
.conf Raw 'UNIX' 'conf' "bootstrap"
* Ascii '????' '????' "Text file"

20
RosBE-PPC/ovr/make Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
export PATH=tools/ppc.lost+found:$PATH
if [ ! -d tmp-ppc ] ; then
mkdir tmp-ppc || echo "Could not make temp dir"
fi
$OLDMAKE \
ARCH=powerpc \
HOST=mingw32-linux \
PREFIX=powerpc-unknown-elf \
ROS_TEMPORARY=tmp-ppc \
ROS_INTERMEDIATE=obj-ppc \
ROS_OUTPUT=output-ppc \
ROS_PREFIX=powerpc-unknown-elf \
ROS_INSTALL=rosppc \
ROS_AUTOMAKE=makefile.ppc \
ROS_RBUILDFLAGS=-rReactOS-ppc.rbuild \
$*

64
RosBE-PPC/ovr/ofboot.b Normal file
View File

@ -0,0 +1,64 @@
<CHRP-BOOT>
<COMPATIBLE>
MacRISC MacRISC3 MacRISC4
</COMPATIBLE>
<DESCRIPTION>
GNU/Linux PPC bootloader
</DESCRIPTION>
<BOOT-SCRIPT>
" screen" output
load-base release-load-area
boot cd:,\install\yaboot
</BOOT-SCRIPT>
<OS-BADGE-ICONS>
1010
000000000000F8FEACF6000000000000
0000000000F5FFFFFEFEF50000000000
00000000002BFAFEFAFCF70000000000
0000000000F65D5857812B0000000000
0000000000F5350B2F88560000000000
0000000000F6335708F8FE0000000000
00000000005600F600F5FD8100000000
00000000F9F8000000F5FAFFF8000000
000000008100F5F50000F6FEFE000000
000000F8F700F500F50000FCFFF70000
00000088F70000F50000F5FCFF2B0000
0000002F582A00F5000008ADE02C0000
00090B0A35A62B0000002D3B350A0000
000A0A0B0B3BF60000505E0B0A0B0A00
002E350B0B2F87FAFCF45F0B2E090000
00000007335FF82BF72B575907000000
000000000000ACFFFF81000000000000
000000000081FFFFFFFF810000000000
0000000000FBFFFFFFFFAC0000000000
000000000081DFDFDFFFFB0000000000
000000000081DD5F83FFFD0000000000
000000000081DDDF5EACFF0000000000
0000000000FDF981F981FFFF00000000
00000000FFACF9F9F981FFFFAC000000
00000000FFF98181F9F981FFFF000000
000000ACACF981F981F9F9FFFFAC0000
000000FFACF9F981F9F981FFFFFB0000
00000083DFFBF981F9F95EFFFFFC0000
005F5F5FDDFFFBF9F9F983DDDD5F0000
005F5F5F5FDD81F9F9E7DF5F5F5F5F00
0083DD5F5F83FFFFFFFFDF5F835F0000
000000FBDDDFACFBACFBDFDFFB000000
000000000000FFFFFFFF000000000000
0000000000FFFFFFFFFFFF0000000000
0000000000FFFFFFFFFFFF0000000000
0000000000FFFFFFFFFFFF0000000000
0000000000FFFFFFFFFFFF0000000000
0000000000FFFFFFFFFFFF0000000000
0000000000FFFFFFFFFFFFFF00000000
00000000FFFFFFFFFFFFFFFFFF000000
00000000FFFFFFFFFFFFFFFFFF000000
000000FFFFFFFFFFFFFFFFFFFFFF0000
000000FFFFFFFFFFFFFFFFFFFFFF0000
000000FFFFFFFFFFFFFFFFFFFFFF0000
00FFFFFFFFFFFFFFFFFFFFFFFFFF0000
00FFFFFFFFFFFFFFFFFFFFFFFFFFFF00
00FFFFFFFFFFFFFFFFFFFFFFFFFF0000
000000FFFFFFFFFFFFFFFFFFFF000000
</OS-BADGE-ICONS>
</CHRP-BOOT>

287
RosBE-PPC/pyhive/hbin.py Normal file
View File

@ -0,0 +1,287 @@
import struct
HCELL_NULL = 0xffffffff
HCELL_TYPE_MASK = 0x80000000
HCELL_BLOCK_MASK = 0x7ffff000
HCELL_OFFSET_MASK = 0x00000fff
HCELL_TYPE_SHIFT = 31
HCELL_BLOCK_SHIFT = 12
HCELL_OFFSET_SHIFT = 0
REG_KEY_VOLATILE_CELL = 1
REG_KEY_ROOT_CELL = 12
REG_KEY_LINK_CELL = 16
REG_KEY_NAME_PACKED = 32
REG_VALUE_NAME_PACKED = 1
USHORT = ">H"
ULONG = ">I"
QUAD = ">Q"
def roundup(n,gran):
return (n + (gran - 1)) & ~(gran - 1)
def pad(block,expsize):
if len(block) >= expsize:
return block
else:
return block + struct.pack(str(expsize - len(block))+"s","")
def round_pad(data,padto):
return pad(data,roundup(len(data),padto))
def chop(data,padto):
if len(data) > padto:
return data[:padto]
else:
return pad(data,padto)
class regval:
def __init__(self,name,type,value):
self.name = name
self.flags = REG_VALUE_NAME_PACKED
self.type = type
self.value = value
self.datacell = HCELL_NULL
def encode(self):
result = ""
for type,value in [
('2s', 'kv'),
(USHORT, len(self.name)),
(ULONG, len(self.value)),
(ULONG, self.datacell),
(ULONG, self.type),
(USHORT, self.flags),
(USHORT, 0)]:
result = result + struct.pack(type, value)
return result + \
round_pad(self.name, 4)
def makecell(self,regf):
self.datacell = regf.claim_write(self.value)
return regf.claim_write(self.encode())
class regkey:
def __init__(self,name,classname,flags):
self.name = name
self.classname = classname
self.flags = flags | REG_KEY_NAME_PACKED
self.values = []
self.subkeys = []
self.parentcell = HCELL_NULL
self.keylist = HCELL_NULL
self.valuelist = HCELL_NULL
self.seccell = HCELL_NULL
self.classnamecell = HCELL_NULL
self.maxname = 0
self.maxclass = 0
self.maxvaluename = 0
self.maxvaluedata = 0
self.maxdatalen = 0
def addsubkey(self,key):
self.subkeys.append(key)
def addvalue(self,val):
self.values.append(val)
self.maxvaluename = max(len(val.name),self.maxvaluename)
self.maxvaluedata = max(len(val.value),self.maxvaluedata)
def navigate(self,name):
for key in self.subkeys:
if key.name.lower() == name.lower():
return key
key = regkey(name,'',0)
self.addsubkey(key)
return key
def encode_header(self):
result = ""
for type,value in [
('2s', 'kn'),
(USHORT, self.flags),
(QUAD, 0),
(ULONG, 0),
(ULONG, self.parentcell),
(ULONG, len(self.subkeys)), # Persistent subkey count
(ULONG, 0),
(ULONG, self.keylist),
(ULONG, 0),
(ULONG, len(self.values)),
(ULONG, self.valuelist),
(ULONG, self.seccell),
(ULONG, self.classnamecell),
(ULONG, self.maxname),
(ULONG, self.maxclass),
(ULONG, self.maxvaluename),
(ULONG, self.maxvaluedata),
(ULONG, 0),
(USHORT, len(self.name)),
(USHORT, len(self.classname))
]:
result = result + struct.pack(type, value)
return result + \
round_pad(self.name,4) + \
round_pad(self.classname,4)
def size_header(self):
return len(self.encode_header())
def make_key_list_cell(self,regf,keycells):
len_of_cell = 4 + (8 * len(keycells))
cellid = regf.claim(len_of_cell)
data = struct.pack(">2sH", 'fl', len(keycells))
for name,cell in keycells:
data = data + struct.pack(">I4s", cell, chop(name,4))
regf.write(cellid, data)
return cellid
def make_value_list_cell(self,regf,valuecells):
len_of_cell = 4 * len(valuecells)
cellid = regf.claim(len_of_cell)
data = struct.pack(">"+str(len(valuecells))+"I",*valuecells)
regf.write(cellid, data)
return cellid
def makecell(self,regf):
valcells = []
keycells = []
mycell = regf.claim(self.size_header())
for val in self.values:
valcells.append(val.makecell(regf))
for key in self.subkeys:
key.parentcell = mycell
keycells.append((key.name,key.makecell(regf)))
self.keylist = self.make_key_list_cell(regf, keycells)
self.valuelist = self.make_value_list_cell(regf, valcells)
regf.write(mycell,self.encode_header())
return mycell
class hbin:
def __init__(self,index):
self.index = index
self.used = 32 # Header Size
self.size = 4096
self.usable = 4092
self.block = pad(self.encode_header(),self.size)
def encode_header(self):
result = ""
for type,value in [
("4s", "nibh"),
(ULONG, self.index * self.size),
(ULONG, self.size),
(ULONG, 0),
(ULONG, 0),
(QUAD, 0),
(ULONG, 0) ]:
result = result + struct.pack(type,value)
return result
def claim(self,bytes):
if roundup(self.used + (bytes+4),16) <= self.usable:
claimed = self.used
self.used = roundup(self.used + (bytes+4),16)
return claimed
else:
return None
def write(self,offset,data):
data = struct.pack(ULONG, ((0xffffffff+1)-roundup(len(data),16)) & 0xffffffff) + \
data
self.block = self.block[:offset] + data + self.block[offset+len(data):]
def export(self,outf):
self.block = pad(self.block[:self.used] + struct.pack(ULONG,0xffffffff), self.size)
outf.write(self.block)
class regf:
def __init__(self,rootkey):
self.bins = []
self.alloc_hbin()
self.blocksize = 4096
self.rootkey = rootkey
self.rootkey.flags = self.rootkey.flags | REG_KEY_ROOT_CELL
def addkey(self,regkey):
pathparts = regkey.split('\\')
curkey = self.rootkey
for i in xrange(1,len(pathparts)):
pp = pathparts[i]
if pp == 'CurrentControlSet':
pp = 'ControlSet001'
curkey = curkey.navigate(pp)
return curkey
def addkey_with_type(self,regkey,flags):
pathparts = regkey.split('\\')
curkey = self.rootkey
for i in xrange(1,len(pathparts)):
pp = pathparts[i]
if pp == 'CurrentControlSet':
pp = 'ControlSet001'
curkey = curkey.navigate(pp)
curkey.flags = flags
return curkey
def export(self,outf):
self.keycell = self.rootkey.makecell(self)
header = ""
for type,value in [
("4s", "fger"),
(ULONG, 1), # Seq
(ULONG, 1),
(QUAD, 0),
(ULONG, 1), # Major
(ULONG, 3), # Minor
(ULONG, 0), # Type Primary
(ULONG, 1), # Format
(ULONG, self.keycell),# Root Key
(ULONG, self.blocksize),# Block size
(ULONG, 1)]: # Cluster size
header = header + struct.pack(type,value)
header = pad(header,0x1fc)
# Compute checksum
hwords = struct.unpack(">"+str(len(header)/4)+"I",header)
checksum = 0
for i in xrange(0,len(hwords)):
checksum = checksum ^ hwords[i]
if checksum == 0xffffffff:
checksum = 0xfffffffe
if checksum == 0:
checksum = 1
header = header + struct.pack(ULONG,checksum & 0xffffffff)
# Write
outf.write(pad(header,self.blocksize))
for hbin in self.bins:
hbin.export(outf)
def alloc_hbin(self):
self.thebin = hbin(len(self.bins))
self.bins.append(self.thebin)
def claim(self,size):
offset = self.thebin.claim(size)
if offset is None:
self.alloc_hbin()
offset = self.thebin.claim(size)
return (self.thebin.index << HCELL_BLOCK_SHIFT) | offset
def write(self,cell,data):
bindex = (cell & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT
boffset = (cell & HCELL_OFFSET_MASK) >> HCELL_OFFSET_SHIFT
self.bins[bindex].write(boffset,data)
def claim_write(self,data):
hcell = self.claim(len(data))
self.write(hcell,data)
return hcell

View File

@ -0,0 +1,56 @@
import os
import os.path
import sys
import hbin
import reginf
regpaths = {
"default": "\Registry\User\.DEFAULT",
"sam": "\Registry\Machine\SAM",
"security": "\Registry\Machine\SECURITY",
"software": "\Registry\Machine\SOFTWARE",
"system": "\Registry\Machine\SYSTEM"
}
if __name__ == '__main__':
if len(sys.argv) < 3:
print sys.argv[0],'[inf-dir]','[hive-dir]'
sys.exit(1)
infdir = sys.argv[1]
hivedir = sys.argv[2]
ri = reginf.reginf()
for file in ["hivesys.inf","hivecls.inf","hivesft.inf","hivedef.inf"]:
lines = open(os.path.join(infdir,file)).read().split('\n')
curline = 0
while curline < len(lines):
regline,curline = reginf.nextline(lines,curline)
if regline != '':
ri.addentry(regline)
for key in regpaths:
outf = open(os.path.join(hivedir,key),"wb")
# Make the absolute root
rookey = hbin.regkey('','',0)
roothive = hbin.regf(rookey)
# Make a hive where we want it
thehive = hbin.regf(roothive.addkey(regpaths[key]))
# Import values into the hive (some may not be children of the target
# hive, but that's fine
for vline in ri.content:
if vline.iskey():
key = roothive.addkey_with_type(vline.keyname(),vline.flags())
elif not vline.empty():
key = roothive.addkey(vline.keyname())
key.addvalue(hbin.regval(vline.valuename(),vline.flags(),vline.bindata()))
# Now write our hive
thehive.export(outf)
outf.close()

149
RosBE-PPC/pyhive/reginf.py Normal file
View File

@ -0,0 +1,149 @@
import hbin
import struct
FLG_ADDREG_BINVALUETYPE = 1
FLG_ADDREG_NOCLOBBER = 2
FLG_ADDREG_DELVAL = 4
FLG_ADDREG_APPEND = 8
FLG_ADDREG_KEYONLY = 16
FLG_ADDREG_OVERWRITEONLY = 32
FLG_ADDREG_TYPE_SZ = 0
FLG_ADDREG_TYPE_MULTI_SZ = 0x00010000
FLG_ADDREG_TYPE_EXPAND_SZ = 0x00020000
FLG_ADDREG_TYPE_BINARY = FLG_ADDREG_BINVALUETYPE
FLG_ADDREG_TYPE_DWORD = 0x00010000 | FLG_ADDREG_BINVALUETYPE
FLG_ADDREG_TYPE_NONE = 0x00020000 | FLG_ADDREG_BINVALUETYPE
FLG_ADDREG_TYPE_MASK = 0xffff0000 | FLG_ADDREG_BINVALUETYPE
UNICODE = 'utf-16-be'
regkeys = {
"HKCR" : "\\Registry\\Machine\\SOFTWARE\\Classes\\",
"HKCU" : "\\Registry\\User\\.DEFAULT\\",
"HKLM" : "\\Registry\\Machine\\",
"HKU" : "\\Register\\User\\"
}
def stripcomment(text):
n = text.find(';')
if n != -1:
text = text[:n].strip()
return text
def nextline(linelist,curline):
rs = ""
stop = False
while curline < len(linelist) and \
(len(stripcomment(linelist[curline]).strip()) == 0 or \
linelist[curline] == '['):
curline = curline + 1
while not stop and curline < len(linelist):
theline = linelist[curline]
if len(theline) and theline[-1] == '\\':
theline = theline[:-1]
else:
stop = True
rs = rs + theline
curline = curline + 1
rs = stripcomment(rs).strip()
return rs,curline
def hexpand(st):
if len(st) > 2 and st[:2] == '0x':
return st
else:
return '0x'+st
class regelt:
def __init__(self,text):
result = []
curword = ""
quoted = 0
for ch in text:
if ch == ',':
if quoted == 2:
curword = curword + '"'
curword = curword.strip()
if len(curword) > 0 and curword[0] == '"':
curword = curword[1:-1]
result.append(curword.strip())
quoted = 0
curword = ""
elif ch == '"':
if quoted == 0:
quoted = 1
curword = curword + ch
elif quoted == 1:
quoted = 2
elif quoted == 2:
quoted = 1
curword = curword + '"'
else:
if quoted == 2:
quoted = 0
curword = curword + '"'
curword = curword + ch
if quoted == 2:
curword = curword + '"'
curword = curword.strip()
if len(curword) > 0 and curword[0] == '"':
curword = curword[1:-1]
result.append(curword.strip())
self.parsed = result
def empty(self):
return len(self.parsed) < 3 or len(self.parsed[0]) == 0
def keyname(self):
return regkeys[self.parsed[0]] + self.parsed[1]
def valuename(self):
return self.parsed[2]
def iskey(self):
return self.flags() & FLG_ADDREG_KEYONLY
def type(self):
return self.flags() & FLG_ADDREG_TYPE_MASK
def flags(self):
if len(self.parsed[3]) == 0:
return FLG_ADDREG_KEYONLY | FLG_ADDREG_NOCLOBBER
else:
return eval(hexpand(self.parsed[3]))
# Accumulate binary data for this value
def bindata(self):
f = self.type()
result = ''
unul = chr(0) + chr(0)
if f == FLG_ADDREG_TYPE_SZ or \
f == FLG_ADDREG_TYPE_EXPAND_SZ:
result = unicode(self.parsed[4]).encode(UNICODE) + unul
elif f == FLG_ADDREG_TYPE_MULTI_SZ:
for i in xrange(4,len(self.parsed)):
result += unicode(self.parsed[i]).encode(UNICODE) + unul
result += unul
elif f == FLG_ADDREG_BINVALUETYPE:
for i in xrange(4,len(self.parsed)):
result += chr(eval(hexpand(self.parsed[i])))
elif f == FLG_ADDREG_TYPE_DWORD:
result = struct.pack(hbin.ULONG, eval(hexpand(self.parsed[4])))
else:
result = self.parsed[4:]
return result
class reginf:
def __init__(self):
self.content = []
def addentry(self,data):
re = regelt(data)
if not re.empty():
self.content.append(re)

View File

@ -0,0 +1,44 @@
#!/usr/bin/env python
import sys
import struct
def swapnls(nlsbuf):
result = ""
nls_file_header = struct.unpack("<8H", nlsbuf[:16])
result = result + struct.pack(">8H", *nls_file_header) + nlsbuf[16:26]
header_size = 2 * nls_file_header[0]
narrow_size = struct.unpack("<H",nlsbuf[header_size:header_size+2])[0]
start = header_size
# Ansi table
for i in xrange(0,narrow_size):
result = result + struct.pack(">H",*struct.unpack("<H",nlsbuf[start:start+2]))
start = start + 2
# Optional OEM table
nextlen = struct.unpack("<H",nlsbuf[start:start+2])[0]
result = result + struct.pack(">H",nextlen)
start = start + 2
if nextlen != 0:
for i in xrange(0,256):
result = result + struct.pack(">H",*struct.unpack("<H",nlsbuf[start:start+2]))
start = start + 2
else:
result = result + struct.pack(">H",nextlen)
dbcs_ranges = struct.unpack("<H",nlsbuf[start:start+2])[0]
if (dbcs_ranges & 0x8000) != 0:
for i in xrange(start/2,len(nlsbuf)/2):
result = result + struct.pack(">H",*struct.unpack("<H",nlsbuf[start:start+2]))
start = start + 2
result = result + nlsbuf[len(result):]
return result
if __name__ == '__main__':
nlsfile = open(sys.argv[1],'rb').read()
open(sys.argv[2],'wb').write(swapnls(nlsfile))