faubackup2/src/rsync rsync.cpp,1.4,1.5

Martin Waitz <[email protected]> Tue, 07 Jun 2005 13:35:56 +0000
Newsgroups gmane.comp.sysutils.backup.faubackup.cvs
Message-ID <[email protected]>
Update of /cvsroot/faubackup/faubackup2/src/rsync
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8406/src/rsync

Modified Files:
	rsync.cpp 
Log Message:
use generic_fls from linux

Index: rsync.cpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/rsync/rsync.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** rsync.cpp	7 Jun 2005 12:37:07 -0000	1.4
--- rsync.cpp	7 Jun 2005 13:35:54 -0000	1.5
***************
*** 13,16 ****
--- 13,50 ----
  {
  
+ /* copied from include/linux/bitops.h */
+ static inline int generic_fls(uint64_t x)
+ {
+ 	int r = 64;
+ 
+ 	if (!x)
+ 		return 0;
+ 	if (!(x & 0xffffffff00000000ull)) {
+ 		x <<= 32;
+ 		r -= 32;
+ 	}
+ 	if (!(x & 0xffff000000000000ull)) {
+ 		x <<= 16;
+ 		r -= 16;
+ 	}
+ 	if (!(x & 0xff00000000000000ull)) {
+ 		x <<= 8;
+ 		r -= 8;
+ 	}
+ 	if (!(x & 0xf000000000000000ull)) {
+ 		x <<= 4;
+ 		r -= 4;
+ 	}
+ 	if (!(x & 0xc000000000000000ull)) {
+ 		x <<= 2;
+ 		r -= 2;
+ 	}
+ 	if (!(x & 0x8000000000000000ull)) {
+ 		x <<= 1;
+ 		r -= 1;
+ 	}
+ 	return r;
+ }
+ 
  void checkSum(string fileName, uint64_t fileSize, NetCommunication &out)
  {
***************
*** 29,33 ****
  
  	// this is somthing like: blocksize = sqrt(fileSize)
! 	blocksize = 1 << (ffsll(fileSize) / 2);
  
  	if(blocksize < MIN_RSYNC_BLOCKSIZE)
--- 63,67 ----
  
  	// this is somthing like: blocksize = sqrt(fileSize)
! 	blocksize = 1 << (generic_fls(fileSize) / 2);
  
  	if(blocksize < MIN_RSYNC_BLOCKSIZE)



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20