snesのソースに書いてあったらしい。
なんかに使えるやろ。
# define op_t unsigned long int # define OPSIZ (sizeof(op_t)) void *memset(void *buf, int ch, size_t n) { int i; if (n == 0) return buf; if ( ch ){ for ( i = 0; i < n; i++ ){ ((char*)buf)[i] = ch; } } else { long int dstp = (long int)buf; if ( n >= 8 ){ size_t xlen; while ( (dstp % OPSIZ) != 0 ){ ((char*)dstp)[0] = 0; dstp += 1; n -= 1; } xlen = n / (OPSIZ * 8); while ( xlen != 0 ){ ((op_t*)dstp)[0] = 0; ((op_t*)dstp)[1] = 0; ((op_t*)dstp)[2] = 0; ((op_t*)dstp)[3] = 0; ((op_t*)dstp)[4] = 0; ((op_t*)dstp)[5] = 0; ((op_t*)dstp)[6] = 0; ((op_t*)dstp)[7] = 0; dstp += 8 * OPSIZ; xlen -= 1; } n %= OPSIZ * 8; xlen = n / OPSIZ; while ( xlen != 0 ){ ((op_t*)dstp)[0] = 0; dstp += OPSIZ; xlen -= 1; } n %= OPSIZ; } while ( n != 0 ){ ((char*)dstp)[0] = 0; dstp += 1; n -= 1; } } return buf; } void *memcpy(void *dest, const void *src, size_t n) { int i; if (n == 0) return dest; for ( i = 0; i < n; i++ ){ ((char*)dest)[i] = ((char*)src)[i]; } return dest; }