Changeset 518 for GPL/trunk/lib32/misc.c


Ignore:
Timestamp:
Jul 20, 2010, 5:46:55 PM (15 years ago)
Author:
David Azarewicz
Message:

Some of my updates from the 2.1.x branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk/lib32/misc.c

    r505 r518  
    4040#include <dbgos2.h>
    4141
     42void StringOut(char *DbgStr);
     43
    4244struct new_utsname system_utsname = {0};
    4345struct resource ioport_resource = {NULL, 0, 0, IORESOURCE_IO, NULL, NULL, NULL};
     
    7577    }
    7678
    77     dprintf( (pszLastALSAError) );
     79        StringOut(pszLastALSAError);
     80//    rprintf( (pszLastALSAError) );
    7881    if(++iLastError > 1) {
    7982        iLastError = 0;
     
    406409//******************************************************************************
    407410//******************************************************************************
     411#define del_timer_sync(t) del_timer(t) /* FIXME: not quite correct on SMP */
     412int cancel_delayed_work(struct delayed_work *dwork)
     413{
     414        struct work_struct *work = &dwork->work;
     415        int ret;
     416
     417        ret = del_timer_sync(&work->timer);
     418        if (ret)
     419                clear_bit(0, &work->pending);
     420        return ret;
     421}
     422//******************************************************************************
     423//******************************************************************************
     424int schedule_work(struct work_struct *works)
     425{
     426#ifndef TARGET_OS2
     427        return kernel_thread(work_caller, works, 0) >= 0;
     428#else
     429        return 1;
     430#endif
     431}
     432//******************************************************************************
     433//******************************************************************************
     434static void delayed_work_timer_fn(unsigned long __data)
     435{
     436        struct work_struct *work = (struct work_struct *)__data;
     437        struct workqueue_struct *wq = work->wq_data;
     438       
     439        if (wq)
     440                __x_queue_work(wq, work);
     441        else
     442                schedule_work(work);
     443}
     444//******************************************************************************
     445//******************************************************************************
     446int queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay)
     447{
     448        struct work_struct *work = &dwork->work;
     449        struct timer_list *timer = &work->timer;
     450
     451        if (!test_and_set_bit(0, &work->pending)) {
     452                work->wq_data = wq;
     453                timer->expires = jiffies + delay;
     454                timer->data = (unsigned long)work;
     455                timer->function = delayed_work_timer_fn;
     456                add_timer(timer);
     457                return 1;
     458        }
     459        return 0;
     460}
     461//******************************************************************************
     462//******************************************************************************
     463/* Greatest common divisor */
     464unsigned long gcd(unsigned long a, unsigned long b)
     465{
     466        unsigned long r;
     467        if (a < b) {
     468                r = a;
     469                a = b;
     470                b = r;
     471        }
     472        while ((r = a % b) != 0) {
     473                a = b;
     474                b = r;
     475        }
     476        return b;
     477}
     478
     479//******************************************************************************
     480//******************************************************************************
     481int strict_strtoul(const char *cp, unsigned int base, unsigned long *res)
     482{
     483        char *tail;
     484        unsigned long val;
     485        size_t len;
     486
     487        *res = 0;
     488        len = strlen(cp);
     489        if (len == 0)
     490                return -EINVAL;
     491
     492        val = simple_strtoul(cp, &tail, base);
     493        if (tail == cp)
     494                return -EINVAL;
     495
     496        if ((*tail == '\0') ||
     497                ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {
     498                *res = val;
     499                return 0;
     500        }
     501
     502        return -EINVAL;
     503}
Note: See TracChangeset for help on using the changeset viewer.