libsys: 64-bit numbers support for printf()
Change some drivers accordingly.
This commit is contained in:
parent
86344bb535
commit
8caec1b57b
6 changed files with 31 additions and 36 deletions
|
@ -426,9 +426,8 @@ static int fbd_transfer(dev_t UNUSED(minor), int do_write, u64_t position,
|
||||||
do_write ? FBD_FLAG_WRITE : FBD_FLAG_READ);
|
do_write ? FBD_FLAG_WRITE : FBD_FLAG_READ);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
printf("FBD: %s operation for pos %lx:%08lx size %u -> hooks %x\n",
|
printf("FBD: %s operation for pos %"PRIx64" size %u -> hooks %x\n",
|
||||||
do_write ? "write" : "read", ex64hi(position),
|
do_write ? "write" : "read", position, size, hooks);
|
||||||
ex64lo(position), size, hooks);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (hooks & PRE_HOOK)
|
if (hooks & PRE_HOOK)
|
||||||
|
|
|
@ -84,13 +84,14 @@ static int driver_open(int which)
|
||||||
return RET_REDO;
|
return RET_REDO;
|
||||||
}
|
}
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
printf("Filter: partition size: 0x%s / %lu sectors\n",
|
printf("Filter: partition size: 0x%"PRIx64" / %lu sectors\n",
|
||||||
print64(disk_size), sectors);
|
disk_size, sectors);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
if(cmp64(disk_size, part.size)) {
|
if(cmp64(disk_size, part.size)) {
|
||||||
printf("Filter: partition size mismatch (%s != %s)\n",
|
printf("Filter: partition size mismatch "
|
||||||
print64(part.size), print64(disk_size));
|
"(0x%"PRIx64" != 0x%"PRIx64")\n",
|
||||||
|
part.size, disk_size);
|
||||||
|
|
||||||
return RET_REDO;
|
return RET_REDO;
|
||||||
}
|
}
|
||||||
|
@ -768,7 +769,7 @@ static int paired_sendrec(message *m1, message *m2, int both)
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
#if DEBUG2
|
#if DEBUG2
|
||||||
printf("paired_sendrec(%d) - <%d,%x:%x,%d> - %x,%x\n",
|
printf("paired_sendrec(%d) - <%d,%lx:%lx,%d> - %x,%x\n",
|
||||||
both, m1->m_type, m1->BDEV_POS_HI, m1->BDEV_POS_LO,
|
both, m1->m_type, m1->BDEV_POS_HI, m1->BDEV_POS_LO,
|
||||||
m1->BDEV_COUNT, m1->BDEV_GRANT, m2->BDEV_GRANT);
|
m1->BDEV_COUNT, m1->BDEV_GRANT, m2->BDEV_GRANT);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -118,6 +118,5 @@ extern void ds_event(void);
|
||||||
/* util.c */
|
/* util.c */
|
||||||
extern char *flt_malloc(size_t size, char *sbuf, size_t ssize);
|
extern char *flt_malloc(size_t size, char *sbuf, size_t ssize);
|
||||||
extern void flt_free(char *buf, size_t size, const char *sbuf);
|
extern void flt_free(char *buf, size_t size, const char *sbuf);
|
||||||
extern char *print64(u64_t p);
|
|
||||||
extern clock_t flt_alarm(clock_t dt);
|
extern clock_t flt_alarm(clock_t dt);
|
||||||
|
|
||||||
|
|
|
@ -568,9 +568,8 @@ int transfer(u64_t pos, char *buffer, size_t *sizep, int flag_rw)
|
||||||
r = read_write(phys_pos, ext_buffer, ext_buffer, &res_size, flag_rw);
|
r = read_write(phys_pos, ext_buffer, ext_buffer, &res_size, flag_rw);
|
||||||
|
|
||||||
#if DEBUG2
|
#if DEBUG2
|
||||||
printf("Filter: transfer: read_write(%x:%x, %u, %d) = %d, %u\n",
|
printf("Filter: transfer: read_write(%"PRIx64", %u, %d) = %d, %u\n",
|
||||||
ex64hi(phys_pos), ex64lo(phys_pos), ext_size, flag_rw, r,
|
phys_pos, ext_size, flag_rw, r, res_size);
|
||||||
res_size);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (r != OK) {
|
if (r != OK) {
|
||||||
|
|
|
@ -38,21 +38,6 @@ void flt_free(char *buf, size_t size, const char *sbuf)
|
||||||
free_contig(buf, size);
|
free_contig(buf, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
|
||||||
* print64 *
|
|
||||||
*===========================================================================*/
|
|
||||||
char *print64(u64_t p)
|
|
||||||
{
|
|
||||||
#define NB 10
|
|
||||||
static int n = 0;
|
|
||||||
static char buf[NB][100];
|
|
||||||
u32_t lo = ex64lo(p), hi = ex64hi(p);
|
|
||||||
n = (n+1) % NB;
|
|
||||||
if(!hi) sprintf(buf[n], "%x", lo);
|
|
||||||
else sprintf(buf[n], "%x%08x", hi, lo);
|
|
||||||
return buf[n];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* flt_alarm *
|
* flt_alarm *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
|
|
|
@ -20,16 +20,16 @@ int vprintf(const char *fmt, va_list argp)
|
||||||
{
|
{
|
||||||
int c, charcount = 0;
|
int c, charcount = 0;
|
||||||
enum { LEFT, RIGHT } adjust;
|
enum { LEFT, RIGHT } adjust;
|
||||||
enum { LONG, INT } intsize;
|
enum { LLONG, LONG, INT } intsize;
|
||||||
int fill;
|
int fill;
|
||||||
int width, max, len, base;
|
int width, max, len, base;
|
||||||
static char X2C_tab[]= "0123456789ABCDEF";
|
static char X2C_tab[]= "0123456789ABCDEF";
|
||||||
static char x2c_tab[]= "0123456789abcdef";
|
static char x2c_tab[]= "0123456789abcdef";
|
||||||
char *x2c;
|
char *x2c;
|
||||||
char *p;
|
char *p;
|
||||||
long i;
|
long long i;
|
||||||
unsigned long u;
|
unsigned long long u;
|
||||||
char temp[8 * sizeof(long) / 3 + 2];
|
char temp[8 * sizeof(long long) / 3 + 2];
|
||||||
|
|
||||||
while ((c= *fmt++) != 0) {
|
while ((c= *fmt++) != 0) {
|
||||||
if (c != '%') {
|
if (c != '%') {
|
||||||
|
@ -93,13 +93,21 @@ int vprintf(const char *fmt, va_list argp)
|
||||||
intsize= LONG;
|
intsize= LONG;
|
||||||
c= *fmt++;
|
c= *fmt++;
|
||||||
}
|
}
|
||||||
|
if (c == 'l' || c == 'L') {
|
||||||
|
/* "Long long" key, e.g. %lld. */
|
||||||
|
intsize= LLONG;
|
||||||
|
c= *fmt++;
|
||||||
|
}
|
||||||
if (c == 0) break;
|
if (c == 0) break;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
/* Decimal. */
|
/* Decimal. */
|
||||||
case 'd':
|
case 'd':
|
||||||
i= intsize == LONG ? va_arg(argp, long)
|
switch (intsize) {
|
||||||
: va_arg(argp, int);
|
case LLONG: i= va_arg(argp, long long); break;
|
||||||
|
case LONG: i= va_arg(argp, long); break;
|
||||||
|
case INT: i= va_arg(argp, int); break;
|
||||||
|
}
|
||||||
u= i < 0 ? -i : i;
|
u= i < 0 ? -i : i;
|
||||||
goto int2ascii;
|
goto int2ascii;
|
||||||
|
|
||||||
|
@ -110,7 +118,8 @@ int vprintf(const char *fmt, va_list argp)
|
||||||
|
|
||||||
/* Pointer, interpret as %X or %lX. */
|
/* Pointer, interpret as %X or %lX. */
|
||||||
case 'p':
|
case 'p':
|
||||||
if (sizeof(char *) > sizeof(int)) intsize= LONG;
|
if (sizeof(char *) > sizeof(long)) intsize= LLONG;
|
||||||
|
else if (sizeof(char *) > sizeof(int)) intsize= LONG;
|
||||||
|
|
||||||
/* Hexadecimal. %X prints upper case A-F, not %lx. */
|
/* Hexadecimal. %X prints upper case A-F, not %lx. */
|
||||||
case 'X':
|
case 'X':
|
||||||
|
@ -122,8 +131,11 @@ int vprintf(const char *fmt, va_list argp)
|
||||||
/* Unsigned decimal. */
|
/* Unsigned decimal. */
|
||||||
case 'u':
|
case 'u':
|
||||||
getint:
|
getint:
|
||||||
u= intsize == LONG ? va_arg(argp, unsigned long)
|
switch (intsize) {
|
||||||
: va_arg(argp, unsigned int);
|
case LLONG: u= va_arg(argp, unsigned long long); break;
|
||||||
|
case LONG: u= va_arg(argp, unsigned long); break;
|
||||||
|
case INT: u= va_arg(argp, unsigned int); break;
|
||||||
|
}
|
||||||
int2ascii:
|
int2ascii:
|
||||||
p= temp + sizeof(temp)-1;
|
p= temp + sizeof(temp)-1;
|
||||||
*p= 0;
|
*p= 0;
|
||||||
|
|
Loading…
Reference in a new issue