OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [test/] [misc/] [sem.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
#include <stdio.h>
2
#include <sys/types.h>
3
#include <sys/ipc.h>
4
#include <sys/sem.h>
5
 
6
int main(void)
7
{
8
    int k, r;
9
    union semun {
10
        int val;
11
        struct semid_ds *buf;
12
        unsigned short int *array;
13
        struct seminfo *__buf;
14
    } sd;
15
    struct semid_ds sd_buf;
16
 
17
    k = semget(IPC_PRIVATE, 10, IPC_CREAT | 0666 );
18
    printf("%d\n", k);
19
 
20
    if (k < 0) {
21
        printf("semget failed: %m\n");
22
        return 1;
23
    }
24
 
25
    sd.buf = &sd_buf;
26
    r = semctl(k, 0, IPC_STAT, sd);
27
    printf("%d\n", r);
28
 
29
    if (r < 0) {
30
        printf("semctl IPC_STAT failed: %m\n");
31
        return 1;
32
    }
33
 
34
    printf("sem_nsems = %lu\n", sd_buf.sem_nsems);
35
    if (sd_buf.sem_nsems != 10) {
36
        printf("failed: incorrect sem_nsems!\n");
37
        return 1;
38
    }
39
 
40
    printf("succeeded\n");
41
 
42
    return 0;
43
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.