2 * Copyright (c) 1994, 1995. Netscape Communications Corporation. All
5 * Use of this software is governed by the terms of the license agreement for
6 * the Netscape Communications or Netscape Comemrce Server between the
11 /* ------------------------------------------------------------------------ */
15 * shmem.h: Portable abstraction for memory shared among a server's workers
28 /* --------------------------- Data structures ---------------------------- */
31 #if defined (SHMEM_UNIX_MMAP) || defined (SHMEM_WIN32_MMAP)
32 #include "file.h" /* SYS_FILE */
35 void *data
; /* the data */
36 #ifdef SHMEM_WIN32_MMAP
38 #endif /* SHMEM_WIN32_MMAP */
39 int size
; /* the maximum length of the data */
41 char *name
; /* internal use: filename to unlink if exposed */
42 SYS_FILE fd
; /* internal use: file descriptor for region */
46 /* ------------------------------ Prototypes ------------------------------ */
50 * shmem_alloc allocates a region of shared memory of the given size, using
51 * the given name to avoid conflicts between multiple regions within the
52 * program. The region will not be automatically grown if its boundaries
53 * are over-run, use shmem_realloc for that.
55 * If expose is non-zero and the underlying system supports it, the
56 * file used to create the shared region will be visible to other processes
57 * running on the system.
59 * name should be unique to the program which calls this routine, otherwise
60 * conflicts will arise.
62 * Returns a new shared memory region, with the data element being a
63 * pointer to the shared memory. This function must be called before any
64 * daemon workers are spawned, in order for the handle to the shared region
65 * to be inherited by the children.
67 * Because of the requirement that the region must be inherited by the
68 * children, the region cannot be re-allocated with a larger size when
71 shmem_s
*shmem_alloc(char *name
, int size
, int expose
);
75 * shmem_free de-allocates the specified region of shared memory.
77 void shmem_free(shmem_s
*region
);
79 #endif /* SHMEM_UNIX_MMAP || SHMEM_WIN32_MMAP */