Commit 25214cb3 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

access_shm: use HAVE_SYS_SHM_H

parent a2dd68cb
...@@ -26,8 +26,10 @@ ...@@ -26,8 +26,10 @@
#include <stdarg.h> #include <stdarg.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/ipc.h> #ifdef HAVE_SYS_SHM_H
#include <sys/shm.h> # include <sys/ipc.h>
# include <sys/shm.h>
#endif
#include <sys/mman.h> #include <sys/mman.h>
#include <vlc_common.h> #include <vlc_common.h>
...@@ -105,16 +107,19 @@ vlc_module_begin () ...@@ -105,16 +107,19 @@ vlc_module_begin ()
* memory location via an unsafe variable rather than the URL. */ * memory location via an unsafe variable rather than the URL. */
add_string ("shm-file", NULL, FILE_TEXT, FILE_LONGTEXT, false) add_string ("shm-file", NULL, FILE_TEXT, FILE_LONGTEXT, false)
change_volatile () change_volatile ()
#ifdef HAVE_SYS_SHM_H
add_integer ("shm-id", (int64_t)IPC_PRIVATE, ID_TEXT, ID_LONGTEXT, false) add_integer ("shm-id", (int64_t)IPC_PRIVATE, ID_TEXT, ID_LONGTEXT, false)
change_volatile () change_volatile ()
#endif
add_shortcut ("shm") add_shortcut ("shm")
vlc_module_end () vlc_module_end ()
static void Demux (void *); static void Demux (void *);
static int Control (demux_t *, int, va_list); static int Control (demux_t *, int, va_list);
static void map_detach (demux_sys_t *); static void map_detach (demux_sys_t *);
#ifdef HAVE_SYS_SHM_H
static void sysv_detach (demux_sys_t *); static void sysv_detach (demux_sys_t *);
#endif
static void no_detach (demux_sys_t *); static void no_detach (demux_sys_t *);
struct demux_sys_t struct demux_sys_t
...@@ -198,6 +203,7 @@ static int Open (vlc_object_t *obj) ...@@ -198,6 +203,7 @@ static int Open (vlc_object_t *obj)
} }
else else
{ {
#ifdef HAVE_SYS_SHM_H
int id = var_InheritInteger (demux, "shm-id"); int id = var_InheritInteger (demux, "shm-id");
if (id == IPC_PRIVATE) if (id == IPC_PRIVATE)
goto error; goto error;
...@@ -210,6 +216,9 @@ static int Open (vlc_object_t *obj) ...@@ -210,6 +216,9 @@ static int Open (vlc_object_t *obj)
} }
sys->addr = mem; sys->addr = mem;
sys->detach = sysv_detach; sys->detach = sysv_detach;
#else
goto error;
#endif
} }
/* Initializes format */ /* Initializes format */
...@@ -274,11 +283,12 @@ static void map_detach (demux_sys_t *sys) ...@@ -274,11 +283,12 @@ static void map_detach (demux_sys_t *sys)
munmap ((void *)sys->addr, sys->length); munmap ((void *)sys->addr, sys->length);
} }
#ifdef HAVE_SYS_SHM_H
static void sysv_detach (demux_sys_t *sys) static void sysv_detach (demux_sys_t *sys)
{ {
shmdt (sys->addr); shmdt (sys->addr);
} }
#endif
static void no_detach (demux_sys_t *sys) static void no_detach (demux_sys_t *sys)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment