Chameleon

Chameleon Commit Details

Date:2011-08-06 19:10:01 (12 years 8 months ago)
Author:Evan Lojewski
Commit:1294
Parents: 1293
Message:Add sprintf to klibc. remove unneded code.
Changes:
D/branches/xZenu/src/arch/i386/libsa/printf.c
D/branches/xZenu/src/arch/i386/libsa/string.c
M/branches/xZenu/src/arch/i386/libsa/Makefile
M/branches/xZenu/src/include/secure/_stdio.h
M/branches/xZenu/src/modules/klibc/Makefile

File differences

branches/xZenu/src/include/secure/_stdio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Copyright (c) 2007 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _STDIO_H_
#error error "Never use <secure/_stdio.h> directly; include <stdio.h> instead."
#endif
#ifndef _SECURE__STDIO_H_
#define _SECURE__STDIO_H_
#include <secure/_common.h>
#if _USE_FORTIFY_LEVEL > 0
#undef sprintf
#undef vsprintf
#undef snprintf
#undef vsnprintf
/* sprintf, vsprintf, snprintf, vsnprintf */
extern int __sprintf_chk (char * __restrict, int, size_t,
const char * __restrict, ...)
__DARWIN_LDBL_COMPAT (__sprintf_chk);
#define sprintf(str, ...) \
__builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
extern int __snprintf_chk (char * __restrict, size_t, int, size_t,
const char * __restrict, ...)
__DARWIN_LDBL_COMPAT (__snprintf_chk);
#define snprintf(str, len, ...) \
__builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
extern int __vsprintf_chk (char * __restrict, int, size_t,
const char * __restrict, va_list)
__DARWIN_LDBL_COMPAT (__vsprintf_chk);
#define vsprintf(str, format, ap) \
__builtin___vsprintf_chk (str, 0, __darwin_obsz(str), format, ap)
extern int __vsnprintf_chk (char * __restrict, size_t, int, size_t,
const char * __restrict, va_list)
__DARWIN_LDBL_COMPAT (__vsnprintf_chk);
#define vsnprintf(str, len, format, ap) \
__builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap)
#endif
#endif
branches/xZenu/src/modules/klibc/Makefile
2020
2121
2222
23
23
2424
2525
26
26
2727
2828
2929
strtoul strtoull strtoumax strxspn strpbrk \
bsearch calloc \
jrand48 lrand48 mrand48 srand48 nrand48 seed48 \
memccpy memcpy memset bzero memchr memmem memmove memrchr memswap memcmp \
memccpy memcpy memset bzero bcopy memchr memmem memmove memrchr memswap memcmp \
strcmp strncmp strcpy strncpy strlcpy strstr strncat strcat strdup strncasecmp strchr strlen strtoul strtol \
qsort sha1hash onexit atexit exit \
snprintf vsnprintf sscanf vsscanf\
snprintf vsnprintf sscanf vsscanf sprintf \
fwrite fprintf vfprintf printf
include ../MakeInc.dir
branches/xZenu/src/arch/i386/libsa/printf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
* Reserved. This file contains Original Code and/or Modifications of
* Original Code as defined in and that are subject to the Apple Public
* Source License Version 2.0 (the "License"). You may not use this file
* except in compliance with the License. Please obtain a copy of the
* License at http://www.apple.com/publicsource and read it before using
* this file.
*
* The Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* Copyright 1993 NeXT, Inc.
* All rights reserved.
*/
#include "libsa.h"
struct putc_info //Azi: exists on console.c & gui.c
{
char * str;
char * last_str;
};
static int
sputc(int c, struct putc_info * pi) //Azi: same as above
{
if (pi->last_str)
if (pi->str == pi->last_str) {
*(pi->str) = '\0';
return 0;
}
*(pi->str)++ = c;
return c;
}
/*VARARGS1*/
/* now slprintf() return the length of the string as in man sprintf()*/
int sprintf(char * str, const char * fmt, ...)
{
va_list ap;
struct putc_info pi;
va_start(ap, fmt);
pi.str = str;
pi.last_str = 0;
prf(fmt, ap, sputc, &pi);
*pi.str = '\0';
va_end(ap);
return (pi.str - str);
}
/*VARARGS1*/
int slvprintf(char * str, int len, const char * fmt, va_list ap)
{
struct putc_info pi;
pi.str = str;
pi.last_str = str + len - 1;
prf(fmt, ap, sputc, &pi);
*pi.str = '\0';
return (pi.str - str);
}
branches/xZenu/src/arch/i386/libsa/string.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
* Reserved. This file contains Original Code and/or Modifications of
* Original Code as defined in and that are subject to the Apple Public
* Source License Version 2.0 (the "License"). You may not use this file
* except in compliance with the License. Please obtain a copy of the
* License at http://www.apple.com/publicsource and read it before using
* this file.
*
* The Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/* string operations */
#include "libsa.h"
void bcopy(const void * src, void * dst, size_t len)
{
asm volatile ( "cld \n\t"
"movl %%ecx, %%edx \n\t"
"shrl $2, %%ecx \n\t"
"rep; movsl \n\t"
"movl %%edx, %%ecx \n\t"
"andl $3, %%ecx \n\t"
"rep; movsb \n\t"
:
: "c" (len), "D" (dst), "S" (src)
: "memory", "%edx" );
}
/*#endif*/
branches/xZenu/src/arch/i386/libsa/Makefile
2121
2222
2323
24
25
24
25
2626
2727
2828
INC = -I. -I$(SYMROOT) -I$(LIBSAIODIR) -I${SRCROOT}/include
OBJECTS = prf printf \
string error \
OBJECTS = prf \
error \
setjmp efi_tables
LIBS = libsa.a

Archive Download the corresponding diff file

Revision: 1294