acl/lib_acl/include/stdlib/acl_myflock.h

50 lines
1.3 KiB
C
Raw Normal View History

#ifndef ACL_FLOCK_INCLUDE_H
2014-11-19 00:25:21 +08:00
#define ACL_FLOCK_INCLUDE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "acl_define.h"
/**
*
* @param fd {ACL_FILE_HANDLE}
* @param lock_style {int} API加锁类型UNIX有效
2014-11-19 00:25:21 +08:00
* ACL_FLOCK_STYLE_FLOCK or ACL_FLOCK_STYLE_FCNTL
* @param operation {int} , ACL_FLOCK_OP_XXX
* @return {int} 0: ; -1:
2014-11-19 00:25:21 +08:00
*/
ACL_API int acl_myflock(ACL_FILE_HANDLE fd, int lock_style, int operation);
/*
* Lock styles.
*/
#define ACL_FLOCK_STYLE_FLOCK 1 /**< 调用 flock 函数加锁(unix) */
#define ACL_FLOCK_STYLE_FCNTL 2 /**< 调用 fcntl 函数加锁(unix) */
2014-11-19 00:25:21 +08:00
/*
* Lock request types.
*/
#define ACL_FLOCK_OP_NONE 0 /**< 解锁 */
#define ACL_FLOCK_OP_SHARED 1 /**< 共享锁 */
#define ACL_FLOCK_OP_EXCLUSIVE 2 /**< 排它独享锁 */
2014-11-19 00:25:21 +08:00
/**
* , ACL_FLOCK_OP_SHARED, ACL_FLOCK_OP_EXCLUSIVE ,
* ACL_FLOCK_OP_SHARED
2014-11-19 00:25:21 +08:00
*/
#define ACL_FLOCK_OP_NOWAIT 4
/**
*
2014-11-19 00:25:21 +08:00
*/
#define ACL_FLOCK_OP_BITS \
(ACL_FLOCK_OP_SHARED | ACL_FLOCK_OP_EXCLUSIVE | ACL_FLOCK_OP_NOWAIT)
#ifdef __cplusplus
}
#endif
#endif