Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sys/time.h problem



Iam using this funktion:


#include "timer.h"

/*--------------------------------------------------------------------------
* Local Data
*--------------------------------------------------------------------------*/
static struct bc_timer **timer_list;
static int timer_max;

/*--------------------------------------------------------------------------*
 *--------------------------------------------------------------------------*/
int
timer_pending(void)
{
    int i;

    for (i = 0; i < timer_max; i++) {
        if (timer_list[i]) {
            return 1;
        }
    }
    return 0;
}

/*--------------------------------------------------------------------------*
 *--------------------------------------------------------------------------*/
int
timer_expired(void)
{
    struct bc_timer *bct;
    int i;
    struct timeval tn;

    (void)gettimeofday(&tn, NULL);

    for (i = 0; i < timer_max; i++) {
        bct = timer_list[i];
        if (bct) {
            if ((bct->tv.tv_sec <= tn.tv_sec) && (bct->tv.tv_usec <= tn.tv_usec)) {
                timer_list[i] = NULL;
                (bct->function)(bct->data);
            }
        }
    }
    return 1;
}




how can I remake the code to get it to work ?

Thanks
Yours
Thomas
Denmark



Den 24/10/2005 kl. 18.58 skrev email@hidden:


On Oct 24, 2005, at 8:31 AM, Thomas Nielsen wrote:

I'm attempting to compile this code but is stops at "int timer_pending(void);" can you help me find the problem ?


#ifndef _TIMER_H
#define _TIMER_H

#include <sys/time.h>

struct bc_timer {
    struct timeval tv;
    void (*function)(void *);
    void *data;
};

int timer_init(int max);
int timer_pending(void);
int timer_expired(void);
int timer_add(struct bc_timer *bct, long timeout);
void timer_remove(struct bc_timer *bct);
#endif

You probably have "max" defined as a preprocessor macro somewhere (i.e. some other header has "#define max(a,b) ({ a > b ? a : b })").

Brendan Younger
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Unix-porting mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Unix-porting mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/unix-porting/email@hidden

This email sent to email@hidden

References: 
 >sys/time.h problem (From: Thomas Nielsen <email@hidden>)
 >Re: sys/time.h problem (From: email@hidden)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.