diff --git a/janus/src/uslibs/memsinksh.c b/janus/src/uslibs/memsinksh.c new file mode 120000 index 0000000..c4edd14 --- /dev/null +++ b/janus/src/uslibs/memsinksh.c @@ -0,0 +1 @@ +../../../src/libs/memsinksh.c \ No newline at end of file diff --git a/python/src/uslibs/memsinksh.c b/python/src/uslibs/memsinksh.c new file mode 120000 index 0000000..c4edd14 --- /dev/null +++ b/python/src/uslibs/memsinksh.c @@ -0,0 +1 @@ +../../../src/libs/memsinksh.c \ No newline at end of file diff --git a/src/libs/memsinksh.c b/src/libs/memsinksh.c new file mode 100644 index 0000000..96a5940 --- /dev/null +++ b/src/libs/memsinksh.c @@ -0,0 +1,48 @@ +/***************************************************************************** +# # +# uStreamer - Lightweight and fast MJPEG-HTTP streamer. # +# # +# Copyright (C) 2018-2023 Maxim Devaev # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +*****************************************************************************/ + + +#include "memsinksh.h" + +#include + +#include + +#include "types.h" + + +us_memsink_shared_s *us_memsink_shared_map(int fd) { + us_memsink_shared_s *mem = mmap( + NULL, + sizeof(us_memsink_shared_s), + PROT_READ | PROT_WRITE, MAP_SHARED, + fd, 0); + if (mem == MAP_FAILED) { + return NULL; + } + assert(mem != NULL); + return mem; +} + +int us_memsink_shared_unmap(us_memsink_shared_s *mem) { + assert(mem != NULL); + return munmap(mem, sizeof(us_memsink_shared_s)); +} diff --git a/src/libs/memsinksh.h b/src/libs/memsinksh.h index a4d0d8a..9fc6c87 100644 --- a/src/libs/memsinksh.h +++ b/src/libs/memsinksh.h @@ -22,8 +22,6 @@ #pragma once -#include - #include "types.h" @@ -62,23 +60,5 @@ typedef struct { } us_memsink_shared_s; -INLINE us_memsink_shared_s *us_memsink_shared_map(int fd) { - us_memsink_shared_s *mem = mmap( - NULL, - sizeof(us_memsink_shared_s), - PROT_READ | PROT_WRITE, - MAP_SHARED, - fd, - 0 - ); - if (mem == MAP_FAILED) { - return NULL; - } - assert(mem != NULL); - return mem; -} - -INLINE int us_memsink_shared_unmap(us_memsink_shared_s *mem) { - assert(mem != NULL); - return munmap(mem, sizeof(us_memsink_shared_s)); -} +us_memsink_shared_s *us_memsink_shared_map(int fd); +int us_memsink_shared_unmap(us_memsink_shared_s *mem);