Commit 1b2d57dc authored by Bruce Momjian's avatar Bruce Momjian

A small patch to keep postgres working on the latest BeOS.

Cyril VELTER
parent d8783c51
...@@ -115,6 +115,22 @@ beos_dl_open(char *filename) ...@@ -115,6 +115,22 @@ beos_dl_open(char *filename)
} }
} }
void
beos_dl_sym(image_id im,char* symname,void** fptr)
{
/* Send command '3' (get symbol) to the support server */
write_port(beos_dl_port_in, 3, symname, strlen(symname) + 1);
write_port(beos_dl_port_in, im, NULL,0);
/* Read sym address */
read_port(beos_dl_port_out, (int32*)(fptr), NULL, 0);
if (fptr==NULL)
{
elog(NOTICE, "loading symbol '%s' failed ", symname);
}
}
status_t status_t
beos_dl_close(image_id im) beos_dl_close(image_id im)
{ {
...@@ -164,12 +180,13 @@ beos_startup(int argc, char **argv) ...@@ -164,12 +180,13 @@ beos_startup(int argc, char **argv)
* server * server
*/ */
read_port(port_in, &opcode, datas, 4000); read_port(port_in, &opcode, datas, 4000);
switch (opcode) switch (opcode)
{ {
image_id addon; image_id addon;
image_info info_im; image_info info_im;
area_info info_ar; area_info info_ar;
void * fpt;
/* Load Add-On */ /* Load Add-On */
case 1: case 1:
...@@ -208,6 +225,33 @@ beos_startup(int argc, char **argv) ...@@ -208,6 +225,33 @@ beos_startup(int argc, char **argv)
write_port(port_out, unload_add_on(*((int *) (datas))), NULL, 0); write_port(port_out, unload_add_on(*((int *) (datas))), NULL, 0);
break; break;
/* Cleanup and exit */ /* Cleanup and exit */
case 3:
/* read image Id on the input port */
read_port(port_in, &addon,NULL,0);
/* Loading symbol */
fpt=NULL;
if (get_image_symbol(addon, datas, B_SYMBOL_TYPE_TEXT, &fpt) == B_OK);
{
/*
* Sometime the loader return B_OK for an inexistant function
* with an invalid address !!! Check that the return address
* is in the image range
*/
get_image_info(addon, &info_im);
if ((fpt < info_im.text) ||(fpt >= (info_im.text +info_im.text_size)))
fpt=NULL;
}
/* Send back fptr of data segment */
write_port(port_out, (int32)(fpt),NULL,0);
break;
default: default:
/* Free system resources */ /* Free system resources */
delete_port(port_in); delete_port(port_in);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/beos.c,v 1.7 2001/03/22 03:59:42 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/beos.c,v 1.8 2001/08/07 16:56:17 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -49,23 +49,8 @@ pg_dlsym(void *handle, char *funcname) ...@@ -49,23 +49,8 @@ pg_dlsym(void *handle, char *funcname)
/* Checking that "Handle" is valid */ /* Checking that "Handle" is valid */
if ((handle) && ((*(int *) (handle)) >= 0)) if ((handle) && ((*(int *) (handle)) >= 0))
{ {
/* Loading symbol */ beos_dl_sym(*((int *) (handle)),funcname,(void **) &fpt);
if (get_image_symbol(*((int *) (handle)), funcname, B_SYMBOL_TYPE_TEXT, (void **) &fpt) == B_OK); return fpt;
{
/*
* Sometime the loader return B_OK for an inexistant function
* with an invalid address !!! Check that the return address
* is in the image range
*/
image_info info;
get_image_info(*((int *) (handle)), &info);
if ((fpt < info.text) ||(fpt >= (info.text +info.text_size)))
return NULL;
return fpt;
}
elog(NOTICE, "loading symbol '%s' failed ", funcname);
} }
elog(NOTICE, "add-on not loaded correctly"); elog(NOTICE, "add-on not loaded correctly");
return NULL; return NULL;
......
#include <kernel/OS.h> #include <kernel/OS.h>
#include "kernel/image.h" #include <kernel/image.h>
#include <sys/ioctl.h>
#define HAS_TEST_AND_SET #define HAS_TEST_AND_SET
...@@ -69,6 +70,9 @@ void beos_startup(int argc, char **argv); ...@@ -69,6 +70,9 @@ void beos_startup(int argc, char **argv);
/* Load a shared library */ /* Load a shared library */
image_id beos_dl_open(char *filename); image_id beos_dl_open(char *filename);
/* Find symbol */
void beos_dl_sym(image_id im,char* symname,void** fptr);
/* UnLoad a shared library */ /* UnLoad a shared library */
status_t beos_dl_close(image_id im); status_t beos_dl_close(image_id im);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment