AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
  • 1.  AIX 5.1 POSIX Timer Function timer_create() Compilation Problems

    Posted Mon October 01, 2007 05:26 PM

    Originally posted by: SystemAdmin


    Hello,

    I've surfed and have found various examples on creating POSIX timers using timer_create(), but for some reason am having lots of trouble with this on the AIX 5.1 platform. The AIX platform for some reason doesn't recognize the SIGEV_THREAD keyword, although just about every example of POSIX timer implementation includes the use of this keyword.

    Here is the code that I'm implementing thus far, which is similar to what is being implemented on other platforms.

    #include <stdlib.h>
    #include <sys/time.h>
    #include <sys/signal.h>
    #include <semaphore.h>
    #include <sys/errno.h>
    #include <pthread.h>

    void callback(union sigval sigev_value) { printf("In callback()\n"); }

    void main()
    {
    int rc;
    timer_t timer_id;
    struct sigevent evp;

    int errno = 0;
    evp.sigev_notify = SIGEV_THREAD;
    evp.sigev_notify_function = callback;
    evp.sigev_notify_attributes = NULL;
    evp.sigev_value.sival_ptr = &timer_id;

    /** if (rc = timer_create(CLOCK_REALTIME, NULL &evp, &timer_id)) { **/
    if (rc = timer_create(CLOCK_REALTIME, &evp, &timer_id)) {

    }

    printf("timer_create() Rtn rc %d error %d\n", rc, errno);
    perror("");
    exit(rc);
    }

    And when I compile (cc timer.c -o timer), I get the following error:

    "timer.c", line 19.24: 1506-045 (S) Undeclared Identifier SIGEV_THREAD.

    Any idea what I need to include to get this to compile on AIX 5.1? Or, perhaps,
    it is not included in any of the files in the /usr/include dir on AIX 5.1?

    Any help or info. would be great.
    Thanks,
    dedham_ma_man

    #AIX-Forum


  • 2.  Re: AIX 5.1 POSIX Timer Function timer_create() Compilation Problems

    Posted Mon October 01, 2007 06:52 PM

    Originally posted by: rayhiggs


    I don't have an AIX 5.1 machine anymore, but take a look at /usr/include/sys/signal.h. I bet there is some ifdef'ing around SIGEV_THREAD.
    #AIX-Forum


  • 3.  Re: AIX 5.1 POSIX Timer Function timer_create() Compilation Problems

    Posted Tue October 02, 2007 09:11 AM

    Originally posted by: SystemAdmin


    Yeah, I had thought of that too, but oddly enough, upon searching signal.h, there's no sign at all of the SIGEV_THREAD keyword. Thanks anyway.
    dedham_ma_man
    #AIX-Forum


  • 4.  Re: AIX 5.1 POSIX Timer Function timer_create() Compilation Problems

    Posted Mon October 08, 2007 03:12 PM

    Originally posted by: SystemAdmin


    Your code compiles fine for me on AIX 5.2.

    In AIX 5.2, there are two signal.h header files (and they both should exist in 5.1 as well):
    /usr/include/sys/signal.h
    /usr/include/signal.h

    SIGEV_THREAD is defined in /usr/include/sys/signal.h but it is NOT defined in /usr/include/signal.h.

    You might check to make sure that you are picking up the correct file (e.g., if you have access you could put a #error into /usr/include/sys/signal.h).
    #AIX-Forum