mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Remove QNX port.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.113 2005/12/09 21:19:34 petere Exp $
|
||||
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.114 2006/01/05 01:56:29 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@@ -27,14 +27,6 @@ LIBS := $(filter-out -lpgport, $(LIBS))
|
||||
# The backend doesn't need everything that's in LIBS, however
|
||||
LIBS := $(filter-out -lz -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS))
|
||||
|
||||
ifeq ($(PORTNAME), qnx4)
|
||||
# This file crashes qnx4's wlink and is therefore not in
|
||||
# bootstrap/SUBSYS.o on that platform. (Wotta hack ... is it still
|
||||
# necessary?) [ Yes, until the Watcom compiler goes open source it's
|
||||
# effectively unsupported ]
|
||||
OBJS += bootstrap/bootstrap.o
|
||||
endif
|
||||
|
||||
##########################################################################
|
||||
|
||||
all: submake-libpgport postgres $(POSTGRES_IMP)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# Makefile for the bootstrap module
|
||||
#
|
||||
# $PostgreSQL: pgsql/src/backend/bootstrap/Makefile,v 1.32 2003/11/29 19:51:40 pgsql Exp $
|
||||
# $PostgreSQL: pgsql/src/backend/bootstrap/Makefile,v 1.33 2006/01/05 01:56:29 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@@ -12,16 +12,9 @@ include $(top_builddir)/src/Makefile.global
|
||||
|
||||
override CPPFLAGS := -I$(srcdir) $(CPPFLAGS)
|
||||
|
||||
# qnx4's wlink currently crashes with bootstrap.o
|
||||
ifneq ($(PORTNAME), qnx4)
|
||||
OBJS= bootparse.o bootstrap.o
|
||||
else
|
||||
OBJS= bootparse.o
|
||||
endif
|
||||
|
||||
|
||||
# make sure bootstrap.o is built even on qnx4
|
||||
all: SUBSYS.o bootstrap.o
|
||||
all: SUBSYS.o
|
||||
|
||||
SUBSYS.o: $(OBJS)
|
||||
$(LD) $(LDREL) $(LDOUT) $@ $^
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# be converted to Method 2.
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $PostgreSQL: pgsql/src/backend/port/Makefile,v 1.20 2003/11/29 19:51:54 pgsql Exp $
|
||||
# $PostgreSQL: pgsql/src/backend/port/Makefile,v 1.21 2006/01/05 01:56:29 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@@ -25,9 +25,6 @@ OBJS+=dynloader.o pg_sema.o pg_shmem.o
|
||||
|
||||
OBJS+=$(TAS)
|
||||
|
||||
ifeq ($(PORTNAME), qnx4)
|
||||
OBJS+=qnx4/SUBSYS.o
|
||||
endif
|
||||
ifeq ($(PORTNAME), beos)
|
||||
OBJS+=beos/SUBSYS.o
|
||||
endif
|
||||
@@ -43,11 +40,6 @@ all: SUBSYS.o
|
||||
SUBSYS.o: $(OBJS)
|
||||
$(LD) $(LDREL) $(LDOUT) $@ $^
|
||||
|
||||
qnx4/SUBSYS.o: qnx4.dir
|
||||
|
||||
qnx4.dir:
|
||||
$(MAKE) -C qnx4 all
|
||||
|
||||
beos/SUBSYS.o: beos.dir
|
||||
|
||||
beos.dir:
|
||||
@@ -74,6 +66,5 @@ distclean clean:
|
||||
rm -f SUBSYS.o $(OBJS) ipc_test ipc_test.o
|
||||
$(MAKE) -C beos clean
|
||||
$(MAKE) -C darwin clean
|
||||
$(MAKE) -C qnx4 clean
|
||||
$(MAKE) -C win32 clean
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* dynloader.c
|
||||
* dynamic loader for QNX4 using the shared library mechanism
|
||||
*
|
||||
* Copyright (c) 1999, repas AEG Automation GmbH
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/port/dynloader/qnx4.c,v 1.6 2004/01/07 18:56:27 neilc Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
/* System includes */
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
/*
|
||||
#include <a.out.h>
|
||||
#include <dl.h>
|
||||
*/
|
||||
|
||||
#include "utils/dynamic_loader.h"
|
||||
#include "dynloader.h"
|
||||
|
||||
void *
|
||||
pg_dlopen(char *filename)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PGFunction
|
||||
pg_dlsym(void *handle, char *funcname)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
pg_dlclose(void *handle)
|
||||
{
|
||||
}
|
||||
|
||||
char *
|
||||
pg_dlerror()
|
||||
{
|
||||
static char errmsg[] = "Failed to load shared library due to lack of shared library support.";
|
||||
|
||||
return errmsg;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* dynloader.h
|
||||
* dynamic loader for QNX4 using the shared library mechanism
|
||||
*
|
||||
* Copyright (c) 1999, repas AEG Automation GmbH
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/port/dynloader/qnx4.h,v 1.4 2003/11/29 19:51:54 pgsql Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "fmgr.h"
|
||||
|
||||
void *pg_dlopen(char *filename);
|
||||
PGFunction pg_dlsym(void *handle, char *funcname);
|
||||
void pg_dlclose(void *handle);
|
||||
char *pg_dlerror();
|
||||
@@ -1,36 +0,0 @@
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile--
|
||||
# Makefile for port/qnx4
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $PostgreSQL: pgsql/src/backend/port/qnx4/Makefile,v 1.6 2003/11/29 19:51:54 pgsql Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
subdir = src/backend/port/qnx4
|
||||
top_builddir = ../../../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
|
||||
OBJS = isnan.o sem.o shm.o
|
||||
|
||||
all: SUBSYS.o tstsem tstshm
|
||||
|
||||
SUBSYS.o: $(OBJS)
|
||||
$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
|
||||
|
||||
tstsem: tstsem.o sem.o
|
||||
$(CC) -o tstsem sem.o tstsem.o
|
||||
|
||||
tstshm: tstshm.o shm.o
|
||||
$(CC) -o tstshm shm.o tstshm.o
|
||||
|
||||
depend dep:
|
||||
$(CC) -MM $(CFLAGS) *.c >depend
|
||||
|
||||
clean:
|
||||
rm -f SUBSYS.o $(OBJS) tstsem tstsem.o tstshm tstshm.o
|
||||
|
||||
ifeq (depend,$(wildcard depend))
|
||||
include depend
|
||||
endif
|
||||
@@ -1,31 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* ipc.h
|
||||
* System V IPC Emulation
|
||||
*
|
||||
* Copyright (c) 1999, repas AEG Automation GmbH
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/port/qnx4/ipc.h,v 1.7 2003/11/29 19:51:54 pgsql Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SYS_IPC_H
|
||||
#define _SYS_IPC_H
|
||||
|
||||
/* Common IPC definitions. */
|
||||
/* Mode bits. */
|
||||
#define IPC_CREAT 0001000 /* create entry if key doesn't exist */
|
||||
#define IPC_EXCL 0002000 /* fail if key exists */
|
||||
#define IPC_NOWAIT 0004000 /* error if request must wait */
|
||||
|
||||
/* Keys. */
|
||||
#define IPC_PRIVATE (key_t)0 /* private key */
|
||||
|
||||
/* Control Commands. */
|
||||
#define IPC_RMID 0 /* remove identifier */
|
||||
#define IPC_STAT 1 /* get shm status */
|
||||
|
||||
#endif /* _SYS_IPC_H */
|
||||
@@ -1,29 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* isnan.c
|
||||
* isnan() implementation
|
||||
*
|
||||
* Copyright (c) 1999, repas AEG Automation GmbH
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/port/qnx4/isnan.c,v 1.5 2004/03/15 03:29:22 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "c.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#ifndef __nan_bytes
|
||||
#define __nan_bytes { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }
|
||||
#endif /* __nan_bytes */
|
||||
|
||||
static unsigned char __nan[8] = __nan_bytes;
|
||||
|
||||
int
|
||||
isnan(double dsrc)
|
||||
{
|
||||
return memcmp(&dsrc, __nan, sizeof(double)) == 0;
|
||||
}
|
||||
@@ -1,396 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* sem.c
|
||||
* System V Semaphore Emulation
|
||||
*
|
||||
* Copyright (c) 1999, repas AEG Automation GmbH
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/port/qnx4/sem.c,v 1.13 2005/10/15 02:49:23 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <semaphore.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/sem.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "miscadmin.h"
|
||||
#include "storage/ipc.h"
|
||||
#include "storage/proc.h"
|
||||
|
||||
|
||||
#define SEMMAX (PROC_NSEMS_PER_SET+1)
|
||||
#define OPMAX 8
|
||||
|
||||
#define MODE 0700
|
||||
#define SHM_INFO_NAME "PgSysV_Sem_Info"
|
||||
|
||||
|
||||
struct pending_ops
|
||||
{
|
||||
int op[OPMAX]; /* array of pending operations */
|
||||
int idx; /* index of first free array member */
|
||||
};
|
||||
|
||||
struct sem_set_info
|
||||
{
|
||||
key_t key;
|
||||
int nsems;
|
||||
sem_t sem[SEMMAX]; /* array of POSIX semaphores */
|
||||
struct sem semV[SEMMAX]; /* array of System V semaphore structures */
|
||||
struct pending_ops pendingOps[SEMMAX]; /* array of pending operations */
|
||||
};
|
||||
|
||||
struct sem_info
|
||||
{
|
||||
sem_t sem;
|
||||
int nsets;
|
||||
/* there are actually nsets of these: */
|
||||
struct sem_set_info set[1]; /* VARIABLE LENGTH ARRAY */
|
||||
};
|
||||
|
||||
static struct sem_info *SemInfo = (struct sem_info *) - 1;
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* semclean - remove the shared memory file on exit
|
||||
* only called by the process which created the shm file
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void
|
||||
semclean(void)
|
||||
{
|
||||
remove("/dev/shmem/" SHM_INFO_NAME);
|
||||
}
|
||||
|
||||
int
|
||||
semctl(int semid, int semnum, int cmd, /* ... */ union semun arg)
|
||||
{
|
||||
int r = 0;
|
||||
|
||||
sem_wait(&SemInfo->sem);
|
||||
|
||||
if (semid < 0 || semid >= SemInfo->nsets ||
|
||||
semnum < 0 || semnum >= SemInfo->set[semid].nsems)
|
||||
{
|
||||
sem_post(&SemInfo->sem);
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case GETNCNT:
|
||||
r = SemInfo->set[semid].semV[semnum].semncnt;
|
||||
break;
|
||||
|
||||
case GETPID:
|
||||
r = SemInfo->set[semid].semV[semnum].sempid;
|
||||
break;
|
||||
|
||||
case GETVAL:
|
||||
r = SemInfo->set[semid].semV[semnum].semval;
|
||||
break;
|
||||
|
||||
case GETALL:
|
||||
for (semnum = 0; semnum < SemInfo->set[semid].nsems; semnum++)
|
||||
arg.array[semnum] = SemInfo->set[semid].semV[semnum].semval;
|
||||
break;
|
||||
|
||||
case SETVAL:
|
||||
SemInfo->set[semid].semV[semnum].semval = arg.val;
|
||||
break;
|
||||
|
||||
case SETALL:
|
||||
for (semnum = 0; semnum < SemInfo->set[semid].nsems; semnum++)
|
||||
SemInfo->set[semid].semV[semnum].semval = arg.array[semnum];
|
||||
break;
|
||||
|
||||
case GETZCNT:
|
||||
r = SemInfo->set[semid].semV[semnum].semzcnt;
|
||||
break;
|
||||
|
||||
case IPC_RMID:
|
||||
for (semnum = 0; semnum < SemInfo->set[semid].nsems; semnum++)
|
||||
{
|
||||
if (sem_destroy(&SemInfo->set[semid].sem[semnum]) == -1)
|
||||
r = -1;
|
||||
}
|
||||
SemInfo->set[semid].key = -1;
|
||||
SemInfo->set[semid].nsems = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
sem_post(&SemInfo->sem);
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
sem_post(&SemInfo->sem);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
semget(key_t key, int nsems, int semflg)
|
||||
{
|
||||
int fd,
|
||||
semid,
|
||||
semnum,
|
||||
nsets;
|
||||
int exist = 0;
|
||||
Size sem_info_size;
|
||||
struct stat statbuf;
|
||||
|
||||
if (nsems < 0 || nsems > SEMMAX)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* open and map shared memory */
|
||||
if (SemInfo == (struct sem_info *) - 1)
|
||||
{
|
||||
/* test if the shared memory already exists */
|
||||
fd = shm_open(SHM_INFO_NAME, O_RDWR | O_CREAT | O_EXCL, MODE);
|
||||
if (fd == -1 && errno == EEXIST)
|
||||
{
|
||||
exist = 1;
|
||||
fd = shm_open(SHM_INFO_NAME, O_RDWR | O_CREAT, MODE);
|
||||
}
|
||||
if (fd == -1)
|
||||
return fd;
|
||||
/* The size may only be set once. Ignore errors. */
|
||||
nsets = PROC_SEM_MAP_ENTRIES(MaxBackends);
|
||||
sem_info_size = sizeof(struct sem_info) + (nsets - 1) * sizeof(struct sem_set_info);
|
||||
ltrunc(fd, sem_info_size, SEEK_SET);
|
||||
if (fstat(fd, &statbuf)) /* would be strange : the only doc'ed */
|
||||
{ /* error is EBADF */
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* size is rounded by proc to the next __PAGESIZE
|
||||
*/
|
||||
if (statbuf.st_size !=
|
||||
(((sem_info_size / __PAGESIZE) + 1) * __PAGESIZE))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Found a pre-existing shared memory block for the semaphore memory\n"
|
||||
"of a different size (%ld instead %ld). Make sure that all executables\n"
|
||||
"are from the same release or remove the file \"/dev/shmem/%s\"\n"
|
||||
"left by a previous version.\n",
|
||||
(long) statbuf.st_size,
|
||||
(long) sem_info_size,
|
||||
SHM_INFO_NAME);
|
||||
errno = EACCES;
|
||||
return -1;
|
||||
}
|
||||
SemInfo = mmap(NULL, sem_info_size,
|
||||
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (SemInfo == MAP_FAILED)
|
||||
return -1;
|
||||
if (!exist)
|
||||
{
|
||||
/* initialize shared memory */
|
||||
memset(SemInfo, 0, sem_info_size);
|
||||
SemInfo->nsets = nsets;
|
||||
for (semid = 0; semid < nsets; semid++)
|
||||
SemInfo->set[semid].key = -1;
|
||||
/* create semaphore for locking */
|
||||
sem_init(&SemInfo->sem, 1, 1);
|
||||
on_proc_exit(semclean, 0);
|
||||
}
|
||||
}
|
||||
|
||||
sem_wait(&SemInfo->sem);
|
||||
nsets = SemInfo->nsets;
|
||||
|
||||
if (key != IPC_PRIVATE)
|
||||
{
|
||||
/* search existing element */
|
||||
semid = 0;
|
||||
while (semid < nsets && SemInfo->set[semid].key != key)
|
||||
semid++;
|
||||
if (!(semflg & IPC_CREAT) && semid >= nsets)
|
||||
{
|
||||
sem_post(&SemInfo->sem);
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
else if (semid < nsets)
|
||||
{
|
||||
if (semflg & IPC_CREAT && semflg & IPC_EXCL)
|
||||
{
|
||||
sem_post(&SemInfo->sem);
|
||||
errno = EEXIST;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nsems != 0 && SemInfo->set[semid].nsems < nsems)
|
||||
{
|
||||
sem_post(&SemInfo->sem);
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
sem_post(&SemInfo->sem);
|
||||
return semid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* search first free element */
|
||||
semid = 0;
|
||||
while (semid < nsets && SemInfo->set[semid].key != -1)
|
||||
semid++;
|
||||
if (semid >= nsets)
|
||||
{
|
||||
sem_post(&SemInfo->sem);
|
||||
errno = ENOSPC;
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (semnum = 0; semnum < nsems; semnum++)
|
||||
{
|
||||
sem_init(&SemInfo->set[semid].sem[semnum], 1, 0);
|
||||
/* Currently sem_init always returns -1. */
|
||||
#ifdef NOT_USED
|
||||
if (sem_init(&SemInfo->set[semid].sem[semnum], 1, 0) == -1)
|
||||
{
|
||||
int semnum1;
|
||||
|
||||
for (semnum1 = 0; semnum1 < semnum; semnum1++)
|
||||
sem_destroy(&SemInfo->set[semid].sem[semnum1]);
|
||||
sem_post(&SemInfo->sem);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
SemInfo->set[semid].key = key;
|
||||
SemInfo->set[semid].nsems = nsems;
|
||||
|
||||
sem_post(&SemInfo->sem);
|
||||
|
||||
return semid;
|
||||
}
|
||||
|
||||
int
|
||||
semop(int semid, struct sembuf * sops, size_t nsops)
|
||||
{
|
||||
int i,
|
||||
r = 0,
|
||||
r1,
|
||||
errno1 = 0,
|
||||
op;
|
||||
|
||||
sem_wait(&SemInfo->sem);
|
||||
|
||||
if (semid < 0 || semid >= SemInfo->nsets)
|
||||
{
|
||||
sem_post(&SemInfo->sem);
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < nsops; i++)
|
||||
{
|
||||
if ( /* sops[i].sem_num < 0 || */ sops[i].sem_num >= SemInfo->set[semid].nsems)
|
||||
{
|
||||
sem_post(&SemInfo->sem);
|
||||
errno = EFBIG;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < nsops; i++)
|
||||
{
|
||||
if (sops[i].sem_op < 0)
|
||||
{
|
||||
if (SemInfo->set[semid].semV[sops[i].sem_num].semval < -sops[i].sem_op)
|
||||
{
|
||||
if (sops[i].sem_flg & IPC_NOWAIT)
|
||||
{
|
||||
sem_post(&SemInfo->sem);
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
SemInfo->set[semid].semV[sops[i].sem_num].semncnt++;
|
||||
if (SemInfo->set[semid].pendingOps[sops[i].sem_num].idx >= OPMAX)
|
||||
{
|
||||
/* pending operations array overflow */
|
||||
sem_post(&SemInfo->sem);
|
||||
errno = ERANGE;
|
||||
return -1;
|
||||
}
|
||||
SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx++] = sops[i].sem_op;
|
||||
/* suspend */
|
||||
sem_post(&SemInfo->sem); /* avoid deadlock */
|
||||
r1 = sem_wait(&SemInfo->set[semid].sem[sops[i].sem_num]);
|
||||
sem_wait(&SemInfo->sem);
|
||||
if (r1)
|
||||
{
|
||||
errno1 = errno;
|
||||
r = r1;
|
||||
/* remove pending operation */
|
||||
SemInfo->set[semid].pendingOps[sops[i].sem_num].op[--SemInfo->set[semid].pendingOps[sops[i].sem_num].idx] = 0;
|
||||
}
|
||||
else
|
||||
SemInfo->set[semid].semV[sops[i].sem_num].semval -= -sops[i].sem_op;
|
||||
SemInfo->set[semid].semV[sops[i].sem_num].semncnt--;
|
||||
}
|
||||
else
|
||||
SemInfo->set[semid].semV[sops[i].sem_num].semval -= -sops[i].sem_op;
|
||||
}
|
||||
else if (sops[i].sem_op > 0)
|
||||
{
|
||||
SemInfo->set[semid].semV[sops[i].sem_num].semval += sops[i].sem_op;
|
||||
op = sops[i].sem_op;
|
||||
while (op > 0 && SemInfo->set[semid].pendingOps[sops[i].sem_num].idx > 0)
|
||||
{ /* operations pending */
|
||||
if (SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx - 1] + op >= 0)
|
||||
{
|
||||
/* unsuspend processes */
|
||||
if (sem_post(&SemInfo->set[semid].sem[sops[i].sem_num]))
|
||||
{
|
||||
errno1 = errno;
|
||||
r = -1;
|
||||
}
|
||||
/* adjust pending operations */
|
||||
op += SemInfo->set[semid].pendingOps[sops[i].sem_num].op[--SemInfo->set[semid].pendingOps[sops[i].sem_num].idx];
|
||||
SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* adjust pending operations */
|
||||
SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx - 1] += op;
|
||||
op = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
/* sops[i].sem_op == 0 */
|
||||
{
|
||||
/* not supported */
|
||||
sem_post(&SemInfo->sem);
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
SemInfo->set[semid].semV[sops[i].sem_num].sempid = getpid();
|
||||
}
|
||||
|
||||
sem_post(&SemInfo->sem);
|
||||
|
||||
errno = errno1;
|
||||
return r;
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* sem.h
|
||||
* System V Semaphore Emulation
|
||||
*
|
||||
* Copyright (c) 1999, repas AEG Automation GmbH
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/port/qnx4/sem.h,v 1.8 2003/11/29 19:51:54 pgsql Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SEM_H
|
||||
#define _SYS_SEM_H
|
||||
|
||||
#include <sys/ipc.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Semctl Command Definitions.
|
||||
*/
|
||||
|
||||
#define GETNCNT 3 /* get semncnt */
|
||||
#define GETPID 4 /* get sempid */
|
||||
#define GETVAL 5 /* get semval */
|
||||
#define GETALL 6 /* get all semval's */
|
||||
#define GETZCNT 7 /* get semzcnt */
|
||||
#define SETVAL 8 /* set semval */
|
||||
#define SETALL 9 /* set all semval's */
|
||||
|
||||
/*
|
||||
* There is one semaphore structure for each semaphore in the system.
|
||||
*/
|
||||
|
||||
struct sem
|
||||
{
|
||||
ushort_t semval; /* semaphore text map address */
|
||||
pid_t sempid; /* pid of last operation */
|
||||
ushort_t semncnt; /* # awaiting semval > cval */
|
||||
ushort_t semzcnt; /* # awaiting semval = 0 */
|
||||
};
|
||||
|
||||
/*
|
||||
* User semaphore template for semop system calls.
|
||||
*/
|
||||
|
||||
struct sembuf
|
||||
{
|
||||
ushort_t sem_num; /* semaphore # */
|
||||
short sem_op; /* semaphore operation */
|
||||
short sem_flg; /* operation flags */
|
||||
};
|
||||
|
||||
extern int semctl(int semid, int semnum, int cmd, /* ... */ union semun arg);
|
||||
extern int semget(key_t key, int nsems, int semflg);
|
||||
extern int semop(int semid, struct sembuf * sops, size_t nsops);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_SEM_H */
|
||||
@@ -1,274 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* shm.c
|
||||
* System V Shared Memory Emulation
|
||||
*
|
||||
* Copyright (c) 1999, repas AEG Automation GmbH
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/port/qnx4/shm.c,v 1.10 2005/10/15 02:49:23 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
||||
#define MODE 0777
|
||||
|
||||
#define SHMMAX 1024
|
||||
|
||||
|
||||
struct shm_info
|
||||
{
|
||||
int shmid;
|
||||
key_t key;
|
||||
size_t size;
|
||||
void *addr;
|
||||
};
|
||||
|
||||
static struct shm_info *ShmInfo;
|
||||
|
||||
|
||||
static int shm_putinfo(struct shm_info * info);
|
||||
static int shm_updinfo(int i, struct shm_info * info);
|
||||
static int shm_getinfo(int shmid, struct shm_info * info);
|
||||
static int shm_getinfobyaddr(const void *addr, struct shm_info * info);
|
||||
|
||||
static char *
|
||||
keytoname(key_t key, char *name)
|
||||
{
|
||||
sprintf(name, "PgShm%x", key);
|
||||
return name;
|
||||
}
|
||||
|
||||
static int
|
||||
shm_putinfo(struct shm_info * info)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (ShmInfo == NULL)
|
||||
{
|
||||
ShmInfo = calloc(SHMMAX, sizeof(struct shm_info));
|
||||
if (ShmInfo == NULL)
|
||||
return -1;
|
||||
/* initialize ShmInfo */
|
||||
for (i = 0; i < SHMMAX; i++)
|
||||
ShmInfo[i].shmid = -1;
|
||||
}
|
||||
|
||||
/* search first free element */
|
||||
i = 0;
|
||||
while (i < SHMMAX && ShmInfo[i].shmid != -1)
|
||||
i++;
|
||||
if (i >= SHMMAX)
|
||||
{
|
||||
errno = ENOSPC;
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(&ShmInfo[i], info, sizeof(struct shm_info));
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static int
|
||||
shm_updinfo(int i, struct shm_info * info)
|
||||
{
|
||||
if (i >= SHMMAX)
|
||||
return -1;
|
||||
if (ShmInfo == NULL)
|
||||
return -1;
|
||||
|
||||
memcpy(&ShmInfo[i], info, sizeof(struct shm_info));
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static int
|
||||
shm_getinfo(int shmid, struct shm_info * info)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (ShmInfo == NULL)
|
||||
return -1;
|
||||
|
||||
/* search element */
|
||||
i = 0;
|
||||
while (i < SHMMAX && ShmInfo[i].shmid != shmid)
|
||||
i++;
|
||||
if (i >= SHMMAX)
|
||||
return -1;
|
||||
|
||||
memcpy(info, &ShmInfo[i], sizeof(struct shm_info));
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static int
|
||||
shm_getinfobyaddr(const void *addr, struct shm_info * info)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (ShmInfo == (struct shm_info *) - 1)
|
||||
return -1;
|
||||
|
||||
/* search element */
|
||||
i = 0;
|
||||
while (i < SHMMAX && ShmInfo[i].addr != addr)
|
||||
i++;
|
||||
if (i >= SHMMAX)
|
||||
return -1;
|
||||
|
||||
memcpy(info, &ShmInfo[i], sizeof(struct shm_info));
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
shmat(int shmid, const void *shmaddr, int shmflg)
|
||||
{
|
||||
struct shm_info info;
|
||||
int i;
|
||||
|
||||
i = shm_getinfo(shmid, &info);
|
||||
if (i == -1)
|
||||
{
|
||||
errno = EACCES;
|
||||
return (void *) -1;
|
||||
}
|
||||
|
||||
info.addr = mmap((void *) shmaddr, info.size,
|
||||
PROT_READ | PROT_WRITE, MAP_SHARED, shmid, 0);
|
||||
if (info.addr == MAP_FAILED)
|
||||
return info.addr;
|
||||
|
||||
if (shm_updinfo(i, &info) == -1)
|
||||
{
|
||||
errno = EACCES;
|
||||
return (void *) -1;
|
||||
}
|
||||
|
||||
return info.addr;
|
||||
}
|
||||
|
||||
int
|
||||
shmdt(const void *addr)
|
||||
{
|
||||
struct shm_info info;
|
||||
|
||||
if (shm_getinfobyaddr(addr, &info) == -1)
|
||||
{
|
||||
errno = EACCES;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return munmap((void *) addr, info.size);
|
||||
}
|
||||
|
||||
int
|
||||
shmctl(int shmid, int cmd, struct shmid_ds * buf)
|
||||
{
|
||||
struct shm_info info;
|
||||
char name[NAME_MAX + 1];
|
||||
int result;
|
||||
int fd;
|
||||
struct stat statbuf;
|
||||
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case IPC_RMID:
|
||||
if (shm_getinfo(shmid, &info) == -1)
|
||||
{
|
||||
errno = EACCES;
|
||||
return -1;
|
||||
}
|
||||
close(info.shmid);
|
||||
keytoname(info.key, name);
|
||||
return shm_unlink(name);
|
||||
|
||||
case IPC_STAT:
|
||||
|
||||
/*
|
||||
* we have to open it first. stat() does no prefix tracking -> the
|
||||
* call would go to fsys instead of proc
|
||||
*/
|
||||
keytoname(shmid, name);
|
||||
fd = shm_open(name, 0, MODE);
|
||||
if (fd >= 0)
|
||||
{
|
||||
result = fstat(fd, &statbuf);
|
||||
|
||||
/*
|
||||
* if the file exists, subtract 2 from linkcount : one for our
|
||||
* own open and one for the dir entry
|
||||
*/
|
||||
if (!result)
|
||||
buf->shm_nattch = statbuf.st_nlink - 2;
|
||||
close(fd);
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* if there's no entry for this key it doesn't matter the next
|
||||
* shmget() would get a different shm anyway
|
||||
*/
|
||||
buf->shm_nattch = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
shmget(key_t key, size_t size, int flags)
|
||||
{
|
||||
char name[NAME_MAX + 1];
|
||||
int oflag = 0;
|
||||
struct shm_info info;
|
||||
|
||||
if (flags & IPC_CREAT)
|
||||
oflag |= O_CREAT;
|
||||
if (flags & IPC_EXCL)
|
||||
oflag |= O_EXCL;
|
||||
if (flags & SHM_R)
|
||||
{
|
||||
if (flags & SHM_W)
|
||||
oflag |= O_RDWR;
|
||||
else
|
||||
oflag |= O_RDONLY;
|
||||
}
|
||||
info.shmid = shm_open(keytoname(key, name), oflag, MODE);
|
||||
|
||||
/* store shared memory information */
|
||||
if (info.shmid != -1)
|
||||
{
|
||||
info.key = key;
|
||||
info.size = size;
|
||||
info.addr = NULL;
|
||||
if (shm_putinfo(&info) == -1)
|
||||
{
|
||||
close(info.shmid);
|
||||
if ((oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
|
||||
shm_unlink(name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* The size may only be set once. Ignore errors. */
|
||||
ltrunc(info.shmid, size, SEEK_SET);
|
||||
|
||||
return info.shmid;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* shm.h
|
||||
* System V Shared Memory Emulation
|
||||
*
|
||||
* Copyright (c) 1999, repas AEG Automation GmbH
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/port/qnx4/shm.h,v 1.8 2003/11/29 19:51:54 pgsql Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SHM_H
|
||||
#define _SYS_SHM_H
|
||||
|
||||
#include <sys/ipc.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define SHM_R 0400 /* read permission */
|
||||
#define SHM_W 0200 /* write permission */
|
||||
|
||||
struct shmid_ds
|
||||
{
|
||||
int dummy;
|
||||
int shm_nattch;
|
||||
};
|
||||
|
||||
extern void *shmat(int shmid, const void *shmaddr, int shmflg);
|
||||
extern int shmdt(const void *addr);
|
||||
extern int shmctl(int shmid, int cmd, struct shmid_ds * buf);
|
||||
extern int shmget(key_t key, size_t size, int flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_SHM_H */
|
||||
@@ -1,206 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* tstsem.c
|
||||
* Test of System V Semaphore Emulation
|
||||
*
|
||||
* Copyright (c) 1999, repas AEG Automation GmbH
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/port/qnx4/tstsem.c,v 1.10 2003/11/29 19:51:54 pgsql Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include "storage/ipc.h"
|
||||
#include <sys/mman.h>
|
||||
#include <sys/sem.h>
|
||||
|
||||
|
||||
#define SEMMAX 16
|
||||
#define OPSMAX 1
|
||||
|
||||
int MaxBackends = SEMMAX;
|
||||
|
||||
static int semid;
|
||||
|
||||
static void
|
||||
sig_handler(int sig_no)
|
||||
{
|
||||
union semun arg;
|
||||
int i = semctl(semid, 0, GETNCNT, arg);
|
||||
|
||||
if (i == -1)
|
||||
perror("semctl");
|
||||
else
|
||||
printf("semval = %d\n", i);
|
||||
}
|
||||
|
||||
void on_proc_exit(void (*function) (), Datum arg)
|
||||
{
|
||||
atexit(function);
|
||||
}
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int c,
|
||||
errflg = 0;
|
||||
char s[80];
|
||||
key_t key = IPC_PRIVATE;
|
||||
int nsems = SEMMAX;
|
||||
int semflg = 0;
|
||||
int unlink = 0;
|
||||
int i;
|
||||
struct sembuf sops[OPSMAX];
|
||||
u_short array[SEMMAX];
|
||||
union semun arg;
|
||||
|
||||
optarg = NULL;
|
||||
while (!errflg && (c = getopt(argc, argv, "k:n:cxu")) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'k':
|
||||
key = atoi(optarg);
|
||||
break;
|
||||
case 'n':
|
||||
nsems = atoi(optarg);
|
||||
break;
|
||||
case 'c':
|
||||
semflg |= IPC_CREAT;
|
||||
break;
|
||||
case 'x':
|
||||
semflg |= IPC_EXCL;
|
||||
break;
|
||||
case 'u':
|
||||
unlink = 1;
|
||||
break;
|
||||
default:
|
||||
errflg++;
|
||||
}
|
||||
}
|
||||
if (errflg)
|
||||
{
|
||||
printf("usage: tstsem [-k key] [-n nsems] [-cxu]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (unlink)
|
||||
{
|
||||
i = shm_unlink("SysV_Sem_Info");
|
||||
if (i == -1)
|
||||
perror("shm_unlink");
|
||||
exit(i);
|
||||
}
|
||||
|
||||
semid = semget(key, nsems, semflg);
|
||||
if (semid == -1)
|
||||
{
|
||||
perror("semget");
|
||||
exit(semid);
|
||||
}
|
||||
|
||||
/* test signal interrupts */
|
||||
signal(SIGTERM, sig_handler);
|
||||
|
||||
do
|
||||
{
|
||||
printf("(-)sem_op, (+)sem_op, (G)ETVAL, (S)ETVAL, GET(P)ID, GET(A)LL, SETA(L)L, GET(N)CNT, GET(Z)CNT, e(x)it: ");
|
||||
scanf("%s", s);
|
||||
switch (s[0])
|
||||
{
|
||||
case '-':
|
||||
case '+':
|
||||
sops[0].sem_num = 0;
|
||||
sops[0].sem_op = atoi(s);
|
||||
if (sops[0].sem_op == 0)
|
||||
sops[0].sem_op = s[0] == '+' ? +1 : -1;
|
||||
sops[0].sem_flg = 0;
|
||||
if (semop(semid, sops, 1) == -1)
|
||||
perror("semop");
|
||||
break;
|
||||
|
||||
case 'G':
|
||||
case 'g':
|
||||
i = semctl(semid, 0, GETVAL, arg);
|
||||
if (i == -1)
|
||||
perror("semctl");
|
||||
else
|
||||
printf("semval = %d\n", i);
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
case 's':
|
||||
printf("semval = ");
|
||||
scanf("%d", &arg.val);
|
||||
if (semctl(semid, 0, SETVAL, arg) == -1)
|
||||
perror("semctl");
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
case 'p':
|
||||
i = semctl(semid, 0, GETPID, arg);
|
||||
if (i == -1)
|
||||
perror("semctl");
|
||||
else
|
||||
printf("PID = %d\n", i);
|
||||
break;
|
||||
|
||||
case 'A':
|
||||
case 'a':
|
||||
arg.array = array;
|
||||
i = semctl(semid, 0, GETALL, arg);
|
||||
if (i == -1)
|
||||
perror("semctl");
|
||||
else
|
||||
{
|
||||
for (i = 0; i < nsems; i++)
|
||||
printf("semval[%d] = %hu\n", i, arg.array[i]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
case 'l':
|
||||
arg.array = array;
|
||||
for (i = 0; i < nsems; i++)
|
||||
{
|
||||
printf("semval[%d] = ", i);
|
||||
scanf("%hu", &arg.array[i]);
|
||||
}
|
||||
if (semctl(semid, 0, SETALL, arg) == -1)
|
||||
perror("semctl");
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
case 'n':
|
||||
i = semctl(semid, 0, GETNCNT, arg);
|
||||
if (i == -1)
|
||||
perror("semctl");
|
||||
else
|
||||
printf("semval = %d\n", i);
|
||||
break;
|
||||
|
||||
case 'Z':
|
||||
case 'z':
|
||||
i = semctl(semid, 0, GETZCNT, arg);
|
||||
if (i == -1)
|
||||
perror("semctl");
|
||||
else
|
||||
printf("semval = %d\n", i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (s[0] != 'x');
|
||||
|
||||
if (semctl(semid, 0, IPC_RMID, arg) == -1)
|
||||
{
|
||||
perror("semctl");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* tstshm.c
|
||||
* Test of System V Shared Memory Emulation
|
||||
*
|
||||
* Copyright (c) 1999, repas AEG Automation GmbH
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/port/qnx4/tstshm.c,v 1.5 2003/11/29 19:51:54 pgsql Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/shm.h>
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int c,
|
||||
errflg = 0;
|
||||
char s[80];
|
||||
key_t key = 0x1000;
|
||||
size_t size = 256;
|
||||
int shmid = -1;
|
||||
caddr_t addr = NULL;
|
||||
|
||||
optarg = NULL;
|
||||
while (!errflg && (c = getopt(argc, argv, "k:s:")) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'k':
|
||||
key = atoi(optarg);
|
||||
break;
|
||||
case 's':
|
||||
size = atoi(optarg);
|
||||
break;
|
||||
default:
|
||||
errflg++;
|
||||
}
|
||||
}
|
||||
if (errflg)
|
||||
{
|
||||
printf("usage: tstshm [-k key] [-s size]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
printf("shm(g)et, shm(a)t, shm(d)t, shm(c)tl, (w)rite, (r)ead, e(x)it: ");
|
||||
scanf("%s", s);
|
||||
switch (s[0])
|
||||
{
|
||||
case 'g':
|
||||
shmid = shmget(key, size, IPC_CREAT | SHM_R | SHM_W);
|
||||
if (shmid == -1)
|
||||
perror("shmget");
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
addr = shmat(shmid, NULL, 0);
|
||||
if (addr == (void *) -1)
|
||||
perror("shmat");
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
if (shmdt(addr) == -1)
|
||||
perror("shmdt");
|
||||
else
|
||||
addr = NULL;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
if (shmctl(shmid, IPC_RMID, NULL) == -1)
|
||||
perror("shmctl");
|
||||
else
|
||||
shmid = -1;
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
printf("String to write: ");
|
||||
scanf("%s", addr);
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
puts(addr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (s[0] != 'x');
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* to contain some useful information. Mechanism differs wildly across
|
||||
* platforms.
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.27 2005/11/22 18:17:26 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.28 2006/01/05 01:56:29 momjian Exp $
|
||||
*
|
||||
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
|
||||
* various details abducted from various places
|
||||
@@ -63,7 +63,7 @@ extern char **environ;
|
||||
#define PS_USE_PS_STRINGS
|
||||
#elif (defined(BSD) || defined(__bsdi__) || defined(__hurd__)) && !defined(__darwin__)
|
||||
#define PS_USE_CHANGE_ARGV
|
||||
#elif defined(__linux__) || defined(_AIX) || defined(__sgi) || (defined(sun) && !defined(BSD)) || defined(ultrix) || defined(__ksr__) || defined(__osf__) || defined(__QNX__) || defined(__svr4__) || defined(__svr5__) || defined(__darwin__)
|
||||
#elif defined(__linux__) || defined(_AIX) || defined(__sgi) || (defined(sun) && !defined(BSD)) || defined(ultrix) || defined(__ksr__) || defined(__osf__) || defined(__svr4__) || defined(__svr5__) || defined(__darwin__)
|
||||
#define PS_USE_CLOBBER_ARGV
|
||||
#elif defined (WIN32)
|
||||
#define PS_USE_WIN32
|
||||
@@ -73,7 +73,7 @@ extern char **environ;
|
||||
|
||||
|
||||
/* Different systems want the buffer padded differently */
|
||||
#if defined(_AIX) || defined(__linux__) || defined(__QNX__) || defined(__svr4__)
|
||||
#if defined(_AIX) || defined(__linux__) || defined(__svr4__)
|
||||
#define PS_PADDING '\0'
|
||||
#else
|
||||
#define PS_PADDING ' '
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.56 2005/11/22 18:17:27 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.57 2006/01/05 01:56:29 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -2153,7 +2153,7 @@ comparetup_index(Tuplesortstate *state, const void *a, const void *b)
|
||||
* Some rather brain-dead implementations of qsort will sometimes call the
|
||||
* comparison routine to compare a value to itself. (At this writing only
|
||||
* QNX 4 is known to do such silly things.) Don't raise a bogus error in
|
||||
* that case.
|
||||
* that case. Update: The QNX port is gone.
|
||||
*/
|
||||
if (state->enforceUnique && !equal_hasnull && tuple1 != tuple2)
|
||||
ereport(ERROR,
|
||||
|
||||
Reference in New Issue
Block a user