wine/ipc/shm_semaph.c
Alexandre Julliard b7258befe0 Release 950901
Thu Aug 31 17:19:57 1995  Alexandre Julliard  <julliard@sunsite.unc.edu>

	* [Configure]
	Added compile-time option for IPC.

	* [configure.in]
	Added command-line options for language, IPC and malloc
	debugging.

	* [controls/menu.c]
	WM_MENUSELECT was sometimes sent to the wrong window.

	* [debugger/break.c]
	For the 'next' command, only step over instruction that require
	it. This allows 'next' to do the right thing with jmp and ret
	instructions.

	* [ipc/*.c] [memory/atom.c] [memory/global.c]
	IPC can now be configured out at compile-time.

	* [loader/task.c]
	Bug fix in TASK_Reschedule() that could cause a task to be deleted
	twice.

	* [miscemu/dosmem.c] (New file)
	Partial emulation of the BIOS data segment.

	* [miscemu/instr.c]
	Trap attempts to access selector 0x40 and remap the access to
	segment __0040H.

	* [tools/build.c]
	Fixed bug in CallTo32_LargeStack() that caused problems when
	compiling Wine with the -fomit-frame-pointer option.

	* [windows/message.c]
	Fixed bug in hardware event handling that could cause some events
	to get ignored.

Sat Aug 26 13:12:59 IST 1995 Michael Veksler <mveksler@vnet.ibm.com>

	* [ipc/README] [ipc/dde.tex]
	LaTeX documentation for the ipc and DDE stuff.

Wed Aug 23 22:01:23 GMT 1995 Michael Veksler <mveksler@vnet.ibm.com>

	* [ipc/Imakefile] [ipc/wine_test_stub.c]
	Fixed IPC testing. Now it can be compiled with "make tests"

Wed Aug 23 21:04:14 1995  Fons Botman  <botman@wab-tis.rabobank.nl>

	* [if1632/kernel.spec] [include/windows.h] [misc/main.c]
	Added GetWinDebugInfo/SetWinDebugInfo stub for player.exe

Sun Aug  20 13:49:42 1995  Marcus Meissner  <msmeissn@faui01.informatik.uni-erlangen.de>

	* [miscemu/int21.c]
	Misc fix to int21,ah=40 (write) to match _lwrite().
	AX=0x440A (check if handle is remote) added.

	* [multimedia/mmsystem.c]
	Moved mciSendString to mcistring.c.

	* [multimedia/mcistring.c]
	New file, string interface for MCI (not complete, not thoroughly
	tested).

	* [multimedia/audio.c]
	IOCTL prints errors; one paranoid check disabled.

	* [misc/file.c]
	Misc operator precedence fixes.

	* [if1632/gdi.spec] [objects/bitblt.c]
	Stub for FastWindowFrame (parameters not correct).

Sat Aug 19 01:31:23 1995  Graham Menhennitt <gfm@werple.mira.net.au>

	* [loader/ne_image.c]
	Preliminary support for iterated segments.

Sat Aug 19 00:43:04 1995  Andrew Taylor  (andrew@riscan.com)

	* [windows/mapping.c]
	In function MAPPING_FixIsotropic(), VportExt[XY] is multiplied by
 	the absolute value of (ydim / xdim) or (xdim / ydim).

Thu Aug 15 23:00:16  Gregory Trubetskoy  <grisha@mira.com>

	* [objects/oembitmap.c]
	Added some includes for Windows 95.

	* [include/sysmetrics.h]
	Added some sysmetrics for Windows 95.

	* [include/bitmaps/*95]
	New files: obm_close_95, obm_closed_95, obm_reduce_95, obm_reduced_95
	obm_zoom_95, obm_zoomd_95 - these are some pixmaps for Windows 95.

Thu Aug 10 12:00:00 1995  Jan Willamowius  (jan@janhh.shnet.org)

	* [misc/shell.c] [rc/sysres*.rc]
	The caption of the ShellAbout dialog box is language specific and
 	should be defined in the resources.
1995-09-01 15:57:28 +00:00

141 lines
3.6 KiB
C

/***************************************************************************
* Copyright 1995, Technion, Israel Institute of Technology
* Electrical Eng, Software Lab.
* Author: Michael Veksler.
***************************************************************************
* File: shm_semaph.c
* Purpose: Handle semaphores for shared memory operations.
***************************************************************************
*/
#ifdef CONFIG_IPC
#define inline __inline__
#include <assert.h>
#include <unistd.h>
#include <sys/sem.h>
#include <stdio.h>
#include <errno.h>
#include <stddebug.h>
#include <debug.h>
#include "shm_semaph.h"
#define SEM_READ 0
#define SEM_WRITE 1
/* IMPORTANT: Make sure that killed process will not lock everything.
* If possible, restrict usage of these functions.
*/
void shm_read_wait(shm_sem semid)
{
struct sembuf sop[2];
int ret;
dprintf_sem(stddeb,"shm_read_wait(%d)\n",semid);
sop[0].sem_num=SEM_READ;
sop[0].sem_op=1; /* add this read instance */
sop[0].sem_flg=SEM_UNDO; /* undo in case process dies */
sop[1].sem_num=SEM_WRITE;
sop[1].sem_op=0; /* wait until no writing instance exists */
sop[1].sem_flg=SEM_UNDO;
do {
ret=semop (semid,sop , 2);
} while (ret<0 && errno==EINTR); /* interrupted system call? */
if (ret<0)
fprintf(stderr,"failed semaphore lock for read. semid=%d,errno=%d\n",
semid, errno);
}
void shm_write_wait(shm_sem semid)
{
struct sembuf sop[3];
int ret;
dprintf_sem(stddeb,"shm_write_wait(%d)\n",semid);
sop[0].sem_num=SEM_READ;
sop[0].sem_op=0; /* wait until no reading instance exist */
sop[0].sem_flg=SEM_UNDO;
sop[1].sem_num=SEM_WRITE;
sop[1].sem_op=1; /* writing is in progress - disable read */
sop[1].sem_flg=SEM_UNDO; /* undo if process dies */
sop[2].sem_num=SEM_READ;
sop[2].sem_op=1; /* disable new writes */
sop[2].sem_flg=SEM_UNDO;
do {
ret=semop (semid,sop , 3);
} while (ret<0 && errno==EINTR); /* interrupted system call? */
if (ret<0) /* test for the error */
fprintf(stderr,"failed semaphore lock for write. semid=%d,errno=%d\n",
semid, errno);
}
void shm_write_signal(shm_sem semid)
{
struct sembuf sop[2];
int ret;
dprintf_sem(stddeb,"shm_write_signal(%d)\n",semid);
sop[0].sem_num=SEM_READ;
sop[0].sem_op=-1;
sop[0].sem_flg=IPC_NOWAIT | SEM_UNDO; /* no reason to wait */
sop[1].sem_num=SEM_WRITE;
sop[1].sem_op=-1;
sop[1].sem_flg=IPC_NOWAIT | SEM_UNDO; /* no reason to wait */
do {
ret=semop (semid,sop , 2);
} while (ret<0 && errno==EINTR); /* interrupted system call? */
if (ret<0) /* test for the error */
fprintf(stderr,"failed semaphore unlock for write. semid=%d,errno=%d\n",
semid, errno);
}
void shm_read_signal(shm_sem semid)
{
struct sembuf sop[2];
int ret;
dprintf_sem(stddeb,"shm_read_signal(%d)\n",semid);
sop[0].sem_num=SEM_READ;
sop[0].sem_op=-1;
sop[0].sem_flg=IPC_NOWAIT | SEM_UNDO; /* no reason to wait */
do {
ret=semop (semid,sop , 1);
} while (ret<0 && errno==EINTR); /* interrupted system call? */
if (ret<0) /* test for the error */
fprintf(stderr,"failed semaphore unlock for read. semid=%d,errno=%d\n",
semid, errno);
}
void shm_sem_init(shm_sem *sptr)
{
shm_sem semid;
union semun arg;
semid=semget (IPC_PRIVATE, 2, 0700 | IPC_CREAT);
arg.val=0;
semctl (semid, 0, SETVAL, arg);
semctl (semid, 1, SETVAL, arg);
*sptr=semid;
}
void shm_sem_done(shm_sem *semptr)
{
union semun arg;
semctl (*semptr, 0, IPC_RMID , arg);
semctl (*semptr, 1, IPC_RMID , arg);
*semptr= -1;
}
#endif /* CONFIG_IPC */