File: eintr_wrapper_semop.h

package info (click to toggle)
fis-gtm 7.1-006-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 32,908 kB
  • sloc: ansic: 344,906; asm: 5,184; csh: 4,859; sh: 2,000; awk: 294; makefile: 73; sed: 13
file content (46 lines) | stat: -rw-r--r-- 1,515 bytes parent folder | download | duplicates (3)
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
44
45
46
/****************************************************************
 *								*
 * Copyright (c) 2011-2021 Fidelity National Information	*
 * Services, Inc. and/or its subsidiaries. All rights reserved.	*
 *								*
 *	This source code contains the intellectual property	*
 *	of its copyright holder(s), and is made available	*
 *	under a license.  If you do not know the terms of	*
 *	the license, please stop and do not read further.	*
 *								*
 ****************************************************************/
#ifndef EINTR_WRP_SEMOP_INCLUDED
#define EINTR_WRP_SEMOP_INCLUDED
#define NO_WAIT 0
#define FORCED_WAIT 1

#include <sys/types.h>
#include <errno.h>
#include "gtm_c_stack_trace_semop.h"
#ifdef DEBUG
#define SEMVALMAX 32767
#endif
/* maintain in parallel with do_semop.c */
#define SEMOP(SEMID, SOPS, NSOPS, RC, TO_WAIT)								\
{													\
	int numsems; 											\
													\
	assert(sizeof(SOPS) >= NSOPS);									\
	for (numsems = NSOPS - 1; numsems >= 0; --numsems)						\
		CHECK_SEMVAL_GRT_SEMOP(SEMID, SOPS[numsems].sem_num, SOPS[numsems].sem_op);		\
	if (FORCED_WAIT == TO_WAIT)									\
	{												\
		RC = try_semop_get_c_stack(SEMID, SOPS, NSOPS);		/* try with patience */		\
		if (0 != RC)										\
		{											\
			errno = RC;									\
			RC = -1;									\
		}											\
	} else												\
	{												\
		assert(NO_WAIT == TO_WAIT);								\
		while (-1 == (RC = semop(SEMID, SOPS, NSOPS)) && ((EINTR == errno)))			\
			;										\
	}												\
}
#endif