Changeset 499 for GPL/branches/uniaud32-2.1.x/lib32/misc.c
- Timestamp:
- Jul 5, 2010, 11:51:20 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/uniaud32-2.1.x/lib32/misc.c
r479 r499 407 407 //****************************************************************************** 408 408 //****************************************************************************** 409 #define del_timer_sync(t) del_timer(t) /* FIXME: not quite correct on SMP */ 410 int cancel_delayed_work(struct delayed_work *dwork) 411 { 412 struct work_struct *work = &dwork->work; 413 int ret; 414 415 ret = del_timer_sync(&work->timer); 416 if (ret) 417 clear_bit(0, &work->pending); 418 return ret; 419 } 420 //****************************************************************************** 421 //****************************************************************************** 422 int schedule_work(struct work_struct *works) 423 { 424 #ifndef TARGET_OS2 425 return kernel_thread(work_caller, works, 0) >= 0; 426 #else 427 return 1; 428 #endif 429 } 430 //****************************************************************************** 431 //****************************************************************************** 432 static void delayed_work_timer_fn(unsigned long __data) 433 { 434 struct work_struct *work = (struct work_struct *)__data; 435 struct workqueue_struct *wq = work->wq_data; 436 437 if (wq) 438 __x_queue_work(wq, work); 439 else 440 schedule_work(work); 441 } 442 //****************************************************************************** 443 //****************************************************************************** 444 int queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay) 445 { 446 struct work_struct *work = &dwork->work; 447 struct timer_list *timer = &work->timer; 448 449 if (!test_and_set_bit(0, &work->pending)) { 450 work->wq_data = wq; 451 timer->expires = jiffies + delay; 452 timer->data = (unsigned long)work; 453 timer->function = delayed_work_timer_fn; 454 add_timer(timer); 455 return 1; 456 } 457 return 0; 458 } 459 //****************************************************************************** 460 //****************************************************************************** 461 /* Greatest common divisor */ 462 unsigned long gcd(unsigned long a, unsigned long b) 463 { 464 unsigned long r; 465 if (a < b) { 466 r = a; 467 a = b; 468 b = r; 469 } 470 while ((r = a % b) != 0) { 471 a = b; 472 b = r; 473 } 474 return b; 475 } 476 477 //****************************************************************************** 478 //****************************************************************************** 479 int strict_strtoul(const char *cp, unsigned int base, unsigned long *res) 480 { 481 char *tail; 482 unsigned long val; 483 size_t len; 484 485 *res = 0; 486 len = strlen(cp); 487 if (len == 0) 488 return -EINVAL; 489 490 val = simple_strtoul(cp, &tail, base); 491 if (tail == cp) 492 return -EINVAL; 493 494 if ((*tail == '\0') || 495 ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) { 496 *res = val; 497 return 0; 498 } 499 500 return -EINVAL; 501 }
Note:
See TracChangeset
for help on using the changeset viewer.