Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
cpu_set_t: what's the equivalent for NetBSD?
Hi!
Can someone please tell me how the following code should be rewritten
for NetBSD?
I tried replacing cpu_set_t with cpuset_t, but then the size wasn't
known for cmask, and CPU_ZERO and CPU_SET don't exist.
The code is from sdlmame (wip/sdlmame).
//============================================================
//  osd_thread_cpu_affinity
//============================================================
int osd_thread_cpu_affinity(osd_thread *thread, UINT32 mask)
{
#if !defined(NO_THREAD_COOPERATIVE) && !defined(NO_AFFINITY_NP)
        cpu_set_t       cmask;
        pthread_t       lthread;
        int                     bitnum;
        CPU_ZERO(&cmask);
        for (bitnum=0; bitnum<32; bitnum++)
                if (mask & (1<<bitnum))
                        CPU_SET(bitnum, &cmask);
        
        if (thread == NULL)
                lthread = pthread_self();
        else
                lthread = thread->thread;
    
        if (pthread_setaffinity_np(lthread, sizeof(cmask), &cmask) <0)
        {
                /* Not available during link in all targets */
                fprintf(stderr, "error %d setting cpu affinity to mask %08x", 
errno, mask);
                return FALSE;
        }
        else
                return TRUE;
#else
        return TRUE;
#endif
}
Thank you,
 Thomas
Home |
Main Index |
Thread Index |
Old Index