Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2de3d96

Browse files
author
Bryan Henderson
committed
Add nextstep port, courtesy of Ovidiu Predescu.
1 parentef228cb commit2de3d96

File tree

5 files changed

+194
-0
lines changed

5 files changed

+194
-0
lines changed

‎src/backend/port/nextstep/Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#-------------------------------------------------------------------------
2+
#
3+
# Makefile--
4+
# Makefile for port/next (NeXTStep 3.3 specific stuff)
5+
#
6+
#-------------------------------------------------------------------------
7+
8+
SRCDIR = ../../..
9+
include ../../../Makefile.global
10+
11+
INCLUDE_OPT = -I../..\
12+
-I../../../include
13+
14+
CFLAGS+=$(INCLUDE_OPT)
15+
16+
OBJS = dynloader.o port.o
17+
18+
all: SUBSYS.o
19+
20+
SUBSYS.o:$(OBJS)
21+
$(LD) -r -o SUBSYS.o$(OBJS)
22+
23+
dependdep:
24+
$(CC) -MM$(INCLUDE_OPT)*.c>depend
25+
26+
clean:
27+
rm -f SUBSYS.o$(OBJS)
28+
29+
ifeq (depend,$(wildcard depend))
30+
include depend
31+
endif

‎src/backend/port/nextstep/dynloader.c

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#include<mach-o/rld.h>
2+
#include<streams/streams.h>
3+
#include<stdlib.h>
4+
5+
staticchar*lastError=NULL;
6+
7+
staticNXStream*OpenError()
8+
{
9+
returnNXOpenMemory(NULL,0,NX_WRITEONLY);
10+
}
11+
12+
staticvoidCloseError(NXStream*s)
13+
{
14+
if (s)
15+
NXCloseMemory (s,NX_FREEBUFFER);
16+
}
17+
18+
staticvoidTransferError(NXStream*s)
19+
{
20+
char*buffer;
21+
intlen,maxlen;
22+
23+
if (lastError)
24+
free (lastError);
25+
NXGetMemoryBuffer (s,&buffer,&len,&maxlen);
26+
lastError=malloc (len+1);
27+
strcpy (lastError,buffer);
28+
}
29+
30+
void*next_dlopen(char*name)
31+
{
32+
intrld_success;
33+
NXStream*errorStream;
34+
char*result=NULL;
35+
char**p;
36+
37+
errorStream=OpenError();
38+
p=calloc (2,sizeof(void*));
39+
p[0]=name;
40+
rld_success=rld_load(errorStream,NULL,p,NULL);
41+
free (p);
42+
43+
if (!rld_success) {
44+
TransferError (errorStream);
45+
result= (char*)1;
46+
}
47+
CloseError (errorStream);
48+
returnresult;
49+
}
50+
51+
intnext_dlclose(void*handle)
52+
{
53+
return0;
54+
}
55+
56+
void*next_dlsym (void*handle,char*symbol)
57+
{
58+
NXStream*errorStream=OpenError();
59+
charsymbuf[1024];
60+
unsigned longsymref=0;
61+
62+
sprintf(symbuf,"_%s",symbol);
63+
if (!rld_lookup (errorStream,symbuf,&symref))
64+
TransferError(errorStream);
65+
CloseError(errorStream);
66+
return (void*)symref;
67+
}
68+
69+
char*next_dlerror(void)
70+
{
71+
returnlastError;
72+
}

‎src/backend/port/nextstep/machine.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndefMACHINE_H
2+
#defineMACHINE_H
3+
4+
#defineBLCKSZ8192
5+
6+
#endif
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* port-protos.h--
4+
* port-specific prototypes for NeXT
5+
*
6+
7+
-------------------------------------------------------------------------
8+
*/
9+
#ifndefPORT_PROTOS_H
10+
#definePORT_PROTOS_H
11+
12+
#include"fmgr.h"/* for func_ptr */
13+
#include"utils/dynamic_loader.h"
14+
15+
void*next_dlopen(char*name);
16+
intnext_dlclose(void*handle);
17+
void*next_dlsym (void*handle,char*symbol);
18+
char*next_dlerror(void);
19+
20+
#definepg_dlopen(f)next_dlopen
21+
#definepg_dlsymnext_dlsym
22+
#definepg_dlclosenext_dlclose
23+
#definepg_dlerrornext_dlerror
24+
25+
/* port.c */
26+
27+
#endif/* PORT_PROTOS_H */

‎src/backend/port/nextstep/port.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#ifndef_POSIX_SOURCE
2+
# include<libc.h>
3+
#else
4+
# include<unistd.h>
5+
# include<stdlib.h>
6+
#endif
7+
8+
#include<string.h>
9+
#include<sys/signal.h>
10+
11+
12+
voidputenv(char*name)
13+
{
14+
externchar**environ;
15+
staticintwas_mallocated=0;
16+
intsize;
17+
18+
/* Compute the size of environ array including the final NULL */
19+
for (size=1;environ[size++];)
20+
/* nothing */;
21+
22+
if (!was_mallocated) {
23+
char**tmp=environ;
24+
inti;
25+
26+
was_mallocated=1;
27+
environ=malloc (size*sizeof(char*));
28+
for (i=0;i<size;i++)
29+
environ[i]=tmp[i];
30+
}
31+
32+
environ=realloc (environ, (size+1)*sizeof (char*));
33+
environ[size-1]=strcpy (malloc (strlen (name)+1),name);
34+
environ[size]=NULL;
35+
}
36+
37+
char*strdup (constchar*string)
38+
{
39+
returnstrcpy (malloc (strlen (string)+1),string);
40+
}
41+
42+
#ifndef_POSIX_SOURCE
43+
intsigaddset(int*set,intsigno)
44+
{
45+
*set |=sigmask(signo);
46+
return*set;
47+
}
48+
49+
intsigemptyset(int*set)
50+
{
51+
return (*set=0);
52+
}
53+
54+
char*getcwd(char*buf,size_tsize)
55+
{
56+
returngetwd (buf);
57+
}
58+
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp