On Sunday 01 June 2008 20:02, Khem Raj wrote:
> > > >diff -d -urpN uClibc.1/libc/termios/tcgetsid.c
> > > >uClibc.2/libc/termios/tcgetsid.c
> > > >--- uClibc.1/libc/termios/tcgetsid.c 2008-05-19 16:23:16.000000000
> > > >+0200
> > > >+++ uClibc.2/libc/termios/tcgetsid.c 2008-05-20 00:03:31.000000000
> > > >+0200
> > > >@@ -34,7 +34,7 @@ tcgetsid (fd)
> > > > pid_t pgrp;
> > > > pid_t sid;
> > > > #ifdef TIOCGSID
> > > >- static int tiocgsid_does_not_work;
> > > >+ static smallint tiocgsid_does_not_work;
> > >
> > > For cases like this i prefer to just use a bool.
> >
> > Yeah, sounds logical. I'd do this too, but I don't have sufficient faith
> > in gcc not being stupid.
>
> In my opinion using bool is right thing to do and less error-prone on
> userside. At least compilers will do it consistent even if wrong.
>
> btw the you did not consider the architectures which do not define their
> own smallint in wordsize.h on such arches the definition will come from
> unistd.h.
Yes, it was intended. Do you want it to be changed so that compile fails
if unistd.h is mistakennly not included?
> libc/misc/fnmatch.c change would require to include unistd.h
> so that it will also get definition for other arches. As far as I see
> only x86 defines smallint as of now.
Fixed now.
> btw saving three bytes in size is fine. Did you also consider/measure
> the performance hit? Now a days accessing int is much faster and I would
> consider this a better trade-off than size.
I thought that uclibc's goal was smaller code size.
Anyway, with attached test program I am getting:
# gcc -Os t.c
# ./a.out
char reads: 1469029 us
int reads: 1441760 us
It measures the time it takes to sum up bytes:
addb buf+8, %al
addb buf+12, %al
addb buf+16, %al
addb buf+20, %al
addb buf+24, %al
versus words:
addl buf+8, %eax
addl buf+12, %eax
addl buf+16, %eax
addl buf+20, %eax
addl buf+24, %eax
--
vda
#include <stdlib.h>
#include <sys/time.h>
#include <stdio.h>
int buf[64*4];
#define LOOPS 10*1000*1000
#define READ_INT(i) a += buf[i]
#define READ_INT4(i) READ_INT(i); READ_INT(i+1); READ_INT(i+2); READ_INT(i+3)
#define READ_INT16(i) READ_INT4(i); READ_INT4(i+4); READ_INT4(i+8); READ_INT4(i+12)
#define READ_INT64(i) READ_INT16(i); READ_INT16(i+16); READ_INT16(i+32); READ_INT16(i+48)
#define READ_CHAR(i) a += *(char*)&buf[i]
#define READ_CHAR4(i) READ_CHAR(i); READ_CHAR(i+1); READ_CHAR(i+2); READ_CHAR(i+3)
#define READ_CHAR16(i) READ_CHAR4(i); READ_CHAR4(i+4); READ_CHAR4(i+8); READ_CHAR4(i+12)
#define READ_CHAR64(i) READ_CHAR16(i); READ_CHAR16(i+16); READ_CHAR16(i+32); READ_CHAR16(i+48)
int main()
{
struct timeval tv;
char *cp;
int *ip;
int i;
unsigned usec, start;
char a = 0;
gettimeofday(&tv, NULL); usec = tv.tv_sec * 1000000 + tv.tv_usec;
start = usec;
for (i = 0; i < LOOPS; i++) {
asm volatile ("" ::: "memory");
READ_CHAR64(0);
READ_CHAR64(0+64);
READ_CHAR64(0+64*2);
READ_CHAR64(0+64*3);
}
gettimeofday(&tv, NULL); usec = tv.tv_sec * 1000000 + tv.tv_usec;
printf("char reads: %u us\n", (usec - start));
gettimeofday(&tv, NULL); usec = tv.tv_sec * 1000000 + tv.tv_usec;
start = usec;
for (i = 0; i < LOOPS; i++) {
asm volatile ("" ::: "memory");
READ_INT64(0);
READ_INT64(0+64);
READ_INT64(0+64*2);
READ_INT64(0+64*3);
}
gettimeofday(&tv, NULL); usec = tv.tv_sec * 1000000 + tv.tv_usec;
printf("int reads: %u us\n", (usec - start));
return (a & 0xffffff00);
}
_______________________________________________
uClibc mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/uclibc