Changeset 331 for EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_subr.c
- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_subr.c
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 88 88 #include <tinet_config.h> 89 89 90 #include <net/if.h> 91 #include <net/if_loop.h> 92 #include <net/if_ppp.h> 93 #include <net/ethernet.h> 90 94 #include <net/net.h> 95 #include <net/net_endian.h> 91 96 92 97 /* … … 103 108 net_rand (void) 104 109 { 105 next = (next * 1103515245 + 12345) % (ULONG_C(0x7fffffff) + 1);110 next = (next * 99991 + 12345) & ULONG_C(0x7fffffff); 106 111 return next; 107 112 } … … 114 119 net_srand (uint32_t seed) 115 120 { 116 next += seed; 121 SYSTIM now; 122 123 syscall(get_tim(&now)); 124 next += now + seed + IF_SRAND(); 117 125 } 118 126 … … 186 194 187 195 /* 188 * rev_memcpy_ word -- 反転メモリコピー(4バイト)196 * rev_memcpy_hword -- 反転メモリコピー(2 バイト) 189 197 * 190 198 * バイト単位にアクセスする事により、 … … 193 201 194 202 void 195 rev_memcpy_word (uint8_t *dst, uint8_t *src) 196 { 197 *(dst ) = *(src + 3); 198 *(dst + 1) = *(src + 2); 199 *(dst + 2) = *(src + 1); 200 *(dst + 3) = *(src ); 201 } 202 203 /* 204 * rev_memcmp_word -- 反転メモリ比較(4 バイト) 203 rev_memcpy_hword (void *dst, void *src) 204 { 205 *((uint8_t*)dst ) = *((uint8_t*)src + 1); 206 *((uint8_t*)dst + 1) = *((uint8_t*)src ); 207 } 208 209 /* 210 * rev_memcpy_word -- 反転メモリコピー(4 バイト) 205 211 * 206 212 * バイト単位にアクセスする事により、 … … 208 214 */ 209 215 216 void 217 rev_memcpy_word (void *dst, void *src) 218 { 219 *((uint8_t*)dst ) = *((uint8_t*)src + 3); 220 *((uint8_t*)dst + 1) = *((uint8_t*)src + 2); 221 *((uint8_t*)dst + 2) = *((uint8_t*)src + 1); 222 *((uint8_t*)dst + 3) = *((uint8_t*)src ); 223 } 224 225 /* 226 * rev_memcmp_word -- 反転メモリ比較(4 バイト) 227 * 228 * バイト単位にアクセスする事により、 229 * 境界へのアラインの問題を解決する。 230 */ 231 210 232 int_t 211 rev_memcmp_word ( uint8_t *data1, uint8_t*data2)233 rev_memcmp_word (void *data1, void *data2) 212 234 { 213 235 int_t ix, diff; 214 236 215 for (ix = 4; ix -- > 0; ) {216 diff = *( data1 + ix) - *(data2 + (3 - ix));237 for (ix = sizeof(uint32_t); ix -- > 0; ) { 238 diff = *((uint8_t*)data1 + ix) - *((uint8_t*)data2 + (3 - ix)); 217 239 if (diff != 0) 218 240 return diff;
Note:
See TracChangeset
for help on using the changeset viewer.