summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
c17bfe9)
This replaces the C99-only initializations in mutex_lock() and
mutex_try_lock() by equivalent but portable code.
static int mutex_lock(int id)
{
static int mutex_lock(int id)
{
int ret;
DSS_DEBUG_LOG("locking\n");
int ret;
DSS_DEBUG_LOG("locking\n");
- struct sembuf sops[4] = {
- {
- .sem_num = 0,
- .sem_op = 0,
- .sem_flg = SEM_UNDO | IPC_NOWAIT
- },
- {
- .sem_num = 0,
- .sem_op = 1,
- .sem_flg = SEM_UNDO | IPC_NOWAIT
- },
- {
- .sem_num = 1,
- .sem_op = 0,
- .sem_flg = SEM_UNDO | IPC_NOWAIT
- },
- {
- .sem_num = 1,
- .sem_op = 1,
- .sem_flg = SEM_UNDO | IPC_NOWAIT
- }
- };
+
+ sops[0].sem_num = 0;
+ sops[0].sem_op = 0;
+ sops[0].sem_flg = SEM_UNDO | IPC_NOWAIT;
+
+ sops[1].sem_num = 0;
+ sops[1].sem_op = 1;
+ sops[1].sem_flg = SEM_UNDO | IPC_NOWAIT;
+
+ sops[2].sem_num = 1;
+ sops[2].sem_op = 0;
+ sops[2].sem_flg = SEM_UNDO | IPC_NOWAIT;
+
+ sops[3].sem_num = 1;
+ sops[3].sem_op = 1;
+ sops[3].sem_flg = SEM_UNDO | IPC_NOWAIT;
+
ret = do_semop(id, sops, 4);
if (ret < 0)
return -ERRNO_TO_DSS_ERROR(errno);
ret = do_semop(id, sops, 4);
if (ret < 0)
return -ERRNO_TO_DSS_ERROR(errno);
static int mutex_try_lock(int id)
{
static int mutex_try_lock(int id)
{
int ret;
DSS_DEBUG_LOG("trying to lock\n");
int ret;
DSS_DEBUG_LOG("trying to lock\n");
- struct sembuf sops[2] = {
- {
- .sem_num = 0,
- .sem_op = 0,
- .sem_flg = SEM_UNDO | IPC_NOWAIT
- },
- {
- .sem_num = 0,
- .sem_op = 1,
- .sem_flg = SEM_UNDO | IPC_NOWAIT
- }
- };
+
+ sops[0].sem_num = 0;
+ sops[0].sem_op = 0;
+ sops[0].sem_flg = SEM_UNDO | IPC_NOWAIT;
+
+ sops[1].sem_num = 0;
+ sops[1].sem_op = 1;
+ sops[1].sem_flg = SEM_UNDO | IPC_NOWAIT;
+
ret = do_semop(id, sops, 2);
if (ret < 0)
return -ERRNO_TO_DSS_ERROR(errno);
ret = do_semop(id, sops, 2);
if (ret < 0)
return -ERRNO_TO_DSS_ERROR(errno);