create.h File Reference
`#include "spebase.h"`
Include dependency graph for create.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Functions

int | _base_spe_open_if_closed (struct spe_context *spe, enum fd_name fdesc, int locked)
void | _base_spe_close_if_open (struct spe_context *spe, enum fd_name fdesc)

## Function Documentation

void _base_spe_close_if_open | ( | struct spe_context * | spe,
|  | enum fd_name | fdesc
| ) |  |

Definition at line 125 of file create.c.

References _base_spe_context_lock(), _base_spe_context_unlock(), spe_context::base_private, spe_context_base_priv::spe_fds_array, and spe_context_base_priv::spe_fds_refcount.

Referenced by __base_spe_event_source_release(), and _base_spe_signal_write().

{
_base_spe_context_lock(spe, fdesc);
if (spe->base_private->spe_fds_array[(int)fdesc] != -1 &&
spe->base_private->spe_fds_refcount[(int)fdesc] == 1) {
spe->base_private->spe_fds_refcount[(int)fdesc]--;
close(spe->base_private->spe_fds_array[(int)fdesc]);
spe->base_private->spe_fds_array[(int)fdesc] = -1;
} else if (spe->base_private->spe_fds_refcount[(int)fdesc] > 0) {
spe->base_private->spe_fds_refcount[(int)fdesc]--;
}
_base_spe_context_unlock(spe, fdesc);
}

Here is the call graph for this function:

int _base_spe_open_if_closed | ( | struct spe_context * | spe,
|  | enum fd_name | fdesc,
|  | int | locked
| ) |  |

Definition at line 101 of file create.c.

References _base_spe_context_lock(), _base_spe_context_unlock(), spe_context::base_private, spe_context_base_priv::fd_spe_dir, fd_attr::mode, fd_attr::name, spe_context_base_priv::spe_fds_array, and spe_context_base_priv::spe_fds_refcount.

Referenced by __base_spe_event_source_acquire(), _base_spe_in_mbox_status(), _base_spe_in_mbox_write(), _base_spe_mssync_start(), _base_spe_mssync_status(), _base_spe_out_intr_mbox_read(), _base_spe_out_intr_mbox_status(), _base_spe_out_mbox_read(), _base_spe_out_mbox_status(), and _base_spe_signal_write().

{
if (!locked)
_base_spe_context_lock(spe, fdesc);
/* already open? */
if (spe->base_private->spe_fds_array[fdesc] != -1) {
spe->base_private->spe_fds_refcount[fdesc]++;
} else {
spe->base_private->spe_fds_array[fdesc] =
openat(spe->base_private->fd_spe_dir,
spe_fd_attr[fdesc].name,
spe_fd_attr[fdesc].mode);
if (spe->base_private->spe_fds_array[(int)fdesc] > 0)
spe->base_private->spe_fds_refcount[(int)fdesc]++;
}
if (!locked)
_base_spe_context_unlock(spe, fdesc);
return spe->base_private->spe_fds_array[(int)fdesc];
}

Here is the call graph for this function: