1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

Revert "IPC: added the prefix 'my' to the semaphore functions."

This reverts commit e6e8b3407d.
This commit is contained in:
Witold Filipczyk 2007-09-02 16:56:10 +02:00 committed by Witold Filipczyk
parent 2d69e2e625
commit cdcbdd720d
4 changed files with 24 additions and 28 deletions

View File

@ -65,7 +65,7 @@ struct program program;
int epoll_fd;
int master_sem = -1;
int shared_mem_ipc = -1;
char *shared_mem = NULL;
unsigned char *shared_mem = NULL;
static int ac;
static unsigned char **av;
@ -124,14 +124,12 @@ init_master_ipc(void)
return;
k1 = ftok(filename.source, 1);
k2 = ftok(filename.source, 2);
master_sem = mysem_create(k1, 0);
master_sem = sem_create(k1, 0);
shared_mem_ipc = shmget(k2, 4096, 0600 | IPC_CREAT | IPC_EXCL);
if (shared_mem_ipc == -1 && errno == EEXIST)
shared_mem_ipc = shmget(k2, 4096, 0600);
if (shared_mem_ipc >= 0) {
shared_mem = shmat(shared_mem_ipc, NULL, 0);
if (shared_mem == (char *)-1)
shared_mem = NULL;
}
done_string(&filename);
#endif
@ -148,12 +146,10 @@ init_slave_ipc(void)
return;
k1 = ftok(filename.source, 1);
k2 = ftok(filename.source, 2);
master_sem = mysem_open(k1);
master_sem = sem_open(k1);
shared_mem_ipc = shmget(k2, 4096, 0600);
if (shared_mem_ipc >= 0) {
shared_mem = shmat(shared_mem_ipc, NULL, 0);
if (shared_mem == (char *)-1)
shared_mem = NULL;
}
done_string(&filename);
#endif
@ -166,7 +162,7 @@ done_ipc(void)
if (shared_mem)
shmdt(shared_mem);
if (master_sem >= 0)
mysem_close(master_sem);
sem_close(master_sem);
/* shared_mem_ipc will be automatically done by sem_close() */
#endif
}

View File

@ -47,7 +47,7 @@
#include "util/string.h"
extern int master_sem;
extern char *shared_mem;
extern unsigned char *shared_mem;
struct mailcap_hash_item {
/* The entries associated with the type */
@ -694,7 +694,7 @@ get_mime_handler_mailcap(unsigned char *type, struct terminal *term)
hard_write(term->fdout, data, len + 2);
fmem_free(data);
mysem_wait(master_sem);
sem_wait(master_sem);
if (!*shared_mem)
return NULL;
desc = strchr(shared_mem, '\0') + 1;
@ -753,7 +753,7 @@ get_slave_mailcap(unsigned char *type)
}
end:
done_mailcap(NULL);
mysem_signal(master_sem);
sem_signal(master_sem);
#endif
}

View File

@ -106,7 +106,7 @@ static struct sembuf op_op[1] = {
*/
int
mysem_create(key_t key, int initval /* used if we create the semaphore */)
sem_create(key_t key, int initval /* used if we create the semaphore */)
{
int id, semval;
union semun {
@ -191,7 +191,7 @@ again:
*/
int
mysem_open(key_t key)
sem_open(key_t key)
{
int id;
@ -224,7 +224,7 @@ mysem_open(key_t key)
*/
void
mysem_rm(int id)
sem_rm(int id)
{
semctl(id, 0, IPC_RMID, 0);
/* err_sys("can't IPC_RMID"); */
@ -244,7 +244,7 @@ mysem_rm(int id)
*/
void
mysem_close(int id)
sem_close(int id)
{
int semval;
@ -271,7 +271,7 @@ mysem_close(int id)
/* if (semval > BIGCOUNT)
err_dump("sem[1] > BIGCOUNT"); */
if (semval == BIGCOUNT)
mysem_rm(id);
sem_rm(id);
else
semop(id, &op_unlock[0], 1);
/* err_sys("can't unlock"); */ /* unlock */
@ -284,9 +284,9 @@ mysem_close(int id)
*/
void
mysem_wait(int id)
sem_wait(int id)
{
mysem_op(id, -1);
sem_op(id, -1);
}
/****************************************************************************
@ -294,9 +294,9 @@ mysem_wait(int id)
* Dijkstra's V operation. Tanenbaum's UP operation.
*/
void
mysem_signal(int id)
sem_signal(int id)
{
mysem_op(id, 1);
sem_op(id, 1);
}
/****************************************************************************
@ -304,7 +304,7 @@ mysem_signal(int id)
* amount (positive or negative; amount can't be zero).
*/
void
mysem_op(int id, int value)
sem_op(int id, int value)
{
op_op[0].sem_op = value;
/* err_sys("can't have value == 0"); */

View File

@ -6,12 +6,12 @@
#include <sys/sem.h>
#include <sys/shm.h>
int mysem_create(key_t key, int initval);
int mysem_open(key_t key);
void mysem_rm(int id);
void mysem_close(int id);
void mysem_wait(int id);
void mysem_signal(int id);
void mysem_op(int id, int value);
int sem_create(key_t key, int initval);
int sem_open(key_t key);
void sem_rm(int id);
void sem_close(int id);
void sem_wait(int id);
void sem_signal(int id);
void sem_op(int id, int value);
#endif