mirror of
https://github.com/pvvx/RTL00MP3.git
synced 2025-07-31 12:41:06 +00:00
first commit
This commit is contained in:
parent
2ee525362e
commit
d108756e9b
792 changed files with 336059 additions and 0 deletions
262
RTL00_SDKV35a/component/common/api/platform/dlist.h
Normal file
262
RTL00_SDKV35a/component/common/api/platform/dlist.h
Normal file
|
|
@ -0,0 +1,262 @@
|
|||
#ifndef __LIST_H
|
||||
#define __LIST_H
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
#ifndef inline
|
||||
#define inline __inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This file is from Linux Kernel (include/linux/list.h)
|
||||
* and modified by simply removing hardware prefetching of list items.
|
||||
* Here by copyright, credits attributed to wherever they belong.
|
||||
* Kulesh Shanmugasundaram (kulesh [squiggly] isis.poly.edu)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Simple doubly linked list implementation.
|
||||
*
|
||||
* Some of the internal functions ("__xxx") are useful when
|
||||
* manipulating whole lists rather than single entries, as
|
||||
* sometimes we already know the next/prev entries and we can
|
||||
* generate better code by using them directly rather than
|
||||
* using the generic single-entry routines.
|
||||
*/
|
||||
|
||||
struct list_head {
|
||||
struct list_head *next, *prev;
|
||||
};
|
||||
|
||||
#define LIST_HEAD_INIT(name) { &(name), &(name) }
|
||||
|
||||
#define LIST_HEAD(name) \
|
||||
struct list_head name = LIST_HEAD_INIT(name)
|
||||
|
||||
#define INIT_LIST_HEAD(ptr) do { \
|
||||
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Insert a new entry between two known consecutive entries.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static inline void __list_add(struct list_head *new,
|
||||
struct list_head *prev,
|
||||
struct list_head *next)
|
||||
{
|
||||
next->prev = new;
|
||||
new->next = next;
|
||||
new->prev = prev;
|
||||
prev->next = new;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_add - add a new entry
|
||||
* @new: new entry to be added
|
||||
* @head: list head to add it after
|
||||
*
|
||||
* Insert a new entry after the specified head.
|
||||
* This is good for implementing stacks.
|
||||
*/
|
||||
static inline void list_add(struct list_head *new, struct list_head *head)
|
||||
{
|
||||
__list_add(new, head, head->next);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_add_tail - add a new entry
|
||||
* @new: new entry to be added
|
||||
* @head: list head to add it before
|
||||
*
|
||||
* Insert a new entry before the specified head.
|
||||
* This is useful for implementing queues.
|
||||
*/
|
||||
static inline void list_add_tail(struct list_head *new, struct list_head *head)
|
||||
{
|
||||
__list_add(new, head->prev, head);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete a list entry by making the prev/next entries
|
||||
* point to each other.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static inline void __list_del(struct list_head *prev, struct list_head *next)
|
||||
{
|
||||
next->prev = prev;
|
||||
prev->next = next;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_del - deletes entry from list.
|
||||
* @entry: the element to delete from the list.
|
||||
* Note: list_empty on entry does not return true after this, the entry is in an undefined state.
|
||||
*/
|
||||
static inline void list_del(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
entry->next = (void *) 0;
|
||||
entry->prev = (void *) 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_del_init - deletes entry from list and reinitialize it.
|
||||
* @entry: the element to delete from the list.
|
||||
*/
|
||||
static inline void list_del_init(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
INIT_LIST_HEAD(entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_move - delete from one list and add as another's head
|
||||
* @list: the entry to move
|
||||
* @head: the head that will precede our entry
|
||||
*/
|
||||
static inline void list_move(struct list_head *list, struct list_head *head)
|
||||
{
|
||||
__list_del(list->prev, list->next);
|
||||
list_add(list, head);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_move_tail - delete from one list and add as another's tail
|
||||
* @list: the entry to move
|
||||
* @head: the head that will follow our entry
|
||||
*/
|
||||
static inline void list_move_tail(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
__list_del(list->prev, list->next);
|
||||
list_add_tail(list, head);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_empty - tests whether a list is empty
|
||||
* @head: the list to test.
|
||||
*/
|
||||
static inline int list_empty(struct list_head *head)
|
||||
{
|
||||
return head->next == head;
|
||||
}
|
||||
|
||||
static inline void __list_splice(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
struct list_head *first = list->next;
|
||||
struct list_head *last = list->prev;
|
||||
struct list_head *at = head->next;
|
||||
|
||||
first->prev = head;
|
||||
head->next = first;
|
||||
|
||||
last->next = at;
|
||||
at->prev = last;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_splice - join two lists
|
||||
* @list: the new list to add.
|
||||
* @head: the place to add it in the first list.
|
||||
*/
|
||||
static inline void list_splice(struct list_head *list, struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list))
|
||||
__list_splice(list, head);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_splice_init - join two lists and reinitialise the emptied list.
|
||||
* @list: the new list to add.
|
||||
* @head: the place to add it in the first list.
|
||||
*
|
||||
* The list at @list is reinitialised
|
||||
*/
|
||||
static inline void list_splice_init(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list)) {
|
||||
__list_splice(list, head);
|
||||
INIT_LIST_HEAD(list);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* list_entry - get the struct for this entry
|
||||
* @ptr: the &struct list_head pointer.
|
||||
* @type: the type of the struct this is embedded in.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_entry(ptr, type, member) \
|
||||
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
|
||||
|
||||
/**
|
||||
* list_first_entry - get the first element from a list
|
||||
* @ptr: the list head to take the element from.
|
||||
* @type: the type of the struct this is embedded in.
|
||||
* @member: the name of the list_head within the struct.
|
||||
*
|
||||
* Note, that list is expected to be not empty.
|
||||
*/
|
||||
|
||||
#define list_first_entry(ptr, type, member) \
|
||||
list_entry((ptr)->next, type, member)
|
||||
|
||||
|
||||
/**
|
||||
* list_for_each - iterate over a list
|
||||
* @pos: the &struct list_head to use as a loop counter.
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each(pos, head) \
|
||||
for (pos = (head)->next; pos != (head); \
|
||||
pos = pos->next)
|
||||
/**
|
||||
* list_for_each_prev - iterate over a list backwards
|
||||
* @pos: the &struct list_head to use as a loop counter.
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each_prev(pos, head) \
|
||||
for (pos = (head)->prev; pos != (head); \
|
||||
pos = pos->prev)
|
||||
|
||||
/**
|
||||
* list_for_each_safe - iterate over a list safe against removal of list entry
|
||||
* @pos: the &struct list_head to use as a loop counter.
|
||||
* @n: another &struct list_head to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each_safe(pos, n, head) \
|
||||
for (pos = (head)->next, n = pos->next; pos != (head); \
|
||||
pos = n, n = pos->next)
|
||||
|
||||
/**
|
||||
* list_for_each_entry - iterate over list of given type
|
||||
* @pos: the type * to use as a loop counter.
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_for_each_entry(pos, head, member, type) \
|
||||
for (pos = list_entry((head)->next, type, member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry(pos->member.next, type, member))
|
||||
|
||||
/**
|
||||
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
|
||||
* @pos: the type * to use as a loop counter.
|
||||
* @n: another type * to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_for_each_entry_safe(pos, n, head, member, type) \
|
||||
for (pos = list_entry((head)->next, type, member), \
|
||||
n = list_entry(pos->member.next, type, member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_entry(n->member.next, type, member))
|
||||
|
||||
#endif
|
||||
247
RTL00_SDKV35a/component/common/api/platform/platform_stdlib.h
Normal file
247
RTL00_SDKV35a/component/common/api/platform/platform_stdlib.h
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2007 - 2014 Realtek Corporation. All rights reserved.
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef __PLATFORM_STDLIB_H__
|
||||
#define __PLATFORM_STDLIB_H__
|
||||
|
||||
#define USE_CLIB_PATCH 0
|
||||
#if defined (__GNUC__)
|
||||
#define USE_RTL_ROM_CLIB 1
|
||||
#else
|
||||
#define USE_RTL_ROM_CLIB 1
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_PLATFORM_8195A)
|
||||
#if defined (__IARSTDLIB__)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "diag.h"
|
||||
|
||||
#define strsep(str, delim) _strsep(str, delim)
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "diag.h"
|
||||
#include "strproc.h"
|
||||
#include "basic_types.h"
|
||||
#include "hal_misc.h"
|
||||
#if USE_RTL_ROM_CLIB
|
||||
#include "rtl_lib.h"
|
||||
#endif
|
||||
|
||||
#undef printf
|
||||
#undef sprintf
|
||||
#undef snprintf
|
||||
#undef atoi
|
||||
#undef memcmp
|
||||
#undef memcpy
|
||||
#undef memset
|
||||
#undef strcmp
|
||||
#undef strcpy
|
||||
#undef strlen
|
||||
#undef strncmp
|
||||
#undef strncpy
|
||||
#undef strsep
|
||||
#undef strtok
|
||||
#if USE_RTL_ROM_CLIB
|
||||
#undef memchr
|
||||
#undef memmove
|
||||
#undef strcat
|
||||
#undef strchr
|
||||
#undef strncat
|
||||
#undef strstr
|
||||
#endif
|
||||
|
||||
#if USE_RTL_ROM_CLIB
|
||||
#define printf rtl_printf
|
||||
#define sprintf rtl_sprintf
|
||||
#define snprintf rtl_snprintf
|
||||
#define memchr rtl_memchr
|
||||
#define memcmp rtl_memcmp
|
||||
#define memcpy rtl_memcpy
|
||||
#define memmove rtl_memmove
|
||||
#define memset rtl_memset
|
||||
#define bzero(s,l) rtl_memset(s,0,l)
|
||||
#define strcat rtl_strcat
|
||||
#define strchr rtl_strchr
|
||||
#define strcmp(s1, s2) rtl_strcmp((const char *)s1, (const char *)s2)
|
||||
#define strcpy rtl_strcpy
|
||||
#define strlen(str) rtl_strlen((const char *)str)
|
||||
#define strncat rtl_strncat
|
||||
#define strncmp(s1, s2, n) rtl_strncmp((const char *)s1, (const char *)s2, n)
|
||||
#define strncpy rtl_strncpy
|
||||
#define strstr rtl_strstr
|
||||
#define strsep rtl_strsep
|
||||
#define strtok rtl_strtok
|
||||
#else
|
||||
#if USE_CLIB_PATCH
|
||||
extern int DiagSscanfPatch(const char *buf, const char *fmt, ...);
|
||||
extern char* DiagStrtokPatch(char *str, const char* delim);
|
||||
extern char* DiagStrstrPatch(char *string, char *substring);
|
||||
extern int DiagSnPrintfPatch(char *buf, size_t size, const char *fmt, ...);
|
||||
extern u32 DiagPrintfPatch(const char *fmt, ...);
|
||||
extern u32 DiagSPrintfPatch(u8 *buf, const char *fmt, ...);
|
||||
#define printf DiagPrintfPatch
|
||||
#define sprintf DiagSPrintfPatch
|
||||
#define snprintf DiagSnPrintfPatch
|
||||
#define strstr(a, b) DiagStrstrPatch((char *)(a), (char *)(b))
|
||||
#define strtok DiagStrtokPatch
|
||||
#else
|
||||
#define printf DiagPrintf
|
||||
#define sprintf(fmt, arg...) DiagSPrintf((u8*)fmt, ##arg)
|
||||
#if defined (__GNUC__)
|
||||
#define snprintf DiagSnPrintf // NULL function
|
||||
#define strstr(str1, str2) prvStrStr(str1, str2) // NULL function
|
||||
#endif
|
||||
#define strtok(str, delim) _strsep(str, delim)
|
||||
#endif
|
||||
#define memcmp(dst, src, sz) _memcmp(dst, src, sz)
|
||||
#define memcpy(dst, src, sz) _memcpy(dst, src, sz)
|
||||
#define memset(dst, val, sz) _memset(dst, val, sz)
|
||||
#define strchr(s, c) _strchr(s, c) // for B-cut ROM
|
||||
#define strcmp(str1, str2) prvStrCmp((const unsigned char *) str1, (const unsigned char *) str2)
|
||||
#define strcpy(dest, src) _strcpy(dest, src)
|
||||
#define strlen(str) prvStrLen((const unsigned char *) str)
|
||||
#define strncmp(str1, str2, cnt) _strncmp(str1, str2, cnt)
|
||||
#define strncpy(dest, src, count) _strncpy(dest, src, count)
|
||||
#define strsep(str, delim) _strsep(str, delim)
|
||||
#endif
|
||||
|
||||
#define atoi(str) prvAtoi(str)
|
||||
#define strpbrk(cs, ct) _strpbrk(cs, ct) // for B-cut ROM
|
||||
|
||||
#if USE_CLIB_PATCH
|
||||
#undef sscanf
|
||||
#define sscanf DiagSscanfPatch
|
||||
#else
|
||||
#if defined (__GNUC__)
|
||||
#undef sscanf //_sscanf
|
||||
//extern int DiagSscanfPatch(const char *buf, const char *fmt, ...);
|
||||
//#define sscanf DiagSscanfPatch
|
||||
#define sscanf sscanf // use libc sscanf
|
||||
#endif
|
||||
#endif
|
||||
#endif // defined (__IARSTDLIB__)
|
||||
|
||||
//
|
||||
// memory management
|
||||
//
|
||||
extern void *pvPortMalloc( size_t xWantedSize );
|
||||
extern void vPortFree( void *pv );
|
||||
#undef malloc
|
||||
#define malloc pvPortMalloc
|
||||
#undef free
|
||||
#define free vPortFree
|
||||
#elif defined (CONFIG_PLATFORM_8711B)
|
||||
#if defined (__IARSTDLIB__)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "diag.h"
|
||||
|
||||
#define strsep(str, delim) _strsep(str, delim)
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "diag.h"
|
||||
#include "strproc.h"
|
||||
#include "basic_types.h"
|
||||
#include "hal_misc.h"
|
||||
|
||||
#undef printf
|
||||
#undef sprintf
|
||||
#undef snprintf
|
||||
#undef atoi
|
||||
#undef memcmp
|
||||
#undef memcpy
|
||||
#undef memset
|
||||
#undef strcmp
|
||||
#undef strcpy
|
||||
#undef strlen
|
||||
#undef strncmp
|
||||
#undef strncpy
|
||||
#undef strsep
|
||||
#undef strtok
|
||||
|
||||
#if USE_RTL_ROM_CLIB
|
||||
#undef memchr
|
||||
#undef memmove
|
||||
#undef strcat
|
||||
#undef strchr
|
||||
#undef strncat
|
||||
#undef strstr
|
||||
|
||||
#define printf rtl_printf
|
||||
#define sprintf rtl_sprintf
|
||||
#define snprintf rtl_snprintf
|
||||
#define memchr rtl_memchr
|
||||
#define memcmp rtl_memcmp
|
||||
#define memcpy rtl_memcpy
|
||||
#define memmove rtl_memmove
|
||||
#define memset rtl_memset
|
||||
#define strcat rtl_strcat
|
||||
#define strchr rtl_strchr
|
||||
#define strcmp(s1, s2) rtl_strcmp((const char *)s1, (const char *)s2)
|
||||
#define strcpy rtl_strcpy
|
||||
#define strlen(str) rtl_strlen((const char *)str)
|
||||
#define strncat rtl_strncat
|
||||
#define strncmp(s1, s2, n) rtl_strncmp((const char *)s1, (const char *)s2, n)
|
||||
#define strncpy rtl_strncpy
|
||||
#define strstr rtl_strstr
|
||||
#define strsep rtl_strsep
|
||||
#define strtok rtl_strtok
|
||||
#else
|
||||
#define printf DiagPrintf
|
||||
#define sprintf(fmt, arg...) DiagSPrintf((u8*)fmt, ##arg)
|
||||
#if defined (__GNUC__)
|
||||
#define snprintf DiagSnPrintf // NULL function
|
||||
#define strstr(str1, str2) prvStrStr(str1, str2) // NULL function
|
||||
#endif
|
||||
#define strtok(str, delim) _strsep(str, delim)
|
||||
|
||||
#define memcmp(dst, src, sz) _memcmp(dst, src, sz)
|
||||
#define memcpy(dst, src, sz) _memcpy(dst, src, sz)
|
||||
#define memset(dst, val, sz) _memset(dst, val, sz)
|
||||
#define strchr(s, c) _strchr(s, c) // for B-cut ROM
|
||||
#define strcmp(str1, str2) prvStrCmp((const unsigned char *) str1, (const unsigned char *) str2)
|
||||
#define strcpy(dest, src) _strcpy(dest, src)
|
||||
#define strlen(str) prvStrLen((const unsigned char *) str)
|
||||
#define strncmp(str1, str2, cnt) _strncmp(str1, str2, cnt)
|
||||
#define strncpy(dest, src, count) _strncpy(dest, src, count)
|
||||
#define strsep(str, delim) _strsep(str, delim)
|
||||
|
||||
#define atoi(str) prvAtoi(str)
|
||||
#define strpbrk(cs, ct) _strpbrk(cs, ct) // for B-cut ROM
|
||||
|
||||
#if defined (__GNUC__)
|
||||
#undef sscanf
|
||||
#define sscanf _sscanf
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif // defined (__IARSTDLIB__)
|
||||
|
||||
//
|
||||
// memory management
|
||||
//
|
||||
extern void *pvPortMalloc( size_t xWantedSize );
|
||||
extern void vPortFree( void *pv );
|
||||
#define malloc pvPortMalloc
|
||||
#define free vPortFree
|
||||
#elif defined(USE_STM322xG_EVAL) || defined(USE_STM324xG_EVAL) || defined(STM32F10X_XL)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
|
||||
#endif //__PLATFORM_STDLIB_H__
|
||||
918
RTL00_SDKV35a/component/common/api/platform/stdlib_patch.c
Normal file
918
RTL00_SDKV35a/component/common/api/platform/stdlib_patch.c
Normal file
|
|
@ -0,0 +1,918 @@
|
|||
/*
|
||||
|
||||
this is the c lib patch, It can help when the clib provided by IAR
|
||||
does not work well.
|
||||
|
||||
How to use this:
|
||||
1.You must include platform_stdlib.h in you source file。
|
||||
2.There is a macro USE_CLIB_PATCH in platform_stdlib.h should be opened.
|
||||
|
||||
If there is some problems using this patch,
|
||||
You'd better check if you code runs into these functions:
|
||||
|
||||
DiagSscanfPatch
|
||||
DiagStrtokPatch
|
||||
DiagStrstrPatch
|
||||
DiagSnPrintfPatch
|
||||
DiagPrintfPatch
|
||||
DiagSPrintfPatch
|
||||
DiagPrintfPatch
|
||||
DiagSPrintfPatch
|
||||
DiagSnPrintfPatch
|
||||
DiagStrstrPatch
|
||||
DiagStrtokPatch
|
||||
|
||||
*/
|
||||
#ifndef CONFIG_PLATFORM_8711B
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define DiagPutChar HalSerialPutcRtl8195a
|
||||
|
||||
#define IN
|
||||
#define NULL 0
|
||||
|
||||
typedef unsigned int size_t;
|
||||
typedef unsigned int SIZE_T;
|
||||
typedef unsigned long long u64;
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned short int u16;
|
||||
typedef unsigned char u8;
|
||||
typedef signed long long s64;
|
||||
typedef signed int s32;
|
||||
typedef signed short int s16;
|
||||
typedef unsigned char bool;
|
||||
|
||||
|
||||
#define in_range(c, lo, up) ((u8)c >= lo && (u8)c <= up)
|
||||
#define isprint(c) in_range(c, 0x20, 0x7f)
|
||||
#define isdigit(c) in_range(c, '0', '9')
|
||||
#define isxdigit(c) (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F'))
|
||||
#define islower(c) in_range(c, 'a', 'z')
|
||||
#define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == ',')
|
||||
#define ULLONG_MAX (~0ULL)
|
||||
#define USHRT_MAX ((u16)(~0U))
|
||||
#define KSTRTOX_OVERFLOW (1U << 31)
|
||||
#define SHRT_MAX ((s16)(USHRT_MAX>>1))
|
||||
|
||||
static inline char _tolower(const char c)
|
||||
{
|
||||
return c | 0x20;
|
||||
}
|
||||
|
||||
|
||||
extern s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder);
|
||||
extern s64 div_s64(s64 dividend, s32 divisor);
|
||||
extern inline char _tolower(const char c);
|
||||
extern u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder);
|
||||
extern u64 div_u64(u64 dividend, u32 divisor);
|
||||
extern unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *p);
|
||||
extern const char *_parse_integer_fixup_radix(const char *s, unsigned int *base);
|
||||
extern char *skip_spaces(const char *str);
|
||||
extern int skip_atoi(const char **s);
|
||||
extern void HalSerialPutcRtl8195a(u8 c);
|
||||
|
||||
|
||||
static unsigned long long simple_strtoull_patch(const char *cp, char **endp, unsigned int base)
|
||||
{
|
||||
unsigned long long result;
|
||||
unsigned int rv;
|
||||
|
||||
cp = _parse_integer_fixup_radix(cp, &base);
|
||||
rv = _parse_integer(cp, base, &result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static long long simple_strtoll_patch(const char *cp, char **endp, unsigned int base)
|
||||
{
|
||||
if(*cp == '-')
|
||||
return -simple_strtoull_patch(cp + 1, endp, base);
|
||||
|
||||
return simple_strtoull_patch(cp, endp, base);
|
||||
}
|
||||
static unsigned long simple_strtoul_patch(const char *cp, char **endp, unsigned int base)
|
||||
{
|
||||
return simple_strtoull_patch(cp, endp, base);
|
||||
}
|
||||
|
||||
static long simple_strtol_patch(const char *cp, char **endp, unsigned int base)
|
||||
{
|
||||
if(*cp == '-')
|
||||
return -simple_strtoul_patch(cp + 1, endp, base);
|
||||
|
||||
return simple_strtoul_patch(cp, endp, base);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static int judge_digit_width(const char *str)
|
||||
{
|
||||
|
||||
int width = 0;
|
||||
|
||||
while(isdigit(*str)) {
|
||||
width++;
|
||||
str++;
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
static int _vsscanf_patch(const char *buf, const char *fmt, va_list args)
|
||||
{
|
||||
const char *str = buf;
|
||||
char *next;
|
||||
char digit;
|
||||
int num = 0;
|
||||
int i =0;
|
||||
u8 qualifier;
|
||||
unsigned int base;
|
||||
union {
|
||||
long long s;
|
||||
unsigned long long u;
|
||||
} val;
|
||||
s16 field_width;
|
||||
bool is_sign;
|
||||
|
||||
char str_store[20] = {0};
|
||||
|
||||
|
||||
|
||||
while(*fmt) {
|
||||
/* skip any white space in format */
|
||||
/* white space in format matchs any amount of
|
||||
* white space, including none, in the input.
|
||||
*/
|
||||
if(isspace(*fmt)) {
|
||||
fmt = skip_spaces(++fmt);
|
||||
str = skip_spaces(str);
|
||||
}
|
||||
|
||||
/* anything that is not a conversion must match exactly */
|
||||
if(*fmt != '%' && *fmt) {
|
||||
if(*fmt++ != *str++) {
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!*fmt) {
|
||||
break;
|
||||
}
|
||||
|
||||
++fmt;
|
||||
|
||||
/* skip this conversion.
|
||||
* advance both strings to next white space
|
||||
*/
|
||||
if(*fmt == '*') {
|
||||
if(!*str) {
|
||||
break;
|
||||
}
|
||||
|
||||
while(!isspace(*fmt) && *fmt != '%' && *fmt)
|
||||
fmt++;
|
||||
|
||||
while(!isspace(*str) && *str)
|
||||
str++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* get field width */
|
||||
field_width = -1;
|
||||
|
||||
if(isdigit(*fmt)) {
|
||||
|
||||
field_width = skip_atoi(&fmt);
|
||||
|
||||
|
||||
|
||||
if(field_width <= 0) {
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* get conversion qualifier */
|
||||
qualifier = -1;
|
||||
|
||||
if(*fmt == 'h' || _tolower(*fmt) == 'l' ||
|
||||
_tolower(*fmt) == 'z') {
|
||||
qualifier = *fmt++;
|
||||
|
||||
if(qualifier == *fmt) {
|
||||
if(qualifier == 'h') {
|
||||
qualifier = 'H';
|
||||
fmt++;
|
||||
} else if(qualifier == 'l') {
|
||||
qualifier = 'L';
|
||||
fmt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!*fmt) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(*fmt == 'n') {
|
||||
/* return number of characters read so far */
|
||||
*va_arg(args, int *) = str - buf;
|
||||
++fmt;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!*str) {
|
||||
break;
|
||||
}
|
||||
|
||||
base = 10;
|
||||
is_sign = 0;
|
||||
|
||||
switch(*fmt++) {
|
||||
case 'c': {
|
||||
char *s = (char *)va_arg(args, char*);
|
||||
|
||||
if(field_width == -1)
|
||||
field_width = 1;
|
||||
|
||||
do {
|
||||
*s++ = *str++;
|
||||
} while(--field_width > 0 && *str);
|
||||
|
||||
num++;
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
case 's': {
|
||||
char *s = (char *)va_arg(args, char *);
|
||||
|
||||
if(field_width == -1)
|
||||
field_width = SHRT_MAX;
|
||||
|
||||
/* first, skip leading white space in buffer */
|
||||
str = skip_spaces(str);
|
||||
|
||||
/* now copy until next white space */
|
||||
while(*str && !isspace(*str) && field_width--) {
|
||||
*s++ = *str++;
|
||||
}
|
||||
|
||||
*s = '\0';
|
||||
num++;
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
case 'o':
|
||||
base = 8;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
case 'X':
|
||||
base = 16;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
base = 0;
|
||||
|
||||
case 'd':
|
||||
is_sign = 1;
|
||||
|
||||
case 'u':
|
||||
break;
|
||||
|
||||
case '%':
|
||||
|
||||
/* looking for '%' in str */
|
||||
if(*str++ != '%') {
|
||||
return num;
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
default:
|
||||
/* invalid format; stop here */
|
||||
return num;
|
||||
}
|
||||
|
||||
/* have some sort of integer conversion.
|
||||
* first, skip white space in buffer.
|
||||
*/
|
||||
str = skip_spaces(str);
|
||||
|
||||
digit = *str;
|
||||
|
||||
if(is_sign && digit == '-')
|
||||
digit = *(str + 1);
|
||||
|
||||
if(!digit
|
||||
|| (base == 16 && !isxdigit(digit))
|
||||
|| (base == 10 && !isdigit(digit))
|
||||
|| (base == 8 && (!isdigit(digit) || digit > '7'))
|
||||
|| (base == 0 && !isdigit(digit))) {
|
||||
break;
|
||||
}
|
||||
|
||||
//here problem *******************************************
|
||||
|
||||
|
||||
|
||||
//troy add ,fix support %2d, but not support %d
|
||||
if(field_width <= 0) {
|
||||
|
||||
field_width = judge_digit_width(str);
|
||||
}
|
||||
|
||||
|
||||
/////troy add, fix str passed inwidth wrong
|
||||
for(i = 0; i<field_width ; i++)
|
||||
str_store[i] = str[i];
|
||||
|
||||
next = (char*)str + field_width;
|
||||
|
||||
|
||||
|
||||
if(is_sign) {
|
||||
val.s = qualifier != 'L' ?
|
||||
simple_strtol_patch(str_store, &next, base) :
|
||||
simple_strtoll_patch(str_store, &next, base);
|
||||
} else {
|
||||
val.u = qualifier != 'L' ?
|
||||
simple_strtoul_patch(str_store, &next, base) :
|
||||
simple_strtoull_patch(str_store, &next, base);
|
||||
}
|
||||
|
||||
|
||||
////troy add
|
||||
for(i = 0; i<20 ; i++)
|
||||
str_store[i] = 0;
|
||||
|
||||
|
||||
//判断转换的字符串的宽度是否大于 %2d
|
||||
if(field_width > 0 && next - str > field_width) {
|
||||
if(base == 0)
|
||||
_parse_integer_fixup_radix(str, &base);
|
||||
|
||||
while(next - str > field_width) {
|
||||
if(is_sign) {
|
||||
val.s = div_s64(val.s, base);
|
||||
} else {
|
||||
val.u = div_u64(val.u, base);
|
||||
}
|
||||
|
||||
--next;
|
||||
}
|
||||
}
|
||||
|
||||
switch(qualifier) {
|
||||
case 'H': /* that's 'hh' in format */
|
||||
if(is_sign)
|
||||
*va_arg(args, signed char *) = val.s;
|
||||
else
|
||||
*va_arg(args, unsigned char *) = val.u;
|
||||
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
if(is_sign)
|
||||
*va_arg(args, short *) = val.s;
|
||||
else
|
||||
*va_arg(args, unsigned short *) = val.u;
|
||||
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
if(is_sign)
|
||||
*va_arg(args, long *) = val.s;
|
||||
else
|
||||
*va_arg(args, unsigned long *) = val.u;
|
||||
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
if(is_sign)
|
||||
*va_arg(args, long long *) = val.s;
|
||||
else
|
||||
*va_arg(args, unsigned long long *) = val.u;
|
||||
|
||||
break;
|
||||
|
||||
case 'Z':
|
||||
case 'z':
|
||||
*va_arg(args, size_t *) = val.u;
|
||||
break;
|
||||
|
||||
default:
|
||||
if(is_sign)
|
||||
*va_arg(args, int *) = val.s;
|
||||
else
|
||||
*va_arg(args, unsigned int *) = val.u;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
num++;
|
||||
|
||||
if(!next) {
|
||||
break;
|
||||
}
|
||||
|
||||
str = next;
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
int DiagSscanfPatch(const char *buf, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
va_start(args, fmt);
|
||||
i = _vsscanf_patch(buf, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
|
||||
|
||||
char* DiagStrtokPatch(char *str, const char* delim) {
|
||||
static char* _buffer;
|
||||
|
||||
if(str != NULL) _buffer = str;
|
||||
|
||||
if(_buffer[0] == '\0') return NULL;
|
||||
|
||||
char *ret = _buffer, *b;
|
||||
const char *d;
|
||||
|
||||
for(b = _buffer; *b !='\0'; b++) {
|
||||
for(d = delim; *d != '\0'; d++) {
|
||||
if(*b == *d) {
|
||||
*b = '\0';
|
||||
_buffer = b+1;
|
||||
|
||||
// skip the beginning delimiters
|
||||
if(b == ret) {
|
||||
ret++;
|
||||
continue;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
|
||||
|
||||
char *DiagStrstrPatch(char *string, char *substring)
|
||||
{
|
||||
register char *a, *b;
|
||||
|
||||
/* First scan quickly through the two strings looking for a
|
||||
* single-character match. When it's found, then compare the
|
||||
* rest of the substring.
|
||||
*/
|
||||
|
||||
b = substring;
|
||||
|
||||
if(*b == 0) {
|
||||
return string;
|
||||
}
|
||||
|
||||
for(; *string != 0; string += 1) {
|
||||
if(*string != *b) {
|
||||
continue;
|
||||
}
|
||||
|
||||
a = string;
|
||||
|
||||
while(1) {
|
||||
if(*b == 0) {
|
||||
return string;
|
||||
}
|
||||
|
||||
if(*a++ != *b++) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
b = substring;
|
||||
}
|
||||
|
||||
return (char *) 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
int DiagSnPrintfPatch(char *buf, size_t size, const char *fmt, ...)
|
||||
{
|
||||
|
||||
va_list ap;
|
||||
char *p, *s, *buf_end = NULL;
|
||||
const int *dp = ((const int *)&fmt)+1;
|
||||
|
||||
if(buf == NULL)
|
||||
return 0;
|
||||
|
||||
|
||||
va_start(ap, fmt);
|
||||
s = buf;
|
||||
buf_end = size? (buf + size):(char*)~0;
|
||||
|
||||
for(; *fmt != '\0'; ++fmt) {
|
||||
|
||||
if(*fmt != '%') {
|
||||
*s++ = *fmt;
|
||||
|
||||
if(s >= buf_end) {
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if(*++fmt == 's') {
|
||||
for(p = (char *)*dp++; *p != '\0'; p++) {
|
||||
*s++ = *p;
|
||||
|
||||
if(s >= buf_end) {
|
||||
goto Exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
else { /* Length of item is bounded */
|
||||
char tmp[20], *q = tmp;
|
||||
int alt = 0;
|
||||
int shift = 0;// = 12;
|
||||
const long *lpforchk = (const long *)dp;
|
||||
|
||||
if((*lpforchk) < 0x10) {
|
||||
shift = 0;
|
||||
}
|
||||
else if(((*lpforchk) >= 0x10) && ((*lpforchk) < 0x100)) {
|
||||
shift = 4;
|
||||
}
|
||||
else if(((*lpforchk) >= 0x100) && ((*lpforchk) < 0x1000)) {
|
||||
shift = 8;
|
||||
}
|
||||
else if(((*lpforchk) >= 0x1000) && ((*lpforchk) < 0x10000)) {
|
||||
shift = 12;
|
||||
}
|
||||
else if(((*lpforchk) >= 0x10000) && ((*lpforchk) < 0x100000)) {
|
||||
shift = 16;
|
||||
}
|
||||
else if(((*lpforchk) >= 0x100000) && ((*lpforchk) < 0x1000000)) {
|
||||
shift = 20;
|
||||
}
|
||||
else if(((*lpforchk) >= 0x1000000) && ((*lpforchk) < 0x10000000)) {
|
||||
shift = 24;
|
||||
}
|
||||
else if((*lpforchk) >= 0x10000000) {
|
||||
shift = 28;
|
||||
}
|
||||
else {
|
||||
shift = 28;
|
||||
}
|
||||
|
||||
if((*fmt >= '0') && (*fmt <= '9'))
|
||||
{
|
||||
int width;
|
||||
unsigned char fch = *fmt;
|
||||
|
||||
for(width=0; (fch>='0') && (fch<='9'); fch=*++fmt)
|
||||
{ width = width * 10 + fch - '0';
|
||||
}
|
||||
|
||||
shift=(width-1)*4;
|
||||
}
|
||||
|
||||
/*
|
||||
* Before each format q points to tmp buffer
|
||||
* After each format q points past end of item
|
||||
*/
|
||||
if((*fmt == 'x')||(*fmt == 'X') || (*fmt == 'p') || (*fmt == 'P')) {
|
||||
/* With x86 gcc, sizeof(long) == sizeof(int) */
|
||||
const long *lp = (const long *)dp;
|
||||
long h = *lp++;
|
||||
int hex_count = 0;
|
||||
unsigned long h_back = h;
|
||||
int ncase = (*fmt & 0x20);
|
||||
dp = (const int *)lp;
|
||||
|
||||
if((*fmt == 'p') || (*fmt == 'P'))
|
||||
alt=1;
|
||||
|
||||
if(alt) {
|
||||
*q++ = '0';
|
||||
*q++ = 'X' | ncase;
|
||||
}
|
||||
|
||||
while(h_back) {
|
||||
hex_count += (h_back & 0xF) ? 1 : 0;
|
||||
h_back = h_back >> 4;
|
||||
}
|
||||
|
||||
if(shift < (hex_count - 1)*4)
|
||||
shift = (hex_count - 1)*4;
|
||||
|
||||
for(; shift >= 0; shift -= 4)
|
||||
*q++ = "0123456789ABCDEF"[(h >> shift) & 0xF] | ncase;
|
||||
}
|
||||
else if(*fmt == 'd') {
|
||||
int i = *dp++;
|
||||
char *r;
|
||||
int digit_space = 0;
|
||||
|
||||
|
||||
if(i < 0) {
|
||||
*q++ = '-';
|
||||
i = -i;
|
||||
digit_space++;
|
||||
}
|
||||
|
||||
p = q; /* save beginning of digits */
|
||||
|
||||
|
||||
do {
|
||||
*q++ = '0' + (i % 10);
|
||||
i /= 10;
|
||||
digit_space++;
|
||||
} while(i);
|
||||
|
||||
|
||||
for(; shift >= 0; shift -= 4) {
|
||||
|
||||
if(digit_space-- > 0) {
|
||||
; //do nothing
|
||||
} else {
|
||||
*q++ = '0';
|
||||
}
|
||||
}
|
||||
|
||||
/* reverse digits, stop in middle */
|
||||
r = q; /* don't alter q */
|
||||
|
||||
while(--r > p) {
|
||||
i = *r;
|
||||
*r = *p;
|
||||
*p++ = i;
|
||||
}
|
||||
}
|
||||
else if(*fmt == 'c')
|
||||
*q++ = *dp++;
|
||||
else
|
||||
*q++ = *fmt;
|
||||
|
||||
/* now output the saved string */
|
||||
for(p = tmp; p < q; ++p) {
|
||||
*s++ = *p;
|
||||
|
||||
if(s >= buf_end) {
|
||||
goto Exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Exit:
|
||||
|
||||
if(buf)
|
||||
*s = '\0';
|
||||
|
||||
va_end(ap);
|
||||
return(s-buf);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
static int VSprintfPatch(char *buf, const char *fmt, const int *dp)
|
||||
{
|
||||
char *p, *s;
|
||||
s = buf;
|
||||
|
||||
for(; *fmt != '\0'; ++fmt) {
|
||||
if(*fmt != '%') {
|
||||
if(buf) {
|
||||
*s++ = *fmt;
|
||||
} else {
|
||||
DiagPutChar(*fmt);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if(*++fmt == 's') {
|
||||
for(p = (char *)*dp++; *p != '\0'; p++) {
|
||||
if(buf) {
|
||||
*s++ = *p;
|
||||
} else {
|
||||
DiagPutChar(*p);
|
||||
}
|
||||
}
|
||||
}
|
||||
else { /* Length of item is bounded */
|
||||
char tmp[20], *q = tmp;
|
||||
int alt = 0;
|
||||
int shift = 0;// = 12;
|
||||
const long *lpforchk = (const long *)dp;
|
||||
|
||||
if((*lpforchk) < 0x10) {
|
||||
shift = 0;
|
||||
}
|
||||
else if(((*lpforchk) >= 0x10) && ((*lpforchk) < 0x100)) {
|
||||
shift = 4;
|
||||
}
|
||||
else if(((*lpforchk) >= 0x100) && ((*lpforchk) < 0x1000)) {
|
||||
shift = 8;
|
||||
}
|
||||
else if(((*lpforchk) >= 0x1000) && ((*lpforchk) < 0x10000)) {
|
||||
shift = 12;
|
||||
}
|
||||
else if(((*lpforchk) >= 0x10000) && ((*lpforchk) < 0x100000)) {
|
||||
shift = 16;
|
||||
}
|
||||
else if(((*lpforchk) >= 0x100000) && ((*lpforchk) < 0x1000000)) {
|
||||
shift = 20;
|
||||
}
|
||||
else if(((*lpforchk) >= 0x1000000) && ((*lpforchk) < 0x10000000)) {
|
||||
shift = 24;
|
||||
}
|
||||
else if((*lpforchk) >= 0x10000000) {
|
||||
shift = 28;
|
||||
}
|
||||
else {
|
||||
shift = 28;
|
||||
}
|
||||
|
||||
#if 1 //wei patch for %02x
|
||||
|
||||
if((*fmt >= '0') && (*fmt <= '9'))
|
||||
{
|
||||
int width;
|
||||
unsigned char fch = *fmt;
|
||||
|
||||
for(width=0; (fch>='0') && (fch<='9'); fch=*++fmt)
|
||||
{ width = width * 10 + fch - '0';
|
||||
}
|
||||
|
||||
shift=(width-1)*4;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Before each format q points to tmp buffer
|
||||
* After each format q points past end of item
|
||||
*/
|
||||
|
||||
if((*fmt == 'x')||(*fmt == 'X') || (*fmt == 'p') || (*fmt == 'P')) {
|
||||
/* With x86 gcc, sizeof(long) == sizeof(int) */
|
||||
const long *lp = (const long *)dp;
|
||||
long h = *lp++;
|
||||
int hex_count = 0;
|
||||
unsigned long h_back = h;
|
||||
int ncase = (*fmt & 0x20);
|
||||
dp = (const int *)lp;
|
||||
|
||||
if((*fmt == 'p') || (*fmt == 'P'))
|
||||
alt=1;
|
||||
|
||||
if(alt) {
|
||||
*q++ = '0';
|
||||
*q++ = 'X' | ncase;
|
||||
}
|
||||
|
||||
//hback 是实际得到的数据,hex_count是统计数据的HEX字符个数
|
||||
while(h_back) {
|
||||
hex_count += (h_back & 0xF) ? 1 : 0;
|
||||
h_back = h_back >> 4;
|
||||
}
|
||||
|
||||
//这里修复 example: 字符有4个,但是用了%02x导致字符被截断的情况
|
||||
if(shift < (hex_count - 1)*4)
|
||||
shift = (hex_count - 1)*4;
|
||||
|
||||
//printf("(%d,%d)", hex_count, shift);
|
||||
|
||||
for(; shift >= 0; shift -= 4) {
|
||||
|
||||
*q++ = "0123456789ABCDEF"[(h >> shift) & 0xF] | ncase;
|
||||
}
|
||||
|
||||
}
|
||||
else if(*fmt == 'd') {
|
||||
int i = *dp++;
|
||||
char *r;
|
||||
int digit_space = 0;
|
||||
|
||||
if(i < 0) {
|
||||
*q++ = '-';
|
||||
i = -i;
|
||||
digit_space++;
|
||||
}
|
||||
|
||||
p = q; /* save beginning of digits */
|
||||
|
||||
do {
|
||||
*q++ = '0' + (i % 10);
|
||||
i /= 10;
|
||||
digit_space++;
|
||||
} while(i);
|
||||
|
||||
//这里修复 example:用了%08d后,在数字前面没有0的情况
|
||||
for(; shift >= 0; shift -= 4) {
|
||||
|
||||
if(digit_space-- > 0) {
|
||||
; //do nothing
|
||||
} else {
|
||||
*q++ = '0';
|
||||
}
|
||||
}
|
||||
|
||||
/* reverse digits, stop in middle */
|
||||
r = q; /* don't alter q */
|
||||
|
||||
while(--r > p) {
|
||||
i = *r;
|
||||
*r = *p;
|
||||
*p++ = i;
|
||||
}
|
||||
}
|
||||
else if(*fmt == 'c')
|
||||
*q++ = *dp++;
|
||||
else
|
||||
*q++ = *fmt;
|
||||
|
||||
/* now output the saved string */
|
||||
for(p = tmp; p < q; ++p) {
|
||||
if(buf) {
|
||||
*s++ = *p;
|
||||
} else {
|
||||
DiagPutChar(*p);
|
||||
}
|
||||
|
||||
if((*p) == '\n') {
|
||||
DiagPutChar('\r');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(buf)
|
||||
*s = '\0';
|
||||
|
||||
return (s - buf);
|
||||
}
|
||||
|
||||
|
||||
u32 DiagPrintfPatch(
|
||||
IN const char *fmt, ...
|
||||
)
|
||||
{
|
||||
(void)VSprintfPatch(0, fmt, ((const int *)&fmt)+1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
u32 DiagSPrintfPatch(
|
||||
IN u8 *buf,
|
||||
IN const char *fmt, ...
|
||||
)
|
||||
{
|
||||
(void)VSprintfPatch((char*)buf, fmt, ((const int *)&fmt)+1);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue