shut up new gcc 6 warnings
parent
05e4dcc94a
commit
d26b8082d8
@ -1,36 +1,12 @@
|
|||||||
|
#include <stdint.h>
|
||||||
#include "byte.h"
|
#include "byte.h"
|
||||||
|
|
||||||
/* byte_copy copies in[0] to out[0], in[1] to out[1], ... and in[len-1]
|
/* byte_copy copies in[0] to out[0], in[1] to out[1], ... and in[len-1]
|
||||||
* to out[len-1]. */
|
* to out[len-1]. */
|
||||||
void byte_copy(void* out, size_t len, const void* in) {
|
void byte_copy(void* out, size_t len, const void* in) {
|
||||||
char* s=out;
|
char* d=out;
|
||||||
const char* t=in;
|
const char* s=in;
|
||||||
#if 1
|
|
||||||
/* gcc 4.3.1 generates wrong code for this, so I'm switching to
|
|
||||||
* simpler code */
|
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i=0; i<len; ++i)
|
for (i=0; i<len; ++i)
|
||||||
s[i]=t[i];
|
d[i]=s[i];
|
||||||
#else
|
|
||||||
const char* u=t+len;
|
|
||||||
if (len>127) {
|
|
||||||
while ((unsigned long)s&(sizeof(unsigned long)-1)) {
|
|
||||||
*s=*t; ++s; ++t;
|
|
||||||
}
|
|
||||||
/* s (destination) is now unsigned long aligned */
|
|
||||||
#ifndef __i386__
|
|
||||||
if (!((unsigned long)t&(sizeof(unsigned long)-1)))
|
|
||||||
#endif
|
|
||||||
while (t+sizeof(unsigned long)<=u) {
|
|
||||||
*(unsigned long*)s=*(unsigned long*)t;
|
|
||||||
s+=sizeof(unsigned long); t+=sizeof(unsigned long);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (;;) {
|
|
||||||
if (t==u) break; *s=*t; ++s; ++t;
|
|
||||||
if (t==u) break; *s=*t; ++s; ++t;
|
|
||||||
if (t==u) break; *s=*t; ++s; ++t;
|
|
||||||
if (t==u) break; *s=*t; ++s; ++t;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,15 @@
|
|||||||
#include "byte.h"
|
#include "byte.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/* byte_zero sets the bytes out[0], out[1], ..., out[len-1] to 0 */
|
/* byte_zero sets the bytes out[0], out[1], ..., out[len-1] to 0 */
|
||||||
void byte_zero(void* out, size_t len) {
|
void byte_zero(void* out, size_t len) {
|
||||||
#if 1
|
/* instead of doing this ourselves, defer to the hopefully amazingly
|
||||||
/* gcc 4.3.1 generates wrong code for this, so I'm switching to
|
* optimized memset from libc */
|
||||||
* simpler code */
|
memset(out,0,len);
|
||||||
|
#if 0
|
||||||
register char* s=out;
|
register char* s=out;
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i=0; i<len; ++i)
|
for (i=0; i<len; ++i)
|
||||||
s[i]=0;
|
s[i]=0;
|
||||||
#else
|
|
||||||
register char* s=out;
|
|
||||||
register const char* t=s+len;
|
|
||||||
for (;;) {
|
|
||||||
if (s==t) break; *s=0; ++s;
|
|
||||||
if (s==t) break; *s=0; ++s;
|
|
||||||
if (s==t) break; *s=0; ++s;
|
|
||||||
if (s==t) break; *s=0; ++s;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue