upload sdk

git-svn-id: svn://kolibrios.org@4349 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge)
2013-12-15 08:09:20 +00:00
parent 6c6781f799
commit 754f9336f0
5801 changed files with 1688660 additions and 0 deletions

View File

@@ -0,0 +1,117 @@
/* Error handler for noninteractive utilities
Copyright (C) 1990-1998, 2000-2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "error.h"
/* This variable is incremented each time `error' is called. */
unsigned int error_message_count;
char *strerror_r ();
/* The calling program should define program_name and set it to the
name of the executing program. */
//extern char *program_name;
static void
print_errno_message (int errnum)
{
char const *s;
s = strerror (errnum);
fprintf (stderr, ": %s", s);
}
static void
error_tail (int status, int errnum, const char *message, va_list args)
{
vfprintf (stderr, message, args);
va_end (args);
++error_message_count;
if (errnum)
print_errno_message (errnum);
putc ('\n', stderr);
fflush (stderr);
if (status)
exit (status);
}
/* Print the program name and error message MESSAGE, which is a printf-style
format string with optional args.
If ERRNUM is nonzero, print its corresponding system error message.
Exit with status STATUS if it is nonzero. */
void
error (int status, int errnum, const char *message, ...)
{
va_list args;
// fflush (stdout);
// fprintf (stderr, "%s: ", program_name);
va_start (args, message);
error_tail (status, errnum, message, args);
};
/* Sometimes we want to have at most one error per line. This
variable controls whether this mode is selected or not. */
int error_one_per_line;
void
error_at_line (int status, int errnum, const char *file_name,
unsigned int line_number, const char *message, ...)
{
va_list args;
if (error_one_per_line)
{
static const char *old_file_name;
static unsigned int old_line_number;
if (old_line_number == line_number
&& (file_name == old_file_name
|| strcmp (old_file_name, file_name) == 0))
/* Simply return and print nothing. */
return;
old_file_name = file_name;
old_line_number = line_number;
}
// fflush (stdout);
fprintf (stderr, file_name != NULL ? "%s:%d: " : " ",
file_name, line_number);
va_start (args, message);
error_tail (status, errnum, message, args);
}

View File

@@ -0,0 +1,47 @@
/* Declaration for error-reporting function
Copyright (C) 1995,1996,1997,2003,2006,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifndef _ERROR_H
#define _ERROR_H 1
/* Print a message with `fprintf (stderr, FORMAT, ...)';
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
If STATUS is nonzero, terminate the program with `exit (STATUS)'. */
extern void error (int __status, int __errnum, __const char *__format, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
extern void error_at_line (int __status, int __errnum, __const char *__fname,
unsigned int __lineno, __const char *__format, ...)
__attribute__ ((__format__ (__printf__, 5, 6)));
/* If NULL, error will flush stdout, then print on stderr the program
name, a colon and a space. Otherwise, error will call this
function without parameters instead. */
extern void (*error_print_progname) (void);
/* This variable is incremented each time `error' is called. */
extern unsigned int error_message_count;
/* Sometimes we want to have at most one error per line. This
variable controls whether this mode is selected or not. */
extern int error_one_per_line;
#endif /* error.h */

View File

@@ -0,0 +1,133 @@
use32
LIBC_VERSION = 1
DLL_ENTRY = 1
db 'MENUET02'
dd 1
dd start
dd i_end
dd mem
dd mem
dd cmdline
dd path
dd 0
align 4
start:
mov eax, LIBC_VERSION
mov ecx, sz_libc
mov edx, libc
call load_library
test eax, eax
jz .fail
push dword 0 ; no environment
push cmdline
push path
push (my_app_end - my_app)
push my_app
call [libc.imp_exec]
ret
.fail:
or eax, -1
int 0x40
align 4
load_library: ;eax=VERSION ecx=library path edx=import section
sub esp, 16
mov [esp+8], edx
mov [esp+12], eax
mov eax, 68
mov ebx, 19
int 0x40
test eax, eax
jz .fail
mov [esp+4], eax
mov esi, edx ;import section
mov edx, eax ;export section
.import_loop:
lodsd
test eax, eax
jz .import_done
.import_find:
mov ebx, [edx]
test ebx, ebx
jz .fail ;import_not_found
mov [esp], eax ;import name
@@:
mov cl, [eax]
cmp cl, [ebx]
jnz .import_find_next
test cl, cl
jz .import_found
inc eax
inc ebx
jmp @b
.import_find_next:
mov eax, [esp]
add edx, 8
jmp .import_find
.import_found:
mov eax, [edx+4]
mov [esi-4], eax
mov edx, [esp+4]
jmp .import_loop
.import_done:
mov edx, [esp+8]
mov eax, [esp+12]
cmp word [edx+4], ax
jb .fail
cmp word [edx+6], ax
ja .fail
push DLL_ENTRY
call dword [edx]
.fail:
add esp, 16
ret
sz_libc db '/sys/lib/libc.obj',0
szStart db 'START',0
szVersion db 'version',0
szExec db 'exec',0
libc:
.imp_start dd szStart
.imp_ver dd szVersion
.imp_exec dd szExec
dd 0
; keep this aligned
align 16
my_app:
file 'myapp.exe'
my_app_end:
; keep this aligned
align 4
i_end:
path rb 1024
cmdline rb 256
rb 128 ;required stack
; keep this aligned
align 4096
mem:

View File

@@ -0,0 +1,126 @@
/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <errno.h>
#include <error.h>
#include <limits.h>
#include <malloc.h>
#include <stdlib.h>
#include <stdio.h>
/* Number of samples per size. */
#define N 50000
static void
fixed_test (int size)
{
char *ptrs[N];
int i;
for (i = 0; i < N; ++i)
{
int j;
ptrs[i] = (char *) calloc (1, size);
if (ptrs[i] == NULL)
break;
for (j = 0; j < size; ++j)
{
if (ptrs[i][j] != '\0')
error (EXIT_FAILURE, 0,
"byte not cleared (size %d, element %d, byte %d)",
size, i, j);
ptrs[i][j] = '\xff';
}
}
while (i-- > 0)
free (ptrs[i]);
}
static void
random_test (void)
{
char *ptrs[N];
int i;
for (i = 0; i < N; ++i)
{
int j;
int n = 1 + random () % 10;
int elem = 1 + random () % 100;
int size = n * elem;
ptrs[i] = (char *) calloc (n, elem);
if (ptrs[i] == NULL)
break;
for (j = 0; j < size; ++j)
{
if (ptrs[i][j] != '\0')
error (EXIT_FAILURE, 0,
"byte not cleared (size %d, element %d, byte %d)",
size, i, j);
ptrs[i][j] = '\xff';
}
}
while (i-- > 0)
free (ptrs[i]);
}
static void
null_test (void)
{
/* If the size is 0 the result is implementation defined. Just make
sure the program doesn't crash. */
calloc (0, 0);
calloc (0, UINT_MAX);
calloc (UINT_MAX, 0);
calloc (0, ~((size_t) 0));
calloc (~((size_t) 0), 0);
}
int
main (void)
{
/* We are allocating blocks with `calloc' and check whether every
block is completely cleared. We first try this for some fixed
times and then with random size. */
fixed_test (15);
fixed_test (5);
fixed_test (17);
fixed_test (6);
fixed_test (31);
fixed_test (96);
random_test ();
null_test ();
return 0;
}