2002-05-22 Jeff Johnston <jjohnstn@redhat.com>

* libc/sys/linux/shm_open.c: New file.
        * libc/sys/linux/shm_unlink.c: Ditto.
        * libc/sys/linux/Makefile.am: Add support for shm_open.c and
        shm_unlink.c.
        * libc/sys/linux/Makefile.in: Regenerated.
        * libc/sys/linux/sys/types.h: Add some additional checks to see
        if clock_t or time_t is already defined.
This commit is contained in:
Jeff Johnston 2002-05-22 20:26:28 +00:00
parent 613251a46d
commit 7736feb276
6 changed files with 99 additions and 13 deletions

View File

@ -1,3 +1,13 @@
2002-05-22 Jeff Johnston <jjohnstn@redhat.com>
* libc/sys/linux/shm_open.c: New file.
* libc/sys/linux/shm_unlink.c: Ditto.
* libc/sys/linux/Makefile.am: Add support for shm_open.c and
shm_unlink.c.
* libc/sys/linux/Makefile.in: Regenerated.
* libc/sys/linux/sys/types.h: Add some additional checks to see
if clock_t or time_t is already defined.
2002-05-22 Jeff Johnston <jjohnstn@redhat.com>
* Makefile.am: Don't pass $toollibdir down directly in

View File

@ -6,14 +6,14 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
SUBDIRS = machine \
.
SUBLIBS = $(LINUX_MACH_LIB)
LIB_SOURCES = \
brk.c flockfile.c funlockfile.c getoptlong.c getreent.c ids.c \
inode.c io.c io64.c linux.c mmap.c \
pread.c pread64.c process.c pwrite.c pwrite64.c raise.c realpath.c \
sched.c select.c signal.c siglongjmp.c socket.c sleep.c stack.c \
sched.c select.c shm_open.c shm_unlink.c signal.c siglongjmp.c \
socket.c sleep.c stack.c \
sysconf.c systat.c system.c tcdrain.c termios.c time.c \
usleep.c wait.c

View File

@ -96,14 +96,14 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
SUBDIRS = machine \
.
SUBLIBS = $(LINUX_MACH_LIB)
LIB_SOURCES = \
brk.c flockfile.c funlockfile.c getoptlong.c getreent.c ids.c \
inode.c io.c io64.c linux.c mmap.c \
pread.c pread64.c process.c pwrite.c pwrite64.c raise.c realpath.c \
sched.c select.c signal.c siglongjmp.c socket.c sleep.c stack.c \
sched.c select.c shm_open.c shm_unlink.c signal.c siglongjmp.c \
socket.c sleep.c stack.c \
sysconf.c systat.c system.c tcdrain.c termios.c time.c \
usleep.c wait.c
@ -139,9 +139,9 @@ LIBS = @LIBS@
@USE_LIBTOOL_FALSE@getoptlong.o getreent.o ids.o inode.o io.o io64.o \
@USE_LIBTOOL_FALSE@linux.o mmap.o pread.o pread64.o process.o pwrite.o \
@USE_LIBTOOL_FALSE@pwrite64.o raise.o realpath.o sched.o select.o \
@USE_LIBTOOL_FALSE@signal.o siglongjmp.o socket.o sleep.o stack.o \
@USE_LIBTOOL_FALSE@sysconf.o systat.o system.o tcdrain.o termios.o \
@USE_LIBTOOL_FALSE@time.o usleep.o wait.o
@USE_LIBTOOL_FALSE@shm_open.o shm_unlink.o signal.o siglongjmp.o \
@USE_LIBTOOL_FALSE@socket.o sleep.o stack.o sysconf.o systat.o system.o \
@USE_LIBTOOL_FALSE@tcdrain.o termios.o time.o usleep.o wait.o
LTLIBRARIES = $(noinst_LTLIBRARIES)
@USE_LIBTOOL_TRUE@liblinux_la_DEPENDENCIES =
@ -149,10 +149,10 @@ LTLIBRARIES = $(noinst_LTLIBRARIES)
@USE_LIBTOOL_TRUE@funlockfile.lo getoptlong.lo getreent.lo ids.lo \
@USE_LIBTOOL_TRUE@inode.lo io.lo io64.lo linux.lo mmap.lo pread.lo \
@USE_LIBTOOL_TRUE@pread64.lo process.lo pwrite.lo pwrite64.lo raise.lo \
@USE_LIBTOOL_TRUE@realpath.lo sched.lo select.lo signal.lo \
@USE_LIBTOOL_TRUE@siglongjmp.lo socket.lo sleep.lo stack.lo sysconf.lo \
@USE_LIBTOOL_TRUE@systat.lo system.lo tcdrain.lo termios.lo time.lo \
@USE_LIBTOOL_TRUE@usleep.lo wait.lo
@USE_LIBTOOL_TRUE@realpath.lo sched.lo select.lo shm_open.lo \
@USE_LIBTOOL_TRUE@shm_unlink.lo signal.lo siglongjmp.lo socket.lo \
@USE_LIBTOOL_TRUE@sleep.lo stack.lo sysconf.lo systat.lo system.lo \
@USE_LIBTOOL_TRUE@tcdrain.lo termios.lo time.lo usleep.lo wait.lo
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)

View File

@ -0,0 +1,48 @@
/* shm_open - open a shared memory file */
/* Copyright 2002, Red Hat Inc. */
#include <sys/types.h>
#include <sys/mman.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <limits.h>
int
shm_open (const char *name, int oflag, mode_t mode)
{
int fd;
char shm_name[PATH_MAX+20] = "/dev/shm/";
/* skip opening slash */
if (*name == '/')
++name;
/* create special shared memory file name and leave enough space to
cause a path/name error if name is too long */
strlcpy (shm_name + 9, name, PATH_MAX + 10);
fd = open (shm_name, oflag, mode);
if (fd != -1)
{
/* once open we must add FD_CLOEXEC flag to file descriptor */
int flags = fcntl (fd, F_GETFD, 0);
if (flags >= 0)
{
flags |= FD_CLOEXEC;
flags = fcntl (fd, F_SETFD, flags);
}
/* on failure, just close file and give up */
if (flags == -1)
{
close (fd);
fd = -1;
}
}
return fd;
}

View File

@ -0,0 +1,28 @@
/* shm_unlink - remove a shared memory file */
/* Copyright 2002, Red Hat Inc. */
#include <sys/types.h>
#include <sys/mman.h>
#include <unistd.h>
#include <string.h>
#include <limits.h>
int
shm_unlink (const char *name)
{
int rc;
char shm_name[PATH_MAX+20] = "/dev/shm/";
/* skip opening slash */
if (*name == '/')
++name;
/* create special shared memory file name and leave enough space to
cause a path/name error if name is too long */
strlcpy (shm_name + 9, name, PATH_MAX + 10);
rc = unlink (shm_name);
return rc;
}

View File

@ -13,13 +13,13 @@
#include <sys/config.h>
#include <machine/types.h>
#ifndef __time_t_defined
#if !defined(__time_t_defined) && !defined(_TIME_T)
#define _TIME_T
#define __time_t_defined
typedef _TIME_T_ time_t;
#endif
#ifndef __clock_t_defined
#if !defined(__clock_t_defined) && !defined(_CLOCK_T)
#define _CLOCK_T
#define __clock_t_defined
typedef _CLOCK_T_ clock_t;