Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1b2d57d

Browse files
committed
A small patch to keep postgres working on the latest BeOS.
Cyril VELTER
1 parent d8783c5 commit 1b2d57d

File tree

3 files changed

+53
-20
lines changed

3 files changed

+53
-20
lines changed

src/backend/port/beos/support.c

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,22 @@ beos_dl_open(char *filename)
115115
}
116116
}
117117

118+
void
119+
beos_dl_sym(image_id im,char* symname,void** fptr)
120+
{
121+
/* Send command '3' (get symbol) to the support server */
122+
write_port(beos_dl_port_in, 3, symname, strlen(symname) + 1);
123+
write_port(beos_dl_port_in, im, NULL,0);
124+
125+
/* Read sym address */
126+
read_port(beos_dl_port_out, (int32*)(fptr), NULL, 0);
127+
128+
if (fptr==NULL)
129+
{
130+
elog(NOTICE, "loading symbol '%s' failed ", symname);
131+
}
132+
}
133+
118134
status_t
119135
beos_dl_close(image_id im)
120136
{
@@ -164,12 +180,13 @@ beos_startup(int argc, char **argv)
164180
* server
165181
*/
166182
read_port(port_in, &opcode, datas, 4000);
167-
183+
168184
switch (opcode)
169185
{
170186
image_id addon;
171187
image_info info_im;
172188
area_info info_ar;
189+
void * fpt;
173190

174191
/* Load Add-On */
175192
case 1:
@@ -208,6 +225,33 @@ beos_startup(int argc, char **argv)
208225
write_port(port_out, unload_add_on(*((int *) (datas))), NULL, 0);
209226
break;
210227
/* Cleanup and exit */
228+
case 3:
229+
230+
/* read image Id on the input port */
231+
read_port(port_in, &addon,NULL,0);
232+
233+
/* Loading symbol */
234+
fpt=NULL;
235+
236+
237+
if (get_image_symbol(addon, datas, B_SYMBOL_TYPE_TEXT, &fpt) == B_OK);
238+
{
239+
240+
/*
241+
* Sometime the loader return B_OK for an inexistant function
242+
* with an invalid address !!! Check that the return address
243+
* is in the image range
244+
*/
245+
246+
get_image_info(addon, &info_im);
247+
if ((fpt < info_im.text) ||(fpt >= (info_im.text +info_im.text_size)))
248+
fpt=NULL;
249+
}
250+
251+
/* Send back fptr of data segment */
252+
write_port(port_out, (int32)(fpt),NULL,0);
253+
break;
254+
211255
default:
212256
/* Free system resources */
213257
delete_port(port_in);

src/backend/port/dynloader/beos.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/beos.c,v 1.7 2001/03/22 03:59:42 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/beos.c,v 1.8 2001/08/07 16:56:17 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -49,23 +49,8 @@ pg_dlsym(void *handle, char *funcname)
4949
/* Checking that "Handle" is valid */
5050
if ((handle) && ((*(int *) (handle)) >= 0))
5151
{
52-
/* Loading symbol */
53-
if (get_image_symbol(*((int *) (handle)), funcname, B_SYMBOL_TYPE_TEXT, (void **) &fpt) == B_OK);
54-
{
55-
56-
/*
57-
* Sometime the loader return B_OK for an inexistant function
58-
* with an invalid address !!! Check that the return address
59-
* is in the image range
60-
*/
61-
image_info info;
62-
63-
get_image_info(*((int *) (handle)), &info);
64-
if ((fpt < info.text) ||(fpt >= (info.text +info.text_size)))
65-
return NULL;
66-
return fpt;
67-
}
68-
elog(NOTICE, "loading symbol '%s' failed ", funcname);
52+
beos_dl_sym(*((int *) (handle)),funcname,(void **) &fpt);
53+
return fpt;
6954
}
7055
elog(NOTICE, "add-on not loaded correctly");
7156
return NULL;

src/include/port/beos.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <kernel/OS.h>
2-
#include "kernel/image.h"
2+
#include <kernel/image.h>
3+
#include <sys/ioctl.h>
34

45
#define HAS_TEST_AND_SET
56

@@ -69,6 +70,9 @@ void beos_startup(int argc, char **argv);
6970
/* Load a shared library */
7071
image_id beos_dl_open(char *filename);
7172

73+
/* Find symbol */
74+
void beos_dl_sym(image_id im,char* symname,void** fptr);
75+
7276
/* UnLoad a shared library */
7377
status_t beos_dl_close(image_id im);
7478

0 commit comments

Comments
 (0)