Changeset 1691 for branches/FREEBSD/src
- Timestamp:
- Dec 3, 2004, 4:59:13 AM (21 years ago)
- Location:
- branches/FREEBSD/src/emx/src/lib/bsd/stdlib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FREEBSD/src/emx/src/lib/bsd/stdlib/radixsort.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1690 r1691 39 39 #endif /* LIBC_SCCS and not lint */ 40 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/lib/libc/stdlib/radixsort.c,v 1. 6 2002/03/22 09:18:34 obrienExp $");41 __FBSDID("$FreeBSD: src/lib/libc/stdlib/radixsort.c,v 1.7 2003/11/11 04:59:23 kientzle Exp $"); 42 42 43 43 /* … … 178 178 179 179 /* 180 * Special case: if all strings have the same 181 * character at position i, move on to the next 182 * character. 183 */ 184 if (nc == 1 && count[bmin] == n) { 185 push(a, n, i+1); 186 nc = count[bmin] = 0; 187 continue; 188 } 189 190 /* 180 191 * Set top[]; push incompletely sorted bins onto stack. 181 192 * top[] = pointers to last out-of-place element in bins. -
Property cvs2svn:cvs-rev
changed from
-
branches/FREEBSD/src/emx/src/lib/bsd/stdlib/random.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1690 r1691 36 36 #endif /* LIBC_SCCS and not lint */ 37 37 #include <sys/cdefs.h> 38 __FBSDID("$FreeBSD: src/lib/libc/stdlib/random.c,v 1.2 2 2003/02/04 11:24:08 acheExp $");38 __FBSDID("$FreeBSD: src/lib/libc/stdlib/random.c,v 1.24 2004/01/20 03:02:18 das Exp $"); 39 39 40 40 #include "namespace.h" 41 41 #include <sys/time.h> /* for srandomdev() */ 42 42 #include <fcntl.h> /* for srandomdev() */ 43 #include <stdint.h> 43 44 #include <stdio.h> 44 45 #include <stdlib.h> … … 62 63 * 32 bytes, a simple linear congruential R.N.G. is used. 63 64 * 64 * Internally, the state information is treated as an array of longs; the65 * Internally, the state information is treated as an array of uint32_t's; the 65 66 * zeroeth element of the array is the type of R.N.G. being used (small 66 67 * integer); the remainder of the array is the state information for the 67 * R.N.G. Thus, 32 bytes of state information will give 7 longs worth of68 * R.N.G. Thus, 32 bytes of state information will give 7 ints worth of 68 69 * state information, which will allow a degree seven polynomial. (Note: 69 70 * the zeroeth word of state information also has some other information … … 143 144 #define MAX_TYPES 5 /* max number of types above */ 144 145 145 #define NSHUFF 100 /* to drop part of seed -> 1st value correlation */ 146 147 static long degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 }; 148 static long seps [MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 }; 146 #ifdef USE_WEAK_SEEDING 147 #define NSHUFF 0 148 #else /* !USE_WEAK_SEEDING */ 149 #define NSHUFF 50 /* to drop some "seed -> 1st value" linearity */ 150 #endif /* !USE_WEAK_SEEDING */ 151 152 static const int degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 }; 153 static const int seps [MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 }; 149 154 150 155 /* … … 162 167 */ 163 168 164 static longrandtbl[DEG_3 + 1] = {169 static uint32_t randtbl[DEG_3 + 1] = { 165 170 TYPE_3, 166 171 #ifdef USE_WEAK_SEEDING … … 197 202 * to point to randtbl[1] (as explained below). 198 203 */ 199 static long*fptr = &randtbl[SEP_3 + 1];200 static long*rptr = &randtbl[1];204 static uint32_t *fptr = &randtbl[SEP_3 + 1]; 205 static uint32_t *rptr = &randtbl[1]; 201 206 202 207 /* … … 210 215 * the last element to see if the front and rear pointers have wrapped. 211 216 */ 212 static long*state = &randtbl[1];213 static longrand_type = TYPE_3;214 static longrand_deg = DEG_3;215 static longrand_sep = SEP_3;216 static long*end_ptr = &randtbl[DEG_3 + 1];217 218 static inline long good_rand(long);219 220 static inline longgood_rand (x)221 longx;217 static uint32_t *state = &randtbl[1]; 218 static int rand_type = TYPE_3; 219 static int rand_deg = DEG_3; 220 static int rand_sep = SEP_3; 221 static uint32_t *end_ptr = &randtbl[DEG_3 + 1]; 222 223 static inline uint32_t good_rand(int32_t); 224 225 static inline uint32_t good_rand (x) 226 int32_t x; 222 227 { 223 228 #ifdef USE_WEAK_SEEDING … … 237 242 * October 1988, p. 1195. 238 243 */ 239 longhi, lo;244 int32_t hi, lo; 240 245 241 246 /* Can't be initialized with 0, so use another value. */ … … 267 272 unsigned long x; 268 273 { 269 longi, lim;270 271 state[0] = x;274 int i, lim; 275 276 state[0] = (uint32_t)x; 272 277 if (rand_type == TYPE_0) 273 278 lim = NSHUFF; … … 347 352 * Returns a pointer to the old state. 348 353 * 349 * Note: The Sparc platform requires that arg_state begin on a long354 * Note: The Sparc platform requires that arg_state begin on an int 350 355 * word boundary; otherwise a bus error will occur. Even so, lint will 351 356 * complain about mis-alignment, but you should disregard these messages. … … 358 363 { 359 364 char *ostate = (char *)(&state[-1]); 360 long *long_arg_state = (long *)arg_state;365 uint32_t *int_arg_state = (uint32_t *)arg_state; 361 366 362 367 if (rand_type == TYPE_0) … … 390 395 rand_sep = SEP_4; 391 396 } 392 state = (long *) (long_arg_state + 1); /* first location */397 state = int_arg_state + 1; /* first location */ 393 398 end_ptr = &state[rand_deg]; /* must set end_ptr before srandom */ 394 399 srandom(seed); 395 400 if (rand_type == TYPE_0) 396 long_arg_state[0] = rand_type;401 int_arg_state[0] = rand_type; 397 402 else 398 long_arg_state[0] = MAX_TYPES * (rptr - state) + rand_type;403 int_arg_state[0] = MAX_TYPES * (rptr - state) + rand_type; 399 404 return(ostate); 400 405 } … … 415 420 * Returns a pointer to the old state information. 416 421 * 417 * Note: The Sparc platform requires that arg_state begin on a long422 * Note: The Sparc platform requires that arg_state begin on an int 418 423 * word boundary; otherwise a bus error will occur. Even so, lint will 419 424 * complain about mis-alignment, but you should disregard these messages. … … 423 428 char *arg_state; /* pointer to state array */ 424 429 { 425 long *new_state = (long *)arg_state;426 longtype = new_state[0] % MAX_TYPES;427 longrear = new_state[0] / MAX_TYPES;430 uint32_t *new_state = (uint32_t *)arg_state; 431 uint32_t type = new_state[0] % MAX_TYPES; 432 uint32_t rear = new_state[0] / MAX_TYPES; 428 433 char *ostate = (char *)(&state[-1]); 429 434 … … 446 451 "random: state info corrupted; not changed.\n"); 447 452 } 448 state = (long *) (new_state + 1);453 state = new_state + 1; 449 454 if (rand_type != TYPE_0) { 450 455 rptr = &state[rear]; … … 475 480 random() 476 481 { 477 longi;478 long*f, *r;482 uint32_t i; 483 uint32_t *f, *r; 479 484 480 485 if (rand_type == TYPE_0) { … … 498 503 fptr = f; rptr = r; 499 504 } 500 return( i);505 return((long)i); 501 506 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.