X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=ipc.c;h=d7f515dfec8788f267a41f8c33264d25b15abf8a;hp=89bbe53564e3c678e97b453e38b7c70be8063314;hb=8aac5dd1bc1520ea8c518e902ecc82bb198d993f;hpb=5ae09eae1f157cbfcbe6f20c50d559cd6ad4c128 diff --git a/ipc.c b/ipc.c index 89bbe535..d7f515df 100644 --- a/ipc.c +++ b/ipc.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2013 Andre Noll + * Copyright (C) 2006 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -161,6 +161,27 @@ int shm_attach(int id, enum shm_attach_mode mode, void **result) return *result == (void *) -1? -ERRNO_TO_PARA_ERROR(errno) : 1; } +/** + * Get the size of a shared memory segment. + * + * \param id The shared memory segment identifier. + * \param result Size in bytes is returned here, zero on errors. + * + * \return Standard. + * + * \sa shmctl(2). + */ +int shm_size(int id, size_t *result) +{ + struct shmid_ds ds; /* data structure */ + + *result = 0; + if (shmctl(id, IPC_STAT, &ds) < 0) + return -ERRNO_TO_PARA_ERROR(errno); + *result = ds.shm_segsz; + return 1; +} + /** * Detach a shared memory segment. *