File: test_api.c

package info (click to toggle)
librtpi 1.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 524 kB
  • sloc: ansic: 3,463; cpp: 1,121; makefile: 62; sh: 40
file content (43 lines) | stat: -rw-r--r-- 764 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-License-Identifier: LGPL-2.1-only
// Copyright © 2018 VMware, Inc. All Rights Reserved.

#include <pthread.h>
#include <stdio.h>

#include "rtpi.h"

int main(int argc, char *argv)
{
	pi_mutex_t *mutex;
	pi_cond_t *cond;
	int ret;

	mutex = pi_mutex_alloc();
	if (!mutex) {
		printf("ERROR: failed to allocated a mutex.\n");
		goto out;
	}
	cond = pi_cond_alloc();
	if (!cond) {
		printf("ERROR: failed to allocated a cond.\n");
		goto out;
	}
	ret = pi_mutex_init(mutex, 0x0);
	if (ret) {
		printf("ERROR: pi_mutex_init returned %d\n", ret);
		goto out;
	}

	ret = pi_cond_init(cond, 0x0);
	if (ret) {
		printf("ERROR: pi_cond_init returned %d\n", ret);
		goto out;
	}

	printf("mutex @ %p\n", mutex);
	printf("cond @ %p\n", cond);

 out:
	return ret;
}